From 62615496d6e4cc2c44a72107c4293473606e3e57 Mon Sep 17 00:00:00 2001 From: Christopher Brind Date: Mon, 16 Oct 2023 20:12:13 +0100 Subject: [PATCH] address bar position (#2072) --- Core/PixelEvent.swift | 8 +- Core/UserDefaultsPropertyWrapper.swift | 3 + DuckDuckGo.xcodeproj/project.pbxproj | 20 +- .../xcshareddata/swiftpm/Package.resolved | 4 +- DuckDuckGo/ActionMessageView.swift | 19 +- ...essBarPositionSettingsViewController.swift | 99 ++++++++ DuckDuckGo/AppDelegate.swift | 7 +- DuckDuckGo/AppSettings.swift | 3 +- DuckDuckGo/AppUserDefaults.swift | 17 +- .../Arrow-Down-Left-24.svg | 3 + .../Arrow-Down-Left-24.imageset/Contents.json | 16 ++ .../24px/Share-24.imageset/Contents.json | 2 +- .../24px/Share-24.imageset/Share-24.pdf | Bin 2300 -> 0 bytes .../24px/Share-24.imageset/Share-Apple-24.svg | 4 + DuckDuckGo/AutocompleteViewController.swift | 50 +++- .../AutocompleteViewControllerDelegate.swift | 1 + .../Base.lproj/DaxOnboarding.storyboard | 31 ++- DuckDuckGo/Base.lproj/OmniBar.xib | 9 +- DuckDuckGo/Base.lproj/Settings.storyboard | 180 ++++++++++---- DuckDuckGo/BlankSnapshot.storyboard | 106 -------- DuckDuckGo/BlankSnapshotViewController.swift | 109 +++++---- DuckDuckGo/BrowserChromeManager.swift | 2 +- .../BrowsingMenuViewController.swift | 12 +- DuckDuckGo/DarkTheme.swift | 19 +- DuckDuckGo/FavoritesOverlay.swift | 22 +- .../FullscreenDaxDialogViewController.swift | 29 ++- DuckDuckGo/LightTheme.swift | 18 +- DuckDuckGo/MainView.swift | 122 +++++++-- .../MainViewController+CookiesManaged.swift | 2 +- DuckDuckGo/MainViewController+Email.swift | 4 +- .../MainViewController+KeyCommands.swift | 4 +- DuckDuckGo/MainViewController.swift | 231 +++++++++++------- DuckDuckGo/OmniBar.swift | 35 ++- DuckDuckGo/SettingsViewController.swift | 34 ++- DuckDuckGo/SuggestionTableViewCell.swift | 10 +- DuckDuckGo/TabViewController.swift | 38 ++- ...bViewControllerBrowsingMenuExtension.swift | 22 +- ...ControllerLongPressBookmarkExtension.swift | 12 +- DuckDuckGo/Theme+DesignSystem.swift | 36 +++ DuckDuckGo/UserText.swift | 5 +- DuckDuckGo/en.lproj/Localizable.strings | 6 + DuckDuckGo/menu_dark.json | 2 +- DuckDuckGo/menu_light.json | 2 +- DuckDuckGoTests/AppSettingsMock.swift | 5 + DuckDuckGoTests/BarsAnimatorTests.swift | 2 +- LocalPackages/Waitlist/Package.swift | 2 +- 46 files changed, 925 insertions(+), 442 deletions(-) create mode 100644 DuckDuckGo/AddressBarPositionSettingsViewController.swift 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 delete mode 100644 DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Share-24.pdf create mode 100644 DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Share-Apple-24.svg delete mode 100644 DuckDuckGo/BlankSnapshot.storyboard create mode 100644 DuckDuckGo/Theme+DesignSystem.swift diff --git a/Core/PixelEvent.swift b/Core/PixelEvent.swift index 1b1193ddc2..e3b1b8dc82 100644 --- a/Core/PixelEvent.swift +++ b/Core/PixelEvent.swift @@ -245,6 +245,9 @@ extension Pixel { case autofillJSPixelFired(_ pixel: AutofillUserScript.JSPixel) + case navigationbarPositionBottom + case navigationBarPositionTop + case secureVaultInitError case secureVaultError @@ -576,7 +579,10 @@ extension Pixel.Event { case .autocompleteSelectedLocal: return "m_au_l" case .autocompleteSelectedRemote: return "m_au_r" - + + case .navigationbarPositionBottom: return "m_seturlbar_bottom" + case .navigationBarPositionTop: return "m_seturlbar_top" + case .feedbackPositive: return "mfbs_positive_submit" case .feedbackNegativePrefix(category: let category): return "mfbs_negative_\(category)" diff --git a/Core/UserDefaultsPropertyWrapper.swift b/Core/UserDefaultsPropertyWrapper.swift index 0d657b9533..7949c231c3 100644 --- a/Core/UserDefaultsPropertyWrapper.swift +++ b/Core/UserDefaultsPropertyWrapper.swift @@ -99,6 +99,9 @@ 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" + case showFullSiteAddress = "com.duckduckgo.ios.showfullsiteaddress" } private let key: Key diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index ecb3e45d5a..0f645d1aea 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 */; }; @@ -405,6 +406,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 */; }; @@ -501,7 +503,6 @@ 981CA7EA2617797500E119D5 /* MainViewController+AddFavoriteFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 981CA7E92617797500E119D5 /* MainViewController+AddFavoriteFlow.swift */; }; 981FED692201FE69008488D7 /* AutoClearSettingsScreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 981FED682201FE69008488D7 /* AutoClearSettingsScreenTests.swift */; }; 981FED6E22025151008488D7 /* BlankSnapshotViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 981FED6C22025151008488D7 /* BlankSnapshotViewController.swift */; }; - 981FED712202519C008488D7 /* BlankSnapshot.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 981FED702202519C008488D7 /* BlankSnapshot.storyboard */; }; 981FED7422046017008488D7 /* AutoClearTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 981FED7322046017008488D7 /* AutoClearTests.swift */; }; 981FED76220464EF008488D7 /* AutoClearSettingsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 981FED75220464EF008488D7 /* AutoClearSettingsModel.swift */; }; 9820EAF522613CD30089094D /* WebProgressWorker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9820EAF422613CD30089094D /* WebProgressWorker.swift */; }; @@ -1376,6 +1377,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 = ""; }; @@ -1409,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 = ""; }; @@ -1544,7 +1547,6 @@ 981DCA992521EFAB00CD4C18 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = ""; }; 981FED682201FE69008488D7 /* AutoClearSettingsScreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoClearSettingsScreenTests.swift; sourceTree = ""; }; 981FED6C22025151008488D7 /* BlankSnapshotViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlankSnapshotViewController.swift; sourceTree = ""; }; - 981FED702202519C008488D7 /* BlankSnapshot.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = BlankSnapshot.storyboard; sourceTree = ""; }; 981FED7322046017008488D7 /* AutoClearTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoClearTests.swift; sourceTree = ""; }; 981FED75220464EF008488D7 /* AutoClearSettingsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoClearSettingsModel.swift; sourceTree = ""; }; 9820A5D522B1C0B20024E37C /* DDG Trace.tracetemplate */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = "DDG Trace.tracetemplate"; sourceTree = ""; }; @@ -3684,19 +3686,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 = ""; @@ -4067,6 +4070,7 @@ 98DA6EC92181E41F00E65433 /* ThemeManager.swift */, 98F3A1D9217B37200011A0D4 /* LightTheme.swift */, 98F3A1DB217B373E0011A0D4 /* DarkTheme.swift */, + 8536A1FC2ACF114B003AC5BA /* Theme+DesignSystem.swift */, ); name = Themes; sourceTree = ""; @@ -4933,7 +4937,6 @@ children = ( 984147B624F0264B00362052 /* Authentication.storyboard */, F1AE54E71F0425FC00D9A700 /* AuthenticationViewController.swift */, - 981FED702202519C008488D7 /* BlankSnapshot.storyboard */, 981FED6C22025151008488D7 /* BlankSnapshotViewController.swift */, F1CA3C3A1F045B65005FADB3 /* Authenticator.swift */, F1CA3C361F045878005FADB3 /* PrivacyStore.swift */, @@ -5709,7 +5712,6 @@ 1E16260B296845120004127F /* cookie-banner-illustration-animated.json in Resources */, AA4D6AD323DE4D27007E8790 /* AppIconPurple29x29@2x.png in Resources */, AA4D6AA123DE4CC4007E8790 /* AppIconBlue60x60@3x.png in Resources */, - 981FED712202519C008488D7 /* BlankSnapshot.storyboard in Resources */, 984147A824F0259000362052 /* Onboarding.storyboard in Resources */, AA4D6AF723DF0312007E8790 /* AppIconRed60x60@2x.png in Resources */, AA4D6AE923DE4D33007E8790 /* AppIconGreen29x29@3x.png in Resources */, @@ -6166,6 +6168,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 */, @@ -6388,6 +6391,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 */, @@ -8978,7 +8982,7 @@ repositoryURL = "https://github.com/duckduckgo/DesignResourcesKit"; requirement = { kind = exactVersion; - version = 1.1.1; + version = 2.0.0; }; }; F486D2EF25069482002D07D7 /* XCRemoteSwiftPackageReference "Kingfisher" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d12c93a90a..6b534cc924 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -42,8 +42,8 @@ "repositoryURL": "https://github.com/duckduckgo/DesignResourcesKit", "state": { "branch": null, - "revision": "5de78d59358ff60651b2cf9322c74a2297927b4e", - "version": "1.1.1" + "revision": "d7ea2561ec7624c224f52e1c9b349075ddf1c782", + "version": "2.0.0" } }, { diff --git a/DuckDuckGo/ActionMessageView.swift b/DuckDuckGo/ActionMessageView.swift index 37e86221b5..57ff705e6e 100644 --- a/DuckDuckGo/ActionMessageView.swift +++ b/DuckDuckGo/ActionMessageView.swift @@ -22,9 +22,9 @@ import UIKit extension ActionMessageView: NibLoading {} class ActionMessageView: UIView { - + enum PresentationLocation { - case withBottomBar + case withBottomBar(andAddressBarBottom: Bool) case withoutBottomBar } @@ -45,6 +45,11 @@ class ActionMessageView: UIView { return 70 } + + static var windowBottomPaddingWithAddressBar: CGFloat { + return windowBottomPaddingWithBottomBar + 52 + } + static var windowBottomPaddingWithoutBottomBar: CGFloat { return 0 } @@ -53,8 +58,8 @@ class ActionMessageView: UIView { private static func bottomPadding(for location: PresentationLocation) -> CGFloat { switch location { - case .withBottomBar: - return Constants.windowBottomPaddingWithBottomBar + case .withBottomBar(let isAddressBarBottom): + return isAddressBarBottom ? Constants.windowBottomPaddingWithAddressBar : Constants.windowBottomPaddingWithBottomBar case .withoutBottomBar: return Constants.windowBottomPaddingWithoutBottomBar } @@ -84,7 +89,7 @@ class ActionMessageView: UIView { static func present(message: NSAttributedString, numberOfLines: Int = 0, actionTitle: String? = nil, - presentationLocation: PresentationLocation = .withBottomBar, + presentationLocation: PresentationLocation = .withBottomBar(andAddressBarBottom: false), onAction: @escaping () -> Void = {}, onDidDismiss: @escaping () -> Void = {}) { let messageView = loadFromXib() @@ -100,7 +105,7 @@ class ActionMessageView: UIView { static func present(message: String, actionTitle: String? = nil, - presentationLocation: PresentationLocation = .withBottomBar, + presentationLocation: PresentationLocation = .withBottomBar(andAddressBarBottom: false), onAction: @escaping () -> Void = {}, onDidDismiss: @escaping () -> Void = {}) { let messageView = loadFromXib() @@ -116,7 +121,7 @@ class ActionMessageView: UIView { private static func present(messageView: ActionMessageView, message: String, actionTitle: String? = nil, - presentationLocation: PresentationLocation = .withBottomBar, + presentationLocation: PresentationLocation = .withBottomBar(andAddressBarBottom: false), onAction: @escaping () -> Void = {}, onDidDismiss: @escaping () -> Void = {}) { guard let window = UIApplication.shared.windows.filter({ $0.isKeyWindow }).first else { return } diff --git a/DuckDuckGo/AddressBarPositionSettingsViewController.swift b/DuckDuckGo/AddressBarPositionSettingsViewController.swift new file mode 100644 index 0000000000..b7df80ab5e --- /dev/null +++ b/DuckDuckGo/AddressBarPositionSettingsViewController.swift @@ -0,0 +1,99 @@ +// +// 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.descriptionText == cell.textLabel?.text ? .checkmark : .none + } + + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + appSettings.currentAddressBarPosition = AddressBarPosition.allCases[indexPath.row] + + switch appSettings.currentAddressBarPosition { + case .top: + Pixel.fire(pixel: .navigationBarPositionTop) + case .bottom: + Pixel.fire(pixel: .navigationbarPositionBottom) + } + + 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 + case bottom + + var isBottom: Bool { + self == .bottom + } + + var descriptionText: String { + switch self { + case .top: + return UserText.addressBarPositionTop + case .bottom: + return UserText.addressBarPositionBottom + } + } +} diff --git a/DuckDuckGo/AppDelegate.swift b/DuckDuckGo/AppDelegate.swift index 604b6db7f2..8707bce4f6 100644 --- a/DuckDuckGo/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate.swift @@ -214,7 +214,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { bookmarksDatabaseCleaner: syncDataProviders.bookmarksAdapter.databaseCleaner, appTrackingProtectionDatabase: appTrackingProtectionDatabase, syncService: syncService, - syncDataProviders: syncDataProviders) + syncDataProviders: syncDataProviders, + appSettings: AppDependencyProvider.shared.appSettings) main.loadViewIfNeeded() window = UIWindow(frame: UIScreen.main.bounds) @@ -543,9 +544,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { overlayWindow = UIWindow(frame: frame) overlayWindow?.windowLevel = UIWindow.Level.alert - let overlay = BlankSnapshotViewController.loadFromStoryboard() + let overlay = BlankSnapshotViewController(appSettings: AppDependencyProvider.shared.appSettings) overlay.delegate = self - + overlayWindow?.rootViewController = overlay overlayWindow?.makeKeyAndVisible() window?.isHidden = true diff --git a/DuckDuckGo/AppSettings.swift b/DuckDuckGo/AppSettings.swift index d79c06e746..45b1354046 100644 --- a/DuckDuckGo/AppSettings.swift +++ b/DuckDuckGo/AppSettings.swift @@ -31,7 +31,8 @@ protocol AppSettings: AnyObject { var sendDoNotSell: Bool { get set } var currentFireButtonAnimation: FireButtonAnimationType { get set } - + var currentAddressBarPosition: AddressBarPosition { get set } + var textSize: Int { get set } var autofillCredentialsEnabled: Bool { get set } diff --git a/DuckDuckGo/AppUserDefaults.swift b/DuckDuckGo/AppUserDefaults.swift index 0a7d98d880..efbfe51d59 100644 --- a/DuckDuckGo/AppUserDefaults.swift +++ b/DuckDuckGo/AppUserDefaults.swift @@ -30,6 +30,7 @@ public class AppUserDefaults: AppSettings { public static let autofillEnabledChange = Notification.Name("com.duckduckgo.app.AutofillEnabledChange") public static let didVerifyInternalUser = Notification.Name("com.duckduckgo.app.DidVerifyInternalUser") public static let inspectableWebViewsToggled = Notification.Name("com.duckduckgo.app.DidToggleInspectableWebViews") + public static let addressBarPositionChanged = Notification.Name("com.duckduckgo.app.AddressBarPositionChanged") } private let groupName: String @@ -176,7 +177,21 @@ 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?.lowercased() ?? "") ?? .top + } + + set { + addressBarPositionStorage = newValue.rawValue + NotificationCenter.default.post(name: Notifications.addressBarPositionChanged, object: currentAddressBarPosition) + } + } + @UserDefaultsWrapper(key: .textSize, defaultValue: 100) var textSize: Int 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/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Contents.json b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Contents.json index baf2e36c14..75bb7a584e 100644 --- a/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Contents.json +++ b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "Share-24.pdf", + "filename" : "Share-Apple-24.svg", "idiom" : "universal" } ], diff --git a/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Share-24.pdf b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Share-24.pdf deleted file mode 100644 index 0031e2fa919d01be6aeeaf624dfa25145467550a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2300 zcmb7`O>Y}F5Qgvk6}%Wo4q9>eO&|!+*hx{eMI5EKpa*rmaTHj)t)vube|=tZm&0{k zpy(cq(Zk_zzR2;_?aiAFbwLP{N>0Ch7E-==Az!`}!+4i}3ccprpN8@N@<|%NUDi5Z zPQ(5vwl~9{hkn?7|4LrJU;paQ;txTcDxXwU*s#QFx~_%J&D#A@u-a4M+>au4#zWUh za-H_kl99&@tqBwhbT%52KsrP}BddZn8IiV87cK26knDx-l1bh~tZE&#Qt|=JnP9z@ zv5Pk05D7w2M-QUON0mS#R+N#Ui)6iVuw^N; zgMIDIT-RV+%nqu~2b73RpHM7g0{bV;Kk(6qt3kTSI@;nb{& z?nwm6)qVx5rDK-s8I4h>VpB};#`)xnJ(pBUC>^@YxMI#kAE2MN+Th5SbB(h`>0DxR zKFoRquk+R?m!KD)#78lTcmMnHk*P8K_wC~wyJ6{w>$2nkugcPmRND=xCa4Mx^|bVeoeixpIth1vHnqa~ zUrt&vb_owm(`4`Q#5CHHhK|UW)WX&33Gp+~7(9)0-uzlK);%q8(5n&g*=2X7>}LtH z(ufOcU4A?BRV~tn{a9s*Sua{f8RmC1CiE~;&yd~N@F5McH~Cqv&am{r9i9i(GKK2M z%F}5cW#nDrNoE;i!fn4B$LVsGAAZHe!?*qAuipo`z1`mr3;21sJM3RgU*(7PPI93% z$JnH5X*ZmwFQ9EpFviZ{3A;_z%w7%0>9p0_7Btjv$!$+ZH5Oe&klFb=cH_R i({zzJ;F93&`@`P@yf6Q!>`#{xj#eRxtE<;<-+Tj}ZPiZz diff --git a/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Share-Apple-24.svg b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Share-Apple-24.svg new file mode 100644 index 0000000000..4615b33b2c --- /dev/null +++ b/DuckDuckGo/Assets.xcassets/DesignSystemIcons/24px/Share-24.imageset/Share-Apple-24.svg @@ -0,0 +1,4 @@ + + + + diff --git a/DuckDuckGo/AutocompleteViewController.swift b/DuckDuckGo/AutocompleteViewController.swift index 6113b67a2d..cc13fc7ead 100644 --- a/DuckDuckGo/AutocompleteViewController.swift +++ b/DuckDuckGo/AutocompleteViewController.swift @@ -43,9 +43,17 @@ class AutocompleteViewController: UIViewController { private var bookmarksSearch: BookmarksStringSearch! + private var appSettings: AppSettings! + + var backgroundColor: UIColor { + appSettings.currentAddressBarPosition.isBottom ? + UIColor(designSystemColor: .background) : + UIColor.black.withAlphaComponent(0.2) + } + var showBackground = true { didSet { - view.backgroundColor = showBackground ? UIColor.black.withAlphaComponent(0.2) : UIColor.clear + view.backgroundColor = showBackground ? backgroundColor : UIColor.clear } } @@ -61,12 +69,15 @@ class AutocompleteViewController: UIViewController { @IBOutlet weak var tableView: UITableView! var shouldOffsetY = false - static func loadFromStoryboard(bookmarksSearch: BookmarksStringSearch) -> AutocompleteViewController { + static func loadFromStoryboard(bookmarksSearch: BookmarksStringSearch, + appSettings: AppSettings = AppDependencyProvider.shared.appSettings) -> AutocompleteViewController { let storyboard = UIStoryboard(name: "Autocomplete", bundle: nil) + guard let controller = storyboard.instantiateInitialViewController() as? AutocompleteViewController else { fatalError("Failed to instatiate correct Autocomplete view controller") } controller.bookmarksSearch = bookmarksSearch + controller.appSettings = appSettings return controller } @@ -101,13 +112,18 @@ class AutocompleteViewController: UIViewController { override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - resetNaviagtionBar() + resetNavigationBar() } - private func resetNaviagtionBar() { + private func resetNavigationBar() { navigationController?.hidesBarsOnSwipe = hidesBarsOnSwipeDefault } + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + tableView.reloadData() + } + func updateQuery(query: String) { self.query = query selectedItem = -1 @@ -210,12 +226,16 @@ 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, + isAddressBarAtBottom: appSettings.currentAddressBarPosition.isBottom) cell.plusButton.tag = indexPath.row - let color = indexPath.row == selectedItem ? currentTheme.tableCellSelectedColor : UIColor(designSystemColor: .panel) - - cell.backgroundColor = color + let baseBackgroundColor = isPad ? UIColor(designSystemColor: .panel) : UIColor(designSystemColor: .background) + let backgroundColor = indexPath.row == selectedItem ? currentTheme.tableCellSelectedColor : baseBackgroundColor + + cell.backgroundColor = backgroundColor cell.tintColor = currentTheme.autocompleteCellAccessoryColor cell.setHighlightedStateBackgroundColor(currentTheme.tableCellHighlightedBackgroundColor) @@ -229,14 +249,24 @@ extension AutocompleteViewController: UITableViewDataSource { } let currentTheme = ThemeManager.shared.currentTheme - cell.backgroundColor = UIColor(designSystemColor: .panel) + cell.backgroundColor = appSettings.currentAddressBarPosition.isBottom ? + UIColor(designSystemColor: .background) : + UIColor(designSystemColor: .panel) + cell.tintColor = currentTheme.autocompleteCellAccessoryColor cell.label?.textColor = currentTheme.tableCellTextColor cell.setHighlightedStateBackgroundColor(currentTheme.tableCellHighlightedBackgroundColor) - + return cell } + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + if appSettings.currentAddressBarPosition.isBottom && suggestions.isEmpty { + return view.frame.height + } + return 46 + } + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return receivedResponse ? max(Constants.minItems, suggestions.count) : 0 } diff --git a/DuckDuckGo/AutocompleteViewControllerDelegate.swift b/DuckDuckGo/AutocompleteViewControllerDelegate.swift index d345970988..fbb0b6d9fb 100644 --- a/DuckDuckGo/AutocompleteViewControllerDelegate.swift +++ b/DuckDuckGo/AutocompleteViewControllerDelegate.swift @@ -28,6 +28,7 @@ protocol AutocompleteViewControllerDelegate: AnyObject { func autocomplete(pressedPlusButtonForSuggestion suggestion: Suggestion) func autocompleteWasDismissed() + } protocol AutocompleteViewControllerPresentationDelegate: AnyObject { 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! - +