From e2f2fb428681eaf602bb926d619bbb75b4e3d67e Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 25 Jun 2020 10:01:19 -0400 Subject: [PATCH 1/6] New right variable Toggle fixes --- MVMCoreUI.xcodeproj/project.pbxproj | 12 +- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 10 +- MVMCoreUI/Atomic/MoleculeObjectMapping.swift | 1 + ...stRightVariableToggleAllTextAndLinks.swift | 112 ++++++++++++++++++ ...htVariableToggleAllTextAndLinksModel.swift | 58 +++++++++ 5 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift create mode 100644 MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinksModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 6c80ccd2..676d554f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -290,6 +290,8 @@ D224799B231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */; }; D22D8393241C27B100D3DF69 /* TemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8392241C27B100D3DF69 /* TemplateModel.swift */; }; D22D8395241FB41200D3DF69 /* UIStackView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */; }; + D2351C7A24A4D433007DF0BC /* ListRightVariableToggleAllTextAndLinksModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2351C7924A4D433007DF0BC /* ListRightVariableToggleAllTextAndLinksModel.swift */; }; + D2351C7C24A4D4C3007DF0BC /* ListRightVariableToggleAllTextAndLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2351C7B24A4D4C3007DF0BC /* ListRightVariableToggleAllTextAndLinks.swift */; }; D236E5B4241FEB1000C38625 /* ListTwoColumnPriceDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */; }; D236E5B5241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */; }; D236E5B7242007C500C38625 /* MVMControllerModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */; }; @@ -744,6 +746,8 @@ D224799A231965AD003FCCF9 /* AccordionMoleculeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccordionMoleculeTableViewCell.swift; sourceTree = ""; }; D22D8392241C27B100D3DF69 /* TemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateModel.swift; sourceTree = ""; }; D22D8394241FB41200D3DF69 /* UIStackView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIStackView+Extension.swift"; sourceTree = ""; }; + D2351C7924A4D433007DF0BC /* ListRightVariableToggleAllTextAndLinksModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableToggleAllTextAndLinksModel.swift; sourceTree = ""; }; + D2351C7B24A4D4C3007DF0BC /* ListRightVariableToggleAllTextAndLinks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListRightVariableToggleAllTextAndLinks.swift; sourceTree = ""; }; D236E5B2241FEB1000C38625 /* ListTwoColumnPriceDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescription.swift; sourceTree = ""; }; D236E5B3241FEB1000C38625 /* ListTwoColumnPriceDescriptionModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListTwoColumnPriceDescriptionModel.swift; sourceTree = ""; }; D236E5B6242007C500C38625 /* MVMControllerModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMControllerModelProtocol.swift; sourceTree = ""; }; @@ -1152,6 +1156,8 @@ 8D8067D22444473A00203BE8 /* ListRightVariablePriceChangeAllTextAndLinks.swift */, C7F8012223E846C300396FBD /* ListRVWheelModel.swift */, C7F8012023E8303200396FBD /* ListRVWheel.swift */, + D2351C7924A4D433007DF0BC /* ListRightVariableToggleAllTextAndLinksModel.swift */, + D2351C7B24A4D4C3007DF0BC /* ListRightVariableToggleAllTextAndLinks.swift */, ); path = RightVariable; sourceTree = ""; @@ -1502,7 +1508,7 @@ children = ( AA104AC824472DC7004D2810 /* HeadersH1ButtonModel.swift */, AA104AC624472DB0004D2810 /* HeadersH1Button.swift */, - AA104ADB244734EA004D2810 /* HeadersH1LandingPageHeaderModel.swift */, + AA104ADB244734EA004D2810 /* HeadersH1LandingPageHeaderModel.swift */, AA104AD9244734DB004D2810 /* HeadersH1LandingPageHeader.swift */, ); path = H1; @@ -1517,7 +1523,7 @@ AA26850B244840AE00CE34CC /* HeadersH2TinyButton.swift */, AA104B1B24474A76004D2810 /* HeadersH2ButtonsModel.swift */, AA104B1924474A66004D2810 /* HeadersH2Buttons.swift */, - AA633B3024989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift */, + AA633B3024989EC000731E80 /* HeadersH2PricingTwoRowsModel.swift */, AA633B3224989ED500731E80 /* HeadersH2PricingTwoRows.swift */, ); path = H2; @@ -2310,6 +2316,7 @@ BB55B51D244482C1002001AD /* ListRightVariablePriceChangeBodyText.swift in Sources */, 017BEB382360C6AC0024EF95 /* RadioButtonLabel.swift in Sources */, D28A837923C7D5BC00DFE4FC /* PageModelProtocol.swift in Sources */, + D2351C7C24A4D4C3007DF0BC /* ListRightVariableToggleAllTextAndLinks.swift in Sources */, 017BEB7B236763000024EF95 /* LineModel.swift in Sources */, D256E9932412880000360572 /* Header.swift in Sources */, 94C2D9A523872C350006CF46 /* LabelAttributeFontModel.swift in Sources */, @@ -2407,6 +2414,7 @@ AA26850E244840C300CE34CC /* HeadersH2TinyButtonModel.swift in Sources */, D260105F23D0BFFC00764D80 /* StackItem.swift in Sources */, 9432A79F23DB47BA00719041 /* EntryFieldContainer.swift in Sources */, + D2351C7A24A4D433007DF0BC /* ListRightVariableToggleAllTextAndLinksModel.swift in Sources */, 01EB369323609801006832FA /* HeaderModel.swift in Sources */, 8DE5BECF2456F7B100772E76 /* ListTwoColumnDropdownSelectors.swift in Sources */, D2E1FADF2268B8E700AEFD8C /* ThreeLayerTableViewController.swift in Sources */, diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 17fabef7..bfa5ba33 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -159,7 +159,6 @@ public typealias ActionBlockConfirmation = () -> (Bool) public override init(frame: CGRect) { super.init(frame: frame) - setupView() } public convenience override init() { @@ -305,6 +304,15 @@ public typealias ActionBlockConfirmation = () -> (Bool) isAnimated = isAnimatedState } + override open func accessibilityActivate() -> Bool { + // Hold state in case User wanted isAnimated to remain off. + let isAnimatedState = isAnimated + isAnimated = false + sendActions(for: .touchUpInside) + isAnimated = isAnimatedState + return true + } + //-------------------------------------------------- // MARK: - UIResponder //-------------------------------------------------- diff --git a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift index c6bb77bb..2ac82b23 100644 --- a/MVMCoreUI/Atomic/MoleculeObjectMapping.swift +++ b/MVMCoreUI/Atomic/MoleculeObjectMapping.swift @@ -180,6 +180,7 @@ import Foundation MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableButtonAllTextAndLinks.self, viewModelClass: ListRightVariableButtonAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariablePriceChangeBodyText.self, viewModelClass: ListRightVariablePriceChangeBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariablePriceChangeAllTextAndLinks.self, viewModelClass: ListRightVariablePriceChangeAllTextAndLinksModel.self) + MoleculeObjectMapping.shared()?.register(viewClass: ListRightVariableToggleAllTextAndLinks.self, viewModelClass: ListRightVariableToggleAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextAllTextAndLinks.self, viewModelClass: ListOneColumnFullWidthTextAllTextAndLinksModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListOneColumnFullWidthTextBodyText.self, viewModelClass: ListOneColumnFullWidthTextBodyTextModel.self) MoleculeObjectMapping.shared()?.register(viewClass: ListTwoColumnCompareChanges.self, viewModelClass: ListTwoColumnCompareChangesModel.self) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift new file mode 100644 index 00000000..9d5f6b84 --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift @@ -0,0 +1,112 @@ +// +// ListRightVariableToggleAllTextAndLinks.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 6/25/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +@objcMembers open class ListRightVariableToggleAllTextAndLinks: TableViewCell { + //----------------------------------------------------- + // MARK: - Outlets + //----------------------------------------------------- + + public let toggle = Toggle() + public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() + + //----------------------------------------------------- + // MARK: - Properties + //----------------------------------------------------- + + public var stack: Stack! + + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + stack = Stack.createStack(with: [(view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading)), + (view: toggle, model: StackItemModel(horizontalAlignment: .fill))], + axis: .horizontal) + super.init(style: style, reuseIdentifier: reuseIdentifier) + } + + public required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + + //----------------------------------------------------- + // MARK: - Lifecycle + //----------------------------------------------------- + + override open func setupView() { + super.setupView() + addMolecule(stack) + stack.restack() + accessibilityHint = toggle.accessibilityHint + accessibilityTraits = toggle.accessibilityTraits + } + + //----------------------------------------------------- + // MARK: - Molecular + //----------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) + guard let model = model as? ListRightVariableToggleAllTextAndLinksModel else { return } + toggle.set(with: model.toggle, delegateObject, additionalData) + eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) + updateAccessibilityLabel() + } + + open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { + return 90 + } + + //---------------------------------------------------- + // MARK: - Accessibility + //---------------------------------------------------- + + func getAccessibilityMessage() -> String? { + guard let toggleMessage = toggle.accessibilityLabel else { + return eyebrowHeadlineBodyLink.getAccessibilityMessage() + } + guard let label = eyebrowHeadlineBodyLink.getAccessibilityMessage() else { + return toggleMessage + } + return label + ", " + toggleMessage + } + + func updateAccessibilityLabel() { + accessibilityValue = toggle.accessibilityValue + let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 + if !linkShowing && accessoryView == nil { + // Make whole cell focusable if one action + isAccessibilityElement = true + accessibilityLabel = getAccessibilityMessage() + } else { + // Make buttons focusable. + isAccessibilityElement = false + var elements: [Any] = [] + if let accessoryView = accessoryView { + accessoryView.accessibilityLabel = eyebrowHeadlineBodyLink.getAccessibilityMessage() + elements.append(accessoryView) + } else { + toggle.accessibilityLabel = getAccessibilityMessage() + } + elements.append(toggle) + + if linkShowing { + elements.append(eyebrowHeadlineBodyLink.link) + } + accessibilityElements = elements + } + } + + open override func accessibilityActivate() -> Bool { + return toggle.accessibilityActivate() + } +} diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinksModel.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinksModel.swift new file mode 100644 index 00000000..9fdc16ca --- /dev/null +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinksModel.swift @@ -0,0 +1,58 @@ +// +// ListRightVariableToggleAllTextAndLinksModel.swift +// MVMCoreUI +// +// Created by Scott Pfeil on 6/25/20. +// Copyright © 2020 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class ListRightVariableToggleAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "listRVTgl" + public var toggle: ToggleModel + public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel + + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + + public init(toggle: ToggleModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) { + self.toggle = toggle + self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink + super.init() + } + + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + + private enum CodingKeys: String, CodingKey { + case moleculeName + case toggle + case eyebrowHeadlineBodyLink + } + + //-------------------------------------------------- + // MARK: - codec + //-------------------------------------------------- + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + toggle = try typeContainer.decode(ToggleModel.self, forKey: .toggle) + eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink) + try super.init(from: decoder) + } + + public override func encode(to encoder: Encoder) throws { + try super.encode(to: encoder) + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encode(toggle, forKey: .toggle) + try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink) + } +} From 6c5f80aa0b9681b252a42df782bf85769a432d4f Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 25 Jun 2020 10:18:59 -0400 Subject: [PATCH 2/6] list toggle accessibility fix --- .../ListRightVariableToggleAllTextAndLinks.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift index 9d5f6b84..ca2a3b92 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift @@ -107,6 +107,8 @@ import Foundation } open override func accessibilityActivate() -> Bool { - return toggle.accessibilityActivate() + let activate = toggle.accessibilityActivate() + accessibilityValue = toggle.accessibilityValue + return activate } } From 1e90e33b1e5c91decdf9c27b48561bacebd75300 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 25 Jun 2020 10:54:51 -0400 Subject: [PATCH 3/6] fix enabled state for toggle --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 17fabef7..98619c8f 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -96,8 +96,8 @@ public typealias ActionBlockConfirmation = () -> (Bool) }, completion: nil) } else { - backgroundColor = isOn ? containerTintColor.on : containerTintColor.off - knobView.backgroundColor = isOn ? knobTintColor.on : knobTintColor.off + backgroundColor = isEnabled ? isOn ? containerTintColor.on : containerTintColor.off : disabledTintColor.container + knobView.backgroundColor = isEnabled ? isOn ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob self.constrainKnob() } From 9d15c7c3dbaed3ca82485f499a3f39cf00d6396d Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 25 Jun 2020 10:56:49 -0400 Subject: [PATCH 4/6] update hint for deactivated. --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 2 ++ .../ListRightVariableToggleAllTextAndLinks.swift | 4 ++-- .../SupportingFiles/Strings/en.lproj/Localizable.strings | 2 +- .../SupportingFiles/Strings/es-MX.lproj/Localizable.strings | 1 + .../SupportingFiles/Strings/es.lproj/Localizable.strings | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index bfa5ba33..d4e090aa 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -64,6 +64,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) changeStateNoAnimation(isEnabled ? isOn : false) backgroundColor = isEnabled ? (isOn ? containerTintColor.on : containerTintColor.off) : disabledTintColor.container knobView.backgroundColor = isEnabled ? (isOn ? knobTintColor.on : knobTintColor.off) : disabledTintColor.knob + accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: isEnabled ? "AccToggleHint" : "AccDisabled") } } @@ -306,6 +307,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) override open func accessibilityActivate() -> Bool { // Hold state in case User wanted isAnimated to remain off. + guard isUserInteractionEnabled == true else { return false } let isAnimatedState = isAnimated isAnimated = false sendActions(for: .touchUpInside) diff --git a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift index ca2a3b92..a631616b 100644 --- a/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift +++ b/MVMCoreUI/Atomic/Molecules/DesignedComponents/List/RightVariable/ListRightVariableToggleAllTextAndLinks.swift @@ -46,8 +46,6 @@ import Foundation super.setupView() addMolecule(stack) stack.restack() - accessibilityHint = toggle.accessibilityHint - accessibilityTraits = toggle.accessibilityTraits } //----------------------------------------------------- @@ -81,6 +79,8 @@ import Foundation } func updateAccessibilityLabel() { + accessibilityHint = toggle.accessibilityHint + accessibilityTraits = toggle.accessibilityTraits accessibilityValue = toggle.accessibilityValue let linkShowing = eyebrowHeadlineBodyLink.link.titleLabel?.text?.count ?? 0 > 0 if !linkShowing && accessoryView == nil { diff --git a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings index da55d597..74b907e3 100644 --- a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings @@ -9,7 +9,7 @@ // MARK: Accessibility "AccCloseButton" = "Close"; "swipe_to_select_with_action_hint" = "swipe up or down to select action, then double tap to select."; - +"AccDisabled" = "Disabled"; // MARK: Tab "AccTab" = ", tab"; diff --git a/MVMCoreUI/SupportingFiles/Strings/es-MX.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/es-MX.lproj/Localizable.strings index 0a9eadb9..b3b6298c 100644 --- a/MVMCoreUI/SupportingFiles/Strings/es-MX.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/es-MX.lproj/Localizable.strings @@ -8,6 +8,7 @@ // Accessibility "swipe_to_select_with_action_hint" = "deslízate hacia arriba o hacia abajo para seleccionar la acción, luego toca dos veces para seleccionar."; +"AccDisabled" = "desactivado"; "AccCloseButton" = "Cerrar"; // Tab diff --git a/MVMCoreUI/SupportingFiles/Strings/es.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/es.lproj/Localizable.strings index bbc45f4a..8e0dbd02 100644 --- a/MVMCoreUI/SupportingFiles/Strings/es.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/es.lproj/Localizable.strings @@ -8,6 +8,7 @@ // Accessibility "swipe_to_select_with_action_hint" = "deslízate hacia arriba o hacia abajo para seleccionar la acción, luego toca dos veces para seleccionar."; +"AccDisabled" = "desactivado"; "AccCloseButton" = "Cerrar"; // Tab From c8ac41fbadd74d61169240953fbdd0b53f28ae16 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 25 Jun 2020 10:58:04 -0400 Subject: [PATCH 5/6] refactored --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 98619c8f..7407fa61 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -62,8 +62,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) didSet { isUserInteractionEnabled = isEnabled changeStateNoAnimation(isEnabled ? isOn : false) - backgroundColor = isEnabled ? (isOn ? containerTintColor.on : containerTintColor.off) : disabledTintColor.container - knobView.backgroundColor = isEnabled ? (isOn ? knobTintColor.on : knobTintColor.off) : disabledTintColor.knob + setToggleAppearanceFromState() } } @@ -96,8 +95,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) }, completion: nil) } else { - backgroundColor = isEnabled ? isOn ? containerTintColor.on : containerTintColor.off : disabledTintColor.container - knobView.backgroundColor = isEnabled ? isOn ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob + setToggleAppearanceFromState() self.constrainKnob() } @@ -342,6 +340,12 @@ public typealias ActionBlockConfirmation = () -> (Bool) // MARK: - Animations //-------------------------------------------------- + public func setToggleAppearanceFromState() { + + backgroundColor = isEnabled ? isOn ? containerTintColor.on : containerTintColor.off : disabledTintColor.container + knobView.backgroundColor = isEnabled ? isOn ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob + } + public func knobReformAnimation() { if isAnimated { From aaca9583351aa34296364b6ebdc4c891e8f3b845 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 25 Jun 2020 13:48:45 -0400 Subject: [PATCH 6/6] push code reduction --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 5be3ce31..2e50dfca 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -305,7 +305,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) override open func accessibilityActivate() -> Bool { // Hold state in case User wanted isAnimated to remain off. - guard isUserInteractionEnabled == true else { return false } + guard isUserInteractionEnabled else { return false } let isAnimatedState = isAnimated isAnimated = false sendActions(for: .touchUpInside)