New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Menu 2.0 #1058
Merged
+2,124
−1,375
Merged
Menu 2.0 #1058
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
57860c2
MVP for iPhone
iccub d2a4044
Migrate urlbar items to stackview
iccub 0e2a935
Better naming and file separation for toolbar objects
iccub 799f2c7
WIP: menu actions
iccub 1f25420
Long press actions: dismissal and refactor.
iccub 2cb5750
Remove HomeViewController
iccub 191f371
BookmarksVC cleanup: remove unused code
iccub 7926cfe
folder hirerarchy alpha version
iccub 17afd7d
Make separator line work.
iccub bbdaa80
Add bookmark mvp, can add at root level.
iccub 7d19867
Merge branch 'development' of github.com:brave/brave-ios into feature…
iccub ea4f0d8
Adding bookmark works.
iccub c3a737a
Add folders mvp
iccub ee76b6a
xcode 10.2
iccub f06a617
Correct buttons when adding a folder.
iccub 02dab4c
Dismiss view when bookmark is selected.
iccub c0d29cd
Support editing modes in AddEditBookmarkVC
iccub 736fc5e
Edit without saving location mvp.
iccub 5138870
Edit bookmark location mvp
iccub ada5f14
Fetch favicon to bookmark details
iccub 134d4a9
whitespace
iccub d68cad8
Add localized strings
iccub c022eb5
Edit improvements, title for add/edit screen
iccub 7e30962
Remove unused BookmarkEditViewController
iccub f781004
Update image assets.
iccub 1d5d612
Make folder detail height equal to folder hierarchy cells height.
iccub e6c7a1c
Harden against sync changes.
iccub 93c9a24
Make updated url bar work with safe area insets
iccub 880de9e
Show share menu popover at correct location.
iccub 40f11b9
Design feedback from James.
iccub 99b171f
Bookmark/folder detail views refactor.
iccub 0bf5ddc
Header view refactor.
iccub c57f709
AddEditBookmarkTableViewController refactor.
iccub 1d9e0c3
MenuViewController refactor.
iccub de90bd1
final touches
iccub 32e1e30
Fix unit tests.
iccub bc45a12
review
iccub f7fd274
Make folderCellTag private
iccub 839602c
Merge branch 'development' of github.com:brave/brave-ios into feature…
iccub 8ad53f3
Swift 4.2 conformance
iccub 21d08ed
Fix title helper function
iccub 76ab847
Set syncParentUUID when updating location.
iccub File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Long press actions: dismissal and refactor.
- Loading branch information
| @@ -0,0 +1,70 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| import UIKit | ||
| import Shared | ||
|
|
||
| protocol ToolbarUrlActionsProtocol where Self: UIViewController { | ||
|
||
| var toolbarUrlActionsDelegate: ToolbarUrlActionsDelegate? { get } | ||
|
|
||
| func presentLongPressActions(_ gesture: UILongPressGestureRecognizer, urlString: String?, | ||
| isPrivateBrowsing: Bool, customActions: [UIAlertAction]?) | ||
| } | ||
|
|
||
| extension ToolbarUrlActionsProtocol { | ||
| func presentLongPressActions(_ gesture: UILongPressGestureRecognizer, urlString: String?, | ||
| isPrivateBrowsing: Bool, customActions: [UIAlertAction]? = nil) { | ||
|
|
||
| let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) | ||
| alert.title = urlString?.replacingOccurrences(of: "mailto:", with: "").ellipsize(maxLength: 120) | ||
|
|
||
| let alertActions = customActions ?? actions(forUrl: URL(string: urlString ?? ""), | ||
| currentTabIsPrivate: isPrivateBrowsing) | ||
| alertActions.forEach { alert.addAction($0) } | ||
|
|
||
| if alertActions.isEmpty { | ||
| assertionFailure("Alert actions should not be empty") | ||
| return | ||
| } | ||
|
|
||
| let cancelAction = UIAlertAction(title: Strings.CancelButtonTitle, style: .cancel, handler: nil) | ||
| alert.addAction(cancelAction) | ||
|
|
||
| // If we're showing an arrow popup, set the anchor to the long press location. | ||
| if let popoverPresentationController = alert.popoverPresentationController { | ||
| popoverPresentationController.sourceView = view | ||
| popoverPresentationController.sourceRect = CGRect(origin: gesture.location(in: view), size: CGSize(width: 0, height: 16)) | ||
| popoverPresentationController.permittedArrowDirections = .any | ||
| } | ||
|
|
||
| present(alert, animated: true) | ||
| } | ||
|
|
||
| private func actions(forUrl url: URL?, currentTabIsPrivate: Bool) -> [UIAlertAction] { | ||
| guard let url = url, let delegate = toolbarUrlActionsDelegate else { return [] } | ||
|
|
||
| typealias Action = (title: String, action: () -> Void) | ||
|
|
||
| let newTabAction = Action(title: Strings.OpenNewTabButtonTitle, | ||
| action: { delegate.openInNewTab(url, isPrivate: currentTabIsPrivate) }) | ||
|
|
||
| let newPrivateTabAction = currentTabIsPrivate ? nil : | ||
| Action(title: Strings.OpenNewPrivateTabButtonTitle, action: { | ||
| delegate.openInNewTab(url, isPrivate: currentTabIsPrivate) | ||
| }) | ||
|
|
||
| let copyAction = Action(title: Strings.CopyLinkActionTitle, | ||
| action: { delegate.copy(url) }) | ||
|
|
||
| let shareAction = Action(title: Strings.ShareLinkActionTitle, | ||
| action: { delegate.share(url) }) | ||
|
|
||
| return [newTabAction, newPrivateTabAction, copyAction, shareAction].compactMap { $0 }.map { action in | ||
| UIAlertAction(title: action.title, style: .default) { _ in | ||
| self.dismiss(animated: true, completion: action.action) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
No changes here, moved it to its own file