Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fix #3491: Add New Menu UI #3465

Merged
merged 17 commits into from
May 6, 2021
Merged

Fix #3491: Add New Menu UI #3465

merged 17 commits into from
May 6, 2021

Conversation

kylehickinson
Copy link
Collaborator

@kylehickinson kylehickinson commented Mar 25, 2021

Summary of Changes

This pull request fixes #3491

This also changes private mode theming to only affect the main browser toolbars

Submitter Checklist:

  • Unit Tests are updated to cover new or changed functionality
  • User-facing strings use NSLocalizableString()

Test Plan:

  • Verify all menu options from old design are available in the new design and function correctly
  • Verify theming works as needed
  • Verify VPN button toggles correctly, shows loading accordingly while connecting, and shows the correct on/off state when opening the menu
  • Note: Ref #3491: Move share with button; Fix bookmarks dismiss on navigation #3672 moves the share with… button to the top, which will be inconsistent with screenshots below

Screenshots:

Old (NTP) New (NTP)
Simulator Screen Shot - iPhone 12 Pro - 2021-05-06 at 11 00 48 new menu
Old (Website) New (Website)
Simulator Screen Shot - iPhone 12 Pro - 2021-05-06 at 11 00 52 Simulator Screen Shot - iPhone 12 Pro - 2021-05-06 at 10 54 18
Old (Website) New (Website) Expanded
Simulator Screen Shot - iPhone 12 Pro - 2021-05-06 at 11 00 52 Simulator Screen Shot - iPhone 12 Pro - 2021-05-06 at 10 54 20

Reviewer Checklist:

  • Issues include necessary QA labels:
    • QA/(Yes|No)
    • release-notes/(include|exclude)
    • bug / enhancement
  • Necessary security reviews have taken place.
  • Adequate unit test coverage exists to prevent regressions.
  • Adequate test plan exists for QA to validate (if applicable).
  • Issue is assigned to a milestone (should happen at merge time).

@kylehickinson kylehickinson force-pushed the new-panel branch 3 times, most recently from f6535f8 to 1e6db6d Compare March 30, 2021 18:13
@kylehickinson kylehickinson changed the title New Menu UI Fix #3491: Add New Menu UI Mar 30, 2021
@kylehickinson kylehickinson requested review from iccub, Brandon-T and soner-yuksel and removed request for Brandon-T March 30, 2021 18:22
@kylehickinson kylehickinson added this to the 1.25 milestone Mar 30, 2021
@kylehickinson kylehickinson marked this pull request as ready for review March 30, 2021 18:22
BraveUI/SwiftUI/TableCellButtonStyle.swift Show resolved Hide resolved
.lineLimit(1)
.foregroundColor(Color(Theme.of(nil).colors.tints.home))
}
Text(verbatim: url.baseDomain ?? url.absoluteDisplayString)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe url.baseDomain ?? url.host ?? url.absoluteDisplayString? That way you attempt to get base domain else eTLD else display string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, absoluteDisplayString only strips http/https so host is probably a better fallback

Copy link
Contributor

@iccub iccub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found few problems in dark mode,
code looks nice overall

BraveUI/SwiftUI/TableCellButtonStyle.swift Show resolved Hide resolved
configuration.label
.contentShape(Rectangle()) // Needed or taps don't activate on empty space
.background(
Color(colorScheme == .dark ? .white : .black)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using our theme colors here? do we even have them for 'buttonstyle'

@@ -67,9 +67,6 @@ extension Theme {
InsetButton.appearance(whenContainedInInstancesOf: [SearchSuggestionPromptView.self]).appearanceTextColor = colors.tints.home

// Overrides all views inside of itself
// According to docs, UIWindow override should be enough, but some labels on iOS 13 are still messed up without UIView override as well
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is so contradictory I wonder why did they add it to window before :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I am not sure, keeping it unfortunately completely breaks SwiftUI re-render after color scheme changes

activities = shareActivities(for: url, tab: tab, sourceView: view, sourceRect: self.view.convert(self.topToolbar.menuButton.frame, from: self.topToolbar.menuButton.superview), arrowDirection: .up)
}
let menuController = MenuViewController(content: { menuController in
VStack(spacing: 6) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think we should start adding these values in struct or unnecessary for single instance ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is unnecessary at the moment, as it is a small computed View. If the menu grows to be larger though we can always reconsider

}

struct MenuTabDetailsView: View {
@SwiftUI.Environment(\.colorScheme) var colorScheme: ColorScheme
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are used to force SwiftUI to recompute the body of the View when the users system theme changes (as we don't have an observable "current" theme object anywhere)

}
.buttonStyle(TableCellButtonStyle())
.accentColor(Color(Theme.of(nil).colors.tints.home))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we use .accentColor here instead of .background(

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This accentColor was to set colors of Toggle's to brave's orange, but it doesn't seem to work as Michal tested.

background places a View behind this view, which isn't what we wanted in this case

@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError()
override var preferredStatusBarStyle: UIStatusBarStyle {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious do we need need to set Status bar style for this controller ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to keep the status bar white when the user navigates to other VC's inside the menu

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return visibleButtons.count
private var isPresentingInnerMenu: Bool {
if let _ = presentedViewController as? InnerMenuNavigationController {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use is here instead
presentedViewController is InnerMenuNavigationController

extension MenuViewController: PanModalPresentable {
var panScrollable: UIScrollView? {
// For SwiftUI:
// - in iOS 13, ScrollView will exist within a host view
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn thats great info here 👏

if let scrollView = view as? UIScrollView {
return scrollView
}
if !view.subviews.isEmpty, let childScrollView = _scrollViewChild(in: view, depth: depth + 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have 2 questions here,

  • First one I guess we are doing this check for iOS 13 only, If thats the case can we mark it like that
  • Second question is Can there be a situation where we have a scrollview as a direct subview and also scroll view within a hostview? If yes shouldnt we pick the scrollview which exists as direct subview ?

Copy link
Collaborator Author

@kylehickinson kylehickinson Apr 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Not 13 only, 14 can also have subviews as subview of the view when we create custom VC's that aren't UITVC's
  2. Yes but we always want the top-level one we find since its the one that controls whether or not panning begins to open/close the pan modal. If its the direct view it will return a few lines above, otherwise we check 1 more level deep. Any other scrolls within are assumed to function separately. I guess one improvement would be to find the first one that scrolls vertically, but Im not sure how we could go about doing that

self.panModalSetNeedsLayoutUpdate()
}
if expandToLongForm {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we delay while xpanding to long form ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just makes the animation look nicer, I'll make a comment explaining 🙂

@kylehickinson kylehickinson force-pushed the new-panel branch 4 times, most recently from 75ef0a5 to 6e9395d Compare April 6, 2021 17:03
@iccub iccub modified the milestones: 1.25, 1.26 Apr 7, 2021
// Have to increase the content size by the hidden nav bar height so that the size
// doesn't change when the user navigates within the menu where the nav bar is visible
let navBarHeight = navigationController?.navigationBar.bounds.height ?? 0
return CGSize(width: 375, height: min(max(size.height + 16, 240), 580 + navBarHeight))
Copy link
Contributor

@iccub iccub Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see these 580 and 375 magic numbers in few places, would it be worth extracting to a constant?

@kylehickinson
Copy link
Collaborator Author

Theme related issues will be solved in #3606

Copy link
Contributor

@iccub iccub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs 1 more rebase, code looks good

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Menu UI
4 participants