Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 98fa9b6

Browse files
authored
Updated page actions design #713 (#764)
* Moved Share Page with to the bottom Reorganized the bottom part into horizontal design Request Destkop site should changed to be a toggle Moved "Block Pop-ups" from Privacy Dashboard to Page Actions, just below the "Request Destkop site" * Changed "Share" translation. Moved "bock popups" item below the "reader mode" item.
1 parent 824557f commit 98fa9b6

File tree

4 files changed

+45
-41
lines changed

4 files changed

+45
-41
lines changed

Client/Frontend/Widgets/PhotonActionSheet/CollectionCell/PhotonActionSheetCollectionCell.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ extension PhotonActionSheetCollectionCell: UICollectionViewDelegate {
9797
extension PhotonActionSheetCollectionCell: UICollectionViewDelegateFlowLayout {
9898

9999
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
100-
return CGSize(width: collectionView.frame.width / CGFloat(PhotonActionSheetCollectionCellUX.MaximumCellsCountInScreen), height: collectionView.frame.height)
100+
let cellsCount = min(self.items.count, PhotonActionSheetCollectionCellUX.MaximumCellsCountInScreen)
101+
return CGSize(width: collectionView.frame.width / CGFloat(cellsCount), height: collectionView.frame.height)
101102
}
102103

103104
}

Client/Frontend/Widgets/PhotonActionSheet/PhotonActionSheetProtocol.swift

+41-38
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,13 @@ extension PhotonActionSheetProtocol {
139139
toggleActionTitle = tab.changedUserAgent ? Strings.Menu.ViewMobileSiteTitleString : Strings.Menu.ViewDesktopSiteTitleString
140140
}
141141

142-
let toggleDesktopSite = PhotonActionSheetItem(title: toggleActionTitle, iconString: "menu-RequestDesktopSite", isEnabled: tab.changedUserAgent, badgeIconNamed: "menuBadge") { action in
142+
let toggleDesktopSite = PhotonActionSheetItem(title: toggleActionTitle, iconString: "menu-RequestDesktopSite", isEnabled: tab.changedUserAgent, accessory: .Switch, badgeIconNamed: "menuBadge") { action in
143143
if let url = tab.url {
144144
tab.toggleChangeUserAgent()
145145
Tab.ChangeUserAgent.updateDomainList(forUrl: url, isChangedUA: tab.changedUserAgent, isPrivate: tab.isPrivate)
146146
}
147147
}
148+
var domainActions = [toggleDesktopSite]
148149

149150
let bookmarkPage = PhotonActionSheetItem(title: Strings.Menu.AddBookmarkTitleString, iconString: "menu-Bookmark") { action in
150151
guard let url = tab.canonicalURL?.displayURL,
@@ -192,25 +193,7 @@ extension PhotonActionSheetProtocol {
192193
}.uponQueue(.main) { _ in }
193194
}
194195

195-
let sharePage = PhotonActionSheetItem(title: Strings.Menu.SharePageTitleString, iconString: "action_share") { action in
196-
guard let url = tab.canonicalURL?.displayURL else { return }
197-
198-
if let temporaryDocument = tab.temporaryDocument {
199-
temporaryDocument.getURL().uponQueue(.main, block: { tempDocURL in
200-
// If we successfully got a temp file URL, share it like a downloaded file,
201-
// otherwise present the ordinary share menu for the web URL.
202-
if tempDocURL.isFileURL {
203-
self.share(fileURL: tempDocURL, buttonView: buttonView, presentableVC: presentableVC)
204-
} else {
205-
presentShareMenu(url, tab, buttonView, .up)
206-
}
207-
})
208-
} else {
209-
presentShareMenu(url, tab, buttonView, .up)
210-
}
211-
}
212-
213-
var mainActions = [sharePage]
196+
var mainActions = [PhotonActionSheetItem]()
214197

215198
// Disable bookmarking if the URL is too long.
216199
if !tab.urlIsTooLong {
@@ -222,8 +205,6 @@ extension PhotonActionSheetProtocol {
222205

223206
let refreshPage = self.refreshPageItem()
224207

225-
var domainActions = [toggleDesktopSite]
226-
227208
if let isReaderModeEnabled = isReaderModeEnabled {
228209
let readerModeAction = PhotonActionSheetItem(title: Strings.Menu.ReaderModeTitleString, iconString: "reader", isEnabled: isReaderModeEnabled, accessory: .Switch, badgeIconNamed: "menuBadge") { (item) in
229210
tab.toggleChangeReaderMode()
@@ -232,6 +213,23 @@ extension PhotonActionSheetProtocol {
232213
domainActions.append(readerModeAction)
233214
}
234215

216+
if let url = tab.url {
217+
let popupsBlocking = PhotonActionSheetItem(
218+
title: Strings.PrivacyDashboard.Switch.PopupsBlocking,
219+
iconString: "menu-PopupBlocking",
220+
isEnabled: !ContentBlocker.shared.isPopupsWhitelisted(url: url),
221+
accessory: .Switch
222+
) { action in
223+
ContentBlocker.shared.popupsWhitelist(
224+
enable: !ContentBlocker.shared.isPopupsWhitelisted(url: url),
225+
url: url
226+
) {
227+
tab.reload()
228+
}
229+
}
230+
domainActions.append(popupsBlocking)
231+
}
232+
235233
var commonActions = [refreshPage]
236234

237235
// Disable find in page if document is pdf.
@@ -242,7 +240,26 @@ extension PhotonActionSheetProtocol {
242240
commonActions.insert(findInPageAction, at: 0)
243241
}
244242

245-
return [mainActions, domainActions, commonActions]
243+
let sharePage = PhotonActionSheetItem(title: Strings.Menu.SharePageTitleString, iconString: "action_share") { action in
244+
guard let url = tab.canonicalURL?.displayURL else { return }
245+
246+
if let temporaryDocument = tab.temporaryDocument {
247+
temporaryDocument.getURL().uponQueue(.main, block: { tempDocURL in
248+
// If we successfully got a temp file URL, share it like a downloaded file,
249+
// otherwise present the ordinary share menu for the web URL.
250+
if tempDocURL.isFileURL {
251+
self.share(fileURL: tempDocURL, buttonView: buttonView, presentableVC: presentableVC)
252+
} else {
253+
presentShareMenu(url, tab, buttonView, .up)
254+
}
255+
})
256+
} else {
257+
presentShareMenu(url, tab, buttonView, .up)
258+
}
259+
}
260+
261+
commonActions.append(sharePage)
262+
return [mainActions, domainActions, [PhotonActionSheetItem(title: "", collectionItems: commonActions)]]
246263
}
247264

248265
func fetchBookmarkStatus(for url: String) -> Deferred<Maybe<Bool>> {
@@ -366,21 +383,7 @@ extension PhotonActionSheetProtocol {
366383
}
367384
}
368385

369-
let popupsBlocking = PhotonActionSheetItem(
370-
title: Strings.PrivacyDashboard.Switch.PopupsBlocking,
371-
iconString: "menu-PopupBlocking",
372-
isEnabled: !ContentBlocker.shared.isPopupsWhitelisted(url: currentURL),
373-
accessory: .Switch
374-
) { action in
375-
ContentBlocker.shared.popupsWhitelist(
376-
enable: !ContentBlocker.shared.isPopupsWhitelisted(url: currentURL),
377-
url: currentURL
378-
) {
379-
tab.reload()
380-
}
381-
}
382-
383-
return [trackingProtection, adBlocking, popupsBlocking]
386+
return [trackingProtection, adBlocking]
384387
}
385388

386389
@available(iOS 11.0, *)

Translations/de.lproj/Menu.strings

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"Menu.RemoveBookmarkAction.Title" = "Lesezeichen entfernen";
5555

5656
/* Label for the button, displayed in the menu, used to open the share dialog. */
57-
"Menu.SharePageAction.Title" = "Seite teilen mit…";
57+
"Menu.SharePageAction.Title" = "Teilen";
5858

5959
/* Label for the button, displayed in the menu, used to open the tabs tray */
6060
"Menu.ShowTabs.Title" = "Tabs anzeigen";

Translations/en.lproj/Menu.strings

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"Menu.RemoveBookmarkAction.Title" = "Remove Bookmark";
5555

5656
/* Label for the button, displayed in the menu, used to open the share dialog. */
57-
"Menu.SharePageAction.Title" = "Share Page With…";
57+
"Menu.SharePageAction.Title" = "Share";
5858

5959
/* Label for the button, displayed in the menu, used to open the tabs tray */
6060
"Menu.ShowTabs.Title" = "Show Tabs";

0 commit comments

Comments
 (0)