diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index a0d8294d2d..2ad1cd6b98 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -752,6 +752,7 @@ 9F06EB7D2D0AEBD000905426 /* MaliciousSiteProtectionManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06EB7C2D0AEBD000905426 /* MaliciousSiteProtectionManagerTests.swift */; }; 9F06EB822D0AEE1F00905426 /* MaliciousSiteProtectionMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06EB802D0AEE1F00905426 /* MaliciousSiteProtectionMocks.swift */; }; 9F06EB872D0C733B00905426 /* MaliciousSiteProtectionPreferencesManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06EB862D0C733900905426 /* MaliciousSiteProtectionPreferencesManager.swift */; }; + 9F06EB8A2D10560200905426 /* SettingsMaliciousSiteProtectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06EB892D10560200905426 /* SettingsMaliciousSiteProtectionView.swift */; }; 9F06EB8C2D10578000905426 /* MaliciousSiteProtectionSettingsViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06EB8B2D10578000905426 /* MaliciousSiteProtectionSettingsViewModelTests.swift */; }; 9F06EB922D10740500905426 /* MaliciousSiteProtectionPreferencesManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F06EB912D10740500905426 /* MaliciousSiteProtectionPreferencesManagerTests.swift */; }; 9F16230B2CA0F0190093C4FC /* DebouncerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F16230A2CA0F0190093C4FC /* DebouncerTests.swift */; }; @@ -2636,6 +2637,7 @@ 9F06EB7C2D0AEBD000905426 /* MaliciousSiteProtectionManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaliciousSiteProtectionManagerTests.swift; sourceTree = ""; }; 9F06EB802D0AEE1F00905426 /* MaliciousSiteProtectionMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaliciousSiteProtectionMocks.swift; sourceTree = ""; }; 9F06EB862D0C733900905426 /* MaliciousSiteProtectionPreferencesManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaliciousSiteProtectionPreferencesManager.swift; sourceTree = ""; }; + 9F06EB892D10560200905426 /* SettingsMaliciousSiteProtectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsMaliciousSiteProtectionView.swift; sourceTree = ""; }; 9F06EB8B2D10578000905426 /* MaliciousSiteProtectionSettingsViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaliciousSiteProtectionSettingsViewModelTests.swift; sourceTree = ""; }; 9F06EB912D10740500905426 /* MaliciousSiteProtectionPreferencesManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MaliciousSiteProtectionPreferencesManagerTests.swift; sourceTree = ""; }; 9F16230A2CA0F0190093C4FC /* DebouncerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebouncerTests.swift; sourceTree = ""; }; @@ -3481,6 +3483,7 @@ 1DEAADED2BA45DFE00E25A97 /* SettingsDataClearingView.swift */, D65625A02C232F5E006EF297 /* SettingsDuckPlayerView.swift */, 317CA3422CFF82DB00F88848 /* SettingsAIChatView.swift */, + 9F06EB892D10560200905426 /* SettingsMaliciousSiteProtectionView.swift */, ); name = MainSettings; sourceTree = ""; @@ -8413,6 +8416,7 @@ 9FCFCD852C75C91A006EB7A0 /* ProgressBarView.swift in Sources */, 6F3537A42C4AC140009F8717 /* NewTabPageDaxLogoView.swift in Sources */, 314C92B827C3DD660042EC96 /* QuickLookPreviewView.swift in Sources */, + 9F06EB8A2D10560200905426 /* SettingsMaliciousSiteProtectionView.swift in Sources */, 6F5345AF2C53F2DE00424A43 /* NewTabPageSettingsPersistentStorage.swift in Sources */, F1AE54E81F0425FC00D9A700 /* AuthenticationViewController.swift in Sources */, 560E990F2BEE2CB800507CE0 /* SyncErrorMessage.swift in Sources */, diff --git a/DuckDuckGo/SettingsGeneralView.swift b/DuckDuckGo/SettingsGeneralView.swift index fd62d911a0..2e63dd124c 100644 --- a/DuckDuckGo/SettingsGeneralView.swift +++ b/DuckDuckGo/SettingsGeneralView.swift @@ -86,17 +86,7 @@ struct SettingsGeneralView: View { accessory: .toggle(isOn: viewModel.universalLinksBinding)) } - if viewModel.threatDetectionSettingsViewModel.shouldShowMaliciousSiteProtectionSection { - Section( - header: Text(verbatim: "Malicious Site Protection"), - footer: Text(verbatim: "Disabling this feature can put your personal information at risk. ") - .foregroundColor(.red) - ) { - SettingsCellView(label: "Warn me when a webpage may be malicious or fraudulent", - accessory: .toggle(isOn: viewModel.threatDetectionSettingsViewModel.threatDetectionBinding)) - } - } - + SettingsMaliciousProtectionView() } .applySettingsListModifiers(title: UserText.general, diff --git a/DuckDuckGo/SettingsMaliciousSiteProtectionView.swift b/DuckDuckGo/SettingsMaliciousSiteProtectionView.swift new file mode 100644 index 0000000000..2f7d0060f2 --- /dev/null +++ b/DuckDuckGo/SettingsMaliciousSiteProtectionView.swift @@ -0,0 +1,56 @@ +// +// SettingsMaliciousSiteProtectionView.swift +// DuckDuckGo +// +// Copyright © 2024 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 SwiftUI +import DuckUI + +struct SettingsMaliciousProtectionView: View { + @StateObject private var maliciousSiteProtectionSettingsModel = MaliciousSiteProtectionSettingsViewModel() + + var body: some View { + if maliciousSiteProtectionSettingsModel.shouldShowMaliciousSiteProtectionSection { + Section( + header: Text(UserText.MaliciousSiteProtectionSettings.header), + footer: + VStack(alignment: .leading, spacing: 10) { + Button(action: maliciousSiteProtectionSettingsModel.learnMoreAction) { + Text(UserText.MaliciousSiteProtectionSettings.footerLearnMore) + .foregroundColor(.blueBase) + } + + Text(UserText.MaliciousSiteProtectionSettings.footerDisabledMessage) + .opacity(maliciousSiteProtectionSettingsModel.maliciousSiteProtectionBinding.wrappedValue ? 0 : 1) + .foregroundColor(.red) + .font(.footnote) + } + ) { + SettingsCellView( + label: UserText.MaliciousSiteProtectionSettings.toggleMessage, + accessory: .toggle(isOn: maliciousSiteProtectionSettingsModel.maliciousSiteProtectionBinding) + ) + } + } else { + EmptyView() + } + } +} + +#Preview { + SettingsMaliciousProtectionView() +} diff --git a/DuckDuckGo/UserText.swift b/DuckDuckGo/UserText.swift index 86a2337975..e496cd3956 100644 --- a/DuckDuckGo/UserText.swift +++ b/DuckDuckGo/UserText.swift @@ -1364,6 +1364,13 @@ AI Chat is an optional feature available at [duck.ai](ddgquicklink://duck.ai) th public static let aiChatSettingsEnableAddressBarToggle = NSLocalizedString("aichat.settings.enable.address-bar-toggle", value: "Show AI Chat While Searching", comment: "Toggle text to enable/disable AI Chat in the address bar") + public enum MaliciousSiteProtectionSettings { + public static let header = NSLocalizedString("malicious-site-protection.settings.header", value: "Malicious Site Protection", comment: "Header text for Malicious Site Protection settings") + public static let toggleMessage = NSLocalizedString("malicious-site-protection.settings.toggle.message", value: "Warn me on sites flagged for phishing or malware", comment: "Text explaining what happens when Malicious Site Protection is enabled") + public static let footerLearnMore = NSLocalizedString("malicious-site-protection.settings.footer.button.learn-more", value: "Learn More", comment: "Button that redirect the user to a web page explaining what Malicious Site Protection is") + public static let footerDisabledMessage = NSLocalizedString("malicious-site-protection.settings.footer.message", value: "Disabling this feature can put your personal information at risk.", comment: "Footer text for Malicious Site Protection settings warning the user about the risks of disabling the feature") + } + // MARK: - New Tab Page // MARK: Shortcuts diff --git a/DuckDuckGo/en.lproj/Localizable.strings b/DuckDuckGo/en.lproj/Localizable.strings index d1bf6015ea..81060a5498 100644 --- a/DuckDuckGo/en.lproj/Localizable.strings +++ b/DuckDuckGo/en.lproj/Localizable.strings @@ -1617,6 +1617,18 @@ https://duckduckgo.com/mac"; /* Title for the Mac Waitlist feature */ "mac-waitlist.title" = "DuckDuckGo App for Mac"; +/* Button that redirect the user to a web page explaining what Malicious Site Protection is */ +"malicious-site-protection.settings.footer.button.learn-more" = "Learn More"; + +/* Footer text for Malicious Site Protection settings warning the user about the risks of disabling the feature */ +"malicious-site-protection.settings.footer.message" = "Disabling this feature can put your personal information at risk."; + +/* Header text for Malicious Site Protection settings */ +"malicious-site-protection.settings.header" = "Malicious Site Protection"; + +/* Text explaining what happens when Malicious Site Protection is enabled */ +"malicious-site-protection.settings.toggle.message" = "Warn me on sites flagged for phishing or malware"; + /* No comment provided by engineer. */ "menu.button.hint" = "Browsing Menu";