Skip to content
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
merged 42 commits into from Jun 6, 2019
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 Apr 2, 2019
d2a4044
Migrate urlbar items to stackview
iccub Apr 3, 2019
0e2a935
Better naming and file separation for toolbar objects
iccub Apr 3, 2019
799f2c7
WIP: menu actions
iccub Apr 6, 2019
1f25420
Long press actions: dismissal and refactor.
iccub Apr 8, 2019
2cb5750
Remove HomeViewController
iccub Apr 8, 2019
191f371
BookmarksVC cleanup: remove unused code
iccub Apr 8, 2019
7926cfe
folder hirerarchy alpha version
iccub Apr 11, 2019
17afd7d
Make separator line work.
iccub Apr 11, 2019
bbdaa80
Add bookmark mvp, can add at root level.
iccub Apr 14, 2019
7d19867
Merge branch 'development' of github.com:brave/brave-ios into feature…
iccub Apr 14, 2019
ea4f0d8
Adding bookmark works.
iccub Apr 15, 2019
c3a737a
Add folders mvp
iccub Apr 15, 2019
ee76b6a
xcode 10.2
iccub Apr 15, 2019
f06a617
Correct buttons when adding a folder.
iccub Apr 16, 2019
02dab4c
Dismiss view when bookmark is selected.
iccub Apr 16, 2019
c0d29cd
Support editing modes in AddEditBookmarkVC
iccub Apr 16, 2019
736fc5e
Edit without saving location mvp.
iccub Apr 16, 2019
5138870
Edit bookmark location mvp
iccub Apr 17, 2019
ada5f14
Fetch favicon to bookmark details
iccub Apr 17, 2019
134d4a9
whitespace
iccub Apr 17, 2019
d68cad8
Add localized strings
iccub Apr 17, 2019
c022eb5
Edit improvements, title for add/edit screen
iccub Apr 17, 2019
7e30962
Remove unused BookmarkEditViewController
iccub Apr 17, 2019
f781004
Update image assets.
iccub Apr 17, 2019
1d5d612
Make folder detail height equal to folder hierarchy cells height.
iccub Apr 17, 2019
e6c7a1c
Harden against sync changes.
iccub Apr 17, 2019
93c9a24
Make updated url bar work with safe area insets
iccub Apr 17, 2019
880de9e
Show share menu popover at correct location.
iccub Apr 17, 2019
40f11b9
Design feedback from James.
iccub Apr 18, 2019
99b171f
Bookmark/folder detail views refactor.
iccub Apr 18, 2019
0bf5ddc
Header view refactor.
iccub Apr 18, 2019
c57f709
AddEditBookmarkTableViewController refactor.
iccub Apr 19, 2019
1d9e0c3
MenuViewController refactor.
iccub Apr 19, 2019
de90bd1
final touches
iccub Apr 19, 2019
32e1e30
Fix unit tests.
iccub Apr 19, 2019
bc45a12
review
iccub Apr 23, 2019
f7fd274
Make folderCellTag private
iccub Apr 23, 2019
839602c
Merge branch 'development' of github.com:brave/brave-ios into feature…
iccub Apr 23, 2019
8ad53f3
Swift 4.2 conformance
iccub Apr 23, 2019
21d08ed
Fix title helper function
iccub Apr 23, 2019
76ab847
Set syncParentUUID when updating location.
iccub Apr 23, 2019
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Migrate urlbar items to stackview

  • Loading branch information
iccub committed Apr 3, 2019
commit d2a40444ebd32e53c124ca3c5b30a005db20338e
@@ -1442,13 +1442,6 @@ extension BrowserViewController: URLBarDelegate {
tabManager.selectedTab?.reload()
}

func urlBarDidPressQRButton(_ urlBar: URLBarView) {
let qrCodeViewController = QRCodeViewController()
qrCodeViewController.qrCodeDelegate = self
let controller = QRCodeNavigationController(rootViewController: qrCodeViewController)
self.present(controller, animated: true, completion: nil)
}

func urlBarDidPressStop(_ urlBar: URLBarView) {
tabManager.selectedTab?.stop()
}
@@ -31,7 +31,6 @@ protocol URLBarDelegate: class {
func urlBarDidEnterOverlayMode(_ urlBar: URLBarView)
func urlBarDidLeaveOverlayMode(_ urlBar: URLBarView)
func urlBarDidLongPressLocation(_ urlBar: URLBarView)
func urlBarDidPressQRButton(_ urlBar: URLBarView)
func urlBarLocationAccessibilityActions(_ urlBar: URLBarView) -> [UIAccessibilityCustomAction]?
func urlBarDidPressScrollToTop(_ urlBar: URLBarView)
func urlBar(_ urlBar: URLBarView, didEnterText text: String)
@@ -107,21 +106,9 @@ class URLBarView: UIView {
cancelButton.addTarget(self, action: #selector(didClickCancel), for: .touchUpInside)
cancelButton.setContentCompressionResistancePriority(.required, for: .horizontal)
cancelButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
cancelButton.alpha = 0
return cancelButton
}()

fileprivate lazy var showQRScannerButton: InsetButton = {
let button = InsetButton()
button.setImage(#imageLiteral(resourceName: "menu-ScanQRCode").template, for: .normal)
button.accessibilityIdentifier = "urlBar-scanQRCode"
button.clipsToBounds = false
button.addTarget(self, action: #selector(showQRScanner), for: .touchUpInside)
button.setContentHuggingPriority(UILayoutPriority(rawValue: 1000), for: .horizontal)
button.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 1000), for: .horizontal)
return button
}()

fileprivate lazy var scrollToTopButton: UIButton = {
let button = UIButton()
button.addTarget(self, action: #selector(tappedScrollToTopArea), for: .touchUpInside)
@@ -201,11 +188,14 @@ class URLBarView: UIView {
commonInit()
}

let mainStackView = UIStackView()
let navigationStackView = UIStackView()

fileprivate func commonInit() {
locationContainer.addSubview(locationView)

[scrollToTopButton, line, tabsButton, progressBar, cancelButton/*, showQRScannerButton*/].forEach { addSubview($0) }
[forwardButton, backButton, menuButton, shareButton, shieldsButton, locationContainer].forEach { addSubview($0) }
[scrollToTopButton, line, tabsButton, progressBar, cancelButton].forEach { addSubview($0) }
addSubview(mainStackView)

helper = TabToolbarHelper(toolbar: self)
setupConstraints()
@@ -214,7 +204,46 @@ class URLBarView: UIView {
updateViewsForOverlayModeAndToolbarChanges()
}


fileprivate func setupConstraints() {
mainStackView.alignment = .center
mainStackView.spacing = 16
mainStackView.translatesAutoresizingMaskIntoConstraints = false
navigationStackView.translatesAutoresizingMaskIntoConstraints = false

shieldsButton.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
shieldsButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
menuButton.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
menuButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
cancelButton.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
cancelButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
tabsButton.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
tabsButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
backButton.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
backButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
forwardButton.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
forwardButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)

locationContainer.setContentHuggingPriority(.defaultLow, for: .horizontal)

navigationStackView.distribution = .fillEqually
navigationStackView.spacing = 16
navigationStackView.addArrangedSubview(backButton)
navigationStackView.addArrangedSubview(forwardButton)

mainStackView.addArrangedSubview(navigationStackView)

mainStackView.addArrangedSubview(locationContainer)
mainStackView.addArrangedSubview(shieldsButton)
mainStackView.addArrangedSubview(tabsButton)
mainStackView.addArrangedSubview(menuButton)
mainStackView.addArrangedSubview(cancelButton)

mainStackView.snp.makeConstraints { make in
make.top.bottom.equalTo(self)
make.leading.equalTo(self).inset(URLBarViewUX.Padding)
make.trailing.equalTo(self).inset(URLBarViewUX.Padding)
}

line.snp.makeConstraints { make in
make.bottom.leading.trailing.equalTo(self)
@@ -235,115 +264,6 @@ class URLBarView: UIView {
locationView.snp.makeConstraints { make in
make.edges.equalTo(self.locationContainer)
}

cancelButton.snp.makeConstraints { make in
make.trailing.equalTo(self.safeArea.trailing).offset(-URLBarViewUX.Padding)
make.centerY.equalTo(self.locationContainer)
make.height.equalTo(URLBarViewUX.ButtonHeight)
}

backButton.snp.makeConstraints { make in
make.leading.equalTo(self.safeArea.leading).offset(URLBarViewUX.Padding)
make.centerY.equalTo(self)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}

forwardButton.snp.makeConstraints { make in
make.leading.equalTo(self.backButton.snp.trailing)
make.centerY.equalTo(self)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}

menuButton.snp.makeConstraints { make in
make.leading.equalTo(self.forwardButton.snp.trailing)
make.centerY.equalTo(self)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}

shareButton.snp.makeConstraints { make in
make.trailing.equalTo(self.tabsButton.snp.leading)
make.centerY.equalTo(self)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}

tabsButton.snp.makeConstraints { make in
make.trailing.equalTo(self.safeArea.trailing).offset(-URLBarViewUX.Padding)
make.centerY.equalTo(self)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}

/*
showQRScannerButton.snp.makeConstraints { make in
make.trailing.equalTo(self.safeArea.trailing)
make.centerY.equalTo(self.locationContainer)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}
*/
}

override func updateConstraints() {
super.updateConstraints()
if inOverlayMode {
menuButton.snp.remakeConstraints { make in
make.leading.equalTo(self.safeArea.leading)
make.centerY.equalTo(self)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}
// In overlay mode, we always show the location view full width
locationContainer.snp.remakeConstraints { make in
let height = URLBarViewUX.LocationHeight// + (URLBarViewUX.TextFieldBorderWidthSelected * 2)
make.height.equalTo(height)
make.trailing.equalTo(self.cancelButton.snp.leading).offset(-URLBarViewUX.Padding)
make.leading.equalTo(self.menuButton.snp.trailing)
make.centerY.equalTo(self)
}
locationView.snp.remakeConstraints { make in
make.edges.equalTo(self.locationContainer)
}
locationTextField?.snp.remakeConstraints { make in
make.edges.equalTo(self.locationView).inset(UIEdgeInsets(top: 0, left: URLBarViewUX.LocationLeftPadding, bottom: 0, right: URLBarViewUX.LocationLeftPadding))
}
} else {
menuButton.snp.remakeConstraints { make in
if self.toolbarIsShowing {
make.leading.equalTo(self.forwardButton.snp.trailing)
} else {
make.leading.equalTo(self)
}
make.centerY.equalTo(self)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}
shieldsButton.snp.remakeConstraints { make in
if self.toolbarIsShowing {
make.trailing.equalTo(self.shareButton.snp.leading)
} else {
make.trailing.equalTo(self)
}
make.centerY.equalTo(self)
make.size.equalTo(URLBarViewUX.ButtonHeight)
}
locationContainer.snp.remakeConstraints { make in
if self.toolbarIsShowing {
// When there's toolbar items on the left, add some padding so it looks better
make.leading.equalTo(self.menuButton.snp.trailing).offset(URLBarViewUX.LocationLeftPadding)
make.trailing.equalTo(self.shieldsButton.snp.leading).offset(-URLBarViewUX.LocationLeftPadding)
} else {
make.leading.equalTo(self.menuButton.snp.trailing)
make.trailing.equalTo(self.shieldsButton.snp.leading)
}

make.height.equalTo(URLBarViewUX.LocationHeight)
make.centerY.equalTo(self)
}
locationView.snp.remakeConstraints { make in
make.edges.equalTo(self.locationContainer)
}
}

}

@objc func showQRScanner() {
self.delegate?.urlBarDidPressQRButton(self)
}

func createLocationTextField() {
@@ -368,7 +288,9 @@ class URLBarView: UIView {
locationTextField.attributedPlaceholder = self.locationView.placeholder
locationContainer.addSubview(locationTextField)
locationTextField.snp.remakeConstraints { make in
make.edges.equalTo(self.locationView)
let insets = UIEdgeInsets(top: 0, left: URLBarViewUX.LocationLeftPadding,
bottom: 0, right: URLBarViewUX.LocationLeftPadding)
make.edges.equalTo(self.locationView).inset(insets)
}

locationTextField.applyTheme(currentTheme)
@@ -479,56 +401,17 @@ class URLBarView: UIView {
delegate?.urlBarDidLeaveOverlayMode(self)
}

func prepareOverlayAnimation() {
// Make sure everything is showing during the transition (we'll hide it afterwards).
bringSubview(toFront: self.locationContainer)
cancelButton.isHidden = false
showQRScannerButton.isHidden = false
progressBar.isHidden = false
forwardButton.isHidden = !toolbarIsShowing
backButton.isHidden = !toolbarIsShowing
tabsButton.isHidden = !toolbarIsShowing
shareButton.isHidden = !toolbarIsShowing
locationView.contentView.isHidden = false
}

func transitionToOverlay(_ didCancel: Bool = false) {
cancelButton.alpha = inOverlayMode ? 1 : 0
showQRScannerButton.alpha = inOverlayMode ? 1 : 0
progressBar.alpha = inOverlayMode || didCancel ? 0 : 1
tabsButton.alpha = inOverlayMode ? 0 : 1
forwardButton.alpha = inOverlayMode ? 0 : 1
backButton.alpha = inOverlayMode ? 0 : 1
shareButton.alpha = inOverlayMode ? 0 : 1
shieldsButton.alpha = inOverlayMode ? 0 : 1
locationView.contentView.alpha = inOverlayMode ? 0 : 1

if inOverlayMode {
// Make the editable text field span the entire URL bar, covering the lock and reader icons.
locationTextField?.snp.remakeConstraints { make in
make.edges.equalTo(self.locationView)
}
} else {
// Shrink the editable text field back to the size of the location view before hiding it.
locationTextField?.snp.remakeConstraints { make in
make.edges.equalTo(self.locationView.urlTextField)
}
}
}

func updateViewsForOverlayModeAndToolbarChanges() {
cancelButton.isHidden = !inOverlayMode
showQRScannerButton.isHidden = !inOverlayMode
progressBar.isHidden = inOverlayMode
forwardButton.isHidden = !toolbarIsShowing || inOverlayMode
backButton.isHidden = !toolbarIsShowing || inOverlayMode
navigationStackView.isHidden = !toolbarIsShowing || inOverlayMode
menuButton.isHidden = !toolbarIsShowing || inOverlayMode
shieldsButton.isHidden = inOverlayMode
tabsButton.isHidden = !toolbarIsShowing || inOverlayMode
shareButton.isHidden = !toolbarIsShowing || inOverlayMode
locationView.contentView.isHidden = inOverlayMode
}

func animateToOverlayState(overlayMode overlay: Bool, didCancel cancel: Bool = false) {
prepareOverlayAnimation()
layoutIfNeeded()

inOverlayMode = overlay
@@ -537,13 +420,18 @@ class URLBarView: UIView {
removeLocationTextField()
}

UIView.animate(withDuration: 0.3, delay: 0.0, usingSpringWithDamping: 0.85, initialSpringVelocity: 0.0, options: [], animations: {
self.transitionToOverlay(cancel)
self.setNeedsUpdateConstraints()
self.layoutIfNeeded()
}, completion: { _ in
self.updateViewsForOverlayModeAndToolbarChanges()
})
if inOverlayMode {
[progressBar, self.navigationStackView, self.menuButton, self.shieldsButton, self.tabsButton,
locationView.contentView].forEach {
$0?.isHidden = true
}

cancelButton.isHidden = false
} else {
UIView.animate(withDuration: 0.3) {
self.updateViewsForOverlayModeAndToolbarChanges()
}
}
}

func didClickAddTab() {
@@ -679,16 +567,6 @@ extension URLBarView: AutocompleteTextFieldDelegate {
}
}

// MARK: UIAppearance
extension URLBarView {

@objc dynamic var showQRButtonTintColor: UIColor? {
get { return showQRScannerButton.tintColor }
set { return showQRScannerButton.tintColor = newValue }
}

}

extension URLBarView: Themeable {

func applyTheme(_ theme: Theme) {
@@ -700,7 +578,6 @@ extension URLBarView: Themeable {
progressBar.setGradientColors(startColor: UIColor.LoadingBar.Start.colorFor(theme), endColor: UIColor.LoadingBar.End.colorFor(theme))
currentTheme = theme
cancelButton.setTitleColor(UIColor.Browser.Tint.colorFor(theme), for: .normal)
showQRButtonTintColor = UIColor.Browser.Tint.colorFor(theme)
switch theme {
case .regular:
backgroundColor = BraveUX.ToolbarsBackgroundSolidColor
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.