From f713cc0659c1d6330ff67847ba1779bdcc443c77 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 9 Aug 2024 11:22:26 -0500 Subject: [PATCH] CXTDT-599736 - Unable to turn off the Toggles for Privacy preferences Signed-off-by: Matt Bruce --- VDS/Components/Toggle/Toggle.swift | 19 +++++++++---------- VDS/Components/Toggle/ToggleView.swift | 15 +++++++-------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index c147739b..e4390683 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -153,19 +153,18 @@ open class Toggle: Control, Changeable, FormFieldable { //-------------------------------------------------- // MARK: - Overrides - //-------------------------------------------------- - /// Executed on initialization for this View. - open override func initialSetup() { - super.initialSetup() - onClick = { control in - control.toggle() - } - } - + //-------------------------------------------------- /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() - + + publisher(for: .touchUpInside) + .sink(receiveValue: { [weak self] _ in + guard let self else { return } + toggle() + }) + .store(in: &subscribers) + isAccessibilityElement = true if #available(iOS 17.0, *) { accessibilityTraits = .toggleButton diff --git a/VDS/Components/Toggle/ToggleView.swift b/VDS/Components/Toggle/ToggleView.swift index 9274be1a..a0dbcda4 100644 --- a/VDS/Components/Toggle/ToggleView.swift +++ b/VDS/Components/Toggle/ToggleView.swift @@ -105,17 +105,16 @@ open class ToggleView: Control, Changeable, FormFieldable { //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- - /// Executed on initialization for this View. - open override func initialSetup() { - super.initialSetup() - onClick = { control in - control.toggle() - } - } - /// Called once when a view is initialized and is used to Setup additional UI or other constants and configurations. open override func setup() { super.setup() + + publisher(for: .touchUpInside) + .sink(receiveValue: { [weak self] _ in + guard let self else { return } + toggle() + }) + .store(in: &subscribers) isAccessibilityElement = true if #available(iOS 17.0, *) {