Skip to content

Commit

Permalink
address bar position (#2072)
Browse files Browse the repository at this point in the history
  • Loading branch information
brindy authored Oct 16, 2023
1 parent e119bad commit 6261549
Show file tree
Hide file tree
Showing 46 changed files with 925 additions and 442 deletions.
8 changes: 7 additions & 1 deletion Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ extension Pixel {

case autofillJSPixelFired(_ pixel: AutofillUserScript.JSPixel)

case navigationbarPositionBottom
case navigationBarPositionTop

case secureVaultInitError
case secureVaultError

Expand Down Expand Up @@ -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)"

Expand Down
3 changes: 3 additions & 0 deletions Core/UserDefaultsPropertyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public struct UserDefaultsWrapper<T> {
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
Expand Down
20 changes: 12 additions & 8 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */; };
Expand Down Expand Up @@ -1376,6 +1377,7 @@
853273B124FF114700E3C778 /* DeepLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeepLinks.swift; sourceTree = "<group>"; };
8536A1C7209AF2410050739E /* MockVariantManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockVariantManager.swift; sourceTree = "<group>"; };
8536A1C9209AF6480050739E /* HomeRowReminderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeRowReminderTests.swift; sourceTree = "<group>"; };
8536A1FC2ACF114B003AC5BA /* Theme+DesignSystem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Theme+DesignSystem.swift"; sourceTree = "<group>"; };
85371D232121B9D400920548 /* new_tab.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = new_tab.json; sourceTree = "<group>"; };
85372446220DD103009D09CD /* UIKeyCommandExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIKeyCommandExtension.swift; sourceTree = "<group>"; };
85374D3721AC419800FF5A1E /* NavigationSearchHomeViewSectionRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationSearchHomeViewSectionRenderer.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1409,6 +1411,7 @@
85519124247468580010FDD0 /* TrackerRadarIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackerRadarIntegrationTests.swift; sourceTree = "<group>"; };
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 = "<group>"; };
855D45D22ACD7DD1008F7AC6 /* AddressBarPositionSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressBarPositionSettingsViewController.swift; sourceTree = "<group>"; };
855D914C2063EF6A00C4B448 /* TabSwitcherTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabSwitcherTransition.swift; sourceTree = "<group>"; };
8563A03B1F9288D600F04442 /* BrowserChromeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowserChromeManager.swift; sourceTree = "<group>"; };
8565A34A1FC8D96B00239327 /* LaunchTabNotification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchTabNotification.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1544,7 +1547,6 @@
981DCA992521EFAB00CD4C18 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = "<group>"; };
981FED682201FE69008488D7 /* AutoClearSettingsScreenTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoClearSettingsScreenTests.swift; sourceTree = "<group>"; };
981FED6C22025151008488D7 /* BlankSnapshotViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlankSnapshotViewController.swift; sourceTree = "<group>"; };
981FED702202519C008488D7 /* BlankSnapshot.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = BlankSnapshot.storyboard; sourceTree = "<group>"; };
981FED7322046017008488D7 /* AutoClearTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoClearTests.swift; sourceTree = "<group>"; };
981FED75220464EF008488D7 /* AutoClearSettingsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoClearSettingsModel.swift; sourceTree = "<group>"; };
9820A5D522B1C0B20024E37C /* DDG Trace.tracetemplate */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = "DDG Trace.tracetemplate"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 = "<group>";
Expand Down Expand Up @@ -4067,6 +4070,7 @@
98DA6EC92181E41F00E65433 /* ThemeManager.swift */,
98F3A1D9217B37200011A0D4 /* LightTheme.swift */,
98F3A1DB217B373E0011A0D4 /* DarkTheme.swift */,
8536A1FC2ACF114B003AC5BA /* Theme+DesignSystem.swift */,
);
name = Themes;
sourceTree = "<group>";
Expand Down Expand Up @@ -4933,7 +4937,6 @@
children = (
984147B624F0264B00362052 /* Authentication.storyboard */,
F1AE54E71F0425FC00D9A700 /* AuthenticationViewController.swift */,
981FED702202519C008488D7 /* BlankSnapshot.storyboard */,
981FED6C22025151008488D7 /* BlankSnapshotViewController.swift */,
F1CA3C3A1F045B65005FADB3 /* Authenticator.swift */,
F1CA3C361F045878005FADB3 /* PrivacyStore.swift */,
Expand Down Expand Up @@ -5709,7 +5712,6 @@
1E16260B296845120004127F /* cookie-banner-illustration-animated.json in Resources */,
AA4D6AD323DE4D27007E8790 /* [email protected] in Resources */,
AA4D6AA123DE4CC4007E8790 /* [email protected] in Resources */,
981FED712202519C008488D7 /* BlankSnapshot.storyboard in Resources */,
984147A824F0259000362052 /* Onboarding.storyboard in Resources */,
AA4D6AF723DF0312007E8790 /* [email protected] in Resources */,
AA4D6AE923DE4D33007E8790 /* [email protected] in Resources */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -8978,7 +8982,7 @@
repositoryURL = "https://github.com/duckduckgo/DesignResourcesKit";
requirement = {
kind = exactVersion;
version = 1.1.1;
version = 2.0.0;
};
};
F486D2EF25069482002D07D7 /* XCRemoteSwiftPackageReference "Kingfisher" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
19 changes: 12 additions & 7 deletions DuckDuckGo/ActionMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import UIKit
extension ActionMessageView: NibLoading {}

class ActionMessageView: UIView {

enum PresentationLocation {
case withBottomBar
case withBottomBar(andAddressBarBottom: Bool)
case withoutBottomBar
}

Expand All @@ -45,6 +45,11 @@ class ActionMessageView: UIView {

return 70
}

static var windowBottomPaddingWithAddressBar: CGFloat {
return windowBottomPaddingWithBottomBar + 52
}

static var windowBottomPaddingWithoutBottomBar: CGFloat {
return 0
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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 }
Expand Down
99 changes: 99 additions & 0 deletions DuckDuckGo/AddressBarPositionSettingsViewController.swift
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Loading

0 comments on commit 6261549

Please sign in to comment.