diff --git a/Sources/Brave/Frontend/Settings/SettingsViewController.swift b/Sources/Brave/Frontend/Settings/SettingsViewController.swift index 3b8145f85c7..b0c8a8f2711 100644 --- a/Sources/Brave/Frontend/Settings/SettingsViewController.swift +++ b/Sources/Brave/Frontend/Settings/SettingsViewController.swift @@ -485,7 +485,7 @@ class SettingsViewController: TableViewController { let privateTabsRow = Row( text: Strings.TabsSettings.privateTabsSettingsTitle, selection: { [unowned self] in - let vc = UIHostingController(rootView: PrivateTabsView(tabManager: tabManager)) + let vc = UIHostingController(rootView: PrivateTabsView(tabManager: tabManager, askForAuthentication: self.askForLocalAuthentication)) self.navigationController?.pushViewController(vc, animated: true) }, image: UIImage(braveSystemNamed: "leo.product.private-window"), @@ -656,11 +656,24 @@ class SettingsViewController: TableViewController { return Section( header: .title(Strings.security), rows: [ - .boolRow( - title: Strings.Privacy.browserLock, + Row( + text: Strings.Privacy.browserLock, detailText: Strings.Privacy.browserLockDescription, - option: Preferences.Privacy.lockWithPasscode, - image: UIImage(braveSystemNamed: "leo.biometric.login")), + image: UIImage(braveSystemNamed: "leo.biometric.login"), + accessory: .view(SwitchAccessoryView(initialValue: Preferences.Privacy.lockWithPasscode.value, valueChange: { isOn in + if isOn { + Preferences.Privacy.lockWithPasscode.value = isOn + } else { + self.askForLocalAuthentication { [weak self] success, error in + if success { + Preferences.Privacy.lockWithPasscode.value = isOn + } + } + } + })), + cellClass: MultilineSubtitleCell.self, + uuid: Preferences.Privacy.lockWithPasscode.key + ), Row( text: Strings.Login.loginListNavigationTitle, selection: { [unowned self] in diff --git a/Sources/Brave/Frontend/Settings/Shields/OptionToggleView.swift b/Sources/Brave/Frontend/Settings/Shields/OptionToggleView.swift index 61baedeb87c..4e292e15cdc 100644 --- a/Sources/Brave/Frontend/Settings/Shields/OptionToggleView.swift +++ b/Sources/Brave/Frontend/Settings/Shields/OptionToggleView.swift @@ -9,7 +9,6 @@ import Preferences struct OptionToggleView: View { let title: String var subtitle: String? - var markdownSubtitle: LocalizedStringKey? @ObservedObject var option: Preferences.Option let onChange: ShieldToggleView.OnChangeCallback? diff --git a/Sources/Brave/Frontend/Settings/Tabs/PrivateTabsView.swift b/Sources/Brave/Frontend/Settings/Tabs/PrivateTabsView.swift index 44d0c0d5ff7..691b5c0593f 100644 --- a/Sources/Brave/Frontend/Settings/Tabs/PrivateTabsView.swift +++ b/Sources/Brave/Frontend/Settings/Tabs/PrivateTabsView.swift @@ -16,7 +16,10 @@ struct PrivateTabsView: View { } @ObservedObject var privateBrowsingOnly = Preferences.Privacy.privateBrowsingOnly + @ObservedObject var privateBrowsingLock = Preferences.Privacy.privateBrowsingLock + var tabManager: TabManager? + var askForAuthentication: (AuthViewType, ((Bool, LAError.Code?) -> Void)?) -> Void private var localAuthenticationType: AuthenticationType { let context = LAContext() @@ -84,9 +87,20 @@ struct PrivateTabsView: View { switch localAuthenticationType { case .faceID, .touchID, .pinCode: - OptionToggleView(title: browsingLockTitle, - subtitle: nil, - option: Preferences.Privacy.privateBrowsingLock) + ShieldToggleView( + title: browsingLockTitle, + subtitle: nil, + toggle: .init(get: { + privateBrowsingLock.value + }, set: { isOn in + if isOn { + privateBrowsingLock.value = true + } else { + askForAuthentication(.general) { success, _ in + privateBrowsingLock.value = !success + } + } + })) case .noAuthentication: Toggle(isOn: .constant(false)) { VStack(alignment: .leading, spacing: 4) { @@ -111,7 +125,7 @@ struct PrivateTabsView: View { #if DEBUG struct PrivateTabsView_Previews: PreviewProvider { static var previews: some View { - PrivateTabsView() + PrivateTabsView(askForAuthentication: { _, _ in }) } } #endif