Skip to content

[MOB-3199] Default Browser Settings Card #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1f60c86
[MOB-3199] Implement Settings Card and Detail Page
d4r1091 Apr 8, 2025
55e27a3
[MOB-3199] Update ConfigurableNudgeCard + Analytics
d4r1091 Apr 9, 2025
1912dc1
[MOB-3199] Update strings in #preview to match correct ones
d4r1091 Apr 9, 2025
ecd2710
[MOB-3199] Improved accessibility of nudge card + detail view
d4r1091 Apr 9, 2025
e157f59
[MOB-3199] Replace Preview adding macro
d4r1091 Apr 9, 2025
e724978
[MOB-3199] Mark card as seen right after showing it
d4r1091 Apr 9, 2025
a71260b
[MOB-3199] Add debug option to show/hide the card
d4r1091 Apr 9, 2025
8a7d31e
[MOB-3199] Default Browser Card is now in in a HeaderFooter
d4r1091 Apr 9, 2025
9ee9e39
[MOB-3199] Remove Ecosia's DefaultBrowserSetting
d4r1091 Apr 9, 2025
41c0740
[MOB-3199] Regenerate Settings section on reset Nudge Card
d4r1091 Apr 9, 2025
47b6bf8
[MOB-3199] Optimize changes `AppSettingsTableViewController`
d4r1091 Apr 9, 2025
fe4645c
[MOB-3199] Move Analytics tap on the `onTap()` event
d4r1091 Apr 9, 2025
f3bb015
[MOB-3199] Further optimization to minimize code lines
d4r1091 Apr 9, 2025
40c82e0
[MOB-3199] Update string key to reuse in Setting item
d4r1091 Apr 9, 2025
e8bf86e
[MOB-3199] Simplify DefaultBrowserCoordinator's detail show
d4r1091 Apr 9, 2025
8d323d2
[MOB-3199] Add `EcosiaDefaultBrowserSettings` to Search section
d4r1091 Apr 9, 2025
ec22caa
[MOB-3199] Add old Analytics's defaultBrowser action
d4r1091 Apr 9, 2025
856a685
[MOB-3199] Adds top padding to the Nudge Card Header
d4r1091 Apr 9, 2025
fe85b7f
[MOB-3199] Play Lottie and stop at the end
d4r1091 Apr 9, 2025
8446eb7
[MOB-3199] Update Nudge Card's headerview background
d4r1091 Apr 9, 2025
8b3b7b8
[MOB-3199] Custom `EcosiaText` to facilitate localization
d4r1091 Apr 9, 2025
0251957
[MOB-3199] Improve nudge card shape
d4r1091 Apr 9, 2025
1c0747f
[MOB-3199] Add accesibilityTrait to the whole button
d4r1091 Apr 9, 2025
2b4d94a
[MOB-3199] Loop lottie default browser detail animation
d4r1091 Apr 9, 2025
16e6564
[MOB-3199] Fix CTA button background
d4r1091 Apr 9, 2025
698407c
[MOB-3199] Fix button CTA rounded corner
d4r1091 Apr 9, 2025
6b1bc5f
[MOB-3199] Update to remove `NavigationView`
d4r1091 Apr 9, 2025
f24346d
[MOB-3199] Extra care to show the correct Done localization
d4r1091 Apr 10, 2025
050bd86
[MOB-3199] Better way to handle the topContentViewBackground
d4r1091 Apr 10, 2025
69609dc
[MOB-3199] Review LottieView wrapper
d4r1091 Apr 10, 2025
181b0fb
[MOB-3199] Simplify Analytics functions. Add CTA click event
d4r1091 Apr 10, 2025
afd789e
[MOB-3199] Swiftlint fix
d4r1091 Apr 10, 2025
bf7c010
[MOB-3199] Simplified nudge card name
d4r1091 Apr 10, 2025
e7a910b
[MOB-3199] Update typo in function (thanks GHCoPilot)
d4r1091 Apr 10, 2025
6c0b875
[MOB-3199] Apply safe unwrap as GHCoPilot suggestion
d4r1091 Apr 10, 2025
a9ca20d
[MOB-3199] Introduce `ViewInspector`. Adds tests
d4r1091 Apr 10, 2025
f14d05c
[MOB-3199] Use of `DefaultBrowser` accessibility constant
d4r1091 Apr 14, 2025
36def99
[MOB-3199] Wire the showDetail analytics to `onAppear` event
d4r1091 Apr 14, 2025
f4abbd1
[MOB-3199] Update tests
d4r1091 Apr 14, 2025
56e52aa
[MOB-3199] Use `EcosiaFloatDesignSystemFoundations`
d4r1091 Apr 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions firefox-ios/Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@
28E91E751B443AD5009DF274 /* SyncConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28E91E741B443AD5009DF274 /* SyncConstants.swift */; };
28ECD9BF1BA1F19900D829DA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = E6231C001B90A44F005ABB0D /* libz.tbd */; };
2C1298AF2BF602D3005AE4E4 /* DefaultSuggestedSites.swift in Sources */ = {isa = PBXBuildFile; fileRef = 394CF6CE1BAA493C00906917 /* DefaultSuggestedSites.swift */; };
2C2EA77F2DA3F2990085F5BC /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 2C2EA77E2DA3F2990085F5BC /* Lottie */; };
2C2F31F52D46612F00977F55 /* TopSitesHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A5BD9582878871B000FE773 /* TopSitesHelperTests.swift */; };
2C2F31F62D4663D800977F55 /* DependencyHelperMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A70EF18295E2E1600790249 /* DependencyHelperMock.swift */; };
2C2F31F72D4664CB00977F55 /* MockThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AA75A622A46272000533F8D /* MockThemeManager.swift */; };
Expand Down Expand Up @@ -323,6 +324,7 @@
2C6C908F2C614A6C007D9B43 /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 2C6C908E2C614A6C007D9B43 /* SnapshotTesting */; };
2C7DC2402B1648BA00C049C8 /* LegacyTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB9A179A20E69A7E00B12184 /* LegacyTheme.swift */; };
2C7DC2462B16493C00C049C8 /* UIConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2816EFFF1B33E05400522243 /* UIConstants.swift */; };
2CC0C2AD2DA804EA006FE9B7 /* ViewInspector in Frameworks */ = {isa = PBXBuildFile; productRef = 2CC0C2AC2DA804EA006FE9B7 /* ViewInspector */; };
2CC246602D520EF90098467A /* EcosiaLightTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC2465E2D520EF90098467A /* EcosiaLightTheme.swift */; };
2CC246612D520EF90098467A /* EcosiaColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC2465C2D520EF90098467A /* EcosiaColor.swift */; };
2CC246632D520EF90098467A /* EcosiaDarkTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CC2465D2D520EF90098467A /* EcosiaDarkTheme.swift */; };
Expand Down Expand Up @@ -9705,6 +9707,7 @@
2CFE9FCE2D45363500B25CE0 /* BrazeUI in Frameworks */,
2CFE9FD22D45364600B25CE0 /* Common in Frameworks */,
2CFE9FEA2D45404800B25CE0 /* SwiftSoup in Frameworks */,
2C2EA77F2DA3F2990085F5BC /* Lottie in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -9714,6 +9717,7 @@
files = (
2CFE9FC02D45348700B25CE0 /* RustMozillaAppServices.framework in Frameworks */,
2CFE9FBF2D45348200B25CE0 /* SnowplowTracker in Frameworks */,
2CC0C2AD2DA804EA006FE9B7 /* ViewInspector in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -14893,6 +14897,7 @@
2CFE9FCF2D45364100B25CE0 /* SnowplowTracker */,
2CFE9FD12D45364600B25CE0 /* Common */,
2CFE9FE92D45404800B25CE0 /* SwiftSoup */,
2C2EA77E2DA3F2990085F5BC /* Lottie */,
);
productName = Ecosia;
productReference = 2CFE99662D45329200B25CE0 /* Ecosia.framework */;
Expand All @@ -14917,6 +14922,7 @@
name = EcosiaTests;
packageProductDependencies = (
2CFE9FBE2D45348200B25CE0 /* SnowplowTracker */,
2CC0C2AC2DA804EA006FE9B7 /* ViewInspector */,
);
productName = EcosiaTests;
productReference = 2CFE996F2D45329300B25CE0 /* EcosiaTests.xctest */;
Expand Down Expand Up @@ -15464,6 +15470,7 @@
126509832CD925B30011BA36 /* XCRemoteSwiftPackageReference "braze-swift-sdk" */,
12C25BEB2D27EBFF0048BADA /* XCRemoteSwiftPackageReference "snowplow-ios-tracker" */,
2CFE9FE82D453F9600B25CE0 /* XCRemoteSwiftPackageReference "SwiftSoup" */,
2CC0C2A72DA802CD006FE9B7 /* XCRemoteSwiftPackageReference "ViewInspector" */,
);
productRefGroup = F84B21BF1A090F8100AAB793 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -27139,6 +27146,14 @@
minimumVersion = 1.17.3;
};
};
2CC0C2A72DA802CD006FE9B7 /* XCRemoteSwiftPackageReference "ViewInspector" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/nalexn/ViewInspector.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.10.1;
};
};
2CCFB3D82C0FC4DC00BEDCA0 /* XCRemoteSwiftPackageReference "rust-components-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/ecosia/rust-components-swift/";
Expand Down Expand Up @@ -27270,6 +27285,11 @@
isa = XCSwiftPackageProductDependency;
productName = Redux;
};
2C2EA77E2DA3F2990085F5BC /* Lottie */ = {
isa = XCSwiftPackageProductDependency;
package = 8AB30EC62B6C038600BD9A9B /* XCRemoteSwiftPackageReference "lottie-ios" */;
productName = Lottie;
};
2C69DA7A2C6225C400D7F69F /* Common */ = {
isa = XCSwiftPackageProductDependency;
productName = Common;
Expand All @@ -27284,6 +27304,11 @@
package = 2CCFB3D82C0FC4DC00BEDCA0 /* XCRemoteSwiftPackageReference "rust-components-swift" */;
productName = MozillaAppServices;
};
2CC0C2AC2DA804EA006FE9B7 /* ViewInspector */ = {
isa = XCSwiftPackageProductDependency;
package = 2CC0C2A72DA802CD006FE9B7 /* XCRemoteSwiftPackageReference "ViewInspector" */;
productName = ViewInspector;
};
2CFE9FBE2D45348200B25CE0 /* SnowplowTracker */ = {
isa = XCSwiftPackageProductDependency;
package = 12C25BEB2D27EBFF0048BADA /* XCRemoteSwiftPackageReference "snowplow-ios-tracker" */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@
"version" : "2.0.0"
}
},
{
"identity" : "viewinspector",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nalexn/ViewInspector.git",
"state" : {
"revision" : "788e7879d38a839c4e348ab0762dcc0364e646a2",
"version" : "0.10.1"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ extension AppSettingsTableViewController {

func getEcosiaSettingsSectionsShowingDebug(_ isDebugSectionEnabled: Bool) -> [SettingSection] {
var sections = [
getEcosiaDefaultBrowserSection(),
getSearchSection(),
getCustomizationSection(),
getEcosiaGeneralSection(),
Expand All @@ -20,6 +19,10 @@ extension AppSettingsTableViewController {
getEcosiaAboutSection()
]

if User.shared.shouldShowDefaultBrowserSettingNudgeCard {
sections.insert(getEcosiaDefaultBrowserSection(), at: 0)
}

if isDebugSectionEnabled {
sections.append(getEcosiaDebugSupportSection())
}
Expand All @@ -30,14 +33,15 @@ extension AppSettingsTableViewController {

extension AppSettingsTableViewController {

// We need this section as a placeholder for the default browser nudge card.
private func getEcosiaDefaultBrowserSection() -> SettingSection {
.init(footerTitle: .init(string: .localized(.linksFromWebsites)),
children: [DefaultBrowserSetting(theme: themeManager.getCurrentTheme(for: windowUUID))])
.init(children: [DefaultBrowserSetting(theme: themeManager.getCurrentTheme(for: windowUUID))])
}

private func getSearchSection() -> SettingSection {

var settings: [Setting] = [
let settings: [Setting] = [
EcosiaDefaultBrowserSettings(),
SearchAreaSetting(settings: self),
SafeSearchSettings(settings: self),
AutoCompleteSettings(prefs: profile.prefs, theme: themeManager.getCurrentTheme(for: windowUUID)),
Expand Down Expand Up @@ -149,6 +153,7 @@ extension AppSettingsTableViewController {
AddClaim(settings: self),
ChangeSearchCount(settings: self),
ResetSearchCount(settings: self),
ResetDefaultBrowserNudgeCard(settings: self),
AnalyticsIdentifierSetting(settings: self),
FasterInactiveTabs(settings: self, settingsDelegate: self),
UnleashBrazeIntegrationSetting(settings: self),
Expand All @@ -170,3 +175,30 @@ extension AppSettingsTableViewController {
return SettingSection(title: NSAttributedString(string: "Debug"), children: hiddenDebugSettings)
}
}

// MARK: - Default Browser Nudge Card helpers

extension AppSettingsTableViewController {

func isDefaultBrowserCell(_ section: Int) -> Bool {
settings[section].children.first?.accessibilityIdentifier == AccessibilityIdentifiers.Settings.DefaultBrowser.defaultBrowser
}

func shouldShowDefaultBrowserNudgeCardInSection(_ section: Int) -> Bool {
isDefaultBrowserCell(section) &&
User.shared.shouldShowDefaultBrowserSettingNudgeCard
}

func hideDefaultBrowserNudgeCardInSection(_ section: Int) {
guard section < settings.count else { return }
self.settings.remove(at: section)
self.tableView.deleteSections(IndexSet(integer: section), with: .automatic)
}

func showDefaultBrowserDetailView() {
DefaultBrowserCoordinator.makeDefaultCoordinatorAndShowDetailViewFrom(navigationController,
analyticsLabel: .settingsNudgeCard,
topViewContentBackground: EcosiaColor.DarkGreen50.color,
with: themeManager.getCurrentTheme(for: windowUUID))
}
}
19 changes: 19 additions & 0 deletions firefox-ios/Client/Ecosia/Settings/EcosiaDebugSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@ final class ChangeSearchCount: HiddenSetting {
}
}

final class ResetDefaultBrowserNudgeCard: HiddenSetting {
override var title: NSAttributedString? {
return NSAttributedString(string: "Debug: Makes the Default Browser nudge card visible again", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText])
}

override var status: NSAttributedString? {
let status = "\(User.shared.shouldShowDefaultBrowserSettingNudgeCard)"
let suggestion = User.shared.shouldShowDefaultBrowserSettingNudgeCard ? "" : " (Click to show)"
return NSAttributedString(string: "Card visible: \(status)\(suggestion)", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText])
}

override func onClick(_ navigationController: UINavigationController?) {
guard !User.shared.shouldShowDefaultBrowserSettingNudgeCard else { return }
User.shared.showDefaultBrowserSettingNudgeCard()
self.settings.settings = self.settings.generateSettings()
self.settings.tableView.reloadData()
}
}

class UnleashVariantResetSetting: HiddenSetting {
var titleName: String? { return nil }
var variant: Unleash.Variant? { return nil }
Expand Down
16 changes: 16 additions & 0 deletions firefox-ios/Client/Ecosia/Settings/EcosiaSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ func ecosiaDisclosureIndicator(theme: Theme) -> UIImageView {
return disclosureIndicator
}

final class EcosiaDefaultBrowserSettings: Setting {

override var accessoryView: UIImageView? { ecosiaDisclosureIndicator(theme: theme) }

override var title: NSAttributedString? {
NSAttributedString(string: .localized(.defaultBrowserSettingTitle), attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText])
}

override func onClick(_ navigationController: UINavigationController?) {
DefaultBrowserCoordinator.makeDefaultCoordinatorAndShowDetailViewFrom(navigationController,
analyticsLabel: .settings,
topViewContentBackground: EcosiaColor.DarkGreen50.color,
with: theme)
}
}

final class SearchAreaSetting: Setting {
override var title: NSAttributedString? {
NSAttributedString(string: .localized(.searchRegion), attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText])
Expand Down
Binary file not shown.
Loading
Loading