From 13128a1bdffe385f7380b4c5d422997439b7b32b Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Wed, 4 Oct 2023 12:40:33 +0100 Subject: [PATCH 01/67] add address bar position settings --- Core/UserDefaultsPropertyWrapper.swift | 2 + DuckDuckGo.xcodeproj/project.pbxproj | 10 +- ...essBarPositionSettingsViewController.swift | 87 +++++++++ DuckDuckGo/AppSettings.swift | 1 + DuckDuckGo/AppUserDefaults.swift | 15 +- DuckDuckGo/Base.lproj/Settings.storyboard | 169 +++++++++++++----- DuckDuckGo/SettingsViewController.swift | 9 +- 7 files changed, 248 insertions(+), 45 deletions(-) create mode 100644 DuckDuckGo/AddressBarPositionSettingsViewController.swift diff --git a/Core/UserDefaultsPropertyWrapper.swift b/Core/UserDefaultsPropertyWrapper.swift index 0d657b9533..56475a87d8 100644 --- a/Core/UserDefaultsPropertyWrapper.swift +++ b/Core/UserDefaultsPropertyWrapper.swift @@ -99,6 +99,8 @@ public struct UserDefaultsWrapper { case syncEnvironment = "com.duckduckgo.ios.sync-environment" case networkProtectionDebugOptionAlwaysOnDisabled = "com.duckduckgo.network-protection.always-on.disabled" + + case addressBarPosition = "com.duckduckgo.ios.addressbarposition" } private let key: Key diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 0025da68e4..6e6df217df 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -405,6 +405,7 @@ 85514FFD2372DA0100DBC528 /* ios13-home-row.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 85514FFC2372DA0000DBC528 /* ios13-home-row.mp4 */; }; 8551912724746EDC0010FDD0 /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8551912624746EDC0010FDD0 /* SnapshotHelper.swift */; }; 85582E0029D7409700E9AE35 /* SyncSettingsViewController+PDFRendering.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85582DFF29D7409700E9AE35 /* SyncSettingsViewController+PDFRendering.swift */; }; + 855D45D32ACD7DD1008F7AC6 /* AddressBarPositionSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 855D45D22ACD7DD1008F7AC6 /* AddressBarPositionSettingsViewController.swift */; }; 855D914D2063EF6A00C4B448 /* TabSwitcherTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 855D914C2063EF6A00C4B448 /* TabSwitcherTransition.swift */; }; 8563A03C1F9288D600F04442 /* BrowserChromeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8563A03B1F9288D600F04442 /* BrowserChromeManager.swift */; }; 8565A34B1FC8D96B00239327 /* LaunchTabNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8565A34A1FC8D96B00239327 /* LaunchTabNotification.swift */; }; @@ -1410,6 +1411,7 @@ 85519124247468580010FDD0 /* TrackerRadarIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackerRadarIntegrationTests.swift; sourceTree = ""; }; 8551912624746EDC0010FDD0 /* SnapshotHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SnapshotHelper.swift; path = fastlane/SnapshotHelper.swift; sourceTree = SOURCE_ROOT; }; 85582DFF29D7409700E9AE35 /* SyncSettingsViewController+PDFRendering.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SyncSettingsViewController+PDFRendering.swift"; sourceTree = ""; }; + 855D45D22ACD7DD1008F7AC6 /* AddressBarPositionSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressBarPositionSettingsViewController.swift; sourceTree = ""; }; 855D914C2063EF6A00C4B448 /* TabSwitcherTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabSwitcherTransition.swift; sourceTree = ""; }; 8563A03B1F9288D600F04442 /* BrowserChromeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserChromeManager.swift; sourceTree = ""; }; 8565A34A1FC8D96B00239327 /* LaunchTabNotification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchTabNotification.swift; sourceTree = ""; }; @@ -3659,19 +3661,20 @@ isa = PBXGroup; children = ( F1CDD3F11F16911700BE0581 /* AboutViewController.swift */, - 1E865AEF272042DB001C74F3 /* TextSizeSettingsViewController.swift */, + 855D45D22ACD7DD1008F7AC6 /* AddressBarPositionSettingsViewController.swift */, AA3D854623D9E88E00788410 /* AppIconSettingsCell.swift */, AA3D854423D9942200788410 /* AppIconSettingsViewController.swift */, 98F0FC1F21FF18E700CE77AB /* AutoClearSettingsViewController.swift */, + 1EE7C298294227EC0026C8CB /* AutoconsentSettingsViewController.swift */, + 02C57C4A2514FEFB009E5129 /* DoNotSellSettingsViewController.swift */, F456B3B425810BB900B79B90 /* FireButtonAnimationSettingsViewController.swift */, 85449EF423FDA02800512AAF /* KeyboardSettingsViewController.swift */, 8540BD5523D9E9C20057FDD2 /* PreserveLoginsSettingsViewController.swift */, F176699D1E40BC86003D3222 /* Settings.storyboard */, F1AB2B411E3F7D5C00868554 /* SettingsViewController.swift */, + 1E865AEF272042DB001C74F3 /* TextSizeSettingsViewController.swift */, 9881439B23326DC200573F7C /* ThemeSettingsViewController.swift */, 8531A08D1F9950E6000484F0 /* UnprotectedSitesViewController.swift */, - 02C57C4A2514FEFB009E5129 /* DoNotSellSettingsViewController.swift */, - 1EE7C298294227EC0026C8CB /* AutoconsentSettingsViewController.swift */, ); name = UI; sourceTree = ""; @@ -6366,6 +6369,7 @@ 027F48782A4B663C001A1C6C /* AppTPFAQView.swift in Sources */, 02A4EACA29B0F464009BE006 /* AppTPToggleViewModel.swift in Sources */, 4B6484EE27FD1E350050A7A1 /* WindowsBrowserWaitlistDebugViewController.swift in Sources */, + 855D45D32ACD7DD1008F7AC6 /* AddressBarPositionSettingsViewController.swift in Sources */, F1D796EE1E7AF2EB0019D451 /* UIViewControllerExtension.swift in Sources */, 1EE411F12857C3640003FE64 /* TrackerAnimationImageProvider.swift in Sources */, 1E7A711C2934EEBC00B7EA19 /* OmniBarNotification.swift in Sources */, diff --git a/DuckDuckGo/AddressBarPositionSettingsViewController.swift b/DuckDuckGo/AddressBarPositionSettingsViewController.swift new file mode 100644 index 0000000000..17bba2b02b --- /dev/null +++ b/DuckDuckGo/AddressBarPositionSettingsViewController.swift @@ -0,0 +1,87 @@ +// +// AddressBarPositionSettingsViewController.swift +// DuckDuckGo +// +// Copyright © 2023 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import UIKit +import Core + +class AddressBarPositionSettingsViewController: UITableViewController { + + private lazy var appSettings = AppDependencyProvider.shared.appSettings + + private lazy var options = AddressBarPosition.allCases + + override func viewDidLoad() { + super.viewDidLoad() + + applyTheme(ThemeManager.shared.currentTheme) + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return options.count + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) + } + + override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + let theme = ThemeManager.shared.currentTheme + cell.backgroundColor = theme.tableCellBackgroundColor + cell.setHighlightedStateBackgroundColor(theme.tableCellHighlightedBackgroundColor) + + cell.tintColor = theme.buttonTintColor + cell.textLabel?.textColor = theme.tableCellTextColor + + cell.textLabel?.text = options[indexPath.row].descriptionText + cell.accessoryType = appSettings.currentAddressBarPosition.rawValue == cell.textLabel?.text ? .checkmark : .none + } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + appSettings.currentAddressBarPosition = AddressBarPosition.allCases[indexPath.row] + tableView.performBatchUpdates { + tableView.reloadSections(IndexSet(integer: 0), with: .automatic) + tableView.deselectRow(at: indexPath, animated: true) + } + } +} + +extension AddressBarPositionSettingsViewController: Themable { + + func decorate(with theme: Theme) { + + tableView.backgroundColor = theme.backgroundColor + tableView.separatorColor = theme.tableCellSeparatorColor + + tableView.reloadData() + } +} + +enum AddressBarPosition: String, CaseIterable { + case top = "Top" + case bottom = "Bottom" + + var descriptionText: String { + switch self { + case .top: + return self.rawValue + case .bottom: + return self.rawValue + } + } +} diff --git a/DuckDuckGo/AppSettings.swift b/DuckDuckGo/AppSettings.swift index 6e9a72c829..837ae813a2 100644 --- a/DuckDuckGo/AppSettings.swift +++ b/DuckDuckGo/AppSettings.swift @@ -31,6 +31,7 @@ protocol AppSettings: AnyObject { var sendDoNotSell: Bool { get set } var currentFireButtonAnimation: FireButtonAnimationType { get set } + var currentAddressBarPosition: AddressBarPosition { get set } var textSize: Int { get set } diff --git a/DuckDuckGo/AppUserDefaults.swift b/DuckDuckGo/AppUserDefaults.swift index cdc13cbb36..daf538ca26 100644 --- a/DuckDuckGo/AppUserDefaults.swift +++ b/DuckDuckGo/AppUserDefaults.swift @@ -173,7 +173,20 @@ public class AppUserDefaults: AppSettings { userDefaults?.setValue(newValue.rawValue, forKey: Keys.currentFireButtonAnimationKey) } } - + + @UserDefaultsWrapper(key: .addressBarPosition, defaultValue: nil) + private var addressBarPositionStorage: String? + + var currentAddressBarPosition: AddressBarPosition { + get { + return AddressBarPosition(rawValue: addressBarPositionStorage ?? "") ?? .top + } + + set { + addressBarPositionStorage = newValue.rawValue + } + } + @UserDefaultsWrapper(key: .textSize, defaultValue: 100) var textSize: Int diff --git a/DuckDuckGo/Base.lproj/Settings.storyboard b/DuckDuckGo/Base.lproj/Settings.storyboard index 2bfc09156f..0d8ad0ef6a 100644 --- a/DuckDuckGo/Base.lproj/Settings.storyboard +++ b/DuckDuckGo/Base.lproj/Settings.storyboard @@ -1,9 +1,9 @@ - + - + @@ -294,12 +294,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -343,7 +384,7 @@ - + @@ -387,7 +428,7 @@ - + @@ -408,7 +449,7 @@ - + @@ -452,7 +493,7 @@ - + @@ -496,7 +537,7 @@ - + @@ -538,13 +579,13 @@ - + - - + - - + - - + - - + diff --git a/DuckDuckGo/MainView.swift b/DuckDuckGo/MainView.swift index c22ef7a3f8..e77b971352 100644 --- a/DuckDuckGo/MainView.swift +++ b/DuckDuckGo/MainView.swift @@ -31,14 +31,16 @@ class MainViewFactory { coordinator = MainViewCoordinator(superview: superview) } - static func createViewHierarchy(_ superview: UIView) -> MainViewCoordinator { + static func createViewHierarchy(_ superview: UIView, addressBarPosition: AddressBarPosition) -> MainViewCoordinator { let factory = MainViewFactory(superview) factory.createViews() factory.disableAutoresizingOnViewAndImmediateSubviews(superview) factory.constrainViews() - return factory.coordinator + let coordinator = factory.coordinator + coordinator.moveAddressBarToPosition(addressBarPosition) + return coordinator } private func disableAutoresizingOnViewAndImmediateSubviews(_ view: UIView) { @@ -332,4 +334,23 @@ class MainViewCoordinator { } + func moveAddressBarToPosition(_ position: AddressBarPosition) { + print(#function, position.rawValue) + switch position { + case .top: + moveAddressBarToTop() + + case .bottom: + moveAddressBarToBottom() + } + } + + func moveAddressBarToTop() { + print(#function) + } + + func moveAddressBarToBottom() { + print(#function) + } + } diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index c337040b68..044ce9d537 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -173,8 +173,9 @@ class MainViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - viewCoordinator = MainViewFactory.createViewHierarchy(self.view) - + viewCoordinator = MainViewFactory.createViewHierarchy(self.view, + addressBarPosition: appSettings.currentAddressBarPosition) + viewCoordinator.toolbarBackButton.action = #selector(onBackPressed) viewCoordinator.toolbarForwardButton.action = #selector(onForwardPressed) viewCoordinator.toolbarFireButton.action = #selector(onFirePressed) @@ -299,12 +300,20 @@ class MainViewController: UIViewController { func registerForSettingsChangeNotifications() { NotificationCenter.default.addObserver(self, selector: - #selector(showFullSiteAddressChanged), + #selector(onShowFullSiteAddressChanged), name: AppUserDefaults.Notifications.showFullSiteAddressChanged, object: nil) + NotificationCenter.default.addObserver(self, selector: + #selector(onAddressBarPositionChanged), + name: AppUserDefaults.Notifications.addressBarPositionChanged, + object: nil) + } + + @objc func onAddressBarPositionChanged() { + viewCoordinator.moveAddressBarToPosition(appSettings.currentAddressBarPosition) } - @objc func showFullSiteAddressChanged() { + @objc func onShowFullSiteAddressChanged() { refreshOmniBar() } From 8565c49d01347ae84da1e613cdf58fdd5c601c15 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Wed, 4 Oct 2023 15:23:46 +0100 Subject: [PATCH 05/67] don't show address bar position setting on ipad --- DuckDuckGo/Base.lproj/Settings.storyboard | 1 + DuckDuckGo/SettingsViewController.swift | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DuckDuckGo/Base.lproj/Settings.storyboard b/DuckDuckGo/Base.lproj/Settings.storyboard index aa2d1841ad..6b41b4f721 100644 --- a/DuckDuckGo/Base.lproj/Settings.storyboard +++ b/DuckDuckGo/Base.lproj/Settings.storyboard @@ -1046,6 +1046,7 @@ + diff --git a/DuckDuckGo/SettingsViewController.swift b/DuckDuckGo/SettingsViewController.swift index bbfe0ee2f4..5b017e446d 100644 --- a/DuckDuckGo/SettingsViewController.swift +++ b/DuckDuckGo/SettingsViewController.swift @@ -40,6 +40,7 @@ class SettingsViewController: UITableViewController { @IBOutlet weak var defaultBrowserCell: UITableViewCell! @IBOutlet weak var themeAccessoryText: UILabel! @IBOutlet weak var fireButtonAnimationAccessoryText: UILabel! + @IBOutlet weak var addressBarPositionCell: UITableViewCell! @IBOutlet weak var addressBarPositionAccessoryText: UILabel! @IBOutlet weak var appIconCell: UITableViewCell! @IBOutlet weak var appIconImageView: UIImageView! @@ -120,6 +121,10 @@ class SettingsViewController: UITableViewController { return UIDevice.current.userInterfaceIdiom != .pad } + private var shouldShowAddressBarPositionCell: Bool { + return UIDevice.current.userInterfaceIdiom != .pad + } + private lazy var shouldShowNetPCell: Bool = { #if NETWORK_PROTECTION if #available(iOS 15, *) { @@ -139,7 +144,7 @@ class SettingsViewController: UITableViewController { configureSyncCell() configureThemeCellAccessory() configureFireButtonAnimationCellAccessory() - configureAddressBarPositionCellAccessory() + configureAddressBarPositionCell() configureTextSizeCell() configureDisableAutocompleteToggle() configureShowFullSiteAddressToggle() @@ -169,7 +174,7 @@ class SettingsViewController: UITableViewController { super.viewWillAppear(animated) configureFireButtonAnimationCellAccessory() - configureAddressBarPositionCellAccessory() + configureAddressBarPositionCell() configureTextSizeCell() configureAutoClearCellAccessory() configureRememberLogins() @@ -273,7 +278,8 @@ class SettingsViewController: UITableViewController { fireButtonAnimationAccessoryText.text = appSettings.currentFireButtonAnimation.descriptionText } - private func configureAddressBarPositionCellAccessory() { + private func configureAddressBarPositionCell() { + addressBarPositionCell.isHidden = !shouldShowAddressBarPositionCell addressBarPositionAccessoryText.text = appSettings.currentAddressBarPosition.descriptionText } From 977469d4040a57c3700cafcff92cdd79598e7111 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 00:04:24 +0100 Subject: [PATCH 06/67] handle changing between top and bottom --- DuckDuckGo/MainView.swift | 61 +++++++++++++++++++++++------ DuckDuckGo/MainViewController.swift | 15 ++++--- 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/DuckDuckGo/MainView.swift b/DuckDuckGo/MainView.swift index e77b971352..89d47d45a2 100644 --- a/DuckDuckGo/MainView.swift +++ b/DuckDuckGo/MainView.swift @@ -19,6 +19,8 @@ import UIKit +// swiftlint:disable line_length + class MainViewFactory { private let coordinator: MainViewCoordinator @@ -167,18 +169,24 @@ extension MainViewFactory { private func constrainProgress() { let progress = coordinator.progress! let navigationBarContainer = coordinator.navigationBarContainer! + + coordinator.constraints.progressBarTop = progress.constrainView(navigationBarContainer, by: .top, to: .bottom) + coordinator.constraints.progressBarBottom = progress.constrainView(navigationBarContainer, by: .bottom, to: .top) + NSLayoutConstraint.activate([ progress.constrainView(navigationBarContainer, by: .trailing), progress.constrainView(navigationBarContainer, by: .leading), progress.constrainAttribute(.height, to: 3), - progress.constrainView(navigationBarContainer, by: .top, to: .bottom), + coordinator.constraints.progressBarTop, ]) } private func constrainNavigationBarContainer() { let navigationBarContainer = coordinator.navigationBarContainer! + let toolbar = coordinator.toolbar! coordinator.constraints.navigationBarContainerTop = navigationBarContainer.constrainView(superview.safeAreaLayoutGuide, by: .top) + coordinator.constraints.navigationBarContainerBottom = navigationBarContainer.constrainView(toolbar, by: .bottom, to: .top) NSLayoutConstraint.activate([ navigationBarContainer.constrainView(superview, by: .centerX), @@ -204,11 +212,16 @@ extension MainViewFactory { private func constrainStatusBackground() { let statusBackground = coordinator.statusBackground! let navigationBarContainer = coordinator.navigationBarContainer! + + coordinator.constraints.statusBackgroundToNavigationBarContainerBottom = statusBackground.constrainView(navigationBarContainer, by: .bottom) + + coordinator.constraints.statusBackgroundBottomToSafeAreaTop = statusBackground.constrainView(coordinator.superview.safeAreaLayoutGuide, by: .bottom, to: .top) + NSLayoutConstraint.activate([ statusBackground.constrainView(superview, by: .width), statusBackground.constrainView(superview, by: .centerX), statusBackground.constrainView(superview, by: .top), - statusBackground.constrainView(navigationBarContainer, by: .bottom), + coordinator.constraints.statusBackgroundToNavigationBarContainerBottom, ]) } @@ -216,8 +229,10 @@ extension MainViewFactory { let notificationBarContainer = coordinator.notificationBarContainer! let contentContainer = coordinator.contentContainer! let navigationBarContainer = coordinator.navigationBarContainer! + let statusBackground = coordinator.statusBackground! - coordinator.constraints.notificationContainerTop = notificationBarContainer.constrainView(navigationBarContainer, by: .top, to: .bottom) + coordinator.constraints.notificationContainerTopToNavigationBar = notificationBarContainer.constrainView(navigationBarContainer, by: .top, to: .bottom) + coordinator.constraints.notificationContainerTopToStatusBackground = notificationBarContainer.constrainView(statusBackground, by: .top, to: .bottom) coordinator.constraints.notificationContainerHeight = notificationBarContainer.constrainAttribute(.height, to: 0) NSLayoutConstraint.activate([ @@ -225,7 +240,7 @@ extension MainViewFactory { notificationBarContainer.constrainView(superview, by: .centerX), coordinator.constraints.notificationContainerHeight, notificationBarContainer.constrainView(contentContainer, by: .bottom, to: .top), - coordinator.constraints.notificationContainerTop, + coordinator.constraints.notificationContainerTopToNavigationBar, ]) } @@ -309,6 +324,9 @@ class MainViewCoordinator { let constraints = Constraints() + // The default after creating the hiearchy is top + var addressBarPosition: AddressBarPosition = .top + fileprivate init(superview: UIView) { self.superview = superview } @@ -326,31 +344,48 @@ class MainViewCoordinator { class Constraints { var navigationBarContainerTop: NSLayoutConstraint! + var navigationBarContainerBottom: NSLayoutConstraint! var toolbarBottom: NSLayoutConstraint! var contentContainerTop: NSLayoutConstraint! var tabBarContainerTop: NSLayoutConstraint! - var notificationContainerTop: NSLayoutConstraint! + var notificationContainerTopToNavigationBar: NSLayoutConstraint! + var notificationContainerTopToStatusBackground: NSLayoutConstraint! var notificationContainerHeight: NSLayoutConstraint! + var progressBarTop: NSLayoutConstraint! + var progressBarBottom: NSLayoutConstraint! + var statusBackgroundToNavigationBarContainerBottom: NSLayoutConstraint! + var statusBackgroundBottomToSafeAreaTop: NSLayoutConstraint! } func moveAddressBarToPosition(_ position: AddressBarPosition) { + guard position != addressBarPosition else { return } + print(#function, position.rawValue) switch position { case .top: - moveAddressBarToTop() - + toggleAddressBar(true) case .bottom: - moveAddressBarToBottom() + toggleAddressBar(false) } - } - func moveAddressBarToTop() { - print(#function) + addressBarPosition = position } - func moveAddressBarToBottom() { - print(#function) + func toggleAddressBar(_ top: Bool) { + constraints.navigationBarContainerTop.isActive = top + constraints.navigationBarContainerBottom.isActive = !top + + constraints.progressBarTop.isActive = top + constraints.progressBarBottom.isActive = !top + + constraints.notificationContainerTopToNavigationBar.isActive = top + constraints.notificationContainerTopToStatusBackground.isActive = !top + + constraints.statusBackgroundToNavigationBarContainerBottom.isActive = top + constraints.statusBackgroundBottomToSafeAreaTop.isActive = !top } } + +// swiftlint:enable line_length diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 044ce9d537..52c6f4a1a9 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -311,6 +311,7 @@ class MainViewController: UIViewController { @objc func onAddressBarPositionChanged() { viewCoordinator.moveAddressBarToPosition(appSettings.currentAddressBarPosition) + // TODO update any other view elements } @objc func onShowFullSiteAddressChanged() { @@ -347,6 +348,9 @@ class MainViewController: UIViewController { } } + let navBarOffset = max(0, intersection.height - toolbarHeight) + self.viewCoordinator.constraints.navigationBarContainerBottom.constant = -navBarOffset + animateForKeyboard(userInfo: userInfo, y: view.frame.height - height) } @@ -359,6 +363,7 @@ class MainViewController: UIViewController { let frame = self.findInPageView.frame UIView.animate(withDuration: duration, delay: 0, options: animationCurve, animations: { self.findInPageView.frame = CGRect(x: 0, y: y - frame.height, width: frame.width, height: frame.height) + self.viewCoordinator.navigationBarContainer.updateConstraintsIfNeeded() }, completion: nil) } @@ -507,7 +512,7 @@ class MainViewController: UIViewController { omniBar.frame = viewCoordinator.navigationBarContainer.bounds viewCoordinator.navigationBarContainer.addSubview(omniBar) } - + fileprivate func attachHomeScreen() { viewCoordinator.logoContainer.isHidden = false findInPageView.isHidden = true @@ -915,11 +920,11 @@ class MainViewController: UIViewController { notificationView.setTitle(text: title) notificationView.setMessage(text: message) viewCoordinator.notificationBarContainer.addSubview(notificationView) - viewCoordinator.constraints.notificationContainerTop.constant = -notificationView.frame.size.height + // TODO viewCoordinator.constraints.notificationContainerTop.constant = -notificationView.frame.size.height self.notificationView = notificationView DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { - self.viewCoordinator.constraints.notificationContainerTop.constant = 0 + // TODO self.viewCoordinator.constraints.notificationContainerTop.constant = 0 self.viewCoordinator.constraints.notificationContainerHeight.constant = notificationView.frame.size.height UIView.animate(withDuration: 0.3) { self.view.layoutIfNeeded() @@ -930,12 +935,12 @@ class MainViewController: UIViewController { func hideNotification() { - viewCoordinator.constraints.notificationContainerTop.constant = -(notificationView?.frame.size.height ?? 0) + // TODO viewCoordinator.constraints.notificationContainerTop.constant = -(notificationView?.frame.size.height ?? 0) viewCoordinator.constraints.notificationContainerHeight.constant = 0 UIView.animate(withDuration: 0.5, animations: { self.view.layoutIfNeeded() }, completion: { _ in - self.viewCoordinator.constraints.notificationContainerTop.constant = 0 + // TODO self.viewCoordinator.constraints.notificationContainerTop.constant = 0 self.notificationView?.removeFromSuperview() }) From b84b5d09047123113454c479d7f767647f3a5b1d Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 00:07:12 +0100 Subject: [PATCH 07/67] remove print --- DuckDuckGo/MainView.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/DuckDuckGo/MainView.swift b/DuckDuckGo/MainView.swift index 89d47d45a2..577daf62d5 100644 --- a/DuckDuckGo/MainView.swift +++ b/DuckDuckGo/MainView.swift @@ -360,8 +360,6 @@ class MainViewCoordinator { func moveAddressBarToPosition(_ position: AddressBarPosition) { guard position != addressBarPosition else { return } - - print(#function, position.rawValue) switch position { case .top: toggleAddressBar(true) From d084d7605b8a1b62cb277bf16ff40ca1388a012f Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 00:35:17 +0100 Subject: [PATCH 08/67] make sure home row still works --- DuckDuckGo/MainViewController.swift | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 52c6f4a1a9..50f300b72b 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -363,7 +363,7 @@ class MainViewController: UIViewController { let frame = self.findInPageView.frame UIView.animate(withDuration: duration, delay: 0, options: animationCurve, animations: { self.findInPageView.frame = CGRect(x: 0, y: y - frame.height, width: frame.width, height: frame.height) - self.viewCoordinator.navigationBarContainer.updateConstraintsIfNeeded() + self.view.layoutIfNeeded() }, completion: nil) } @@ -920,11 +920,9 @@ class MainViewController: UIViewController { notificationView.setTitle(text: title) notificationView.setMessage(text: message) viewCoordinator.notificationBarContainer.addSubview(notificationView) - // TODO viewCoordinator.constraints.notificationContainerTop.constant = -notificationView.frame.size.height self.notificationView = notificationView DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { - // TODO self.viewCoordinator.constraints.notificationContainerTop.constant = 0 self.viewCoordinator.constraints.notificationContainerHeight.constant = notificationView.frame.size.height UIView.animate(withDuration: 0.3) { self.view.layoutIfNeeded() @@ -935,12 +933,11 @@ class MainViewController: UIViewController { func hideNotification() { - // TODO viewCoordinator.constraints.notificationContainerTop.constant = -(notificationView?.frame.size.height ?? 0) viewCoordinator.constraints.notificationContainerHeight.constant = 0 UIView.animate(withDuration: 0.5, animations: { - self.view.layoutIfNeeded() + self.notificationView?.frame = self.notificationView?.frame.offsetBy(dx: 0, dy: -100) ?? .zero + self.view.layoutSubviews() }, completion: { _ in - // TODO self.viewCoordinator.constraints.notificationContainerTop.constant = 0 self.notificationView?.removeFromSuperview() }) From 571a4dcc3156c53d4e51ec943f1ff70075934ab1 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 00:53:15 +0100 Subject: [PATCH 09/67] add animation on close --- DuckDuckGo/MainViewController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 50f300b72b..e804f0cb89 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -923,7 +923,7 @@ class MainViewController: UIViewController { self.notificationView = notificationView DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { - self.viewCoordinator.constraints.notificationContainerHeight.constant = notificationView.frame.size.height + self.viewCoordinator.constraints.notificationContainerHeight.constant = notificationView.frame.height UIView.animate(withDuration: 0.3) { self.view.layoutIfNeeded() } @@ -935,7 +935,9 @@ class MainViewController: UIViewController { viewCoordinator.constraints.notificationContainerHeight.constant = 0 UIView.animate(withDuration: 0.5, animations: { - self.notificationView?.frame = self.notificationView?.frame.offsetBy(dx: 0, dy: -100) ?? .zero + if let frame = self.notificationView?.frame { + self.notificationView?.frame = frame.offsetBy(dx: 0, dy: -frame.height) + } self.view.layoutSubviews() }, completion: { _ in self.notificationView?.removeFromSuperview() From d02019ba60dc6c41af4475a08082938475eca702 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 16:14:07 +0100 Subject: [PATCH 10/67] apply background and arrow to suggestions --- .../Arrow-Down-Left-24.svg | 3 +++ .../Arrow-Down-Left-24.imageset/Contents.json | 16 +++++++++++ DuckDuckGo/AutocompleteViewController.swift | 26 +++++++++++++++--- DuckDuckGo/MainViewController.swift | 27 +++++++++++++++++-- DuckDuckGo/SuggestionTableViewCell.swift | 11 ++++++-- 5 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Arrow-Down-Left-24.imageset/Arrow-Down-Left-24.svg create mode 100644 DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Arrow-Down-Left-24.imageset/Contents.json diff --git a/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Arrow-Down-Left-24.imageset/Arrow-Down-Left-24.svg b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Arrow-Down-Left-24.imageset/Arrow-Down-Left-24.svg new file mode 100644 index 0000000000..a2d3aa85a9 --- /dev/null +++ b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Arrow-Down-Left-24.imageset/Arrow-Down-Left-24.svg @@ -0,0 +1,3 @@ + + + diff --git a/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Arrow-Down-Left-24.imageset/Contents.json b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Arrow-Down-Left-24.imageset/Contents.json new file mode 100644 index 0000000000..e7a4bdced3 --- /dev/null +++ b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Arrow-Down-Left-24.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "Arrow-Down-Left-24.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/DuckDuckGo/AutocompleteViewController.swift b/DuckDuckGo/AutocompleteViewController.swift index 6113b67a2d..50eb2e577b 100644 --- a/DuckDuckGo/AutocompleteViewController.swift +++ b/DuckDuckGo/AutocompleteViewController.swift @@ -33,6 +33,8 @@ class AutocompleteViewController: UIViewController { weak var delegate: AutocompleteViewControllerDelegate? weak var presentationDelegate: AutocompleteViewControllerPresentationDelegate? + let appSettings: AppSettings + private var lastRequest: AutocompleteRequest? private var receivedResponse = false private var pendingRequest = false @@ -43,9 +45,15 @@ class AutocompleteViewController: UIViewController { private var bookmarksSearch: BookmarksStringSearch! + var backgroundColor: UIColor { + appSettings.currentAddressBarPosition == .top ? + UIColor.black.withAlphaComponent(0.2) : + UIColor(designSystemColor: .background) + } + var showBackground = true { didSet { - view.backgroundColor = showBackground ? UIColor.black.withAlphaComponent(0.2) : UIColor.clear + view.backgroundColor = showBackground ? backgroundColor : UIColor.clear } } @@ -63,13 +71,25 @@ class AutocompleteViewController: UIViewController { static func loadFromStoryboard(bookmarksSearch: BookmarksStringSearch) -> AutocompleteViewController { let storyboard = UIStoryboard(name: "Autocomplete", bundle: nil) - guard let controller = storyboard.instantiateInitialViewController() as? AutocompleteViewController else { + + guard let controller = storyboard.instantiateInitialViewController(creator: { coder in + AutocompleteViewController(coder: coder, appSettings: AppDependencyProvider.shared.appSettings) + }) else { fatalError("Failed to instatiate correct Autocomplete view controller") } controller.bookmarksSearch = bookmarksSearch return controller } + required init?(coder: NSCoder) { + fatalError("not implemented") + } + + required init?(coder: NSCoder, appSettings: AppSettings) { + self.appSettings = appSettings + super.init(coder: coder) + } + override func viewDidLoad() { super.viewDidLoad() configureTableView() @@ -210,7 +230,7 @@ extension AutocompleteViewController: UITableViewDataSource { let currentTheme = ThemeManager.shared.currentTheme - cell.updateFor(query: query, suggestion: suggestions[indexPath.row], with: currentTheme) + cell.updateFor(query: query, suggestion: suggestions[indexPath.row], with: currentTheme, appSettings: appSettings) cell.plusButton.tag = indexPath.row let color = indexPath.row == selectedItem ? currentTheme.tableCellSelectedColor : UIColor(designSystemColor: .panel) diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index e804f0cb89..ffc77fd182 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -214,6 +214,7 @@ class MainViewController: UIViewController { registerForSettingsChangeNotifications() tabManager.cleanupTabsFaviconCache() + refreshViewsBasedOnAddressBarPosition() } override func viewDidAppear(_ animated: Bool) { @@ -311,7 +312,18 @@ class MainViewController: UIViewController { @objc func onAddressBarPositionChanged() { viewCoordinator.moveAddressBarToPosition(appSettings.currentAddressBarPosition) + decorate(with: ThemeManager.shared.currentTheme) + refreshViewsBasedOnAddressBarPosition() + } + + func refreshViewsBasedOnAddressBarPosition() { // TODO update any other view elements + switch appSettings.currentAddressBarPosition { + case .top: + omniBar.showSeparator() + case .bottom: + omniBar.hideSeparator() + } } @objc func onShowFullSiteAddressChanged() { @@ -1895,11 +1907,12 @@ extension MainViewController: Themable { viewCoordinator.navigationBarContainer.tintColor = theme.barTintColor omniBar.decorate(with: theme) + viewCoordinator.progress.decorate(with: theme) viewCoordinator.toolbar.barTintColor = theme.barBackgroundColor viewCoordinator.toolbar.tintColor = theme.barTintColor - + tabSwitcherButton.decorate(with: theme) gestureBookmarksButton.decorate(with: theme) viewCoordinator.toolbarTabSwitcherButton.tintColor = theme.barTintColor @@ -1911,8 +1924,18 @@ extension MainViewController: Themable { findInPageView.decorate(with: theme) viewCoordinator.logoText.tintColor = theme.ddgTextTintColor + + // Do this last or else things get reset + if appSettings.currentAddressBarPosition == .bottom { +// omniBar.backgroundColor = UIColor(designSystemColor: .panel) +// omniBar.hideSeparator() +// viewCoordinator.toolbar.backgroundColor = UIColor(designSystemColor: .panel) +// viewCoordinator.toolbar.setShadowImage(UIImage(), forToolbarPosition: .bottom) +// viewCoordinator.toolbar.setBackgroundImage(UIImage(), forToolbarPosition: .bottom, barMetrics: .default) + + } } - + } extension MainViewController: OnboardingDelegate { diff --git a/DuckDuckGo/SuggestionTableViewCell.swift b/DuckDuckGo/SuggestionTableViewCell.swift index 0906326091..229c479007 100644 --- a/DuckDuckGo/SuggestionTableViewCell.swift +++ b/DuckDuckGo/SuggestionTableViewCell.swift @@ -32,7 +32,7 @@ class SuggestionTableViewCell: UITableViewCell { @IBOutlet weak var typeImage: UIImageView! @IBOutlet weak var plusButton: UIButton! - func updateFor(query: String, suggestion: Suggestion, with theme: Theme) { + func updateFor(query: String, suggestion: Suggestion, with theme: Theme, appSettings: AppSettings) { switch suggestion.source { case .local: @@ -47,8 +47,15 @@ class SuggestionTableViewCell: UITableViewCell { self.accessibilityValue = UserText.voiceoverSuggestionTypeSearch } } + self.plusButton.accessibilityLabel = UserText.voiceoverActionAutocomplete - + switch appSettings.currentAddressBarPosition { + case .bottom: + self.plusButton.setImage(UIImage(named: "Arrow-Down-Left-24"), for: .normal) + case .top: + self.plusButton.setImage(UIImage(named: "Arrow-Top-Left-24"), for: .normal) + } + styleText(query: query, text: suggestion.suggestion, regularColor: theme.tableCellTextColor, From 9a456145c9599d340f2ec3a68f459bfcc58588e0 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 16:52:59 +0100 Subject: [PATCH 11/67] make it easier to reason about colors by putting design system colors in a single place --- DuckDuckGo.xcodeproj/project.pbxproj | 8 +++++-- DuckDuckGo/DarkTheme.swift | 19 ++++----------- DuckDuckGo/LightTheme.swift | 18 ++++---------- DuckDuckGo/Theme+DesignSystem.swift | 36 ++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 DuckDuckGo/Theme+DesignSystem.swift diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index d52e936ba3..5c626c4090 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -374,6 +374,7 @@ 853273B624FFE0BB00E3C778 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8512EA4E24ED30D20073EE19 /* WidgetKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 8536A1C8209AF2410050739E /* MockVariantManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8536A1C7209AF2410050739E /* MockVariantManager.swift */; }; 8536A1CA209AF6490050739E /* HomeRowReminderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8536A1C9209AF6480050739E /* HomeRowReminderTests.swift */; }; + 8536A1FD2ACF114B003AC5BA /* Theme+DesignSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8536A1FC2ACF114B003AC5BA /* Theme+DesignSystem.swift */; }; 85371D242121B9D500920548 /* new_tab.json in Resources */ = {isa = PBXBuildFile; fileRef = 85371D232121B9D400920548 /* new_tab.json */; }; 85372447220DD103009D09CD /* UIKeyCommandExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85372446220DD103009D09CD /* UIKeyCommandExtension.swift */; }; 85374D3821AC419800FF5A1E /* NavigationSearchHomeViewSectionRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85374D3721AC419800FF5A1E /* NavigationSearchHomeViewSectionRenderer.swift */; }; @@ -694,8 +695,8 @@ C17B59592A03AAD30055F2D1 /* PasswordGenerationPromptViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17B59562A03AAD30055F2D1 /* PasswordGenerationPromptViewModel.swift */; }; C17B595A2A03AAD30055F2D1 /* PasswordGenerationPromptViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17B59572A03AAD30055F2D1 /* PasswordGenerationPromptViewController.swift */; }; C17B595B2A03AAD30055F2D1 /* PasswordGenerationPromptView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17B59582A03AAD30055F2D1 /* PasswordGenerationPromptView.swift */; }; - C18ED43C2AB8364400BF3805 /* FileTextPreviewDebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18ED43B2AB8364400BF3805 /* FileTextPreviewDebugViewController.swift */; }; C18ED43A2AB6F77600BF3805 /* AutofillSettingsEnableFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18ED4392AB6F77600BF3805 /* AutofillSettingsEnableFooterView.swift */; }; + C18ED43C2AB8364400BF3805 /* FileTextPreviewDebugViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C18ED43B2AB8364400BF3805 /* FileTextPreviewDebugViewController.swift */; }; C1963863283794A000298D4D /* BookmarksCachingSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1963862283794A000298D4D /* BookmarksCachingSearch.swift */; }; C1B0F63E2AB08904001EAF05 /* PhasedRolloutFeatureFlagTester.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1B0F63D2AB08904001EAF05 /* PhasedRolloutFeatureFlagTester.swift */; }; C1B0F6422AB08BE9001EAF05 /* MockPrivacyConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1B0F6412AB08BE9001EAF05 /* MockPrivacyConfiguration.swift */; }; @@ -1378,6 +1379,7 @@ 853273B124FF114700E3C778 /* DeepLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinks.swift; sourceTree = ""; }; 8536A1C7209AF2410050739E /* MockVariantManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockVariantManager.swift; sourceTree = ""; }; 8536A1C9209AF6480050739E /* HomeRowReminderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeRowReminderTests.swift; sourceTree = ""; }; + 8536A1FC2ACF114B003AC5BA /* Theme+DesignSystem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Theme+DesignSystem.swift"; sourceTree = ""; }; 85371D232121B9D400920548 /* new_tab.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = new_tab.json; sourceTree = ""; }; 85372446220DD103009D09CD /* UIKeyCommandExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKeyCommandExtension.swift; sourceTree = ""; }; 85374D3721AC419800FF5A1E /* NavigationSearchHomeViewSectionRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationSearchHomeViewSectionRenderer.swift; sourceTree = ""; }; @@ -2268,8 +2270,8 @@ C17B59562A03AAD30055F2D1 /* PasswordGenerationPromptViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordGenerationPromptViewModel.swift; sourceTree = ""; }; C17B59572A03AAD30055F2D1 /* PasswordGenerationPromptViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordGenerationPromptViewController.swift; sourceTree = ""; }; C17B59582A03AAD30055F2D1 /* PasswordGenerationPromptView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordGenerationPromptView.swift; sourceTree = ""; }; - C18ED43B2AB8364400BF3805 /* FileTextPreviewDebugViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileTextPreviewDebugViewController.swift; sourceTree = ""; }; C18ED4392AB6F77600BF3805 /* AutofillSettingsEnableFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutofillSettingsEnableFooterView.swift; sourceTree = ""; }; + C18ED43B2AB8364400BF3805 /* FileTextPreviewDebugViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileTextPreviewDebugViewController.swift; sourceTree = ""; }; C1963862283794A000298D4D /* BookmarksCachingSearch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarksCachingSearch.swift; sourceTree = ""; }; C1B0F63D2AB08904001EAF05 /* PhasedRolloutFeatureFlagTester.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhasedRolloutFeatureFlagTester.swift; sourceTree = ""; }; C1B0F63F2AB08A53001EAF05 /* PhasedRolloutFeatureFlagTesterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhasedRolloutFeatureFlagTesterTests.swift; sourceTree = ""; }; @@ -4047,6 +4049,7 @@ 98DA6EC92181E41F00E65433 /* ThemeManager.swift */, 98F3A1D9217B37200011A0D4 /* LightTheme.swift */, 98F3A1DB217B373E0011A0D4 /* DarkTheme.swift */, + 8536A1FC2ACF114B003AC5BA /* Theme+DesignSystem.swift */, ); name = Themes; sourceTree = ""; @@ -6147,6 +6150,7 @@ F4147354283BF834004AA7A5 /* AutofillContentScopeFeatureToggles.swift in Sources */, 986DA94A24884B18004A7E39 /* WebViewTransition.swift in Sources */, 31B524572715BB23002225AB /* WebJSAlert.swift in Sources */, + 8536A1FD2ACF114B003AC5BA /* Theme+DesignSystem.swift in Sources */, F114C55B1E66EB020018F95F /* NibLoading.swift in Sources */, C10CB5F32A1A5BDF0048E503 /* AutofillViews.swift in Sources */, 982E5630222C3D5B008D861B /* FeedbackPickerViewController.swift in Sources */, diff --git a/DuckDuckGo/DarkTheme.swift b/DuckDuckGo/DarkTheme.swift index c7080613bd..52ec2eece9 100644 --- a/DuckDuckGo/DarkTheme.swift +++ b/DuckDuckGo/DarkTheme.swift @@ -16,9 +16,12 @@ // See the License for the specific language governing permissions and // limitations under the License. // + import UIKit -import DesignResourcesKit +// If you add a new colour here: +// * and it uses the design system, please put it in Theme+DesignSystem instead +// * and it doesn't use the design, please only do so with designer approval struct DarkTheme: Theme { var name = ThemeName.dark @@ -28,15 +31,7 @@ struct DarkTheme: Theme { var tabsBarBackgroundColor = UIColor.black var tabsBarSeparatorColor = UIColor.darkGreyish - - var backgroundColor = UIColor(designSystemColor: .background) - - var mainViewBackgroundColor = UIColor(designSystemColor: .base) - - var omniBarBackgroundColor = UIColor(designSystemColor: .panel) - var barBackgroundColor = UIColor(designSystemColor: .panel) - var barTintColor = UIColor(designSystemColor: .icons) - + var navigationBarTitleColor = UIColor.white var navigationBarTintColor = UIColor.lightMercury @@ -45,7 +40,6 @@ struct DarkTheme: Theme { var searchBarBackgroundColor = UIColor.charcoalGrey var centeredSearchBarBackgroundColor = UIColor.nearlyBlackLight var searchBarTextColor = UIColor.white - var searchBarTextPlaceholderColor = UIColor(designSystemColor: .textSecondary) var searchBarTextDeemphasisColor = UIColor.lightMercury var searchBarBorderColor = UIColor.darkGreyish var searchBarClearTextIconColor = UIColor.greyish2 @@ -53,7 +47,6 @@ struct DarkTheme: Theme { var browsingMenuTextColor = UIColor.white var browsingMenuIconsColor = UIColor.gray20 - var browsingMenuBackgroundColor = UIColor(designSystemColor: .surface) var browsingMenuSeparatorColor = UIColor.charcoalGrey var browsingMenuHighlightColor = UIColor.darkGreyish @@ -63,7 +56,6 @@ struct DarkTheme: Theme { var autocompleteSuggestionTextColor = UIColor.white var autocompleteCellAccessoryColor = UIColor.lightMercury - var tableCellBackgroundColor = UIColor(designSystemColor: .surface) var tableCellSelectedColor = UIColor.charcoalGrey var tableCellSeparatorColor = UIColor.charcoalGrey var tableCellTextColor = UIColor.lightGreyish @@ -72,7 +64,6 @@ struct DarkTheme: Theme { var tableCellHighlightedBackgroundColor = UIColor.greyishBrown var tableHeaderTextColor = UIColor.greyish3 - var tabSwitcherCellBackgroundColor = UIColor(designSystemColor: .surface) var tabSwitcherCellBorderColor = UIColor.white var tabSwitcherCellTextColor = UIColor.white var tabSwitcherCellSecondaryTextColor = UIColor.lightMercury diff --git a/DuckDuckGo/LightTheme.swift b/DuckDuckGo/LightTheme.swift index c3fd3d48f3..465680947a 100644 --- a/DuckDuckGo/LightTheme.swift +++ b/DuckDuckGo/LightTheme.swift @@ -16,9 +16,12 @@ // See the License for the specific language governing permissions and // limitations under the License. // + import UIKit -import DesignResourcesKit +// If you add a new colour here: +// * and it uses the design system, please put it in Theme+DesignSystem instead +// * and it doesn't use the design, please only do so with designer approval struct LightTheme: Theme { var name = ThemeName.light @@ -30,14 +33,7 @@ struct LightTheme: Theme { var tabsBarBackgroundColor = UIColor.gray20 var tabsBarSeparatorColor = UIColor.greyish - var backgroundColor = UIColor(designSystemColor: .background) - - var mainViewBackgroundColor = UIColor(designSystemColor: .base) - - var omniBarBackgroundColor = UIColor(designSystemColor: .panel) - var barBackgroundColor = UIColor(designSystemColor: .panel) - var barTintColor = UIColor(designSystemColor: .icons) - + var navigationBarTitleColor = UIColor.nearlyBlackLight var navigationBarTintColor = UIColor.darkGreyish @@ -46,7 +42,6 @@ struct LightTheme: Theme { var searchBarBackgroundColor = UIColor.lightGreyish var centeredSearchBarBackgroundColor = UIColor.mercury var searchBarTextColor = UIColor.nearlyBlackLight - var searchBarTextPlaceholderColor = UIColor.greyish3 var searchBarTextDeemphasisColor = UIColor.greyish3 var searchBarBorderColor = UIColor.lightGreyish var searchBarClearTextIconColor = UIColor.greyish2 @@ -54,7 +49,6 @@ struct LightTheme: Theme { var browsingMenuTextColor = UIColor.nearlyBlack var browsingMenuIconsColor = UIColor.nearlyBlackLight - var browsingMenuBackgroundColor = UIColor(designSystemColor: .surface) var browsingMenuSeparatorColor = UIColor.mercury var browsingMenuHighlightColor = UIColor.lightGreyish @@ -64,7 +58,6 @@ struct LightTheme: Theme { var autocompleteSuggestionTextColor = UIColor.black var autocompleteCellAccessoryColor = UIColor.darkGreyish - var tableCellBackgroundColor = UIColor(designSystemColor: .surface) var tableCellSelectedColor = UIColor.mercury var tableCellSeparatorColor = UIColor(white: 0, alpha: 0.09) var tableCellTextColor = UIColor.darkGreyish @@ -73,7 +66,6 @@ struct LightTheme: Theme { var tableCellHighlightedBackgroundColor = UIColor.mercury var tableHeaderTextColor = UIColor.greyish3 - var tabSwitcherCellBackgroundColor = UIColor(designSystemColor: .surface) var tabSwitcherCellBorderColor = UIColor.nearlyBlackLight var tabSwitcherCellTextColor = UIColor.black var tabSwitcherCellSecondaryTextColor = UIColor.greyishBrown2 diff --git a/DuckDuckGo/Theme+DesignSystem.swift b/DuckDuckGo/Theme+DesignSystem.swift new file mode 100644 index 0000000000..ea8e387a2c --- /dev/null +++ b/DuckDuckGo/Theme+DesignSystem.swift @@ -0,0 +1,36 @@ +// +// Theme+DesignSystem.swift +// DuckDuckGo +// +// Copyright © 2023 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import UIKit +import DesignResourcesKit + +// Once all colours are from the design system we can consider removing having multiple themes. +extension Theme { + + var omniBarBackgroundColor: UIColor { UIColor(designSystemColor: .panel) } + var backgroundColor: UIColor { UIColor(designSystemColor: .background) } + var mainViewBackgroundColor: UIColor { UIColor(designSystemColor: .base) } + var barBackgroundColor: UIColor { UIColor(designSystemColor: .panel) } + var barTintColor: UIColor { UIColor(designSystemColor: .icons) } + var browsingMenuBackgroundColor: UIColor { UIColor(designSystemColor: .surface) } + var tableCellBackgroundColor: UIColor { UIColor(designSystemColor: .surface) } + var tabSwitcherCellBackgroundColor: UIColor { UIColor(designSystemColor: .surface) } + var searchBarTextPlaceholderColor: UIColor { UIColor(designSystemColor: .textSecondary) } + +} From 3847cdb232268348d7ed7f498307ed69c9b005fc Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 19:28:22 +0100 Subject: [PATCH 12/67] update separators when in bottom mode --- DuckDuckGo/Base.lproj/OmniBar.xib | 16 +++++++--- DuckDuckGo/MainView.swift | 47 ++++++++++++++++++++--------- DuckDuckGo/MainViewController.swift | 6 ++-- DuckDuckGo/OmniBar.swift | 12 ++++++++ 4 files changed, 61 insertions(+), 20 deletions(-) diff --git a/DuckDuckGo/Base.lproj/OmniBar.xib b/DuckDuckGo/Base.lproj/OmniBar.xib index 38cf4da246..858eadc513 100644 --- a/DuckDuckGo/Base.lproj/OmniBar.xib +++ b/DuckDuckGo/Base.lproj/OmniBar.xib @@ -1,9 +1,9 @@ - + - + @@ -381,6 +381,7 @@ + @@ -397,6 +398,11 @@ + + + + + @@ -419,6 +425,8 @@ + + @@ -440,7 +448,7 @@ - + @@ -458,7 +466,7 @@ - + diff --git a/DuckDuckGo/MainView.swift b/DuckDuckGo/MainView.swift index 577daf62d5..84e0c2fa01 100644 --- a/DuckDuckGo/MainView.swift +++ b/DuckDuckGo/MainView.swift @@ -336,9 +336,15 @@ class MainViewCoordinator { logoText.tintColor = theme.ddgTextTintColor } - func hideSuggestionTray() { - suggestionTrayContainer.isHidden = true - suggestionTrayContainer.backgroundColor = .clear + func showToolbarSeparator() { + // Setting the background 'resets' the toolbar + toolbar.setBackgroundImage(nil, forToolbarPosition: .bottom, barMetrics: .default) + toolbar.setShadowImage(nil, forToolbarPosition: .bottom) + } + + func hideToolbarSeparator() { + // The shadow image is what defines the separator, but we don't need to change the background here (in fact we want to keep it). + toolbar.setShadowImage(UIImage(), forToolbarPosition: .bottom) } class Constraints { @@ -362,26 +368,39 @@ class MainViewCoordinator { guard position != addressBarPosition else { return } switch position { case .top: - toggleAddressBar(true) + moveAddressBarToTop() case .bottom: - toggleAddressBar(false) + moveAddressBarToBottom() } addressBarPosition = position } - func toggleAddressBar(_ top: Bool) { - constraints.navigationBarContainerTop.isActive = top - constraints.navigationBarContainerBottom.isActive = !top + func moveAddressBarToTop() { + constraints.progressBarBottom.isActive = false + constraints.navigationBarContainerBottom.isActive = false + constraints.notificationContainerTopToStatusBackground.isActive = false + constraints.statusBackgroundBottomToSafeAreaTop.isActive = false - constraints.progressBarTop.isActive = top - constraints.progressBarBottom.isActive = !top + constraints.navigationBarContainerTop.isActive = true + constraints.progressBarTop.isActive = true + constraints.notificationContainerTopToNavigationBar.isActive = true + constraints.statusBackgroundToNavigationBarContainerBottom.isActive = true + } - constraints.notificationContainerTopToNavigationBar.isActive = top - constraints.notificationContainerTopToStatusBackground.isActive = !top + func moveAddressBarToBottom() { + constraints.navigationBarContainerTop.isActive = false + constraints.progressBarTop.isActive = false + constraints.notificationContainerTopToNavigationBar.isActive = false + constraints.statusBackgroundToNavigationBarContainerBottom.isActive = false - constraints.statusBackgroundToNavigationBarContainerBottom.isActive = top - constraints.statusBackgroundBottomToSafeAreaTop.isActive = !top + constraints.progressBarBottom.isActive = true + constraints.navigationBarContainerBottom.isActive = true + constraints.notificationContainerTopToStatusBackground.isActive = true + constraints.statusBackgroundBottomToSafeAreaTop.isActive = true + } + + func toggleAddressBar(_ top: Bool) { } } diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index ffc77fd182..3df72af359 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -320,9 +320,11 @@ class MainViewController: UIViewController { // TODO update any other view elements switch appSettings.currentAddressBarPosition { case .top: - omniBar.showSeparator() + omniBar.moveSeparatorToBottom() + viewCoordinator.showToolbarSeparator() case .bottom: - omniBar.hideSeparator() + omniBar.moveSeparatorToTop() + viewCoordinator.hideToolbarSeparator() } } diff --git a/DuckDuckGo/OmniBar.swift b/DuckDuckGo/OmniBar.swift index a344919b27..51fa55c9b2 100644 --- a/DuckDuckGo/OmniBar.swift +++ b/DuckDuckGo/OmniBar.swift @@ -62,6 +62,8 @@ class OmniBar: UIView { @IBOutlet var searchContainerMaxWidthConstraint: NSLayoutConstraint! @IBOutlet var omniBarLeadingConstraint: NSLayoutConstraint! @IBOutlet var omniBarTrailingConstraint: NSLayoutConstraint! + @IBOutlet var separatorToTop: NSLayoutConstraint! + @IBOutlet var separatorToBottom: NSLayoutConstraint! weak var omniDelegate: OmniBarDelegate? fileprivate var state: OmniBarState = SmallOmniBarState.HomeNonEditingState() @@ -193,6 +195,16 @@ class OmniBar: UIView { separatorView.isHidden = true } + func moveSeparatorToTop() { + separatorToBottom.isActive = false + separatorToTop.isActive = true + } + + func moveSeparatorToBottom() { + separatorToTop.isActive = false + separatorToBottom.isActive = true + } + func startBrowsing() { refreshState(state.onBrowsingStartedState) } From 6ad723eaba00394e718a5c460cc664913dd7cf28 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 20:58:26 +0100 Subject: [PATCH 13/67] adjust constraints for the webview --- DuckDuckGo/MainView.swift | 11 ++++++++++- DuckDuckGo/MainViewController.swift | 12 +----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/DuckDuckGo/MainView.swift b/DuckDuckGo/MainView.swift index 84e0c2fa01..4accc7eb1f 100644 --- a/DuckDuckGo/MainView.swift +++ b/DuckDuckGo/MainView.swift @@ -248,13 +248,16 @@ extension MainViewFactory { let contentContainer = coordinator.contentContainer! let toolbar = coordinator.toolbar! let notificationBarContainer = coordinator.notificationBarContainer! + let navigationBarContainer = coordinator.navigationBarContainer! coordinator.constraints.contentContainerTop = contentContainer.constrainView(notificationBarContainer, by: .top, to: .bottom) + coordinator.constraints.contentContainerBottomToToolbarTop = contentContainer.constrainView(toolbar, by: .bottom, to: .top) + coordinator.constraints.contentContainerBottomToNavigationBarContainerTop = contentContainer.constrainView(navigationBarContainer, by: .bottom, to: .top) NSLayoutConstraint.activate([ contentContainer.constrainView(superview, by: .leading), contentContainer.constrainView(superview, by: .trailing), - contentContainer.constrainView(toolbar, by: .bottom, to: .top), + coordinator.constraints.contentContainerBottomToToolbarTop, coordinator.constraints.contentContainerTop, ]) } @@ -361,6 +364,8 @@ class MainViewCoordinator { var progressBarBottom: NSLayoutConstraint! var statusBackgroundToNavigationBarContainerBottom: NSLayoutConstraint! var statusBackgroundBottomToSafeAreaTop: NSLayoutConstraint! + var contentContainerBottomToToolbarTop: NSLayoutConstraint! + var contentContainerBottomToNavigationBarContainerTop: NSLayoutConstraint! } @@ -381,7 +386,9 @@ class MainViewCoordinator { constraints.navigationBarContainerBottom.isActive = false constraints.notificationContainerTopToStatusBackground.isActive = false constraints.statusBackgroundBottomToSafeAreaTop.isActive = false + constraints.contentContainerBottomToNavigationBarContainerTop.isActive = false + constraints.contentContainerBottomToToolbarTop.isActive = true constraints.navigationBarContainerTop.isActive = true constraints.progressBarTop.isActive = true constraints.notificationContainerTopToNavigationBar.isActive = true @@ -393,7 +400,9 @@ class MainViewCoordinator { constraints.progressBarTop.isActive = false constraints.notificationContainerTopToNavigationBar.isActive = false constraints.statusBackgroundToNavigationBarContainerBottom.isActive = false + constraints.contentContainerBottomToToolbarTop.isActive = false + constraints.contentContainerBottomToNavigationBarContainerTop.isActive = true constraints.progressBarBottom.isActive = true constraints.navigationBarContainerBottom.isActive = true constraints.notificationContainerTopToStatusBackground.isActive = true diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 3df72af359..972a80333a 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -350,7 +350,7 @@ class MainViewController: UIViewController { findInPageBottomLayoutConstraint.constant = height currentTab?.webView.scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: height, right: 0) - + if let suggestionsTray = suggestionTrayController { let suggestionsFrameInView = suggestionsTray.view.convert(suggestionsTray.contentFrame, to: view) @@ -1926,16 +1926,6 @@ extension MainViewController: Themable { findInPageView.decorate(with: theme) viewCoordinator.logoText.tintColor = theme.ddgTextTintColor - - // Do this last or else things get reset - if appSettings.currentAddressBarPosition == .bottom { -// omniBar.backgroundColor = UIColor(designSystemColor: .panel) -// omniBar.hideSeparator() -// viewCoordinator.toolbar.backgroundColor = UIColor(designSystemColor: .panel) -// viewCoordinator.toolbar.setShadowImage(UIImage(), forToolbarPosition: .bottom) -// viewCoordinator.toolbar.setBackgroundImage(UIImage(), forToolbarPosition: .bottom, barMetrics: .default) - - } } } From 0e12bd50a52631a452df857e5764d873ff646d64 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 22:08:07 +0100 Subject: [PATCH 14/67] tidy up --- DuckDuckGo/MainView.swift | 46 +++++++++++++++------------------------ 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/DuckDuckGo/MainView.swift b/DuckDuckGo/MainView.swift index 4accc7eb1f..14f6ca1822 100644 --- a/DuckDuckGo/MainView.swift +++ b/DuckDuckGo/MainView.swift @@ -373,43 +373,31 @@ class MainViewCoordinator { guard position != addressBarPosition else { return } switch position { case .top: - moveAddressBarToTop() + setAddressBarBottomActive(false) + setAddressBarTopActive(true) + case .bottom: - moveAddressBarToBottom() + setAddressBarTopActive(false) + setAddressBarBottomActive(true) } addressBarPosition = position } - func moveAddressBarToTop() { - constraints.progressBarBottom.isActive = false - constraints.navigationBarContainerBottom.isActive = false - constraints.notificationContainerTopToStatusBackground.isActive = false - constraints.statusBackgroundBottomToSafeAreaTop.isActive = false - constraints.contentContainerBottomToNavigationBarContainerTop.isActive = false - - constraints.contentContainerBottomToToolbarTop.isActive = true - constraints.navigationBarContainerTop.isActive = true - constraints.progressBarTop.isActive = true - constraints.notificationContainerTopToNavigationBar.isActive = true - constraints.statusBackgroundToNavigationBarContainerBottom.isActive = true - } - - func moveAddressBarToBottom() { - constraints.navigationBarContainerTop.isActive = false - constraints.progressBarTop.isActive = false - constraints.notificationContainerTopToNavigationBar.isActive = false - constraints.statusBackgroundToNavigationBarContainerBottom.isActive = false - constraints.contentContainerBottomToToolbarTop.isActive = false - - constraints.contentContainerBottomToNavigationBarContainerTop.isActive = true - constraints.progressBarBottom.isActive = true - constraints.navigationBarContainerBottom.isActive = true - constraints.notificationContainerTopToStatusBackground.isActive = true - constraints.statusBackgroundBottomToSafeAreaTop.isActive = true + func setAddressBarTopActive(_ active: Bool) { + constraints.contentContainerBottomToToolbarTop.isActive = active + constraints.navigationBarContainerTop.isActive = active + constraints.progressBarTop.isActive = active + constraints.notificationContainerTopToNavigationBar.isActive = active + constraints.statusBackgroundToNavigationBarContainerBottom.isActive = active } - func toggleAddressBar(_ top: Bool) { + func setAddressBarBottomActive(_ active: Bool) { + constraints.contentContainerBottomToNavigationBarContainerTop.isActive = active + constraints.progressBarBottom.isActive = active + constraints.navigationBarContainerBottom.isActive = active + constraints.notificationContainerTopToStatusBackground.isActive = active + constraints.statusBackgroundBottomToSafeAreaTop.isActive = active } } From 7b65c4470e69143c45c0b7f02a678d65648b0ea7 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Thu, 5 Oct 2023 23:02:34 +0100 Subject: [PATCH 15/67] offset the menu when in landscape --- .../BrowsingMenu/BrowsingMenuViewController.swift | 12 ++++++++---- DuckDuckGo/MainViewController.swift | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/DuckDuckGo/BrowsingMenu/BrowsingMenuViewController.swift b/DuckDuckGo/BrowsingMenu/BrowsingMenuViewController.swift index 3d39d1d51b..d9c9bef7f1 100644 --- a/DuckDuckGo/BrowsingMenu/BrowsingMenuViewController.swift +++ b/DuckDuckGo/BrowsingMenu/BrowsingMenuViewController.swift @@ -58,16 +58,18 @@ final class BrowsingMenuViewController: UIViewController { private var headerButtons: [BrowsingMenuButton] = [] private let headerEntries: [BrowsingMenuEntry] private let menuEntries: [BrowsingMenuEntry] + private let appSettings: AppSettings - class func instantiate(headerEntries: [BrowsingMenuEntry], menuEntries: [BrowsingMenuEntry]) -> BrowsingMenuViewController { + class func instantiate(headerEntries: [BrowsingMenuEntry], menuEntries: [BrowsingMenuEntry], appSettings: AppSettings) -> BrowsingMenuViewController { UIStoryboard(name: "BrowsingMenuViewController", bundle: nil).instantiateInitialViewController { coder in - BrowsingMenuViewController(headerEntries: headerEntries, menuEntries: menuEntries, coder: coder) + BrowsingMenuViewController(headerEntries: headerEntries, menuEntries: menuEntries, appSettings: appSettings, coder: coder) }! } - init?(headerEntries: [BrowsingMenuEntry], menuEntries: [BrowsingMenuEntry], coder: NSCoder) { + init?(headerEntries: [BrowsingMenuEntry], menuEntries: [BrowsingMenuEntry], appSettings: AppSettings, coder: NSCoder) { self.headerEntries = headerEntries self.menuEntries = menuEntries + self.appSettings = appSettings super.init(coder: coder) self.transitioningDelegate = self } @@ -219,7 +221,9 @@ final class BrowsingMenuViewController: UIViewController { // Make it go above WebView in Landscape topConstraint.constant = frame.minY + (isIPhoneLandscape ? -10 : 5) // Move menu up in Landscape, as bottom toolbar shrinks - bottomConstraint.constant = windowBounds.maxY - frame.maxY - (isIPhoneLandscape ? 2 : 10) + + let barPositionOffset: CGFloat = appSettings.currentAddressBarPosition == .top ? 0 : 52 + bottomConstraint.constant = windowBounds.maxY - frame.maxY - (isIPhoneLandscape ? 2 : 10) - barPositionOffset rightConstraint.constant = isIPad ? 67 : 10 recalculatePreferredWidthConstraint() diff --git a/DuckDuckGo/MainViewController.swift b/DuckDuckGo/MainViewController.swift index 972a80333a..3ab2df3977 100644 --- a/DuckDuckGo/MainViewController.swift +++ b/DuckDuckGo/MainViewController.swift @@ -1265,7 +1265,8 @@ extension MainViewController: OmniBarDelegate { let entries = tab.buildBrowsingMenu(with: menuBookmarksViewModel) let controller = BrowsingMenuViewController.instantiate(headerEntries: tab.buildBrowsingMenuHeaderContent(), - menuEntries: entries) + menuEntries: entries, + appSettings: appSettings) controller.modalPresentationStyle = .custom self.present(controller, animated: true) { From 26e3aa4246356efdd645ee64b732a12aca204097 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Fri, 6 Oct 2023 00:06:32 +0100 Subject: [PATCH 16/67] fix omnibar layout issue --- DuckDuckGo/Base.lproj/OmniBar.xib | 9 +-------- DuckDuckGo/OmniBar.swift | 10 +++------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/DuckDuckGo/Base.lproj/OmniBar.xib b/DuckDuckGo/Base.lproj/OmniBar.xib index 858eadc513..b72d90e54d 100644 --- a/DuckDuckGo/Base.lproj/OmniBar.xib +++ b/DuckDuckGo/Base.lproj/OmniBar.xib @@ -381,7 +381,6 @@ - @@ -398,11 +397,6 @@ - - - - - @@ -425,8 +419,7 @@ - - + diff --git a/DuckDuckGo/OmniBar.swift b/DuckDuckGo/OmniBar.swift index 51fa55c9b2..c794e6a359 100644 --- a/DuckDuckGo/OmniBar.swift +++ b/DuckDuckGo/OmniBar.swift @@ -62,7 +62,6 @@ class OmniBar: UIView { @IBOutlet var searchContainerMaxWidthConstraint: NSLayoutConstraint! @IBOutlet var omniBarLeadingConstraint: NSLayoutConstraint! @IBOutlet var omniBarTrailingConstraint: NSLayoutConstraint! - @IBOutlet var separatorToTop: NSLayoutConstraint! @IBOutlet var separatorToBottom: NSLayoutConstraint! weak var omniDelegate: OmniBarDelegate? @@ -71,8 +70,7 @@ class OmniBar: UIView { private var privacyIconAndTrackersAnimator = PrivacyIconAndTrackersAnimator() private var notificationAnimator = OmniBarNotificationAnimator() - - + static func loadFromXib() -> OmniBar { return OmniBar.load(nibName: "OmniBar") } @@ -196,13 +194,11 @@ class OmniBar: UIView { } func moveSeparatorToTop() { - separatorToBottom.isActive = false - separatorToTop.isActive = true + separatorToBottom.constant = frame.height } func moveSeparatorToBottom() { - separatorToTop.isActive = false - separatorToBottom.isActive = true + separatorToBottom.constant = 0 } func startBrowsing() { From deed0fd42ddfc1adb6332750066c2e1cbc019adb Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Fri, 6 Oct 2023 01:41:25 +0100 Subject: [PATCH 17/67] swift lint --- DuckDuckGo/MainView.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DuckDuckGo/MainView.swift b/DuckDuckGo/MainView.swift index 14f6ca1822..4dcc981f72 100644 --- a/DuckDuckGo/MainView.swift +++ b/DuckDuckGo/MainView.swift @@ -19,6 +19,7 @@ import UIKit +// swiftlint:disable file_length // swiftlint:disable line_length class MainViewFactory { @@ -403,3 +404,4 @@ class MainViewCoordinator { } // swiftlint:enable line_length +// swiftlint:enable file_length From ed845add0043ae2f7cd0d62435fa447f1824db27 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Fri, 6 Oct 2023 12:25:33 +0100 Subject: [PATCH 18/67] fix toast position --- DuckDuckGo/ActionMessageView.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/ActionMessageView.swift b/DuckDuckGo/ActionMessageView.swift index 37e86221b5..36a8a43937 100644 --- a/DuckDuckGo/ActionMessageView.swift +++ b/DuckDuckGo/ActionMessageView.swift @@ -39,11 +39,13 @@ class ActionMessageView: UIView { static var duration: TimeInterval = 3.0 static var windowBottomPaddingWithBottomBar: CGFloat { + let bottomAddressBarModifier: CGFloat = AppDependencyProvider.shared.appSettings.currentAddressBarPosition == .bottom ? 52 : 0 + if UIDevice.current.userInterfaceIdiom == .phone && !isPortrait { - return 40 + return 40 + bottomAddressBarModifier } - return 70 + return 70 + bottomAddressBarModifier } static var windowBottomPaddingWithoutBottomBar: CGFloat { return 0 From c6e63c59a4e315d24b8582b156815206e5cc6010 Mon Sep 17 00:00:00 2001 From: Chris Brind Date: Fri, 6 Oct 2023 13:14:31 +0100 Subject: [PATCH 19/67] dax onboarding fixes --- DuckDuckGo/ActionMessageView.swift | 3 +- .../Base.lproj/DaxOnboarding.storyboard | 31 +++++++++++++------ .../FullscreenDaxDialogViewController.swift | 24 +++++++++++--- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/DuckDuckGo/ActionMessageView.swift b/DuckDuckGo/ActionMessageView.swift index 36a8a43937..babf264ec5 100644 --- a/DuckDuckGo/ActionMessageView.swift +++ b/DuckDuckGo/ActionMessageView.swift @@ -39,7 +39,8 @@ class ActionMessageView: UIView { static var duration: TimeInterval = 3.0 static var windowBottomPaddingWithBottomBar: CGFloat { - let bottomAddressBarModifier: CGFloat = AppDependencyProvider.shared.appSettings.currentAddressBarPosition == .bottom ? 52 : 0 + let addressBarPosition = AppDependencyProvider.shared.appSettings.currentAddressBarPosition + let bottomAddressBarModifier: CGFloat = addressBarPosition == .bottom ? 52 : 0 if UIDevice.current.userInterfaceIdiom == .phone && !isPortrait { return 40 + bottomAddressBarModifier diff --git a/DuckDuckGo/Base.lproj/DaxOnboarding.storyboard b/DuckDuckGo/Base.lproj/DaxOnboarding.storyboard index f9ac8b1264..f95f44d472 100644 --- a/DuckDuckGo/Base.lproj/DaxOnboarding.storyboard +++ b/DuckDuckGo/Base.lproj/DaxOnboarding.storyboard @@ -1,9 +1,9 @@ - + - + @@ -149,7 +149,7 @@ DuckDuckGo! - + @@ -161,7 +161,7 @@ DuckDuckGo! - +