Skip to content

Commit

Permalink
[iOS] Fix P3A toggle flipping back on incorrectly in new onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Oct 28, 2024
1 parent 4408d6f commit 3778eeb
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct FocusP3AScreenView: View {

@State private var isP3AHelpPresented = false
@State private var isSystemSettingsViewPresented = false
@State private var isP3AEnabled: Bool = false

@Binding var shouldDismiss: Bool

Expand Down Expand Up @@ -105,12 +106,7 @@ struct FocusP3AScreenView: View {
.dynamicTypeSize(dynamicTypeRange)
.padding(.bottom, shouldUseExtendedDesign ? 46 : 16)

Toggle(
isOn: Binding(
get: { p3aUtilities?.isP3AEnabled ?? true },
set: { newValue in p3aUtilities?.isP3AEnabled = newValue }
)
) {
Toggle(isOn: $isP3AEnabled) {
VStack(alignment: .leading, spacing: 8) {
Text(Strings.FocusOnboarding.p3aToggleTitle)
.font(
Expand All @@ -129,6 +125,12 @@ struct FocusP3AScreenView: View {
.padding(.vertical, 16)
.padding(.horizontal, 20)
}
.onAppear {
isP3AEnabled = p3aUtilities?.isP3AEnabled ?? true
}
.onChange(of: isP3AEnabled) { newValue in
p3aUtilities?.isP3AEnabled = newValue
}
.padding(.bottom, shouldUseExtendedDesign ? 20 : 16)
.padding(.trailing, 36)
.toggleStyle(SwitchToggleStyle(tint: Color(braveSystemName: .buttonBackground)))
Expand Down

0 comments on commit 3778eeb

Please sign in to comment.