Skip to content

Commit

Permalink
Description views added
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba committed Feb 25, 2024
1 parent 6ef342f commit be57d26
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 119 deletions.
18 changes: 9 additions & 9 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
1D220BF82B86192200F8BBC6 /* PreferencesEmailProtectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BF72B86192200F8BBC6 /* PreferencesEmailProtectionView.swift */; };
1D220BF92B86192200F8BBC6 /* PreferencesEmailProtectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BF72B86192200F8BBC6 /* PreferencesEmailProtectionView.swift */; };
1D220BFA2B86192200F8BBC6 /* PreferencesEmailProtectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BF72B86192200F8BBC6 /* PreferencesEmailProtectionView.swift */; };
1D220BFC2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BFB2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift */; };
1D220BFD2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BFB2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift */; };
1D220BFE2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BFB2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift */; };
1D220BFC2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BFB2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift */; };
1D220BFD2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BFB2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift */; };
1D220BFE2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D220BFB2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift */; };
1D26EBAC2B74BECB0002A93F /* NSImageSendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D26EBAB2B74BECB0002A93F /* NSImageSendable.swift */; };
1D26EBAD2B74BECB0002A93F /* NSImageSendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D26EBAB2B74BECB0002A93F /* NSImageSendable.swift */; };
1D26EBAE2B74BECB0002A93F /* NSImageSendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1D26EBAB2B74BECB0002A93F /* NSImageSendable.swift */; };
Expand Down Expand Up @@ -3310,7 +3310,7 @@
1D1C36E229FAE8DA001FA40C /* FaviconManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FaviconManagerTests.swift; sourceTree = "<group>"; };
1D1C36E529FB019C001FA40C /* HistoryTabExtensionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryTabExtensionTests.swift; sourceTree = "<group>"; };
1D220BF72B86192200F8BBC6 /* PreferencesEmailProtectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesEmailProtectionView.swift; sourceTree = "<group>"; };
1D220BFB2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesPaneStatus.swift; sourceTree = "<group>"; };
1D220BFB2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesProtectionStatus.swift; sourceTree = "<group>"; };
1D26EBAB2B74BECB0002A93F /* NSImageSendable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSImageSendable.swift; sourceTree = "<group>"; };
1D26EBAF2B74DB600002A93F /* TabSnapshotCleanupService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabSnapshotCleanupService.swift; sourceTree = "<group>"; };
1D36E657298AA3BA00AA485D /* InternalUserDeciderStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InternalUserDeciderStore.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5234,15 +5234,15 @@
37AFCE8027DA2CA600471A10 /* PreferencesViewController.swift */,
37AFCE8627DA334800471A10 /* PreferencesRootView.swift */,
37AFCE8427DA2D3900471A10 /* PreferencesSidebar.swift */,
1D220BFB2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift */,
1D220BFB2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift */,
37AFCE8A27DB69BC00471A10 /* PreferencesGeneralView.swift */,
1D01A3D72B88DF8B00FE8150 /* PreferencesSyncView.swift */,
1DDC84FA2B8356CE00670238 /* PreferencesDefaultBrowserView.swift */,
1DDC84F62B83558F00670238 /* PreferencesPrivateSearchView.swift */,
1DDC85022B83903E00670238 /* PreferencesWebTrackingProtectionView.swift */,
1DDD3EBF2B84F5D5004CBF2B /* PreferencesCookiePopupProtectionView.swift */,
4B41EDA62B1543C9001EEDF4 /* PreferencesVPNView.swift */,
1D220BF72B86192200F8BBC6 /* PreferencesEmailProtectionView.swift */,
4B41EDA62B1543C9001EEDF4 /* PreferencesVPNView.swift */,
37D2771427E870D4003365FD /* PreferencesAppearanceView.swift */,
379DE4BC27EA31AC002CC3DE /* PreferencesAutofillView.swift */,
1D01A3CF2B88CEC600FE8150 /* PreferencesAccessibilityView.swift */,
Expand Down Expand Up @@ -9999,7 +9999,7 @@
1D26EBAD2B74BECB0002A93F /* NSImageSendable.swift in Sources */,
3706FBF4293F65D500E42796 /* Visit.swift in Sources */,
3706FBF5293F65D500E42796 /* PixelDataStore.swift in Sources */,
1D220BFD2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift in Sources */,
1D220BFD2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift in Sources */,
3706FBF6293F65D500E42796 /* Pixel.swift in Sources */,
3706FBF7293F65D500E42796 /* PixelEvent.swift in Sources */,
3706FBF8293F65D500E42796 /* TabBarFooter.swift in Sources */,
Expand Down Expand Up @@ -10847,7 +10847,7 @@
4B9579E02AC7AE700062CA31 /* BookmarkExtension.swift in Sources */,
4B9579E12AC7AE700062CA31 /* PasswordManagementCreditCardModel.swift in Sources */,
B677FC522B06376B0099EB04 /* ReportFeedbackView.swift in Sources */,
1D220BFE2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift in Sources */,
1D220BFE2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift in Sources */,
4B9579E22AC7AE700062CA31 /* NSEventExtension.swift in Sources */,
1D26EBB22B74DB600002A93F /* TabSnapshotCleanupService.swift in Sources */,
4B9579E32AC7AE700062CA31 /* Onboarding.swift in Sources */,
Expand Down Expand Up @@ -11638,7 +11638,7 @@
98779A0029999B64005D8EB6 /* Bookmark.xcdatamodeld in Sources */,
85589E9E27BFE4500038AD11 /* DefaultBrowserPromptView.swift in Sources */,
4B4032842AAAC24400CCA602 /* WaitlistActivationDateStore.swift in Sources */,
1D220BFC2B87AACF00F8BBC6 /* PreferencesPaneStatus.swift in Sources */,
1D220BFC2B87AACF00F8BBC6 /* PreferencesProtectionStatus.swift in Sources */,
AA512D1424D99D9800230283 /* FaviconManager.swift in Sources */,
7BB108592A43375D000AB95F /* PFMoveApplication.m in Sources */,
4B0AACAC28BC63ED001038AC /* ChromiumFaviconsReader.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Illustration 2.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Illustration 1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "Illustration.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
3 changes: 3 additions & 0 deletions DuckDuckGo/HomePage/View/HomePageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ final class HomePageViewController: NSViewController {
var recentlyVisitedModel: HomePage.Models.RecentlyVisitedModel!
var featuresModel: HomePage.Models.ContinueSetUpModel!
var accessibilityPreferences: AccessibilityPreferences!
var appearancePreferences: AppearancePreferences!
var cancellables = Set<AnyCancellable>()

@UserDefaultsWrapper(key: .defaultBrowserDismissed, defaultValue: false)
Expand Down Expand Up @@ -72,6 +73,7 @@ final class HomePageViewController: NSViewController {
recentlyVisitedModel = createRecentlyVisitedModel()
featuresModel = createFeatureModel()
accessibilityPreferences = AccessibilityPreferences.shared
appearancePreferences = AppearancePreferences.shared

refreshModels()

Expand All @@ -81,6 +83,7 @@ final class HomePageViewController: NSViewController {
.environmentObject(recentlyVisitedModel)
.environmentObject(featuresModel)
.environmentObject(accessibilityPreferences)
.environmentObject(appearancePreferences)
.onTapGesture { [weak self] in
// Remove focus from the address bar if interacting with this view.
self?.view.makeMeFirstResponder()
Expand Down
9 changes: 9 additions & 0 deletions DuckDuckGo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@
},
"also applies here." : {

},
"Always On" : {

},
"Always Show" : {
"comment" : "Preference for always showing the bookmarks bar"
Expand Down Expand Up @@ -8262,6 +8265,9 @@
},
"Privacy Policy " : {

},
"Private Search" : {

},
"private.search.explenation" : {
"comment" : "feature explanation in settings",
Expand Down Expand Up @@ -9245,6 +9251,9 @@
},
"We were unable to import passwords directly from %@." : {
"comment" : "Message when data import fails from a browser. %@ - a browser name"
},
"Web Tracking Protection" : {

},
"web.tracking.protection.explanation" : {
"comment" : "feature explanation in settings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ extension Preferences {
var body: some View {
PreferencePane("Cookie Pop-up Protection") {

// SECTION 1: Cookie Popup Protection
PreferencePaneSection {
ToggleMenuItem(UserText.autoconsentCheckboxTitle, isOn: $model.isAutoconsentEnabled)
VStack(alignment: .leading, spacing: 0) {
TextMenuItemCaption(UserText.autoconsentExplanation)
TextButton(UserText.learnMore) {
WindowControllersManager.shared.show(url: .cookieConsentPopUpManagement,
source: .ui,
newTab: true)
}
}
}
// SECTION 1: Description
DescriptionView(imageName: "CookiePopupProtection",
header: "Cookie Pop-up Protection",
description: UserText.autoconsentExplanation,
learnMoreUrl: .cookieConsentPopUpManagement,
status: model.isAutoconsentEnabled ? .on : .off)
ToggleMenuItem(UserText.autoconsentCheckboxTitle, isOn: $model.isAutoconsentEnabled)
}
}
}
Expand Down
79 changes: 26 additions & 53 deletions DuckDuckGo/Preferences/View/PreferencesEmailProtectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,69 +25,42 @@ import BrowserServicesKit

extension Preferences {
struct EmailProtectionView: View {
var emailManager: EmailManager

// Local state to trigger the view refresh
@State private var needsRefresh: Bool = false
@State private var notificationToken: AnyCancellable?
var emailManager: EmailManager
@ObservedObject var protectionStatus: PrivacyProtectionStatus = PrivacyProtectionStatus.status(for: .emailProtection)

var body: some View {
PreferencePane("Email Protection") {
// SECTION 1: Email
PreferencePaneSection {

PreferencePaneSubSection {
if emailManager.isSignedIn {
Button(UserText.emailOptionsMenuManageAccountSubItem + "") {
WindowControllersManager.shared.show(url: EmailUrls().emailProtectionAccountLink,
source: .ui,
newTab: true)
}
Button(UserText.emailOptionsMenuTurnOffSubItem) {
let alert = NSAlert.disableEmailProtection()
let response = alert.runModal()
if response == .alertFirstButtonReturn {
try? emailManager.signOut()
needsRefresh.toggle() // Toggle to refresh the view
}
}
} else {
Button(UserText.emailOptionsMenuTurnOnSubItem + "") {
WindowControllersManager.shared.show(url: EmailUrls().emailProtectionLink,
source: .ui,
newTab: true)
}
}
}
// SECTION 1: Description
DescriptionView(imageName: "WebTrackingProtection",
header: "Email Protection",
description: UserText.emailProtectionExplanation,
learnMoreUrl: .duckDuckGoEmailInfo,
status: protectionStatus.status ?? .off)

PreferencePaneSubSection {
VStack(alignment: .leading, spacing: 0) {
TextMenuItemCaption(UserText.emailProtectionExplanation)
TextButton(UserText.learnMore) {
WindowControllersManager.shared.show(url: .duckDuckGoEmailInfo,
source: .ui,
newTab: true)
PreferencePaneSubSection {
if emailManager.isSignedIn {
Button(UserText.emailOptionsMenuManageAccountSubItem + "") {
WindowControllersManager.shared.show(url: EmailUrls().emailProtectionAccountLink,
source: .ui,
newTab: true)
}
Button(UserText.emailOptionsMenuTurnOffSubItem) {
let alert = NSAlert.disableEmailProtection()
let response = alert.runModal()
if response == .alertFirstButtonReturn {
try? emailManager.signOut()
}
}
} else {
Button(UserText.emailOptionsMenuTurnOnSubItem + "") {
WindowControllersManager.shared.show(url: EmailUrls().emailProtectionLink,
source: .ui,
newTab: true)
}
}
}
}
.onAppear {
subscribeToNotifications()
}

}

private func subscribeToNotifications() {
notificationToken = Publishers.Merge(
NotificationCenter.default.publisher(for: .emailDidSignIn),
NotificationCenter.default.publisher(for: .emailDidSignOut)
)
.receive(on: RunLoop.main)
.sink { _ in
// Refresh the view
self.needsRefresh.toggle()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension Preferences {

PreferencePaneSubSection {
ToggleMenuItem(UserText.fireproofCheckboxTitle, isOn: $model.isLoginDetectionEnabled)
VStack(alignment: .leading, spacing: 0) {
VStack(alignment: .leading, spacing: 1) {
TextMenuItemCaption(UserText.fireproofExplanation)
TextButton(UserText.learnMore) {
WindowControllersManager.shared.show(url: .theFireButton,
Expand Down
54 changes: 41 additions & 13 deletions DuckDuckGo/Preferences/View/PreferencesPrivateSearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,12 @@ extension Preferences {
var body: some View {
PreferencePane("Private Search") {

// SECTION 1: Private Search
PreferencePaneSection {
ToggleMenuItem("Always On", isOn: .constant(true))
.disabled(true)
VStack(alignment: .leading, spacing: 0) {
TextMenuItemCaption(UserText.privateSearchExplenation)
TextButton(UserText.learnMore) {
WindowControllersManager.shared.show(url: .privateSearchLearnMore,
source: .ui,
newTab: true)
}
}
}
// SECTION 1: Description
DescriptionView(imageName: "PrivateSearch",
header: "Private Search",
description: UserText.privateSearchExplenation,
learnMoreUrl: .privateSearchLearnMore,
status: .alwaysOn)

// SECTION 2: Search Settings
PreferencePaneSection("Search Settings") {
Expand All @@ -52,3 +45,38 @@ extension Preferences {
}
}
}

extension Preferences {

struct DescriptionView: View {
let imageName: String
let header: String
let description: String
let learnMoreUrl: URL
let status: StatusIndicator

var body: some View {
VStack(alignment: .center, spacing: 16) {
Image(imageName)
VStack(alignment: .center, spacing: 4) {
Text(header)
StatusIndicatorView(status: status)
}
VStack(alignment: .center, spacing: 1) {
Text(description)
.multilineTextAlignment(.center)
.foregroundColor(.secondary)
TextButton(UserText.learnMore) {
WindowControllersManager.shared.show(url: learnMoreUrl,
source: .ui,
newTab: true)
}
}
.padding(.horizontal, 16)
}
.frame(maxWidth: .infinity)
.frame(height: 254)
.roundedBorder()
}
}
}
Loading

0 comments on commit be57d26

Please sign in to comment.