From f3ed68beeda3098303dc8af1f04370a66fd93ec3 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Tue, 24 Mar 2020 15:21:21 -0400 Subject: [PATCH 01/14] accessibilty start --- MVMCoreUI/Atoms/Views/Checkbox.swift | 5 +--- MVMCoreUI/BaseClasses/Control.swift | 4 ++- MVMCoreUI/BaseClasses/TableViewCell.swift | 4 +-- ...tLeftVariableCheckboxAllTextAndLinks.swift | 25 +++++++++++++++---- ...tVariableRadioButtonAndPaymentMethod.swift | 5 +++- .../EyebrowHeadlineBodyLink.swift | 23 +++++++++++++---- .../HeadlineBody.swift | 9 +++++-- MVMCoreUI/Organisms/Stack.swift | 3 +++ 8 files changed, 58 insertions(+), 20 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Checkbox.swift b/MVMCoreUI/Atoms/Views/Checkbox.swift index f288c4cd..cc6895db 100644 --- a/MVMCoreUI/Atoms/Views/Checkbox.swift +++ b/MVMCoreUI/Atoms/Views/Checkbox.swift @@ -158,6 +158,7 @@ import MVMCore super.init(frame: frame) accessibilityTraits = .button + isAccessibilityElement = true accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "checkbox_action_hint") updateAccessibilityLabel() } @@ -198,8 +199,6 @@ import MVMCore open override func setupView() { super.setupView() - guard constraints.isEmpty else { return } - isUserInteractionEnabled = true translatesAutoresizingMaskIntoConstraints = false backgroundColor = .clear @@ -394,8 +393,6 @@ import MVMCore widthConstraint?.constant = dimension heightConstraint?.constant = dimension } - - //layoutIfNeeded() } public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index 265e56b3..9d6ce521 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -12,6 +12,7 @@ import UIKit //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var json: [AnyHashable: Any]? open var model: MoleculeModelProtocol? @@ -78,7 +79,7 @@ extension Control: AppleGuidelinesProtocol { // MARK: - MVMCoreViewProtocol extension Control: MVMCoreViewProtocol { - open func updateView(_ size: CGFloat) {} + open func updateView(_ size: CGFloat) { } /// Will be called only once. open func setupView() { @@ -89,6 +90,7 @@ extension Control: MVMCoreViewProtocol { // MARK: - MVMCoreUIMoleculeViewProtocol extension Control: MVMCoreUIMoleculeViewProtocol { + open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { self.json = json diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index ebf25a3c..510779b2 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -246,7 +246,7 @@ import UIKit // MARK: - MoleculeListCellProtocol /// For when the separator between cells shows using json and frequency. Default is type: standard, frequency: allExceptTop. - public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?, indexPath: IndexPath) { + public func setLines(with model: LineModel?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?, indexPath: IndexPath) { addSeparatorsIfNeeded() if let model = model { topSeparatorView?.set(with: model, delegateObject, additionalData) @@ -258,7 +258,7 @@ import UIKit setSeparatorFrequency(model?.frequency ?? .allExceptTop, indexPath: indexPath) } - public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) { + public func didSelectCell(at index: IndexPath, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) { //TODO: Use object when handleAction is rewrote to handle action model if let actionMap = self.listItemModel?.action?.toJSON() { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift index 8d7fb539..448d76e1 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableCheckboxAllTextAndLinks.swift @@ -9,11 +9,18 @@ import Foundation @objcMembers open class ListLeftVariableCheckboxAllTextAndLinks: TableViewCell { - public let checkbox = Checkbox(frame: .zero) + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public let checkbox = Checkbox() public let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink(frame: .zero) public var stack: Stack + //-------------------------------------------------- // MARK: - Initializers + //-------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: checkbox, model: StackItemModel(horizontalAlignment: .fill)), (view: eyebrowHeadlineBodyLink, model: StackItemModel(horizontalAlignment: .leading))], @@ -25,17 +32,25 @@ import Foundation fatalError("init(coder:) has not been implemented") } - // MARK: - View Lifecycle + //-------------------------------------------------- + // MARK: - Life Cycle + //-------------------------------------------------- + override open func setupView() { super.setupView() addMolecule(stack) stack.restack() } - // MARK:- MVMCoreUIMoleculeViewProtocol - open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { + //-------------------------------------------------- + // MARK: - MVMCoreUIMoleculeViewProtocol + //-------------------------------------------------- + + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return} + + guard let model = model as? ListLeftVariableCheckboxAllTextAndLinksModel else { return } + checkbox.set(with: model.checkbox, delegateObject, additionalData) eyebrowHeadlineBodyLink.set(with: model.eyebrowHeadlineBodyLink, delegateObject, additionalData) } diff --git a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift index 12ae94fe..ab5a24c0 100644 --- a/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift +++ b/MVMCoreUI/Molecules/DesignedComponents/List/LeftVariable/ListLeftVariableRadioButtonAndPaymentMethod.swift @@ -9,10 +9,10 @@ import UIKit @objcMembers open class ListLeftVariableRadioButtonAndPaymentMethod: TableViewCell { - //----------------------------------------------------- // MARK: - Outlets //----------------------------------------------------- + let radioButton = RadioButton(frame: .zero) let leftImage = MFLoadImageView(pinnedEdges: .all) let eyebrowHeadlineBodyLink = EyebrowHeadlineBodyLink() @@ -21,6 +21,7 @@ import UIKit //----------------------------------------------------- // MARK: - Initializers //----------------------------------------------------- + public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { stack = Stack.createStack(with: [(view: radioButton, model: StackItemModel(horizontalAlignment: .fill)), (view: leftImage, model: StackItemModel(horizontalAlignment: .fill)), @@ -36,6 +37,7 @@ import UIKit //----------------------------------------------------- // MARK: - View Lifecycle //----------------------------------------------------- + override open func setupView() { super.setupView() addMolecule(stack) @@ -53,6 +55,7 @@ import UIKit //---------------------------------------------------- // MARK: - Molecule //---------------------------------------------------- + open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { super.set(with: model, delegateObject, additionalData) guard let model = model as? ListLeftVariableRadioButtonAndPaymentMethodModel else { return} diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 49b08b44..410112ed 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -19,7 +19,7 @@ import UIKit public let body = Label.commonLabelB2(true) public let link = Link() - var casteModel: EyebrowHeadlineBodyLinkModel? { + var castModel: EyebrowHeadlineBodyLinkModel? { get { return model as? EyebrowHeadlineBodyLinkModel } } @@ -52,6 +52,19 @@ import UIKit body.styleB2(true) } + public func eyebrow(isHidden: Bool) { + + stack.stackModel?.molecules[0].gone = isHidden + + if isHidden { + accessibilityElements = [headline, body, link] + } else { + accessibilityElements = [eyebrow, headline, body, link] + } + + stack.restack() + } + //-------------------------------------------------- // MARK: - ModelMoleculeViewProtocol //-------------------------------------------------- @@ -59,10 +72,10 @@ import UIKit open override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { super.set(with: model, delegateObject, additionalData) - eyebrow.setOptional(with: casteModel?.eyebrow, delegateObject, additionalData) - headline.setOptional(with: casteModel?.headline, delegateObject, additionalData) - body.setOptional(with: casteModel?.body, delegateObject, additionalData) - link.setOptional(with: casteModel?.link, delegateObject, additionalData) + eyebrow.setOptional(with: castModel?.eyebrow, delegateObject, additionalData) + headline.setOptional(with: castModel?.headline, delegateObject, additionalData) + body.setOptional(with: castModel?.body, delegateObject, additionalData) + link.setOptional(with: castModel?.link, delegateObject, additionalData) // Hide labels if neeeded. stack.stackModel?.molecules[0].gone = !eyebrow.hasText diff --git a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift index a120807d..9cdd9e67 100644 --- a/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift +++ b/MVMCoreUI/Molecules/VerticalCombinationViews/HeadlineBody.swift @@ -9,9 +9,12 @@ import UIKit open class HeadlineBody: View { + let headlineLabel = Label.commonLabelH2(true) let messageLabel = Label.commonLabelB2(true) + var spaceBetweenLabelsConstant = PaddingTwo + var spaceBetweenLabels: NSLayoutConstraint? var leftConstraintTitle: NSLayoutConstraint? var rightConstraintTitle: NSLayoutConstraint? @@ -71,8 +74,6 @@ open class HeadlineBody: View { open override func setupView() { super.setupView() - - guard subviews.isEmpty else { return } backgroundColor = .clear clipsToBounds = true @@ -81,6 +82,10 @@ open class HeadlineBody: View { addSubview(view) NSLayoutConstraint.constraintPinSubview(toSuperview: view) + view.isAccessibilityElement = false + view.shouldGroupAccessibilityChildren = true + view.accessibilityElements = [headlineLabel, messageLabel] + view.addSubview(headlineLabel) view.addSubview(messageLabel) diff --git a/MVMCoreUI/Organisms/Stack.swift b/MVMCoreUI/Organisms/Stack.swift index 8e6df863..2f3b0f78 100644 --- a/MVMCoreUI/Organisms/Stack.swift +++ b/MVMCoreUI/Organisms/Stack.swift @@ -46,6 +46,9 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto for (index, view) in stackItems.enumerated() { addView(view, stackModel.molecules[index], totalSpacing: totalSpace, lastItem: lastItemIndex == index) } + + isAccessibilityElement = false + accessibilityElements = stackItems } /// Removes all stack items views from the view. From 60ca1be4bed89eeaadae612b303139954d7abcd6 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 11:17:43 -0400 Subject: [PATCH 02/14] for accessibility. --- MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift | 3 ++- MVMCoreUI/Templates/MoleculeListTemplate.swift | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 33229092..75f1f0d8 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -24,6 +24,7 @@ import UIKit (molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData) } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) { addMolecule(moleculeView) + accessibilityElements = [moleculeView] } super.set(with: model, delegateObject, additionalData) } @@ -37,7 +38,7 @@ import UIKit return "\(self)<\(moleculeName)>" } - public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { + public class func requiredModules(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { guard let moleculeJSON = json?.optionalDictionaryForKey(KeyMolecule), let theClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: moleculeJSON) else { return nil } diff --git a/MVMCoreUI/Templates/MoleculeListTemplate.swift b/MVMCoreUI/Templates/MoleculeListTemplate.swift index d68a1170..1db1593b 100644 --- a/MVMCoreUI/Templates/MoleculeListTemplate.swift +++ b/MVMCoreUI/Templates/MoleculeListTemplate.swift @@ -215,7 +215,9 @@ open class MoleculeListTemplate: ThreeLayerTableViewController, TemplateProtocol func getMoleculeInfo(with listItem: (ListItemModelProtocol & MoleculeModelProtocol)?) -> (identifier: String, class: AnyClass, molecule: ListItemModelProtocol & MoleculeModelProtocol)? { guard let listItem = listItem, - let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem) else { return nil } + let moleculeClass = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(listItem) + else { return nil } + let moleculeName = (moleculeClass as? ModelMoleculeViewProtocol.Type)?.nameForReuse(with: listItem, delegateObject() as? MVMCoreUIDelegateObject) ?? listItem.moleculeName return (moleculeName, moleculeClass, listItem) } From 7e89e58cd1186c7ecb9d4c50bfe55c8e731cca9c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 14:47:15 -0400 Subject: [PATCH 03/14] more accessibility stuff. --- MVMCoreUI/Atoms/Views/Label/Label.swift | 2 ++ .../Items/MoleculeTableViewCell.swift | 5 +++- .../ToggleMolecules/LabelToggleModel.swift | 24 ++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atoms/Views/Label/Label.swift index c7e72204..a6a7cfe1 100644 --- a/MVMCoreUI/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atoms/Views/Label/Label.swift @@ -316,6 +316,7 @@ public typealias ActionBlock = () -> () text = labelModel.text hero = labelModel.hero Label.setLabel(self, withHTML: labelModel.html) + isAccessibilityElement = hasText let alignment = LabelAlignment(rawValue: labelModel.textAlignment ?? "") switch alignment { @@ -426,6 +427,7 @@ public typealias ActionBlock = () -> () continue } } + attributedText = attributedString originalAttributedString = attributedText } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index 75f1f0d8..d04ff3b1 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -24,7 +24,10 @@ import UIKit (molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData) } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) { addMolecule(moleculeView) - accessibilityElements = [moleculeView] + + if ((moleculeView as? Label) != nil) { + accessibilityElements = [moleculeView] + } } super.set(with: model, delegateObject, additionalData) } diff --git a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift index 16f292ed..64bc7e41 100644 --- a/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift +++ b/MVMCoreUI/Molecules/LeftRightViews/ToggleMolecules/LabelToggleModel.swift @@ -14,9 +14,31 @@ public class LabelToggleModel: MoleculeModelProtocol { public var backgroundColor: Color? public var label: LabelModel public var toggle: ToggleModel - + init(_ label: LabelModel, _ toggle: ToggleModel) { self.label = label self.toggle = toggle } + + private enum CodingKeys: String, CodingKey { + case moleculeName + case backgroundColor + case label + case toggle + } + + required public init(from decoder: Decoder) throws { + let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey:.backgroundColor) + label = try typeContainer.decode(LabelModel.self, forKey:.label) + toggle = try typeContainer.decode(ToggleModel.self, forKey:.toggle) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(moleculeName, forKey: .moleculeName) + try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encode(label, forKey: .label) + try container.encode(toggle, forKey: .toggle) + } } From 7b857414af90d9cf560e807263f20b5d1ee12786 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 17:14:16 -0400 Subject: [PATCH 04/14] didn't carry over --- .../Molecules/Items/DropDownFilterTableViewCell.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index aa581ba1..6b6f5a32 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,16 +29,16 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let model = self.listItemModel as? DropDownListItemModel + let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), + let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]], + !json2d.isEmpty && !(json2d.first?.isEmpty ?? false) else { return } if self.previousIndex != NSNotFound { - self.delegateObject?.moleculeDelegate?.removeMolecules(model.molecules[self.previousIndex], animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], sender: self, animation: .fade) } - if let indexPath = self.delegateObject?.moleculeDelegate?.getIndexPath(for: model) { - self.delegateObject?.moleculeDelegate?.addMolecules(model.molecules[index], indexPath: indexPath, animation: .fade) - } + self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], sender: self, animation: .fade) self.previousIndex = index } } From 60199831a35e698935b7d048194597c5c5b2618c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 17:21:58 -0400 Subject: [PATCH 05/14] apparent merge conflict --- .../Molecules/Items/DropDownFilterTableViewCell.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 6b6f5a32..11e619c6 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,16 +29,21 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), + let model = self.listItemModel as? DropDownListItemModel, let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]], !json2d.isEmpty && !(json2d.first?.isEmpty ?? false) else { return } if self.previousIndex != NSNotFound { - self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], sender: self, animation: .fade) + self.delegateObject?.moleculeDelegate?.removeMolecules(model.molecules[self.previousIndex], animation: .fade) +// self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], animation: .fade) } - self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], sender: self, animation: .fade) + if let indexPath = self.delegateObject?.moleculeDelegate?.getIndexPath(for: model) { + self.delegateObject?.moleculeDelegate?.addMolecules(model.molecules[index], indexPath: indexPath, animation: .fade) +// self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], animation: .fade) + } self.previousIndex = index } } From 3249c9d68b1c50c181a8260753472dda4c0e1724 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 25 Mar 2020 17:39:33 -0400 Subject: [PATCH 06/14] remvoed --- MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 11e619c6..307f64c9 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -37,12 +37,10 @@ import UIKit if self.previousIndex != NSNotFound { self.delegateObject?.moleculeDelegate?.removeMolecules(model.molecules[self.previousIndex], animation: .fade) -// self.delegateObject?.moleculeDelegate?.removeMolecules(json2d[self.previousIndex], animation: .fade) } if let indexPath = self.delegateObject?.moleculeDelegate?.getIndexPath(for: model) { self.delegateObject?.moleculeDelegate?.addMolecules(model.molecules[index], indexPath: indexPath, animation: .fade) -// self.delegateObject?.moleculeDelegate?.addMolecules(json2d[index], animation: .fade) } self.previousIndex = index } From 874007423d0902d18a91cc0279f2bbf0f69e7781 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 09:03:21 -0400 Subject: [PATCH 07/14] tmp --- MVMCoreUI/Molecules/Items/DropDownListItemModel.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 0cd2f5ef..071014d3 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -24,6 +24,12 @@ import Foundation line = LineModel(type: .none) style = "sectionFooter" } + +// public func verify() throws { +// guard dropDown.options.count != molecules.count else { +// throw +// } +// } //-------------------------------------------------- // MARK: - Initializer @@ -32,6 +38,7 @@ import Foundation public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { self.molecules = molecules self.dropDown = dropDown +// try verify() super.init() } From dd7a339a4390e10e9d47fd4b73bb1c04eaa0ac6a Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 10:46:23 -0400 Subject: [PATCH 08/14] correction --- .../MoleculeModelProtocol.swift | 6 +++++ .../Items/DropDownFilterTableViewCell.swift | 5 +--- .../Items/DropDownListItemModel.swift | 24 +++++++++++++------ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift index 913c3bd0..dda19b35 100644 --- a/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Models/ModelProtocols/MoleculeModelProtocol.swift @@ -1,6 +1,12 @@ import Foundation +public enum MolecularError: Swift.Error { + case error(String) + case countImbalance(String) +} + + public protocol MoleculeModelProtocol: ModelProtocol { var moleculeName: String { get } var backgroundColor: Color? { get set } diff --git a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift index 307f64c9..aa581ba1 100644 --- a/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/DropDownFilterTableViewCell.swift @@ -29,10 +29,7 @@ import UIKit guard newValue != oldValue, let self = self, let index = self.dropDown.pickerData.firstIndex(of: newValue), - let model = self.listItemModel as? DropDownListItemModel, - let dropListItemJSON = (self.listItemModel as? DropDownListItemModel).toJSON(), - let json2d = dropListItemJSON.optionalArrayForKey("molecules") as? [[[AnyHashable: Any]]], - !json2d.isEmpty && !(json2d.first?.isEmpty ?? false) + let model = self.listItemModel as? DropDownListItemModel else { return } if self.previousIndex != NSNotFound { diff --git a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift index 071014d3..deb2374b 100644 --- a/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift +++ b/MVMCoreUI/Molecules/Items/DropDownListItemModel.swift @@ -8,6 +8,7 @@ import Foundation + @objcMembers public class DropDownListItemModel: ListItemModel, MoleculeModelProtocol { //-------------------------------------------------- // MARK: - Properties @@ -17,6 +18,10 @@ import Foundation public var molecules: [[ListItemModelProtocol & MoleculeModelProtocol]] public var dropDown: ItemDropdownEntryFieldModel + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + /// Defaults to set public override func setDefaults() { super.setDefaults() @@ -25,20 +30,24 @@ import Foundation style = "sectionFooter" } -// public func verify() throws { -// guard dropDown.options.count != molecules.count else { -// throw -// } -// } + //-------------------------------------------------- + // MARK: - Functions + //-------------------------------------------------- + + public class func verify(dropdown: ItemDropdownEntryFieldModel, molecules: [[ListItemModelProtocol & MoleculeModelProtocol]]) throws { + guard dropdown.options.count == molecules.count else { + throw MolecularError.countImbalance("dropdown.options.count is not equal to molecules.count") + } + } //-------------------------------------------------- // MARK: - Initializer //-------------------------------------------------- - public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) { + public init(molecules: [[ListItemModelProtocol & MoleculeModelProtocol]], dropDown: ItemDropdownEntryFieldModel) throws { self.molecules = molecules self.dropDown = dropDown -// try verify() + try Self.verify(dropdown: dropDown, molecules: molecules) super.init() } @@ -60,6 +69,7 @@ import Foundation let typeContainer = try decoder.container(keyedBy: CodingKeys.self) molecules = try typeContainer.decodeModels2DIfPresent(codingKey: .molecules) ?? [[]] dropDown = try typeContainer.decode(ItemDropdownEntryFieldModel.self, forKey: .dropDown) + try Self.verify(dropdown: dropDown, molecules: molecules) try super.init(from: decoder) } From 88349bc651e3be1ed7c6a0305a509577eb28038f Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 11:36:18 -0400 Subject: [PATCH 09/14] Adding localized string because I didn't see it there for existing key. Updating Toggle to handle accessibility text. --- MVMCoreUI/Atoms/Views/Toggle.swift | 22 ++++++++-------- MVMCoreUI/Atoms/Views/ToggleModel.swift | 26 ++++++++++++++++++- .../Items/MoleculeTableViewCell.swift | 7 ++--- .../Strings/en.lproj/Localizable.strings | 6 ++++- 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index 7e45c567..e5d0c00b 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -190,7 +190,10 @@ public typealias ActionBlockConfirmation = () -> (Bool) public override func setupView() { super.setupView() - guard subviews.isEmpty else { return } + isAccessibilityElement = true + accessibilityTraits = .button + accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") + accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") heightConstraint = heightAnchor.constraint(equalToConstant: Self.containerSize.height) heightConstraint?.isActive = true @@ -214,8 +217,6 @@ public typealias ActionBlockConfirmation = () -> (Bool) knobTrailingConstraint = trailingAnchor.constraint(equalTo: knobView.trailingAnchor, constant: 1) knobLeadingConstraint = knobView.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 1) knobLeadingConstraint?.isActive = true - - accessibilityLabel = MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") } public override func reset() { @@ -336,16 +337,15 @@ public typealias ActionBlockConfirmation = () -> (Bool) // MARK:- ModelMoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { - guard let toggleModel = model as? ToggleModel else { - return - } - - self.model = model self.delegateObject = delegateObject - let toggleModelJSON = toggleModel.toJSON() + self.model = model + + guard let model = model as? ToggleModel else { return } - FormValidator.setupValidation(molecule: toggleModel, delegate: delegateObject?.formHolderDelegate) - setWithJSON(toggleModelJSON, delegateObject: delegateObject, additionalData: additionalData) + accessibilityLabel = model.accessibilityText ?? MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") + + FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) + setWithJSON(model.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } //TODO: change to setWith Model diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index 5e67be8a..ce599083 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -9,16 +9,24 @@ import UIKit public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { - + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "toggle" public var backgroundColor: Color? public var state: Bool = true public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? + public var accessibilityText: String? public var fieldKey: String? public var groupName: String? = FormValidator.defaultGroupName public var baseValue: AnyHashable? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case moleculeName case state @@ -27,16 +35,29 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { case fieldKey case alternateAction case groupName + case accessibilityText } + //-------------------------------------------------- + // MARK: - Methods + //-------------------------------------------------- + public func formFieldValue() -> AnyHashable? { return state } + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public init(_ state: Bool) { self.state = state } + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- + required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { @@ -49,6 +70,8 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { if let groupName = try typeContainer.decodeIfPresent(String.self, forKey: .groupName) { self.groupName = groupName } + + accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) } public func encode(to encoder: Encoder) throws { @@ -60,5 +83,6 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { try container.encode(state, forKey: .state) try container.encodeIfPresent(fieldKey, forKey: .fieldKey) try container.encodeIfPresent(groupName, forKey: .groupName) + try container.encodeIfPresent(accessibilityText, forKey: .accessibilityText) } } diff --git a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift index d04ff3b1..d3c83ea7 100644 --- a/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Molecules/Items/MoleculeTableViewCell.swift @@ -24,10 +24,7 @@ import UIKit (molecule as? ModelMoleculeViewProtocol)?.set(with: castModel.molecule, delegateObject, additionalData) } else if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(castModel.molecule, delegateObject, false) { addMolecule(moleculeView) - - if ((moleculeView as? Label) != nil) { - accessibilityElements = [moleculeView] - } + accessibilityElements = [moleculeView] } super.set(with: model, delegateObject, additionalData) } @@ -36,7 +33,7 @@ import UIKit guard let moleculeModel = (model as? MoleculeListItemModel)?.molecule else { return "\(self)<>" } let className = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(moleculeModel) as? ModelMoleculeViewProtocol.Type - let moleculeName = className?.nameForReuse(with: moleculeModel, delegateObject) ?? moleculeModel.moleculeName ?? "" + let moleculeName = className?.nameForReuse(with: moleculeModel, delegateObject) ?? moleculeModel.moleculeName return "\(self)<\(moleculeName)>" } diff --git a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings index b9d21b67..cbf2611a 100644 --- a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings @@ -31,6 +31,7 @@ // Camera "AccCameraButton" = "Camera Button"; "AccCameraHint" = "Double tap to launch camera for scanning"; + // Checkbox "checkbox_action_hint" = "Double tap to change state"; "checkbox_checked_state" = "Checked"; @@ -43,14 +44,17 @@ "radio_not_selected_state" = "Not Selected"; "radio_desc_state" = "Option"; -// Switch +// Switch / Toggle "mfswitch_buttonlabel" = "Switch Button"; +"Toggle_buttonlabel" = "Toggle Button" "AccOn" = "on"; "AccOff" = "off"; "AccToggleHint" = "double tap to toggle"; + // Carousel "MVMCoreUIPageControl_currentpage_index" = "page %ld of %ld"; "MVMCoreUIPageControlslides_currentpage_index" = "slide %ld of %ld"; + //Styler "CountDownDay" = " day"; "CountDownHour" = " hour"; From f133bad78cf9f7824d0265e33967766386ae5f87 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 12:48:23 -0400 Subject: [PATCH 10/14] accessibile togle --- MVMCoreUI/Atoms/Views/Toggle.swift | 3 ++- MVMCoreUI/Atoms/Views/ToggleModel.swift | 3 ++- MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index e5d0c00b..90a5197d 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -127,6 +127,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) private var widthConstraint: NSLayoutConstraint? private func constrainKnob() { + knobLeadingConstraint?.isActive = !isOn knobTrailingConstraint?.isActive = isOn } @@ -343,7 +344,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) guard let model = model as? ToggleModel else { return } accessibilityLabel = model.accessibilityText ?? MVMCoreUIUtility.hardcodedString(withKey: "Toggle_buttonlabel") - + isOn = model.state FormValidator.setupValidation(molecule: model, delegate: delegateObject?.formHolderDelegate) setWithJSON(model.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } diff --git a/MVMCoreUI/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atoms/Views/ToggleModel.swift index ce599083..53244dce 100644 --- a/MVMCoreUI/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atoms/Views/ToggleModel.swift @@ -15,7 +15,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { public static var identifier: String = "toggle" public var backgroundColor: Color? - public var state: Bool = true + public var state: Bool = false public var action: ActionModelProtocol? public var alternateAction: ActionModelProtocol? public var accessibilityText: String? @@ -60,6 +60,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol { required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) + if let state = try typeContainer.decodeIfPresent(Bool.self, forKey: .state) { self.state = state } diff --git a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings index cbf2611a..a7f4cdf2 100644 --- a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings @@ -46,7 +46,7 @@ // Switch / Toggle "mfswitch_buttonlabel" = "Switch Button"; -"Toggle_buttonlabel" = "Toggle Button" +"Toggle_buttonlabel" = "Toggle Button"; "AccOn" = "on"; "AccOff" = "off"; "AccToggleHint" = "double tap to toggle"; From b6ec314d14c6749d1786ec0d12d8936f9cdde2d9 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Thu, 26 Mar 2020 15:30:44 -0400 Subject: [PATCH 11/14] replaced --- 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 8701f6b3..410c3221 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -190,7 +190,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) public override func setupView() { super.setupView() - + guard subviews.isEmpty else { return } isAccessibilityElement = true accessibilityTraits = .button accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccToggleHint") From 70100791e63561556c3b1ac0aa89214566ce7b04 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 27 Mar 2020 09:13:57 -0400 Subject: [PATCH 12/14] remvoing to progess --- MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift b/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift index d0267afc..0c9dec3b 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/MoleculeTableViewCell.swift @@ -24,7 +24,6 @@ import UIKit molecule?.set(with: castModel.molecule, delegateObject, additionalData) } else if let moleculeView = MoleculeObjectMapping.shared()?.createMolecule(castModel.molecule, delegateObject: delegateObject, additionalData: additionalData) { addMolecule(moleculeView) - accessibilityElements = [moleculeView] } super.set(with: model, delegateObject, additionalData) } From dcbfcf033fecd2ecef36e7461b5395a48277f316 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 30 Mar 2020 09:53:38 -0400 Subject: [PATCH 13/14] latest --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 1 + .../Molecules/Items/StackItemModel.swift | 10 +++++ .../EyebrowHeadlineBodyLink.swift | 24 +++++------ MVMCoreUI/Atomic/Organisms/Stack.swift | 16 +++++--- MVMCoreUI/BaseClasses/Control.swift | 1 + MVMCoreUI/BaseClasses/TableViewCell.swift | 3 ++ .../Views/Container/ContainerModel.swift | 16 ++++++++ .../Strings/en.lproj/Localizable.strings | 41 +++++++++++++------ 8 files changed, 82 insertions(+), 30 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index 410c3221..8ab7b07b 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -338,6 +338,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) // MARK:- MoleculeViewProtocol public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { + super.set(with: model, delegateObject, additionalData) self.delegateObject = delegateObject guard let model = model as? ToggleModel else { return } diff --git a/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift b/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift index 12254fb5..436ed9cd 100644 --- a/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift +++ b/MVMCoreUI/Atomic/Molecules/Items/StackItemModel.swift @@ -9,6 +9,10 @@ import Foundation @objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public static var identifier: String = "simpleStackItem" public var moleculeName: String = StackItemModel.identifier public var backgroundColor: Color? @@ -16,12 +20,18 @@ import Foundation public var percent: Int? public var gone: Bool = false + //-------------------------------------------------- + // MARK: - Initializer + //-------------------------------------------------- + public convenience init(spacing: CGFloat? = nil, percent: Int? = nil, horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil, gone: Bool? = nil) { self.init() + self.horizontalAlignment = horizontalAlignment self.verticalAlignment = verticalAlignment self.spacing = spacing self.percent = percent + if let gone = gone { self.gone = gone } diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index 9672b789..ff530d92 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -52,18 +52,18 @@ import UIKit body.styleB2(true) } - public func eyebrow(isHidden: Bool) { - - stack.stackModel?.molecules[0].gone = isHidden - - if isHidden { - accessibilityElements = [headline, body, link] - } else { - accessibilityElements = [eyebrow, headline, body, link] - } - - stack.restack() - } +// public func eyebrow(isHidden: Bool) { +// +// stack.stackModel?.molecules[0].gone = isHidden +// +// if isHidden { +// accessibilityElements = [headline, body, link] +// } else { +// accessibilityElements = [eyebrow, headline, body, link] +// } +// +// stack.restack() +// } //-------------------------------------------------- // MARK: - MoleculeViewProtocol diff --git a/MVMCoreUI/Atomic/Organisms/Stack.swift b/MVMCoreUI/Atomic/Organisms/Stack.swift index b7dab506..e957a2a6 100644 --- a/MVMCoreUI/Atomic/Organisms/Stack.swift +++ b/MVMCoreUI/Atomic/Organisms/Stack.swift @@ -15,10 +15,11 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto //-------------------------------------------------- open var contentView: UIView = MVMCoreUICommonViewsUtility.commonView() + open var stackItems: [UIView] = [] + open var stackModel: T? { get { return model as? T } } - open var stackItems: [UIView] = [] //-------------------------------------------------- // MARK: - Helpers @@ -37,18 +38,21 @@ open class Stack: Container where T: (StackModelProtocol & MoleculeModelProto guard let stackModel = stackModel else { return } let stackItems = self.stackItems self.stackItems = [] - let lastItemIndex = stackModel.molecules.lastIndex(where: { (item) -> Bool in - return !item.gone - }) + let lastItemIndex = stackModel.molecules.lastIndex { !$0.gone } // Adds the views let totalSpace = getTotalSpace() for (index, view) in stackItems.enumerated() { addView(view, stackModel.molecules[index], totalSpacing: totalSpace, lastItem: lastItemIndex == index) } - + isAccessibilityElement = false - accessibilityElements = stackItems + var accessibleViews: [Any] = [] + for (index, view) in stackItems.enumerated() where !stackModel.molecules[index].gone { + accessibleViews.append(view) + } + + accessibilityElements = accessibleViews } /// Removes all stack items views from the view. diff --git a/MVMCoreUI/BaseClasses/Control.swift b/MVMCoreUI/BaseClasses/Control.swift index b73fcc81..ebb88977 100644 --- a/MVMCoreUI/BaseClasses/Control.swift +++ b/MVMCoreUI/BaseClasses/Control.swift @@ -12,6 +12,7 @@ import UIKit //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- + open var model: MoleculeModelProtocol? private var initialSetupPerformed = false diff --git a/MVMCoreUI/BaseClasses/TableViewCell.swift b/MVMCoreUI/BaseClasses/TableViewCell.swift index 7af0b57b..dc4d270a 100644 --- a/MVMCoreUI/BaseClasses/TableViewCell.swift +++ b/MVMCoreUI/BaseClasses/TableViewCell.swift @@ -197,10 +197,13 @@ import UIKit // MARK: - Caret View /// Adds the standard mvm style caret to the accessory view @objc public func addCaretViewAccessory() { + guard accessoryView == nil else { return } let caret = CaretView(lineWidth: 1) caret.translatesAutoresizingMaskIntoConstraints = true + caret.isAccessibilityElement = true + caret.accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccTabHint") caret.size = .small(.vertical) if let size = caret.size?.dimensions() { caret.frame = CGRect(origin: CGPoint.zero, size: size) diff --git a/MVMCoreUI/Containers/Views/Container/ContainerModel.swift b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift index a18e8589..ec6f9769 100644 --- a/MVMCoreUI/Containers/Views/Container/ContainerModel.swift +++ b/MVMCoreUI/Containers/Views/Container/ContainerModel.swift @@ -9,6 +9,10 @@ import Foundation open class ContainerModel: ContainerModelProtocol, Codable { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + public var horizontalAlignment: UIStackView.Alignment? public var verticalAlignment: UIStackView.Alignment? public var useHorizontalMargins: Bool? @@ -17,6 +21,10 @@ open class ContainerModel: ContainerModelProtocol, Codable { public var topMarginPadding: CGFloat? public var bottomMarginPadding: CGFloat? + //-------------------------------------------------- + // MARK: - Keys + //-------------------------------------------------- + private enum CodingKeys: String, CodingKey { case verticalAlignment case horizontalAlignment @@ -26,6 +34,10 @@ open class ContainerModel: ContainerModelProtocol, Codable { case bottomMarginPadding } + //-------------------------------------------------- + // MARK: - Initializers + //-------------------------------------------------- + public init() {} public convenience init(horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil) { @@ -33,6 +45,10 @@ open class ContainerModel: ContainerModelProtocol, Codable { self.horizontalAlignment = horizontalAlignment self.verticalAlignment = verticalAlignment } + + //-------------------------------------------------- + // MARK: - Codec + //-------------------------------------------------- required public init(from decoder: Decoder) throws { let typeContainer = try decoder.container(keyedBy: CodingKeys.self) diff --git a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings index a7f4cdf2..48cbe3ce 100644 --- a/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings +++ b/MVMCoreUI/SupportingFiles/Strings/en.lproj/Localizable.strings @@ -6,56 +6,73 @@ Copyright © 2017 myverizon. All rights reserved. */ -//// Accessibility +// MARK: Accessibility "AccCloseButton" = "Close"; "swipe_to_select_with_action_hint" = "swipe up or down to select action, then double tap to select."; -// Tab + + +// MARK: Tab "AccTab" = ", tab"; "AccTabHint" = "Double tap to select."; "AccTabIndex" = ", %ld of %ld"; -// top alert + + +// MARK: Top alert "toptabbar_tab_selected" = ", tab, Selected"; "AccTopAlertClosed" = "Top alert notification is closed."; "top_alert_notification" = "Top alert notification"; -// Textfield + + +// MARK: Textfield "textfield_today_string" = "Today"; "textfield_error_message" = "%@.\n The error message.\n %@"; "textfield_picker_item" = " picker item"; "textfield_regular" = " regular"; "textfield_disabled_state" = "disabled"; -// MDNTextfield + + +// MARK: MDNTextfield "textfield_contacts_barbutton" = "My Contacts"; "textfield_phone_format_error_message" = "Invalid phone number format."; -// DigitTextfield + + +// MARK: DigitTextfield "mfdigittextfield_regular" = " regular"; -// Camera + + +// MARK: Camera "AccCameraButton" = "Camera Button"; "AccCameraHint" = "Double tap to launch camera for scanning"; -// Checkbox + +// MARK: Checkbox "checkbox_action_hint" = "Double tap to change state"; "checkbox_checked_state" = "Checked"; "checkbox_unchecked_state" = "Unchecked"; "checkbox_desc_state" = "%@ CheckBox %@"; -// Radio Button + +// MARK: Radio Button "radio_action_hint" = "Double tap to select"; "radio_selected_state" = "Selected"; "radio_not_selected_state" = "Not Selected"; "radio_desc_state" = "Option"; -// Switch / Toggle + +// MARK: Switch / Toggle "mfswitch_buttonlabel" = "Switch Button"; "Toggle_buttonlabel" = "Toggle Button"; "AccOn" = "on"; "AccOff" = "off"; "AccToggleHint" = "double tap to toggle"; -// Carousel + +// MARK: Carousel "MVMCoreUIPageControl_currentpage_index" = "page %ld of %ld"; "MVMCoreUIPageControlslides_currentpage_index" = "slide %ld of %ld"; -//Styler + +// MARK: Styler "CountDownDay" = " day"; "CountDownHour" = " hour"; "CountDownMin" = " min"; From a38b781c117c590812f6b65e3ea1d057031925af Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 30 Mar 2020 10:42:51 -0400 Subject: [PATCH 14/14] no --- .../EyebrowHeadlineBodyLink.swift | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift index ff530d92..82f83530 100644 --- a/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift +++ b/MVMCoreUI/Atomic/Molecules/VerticalCombinationViews/EyebrowHeadlineBodyLink.swift @@ -52,19 +52,6 @@ import UIKit body.styleB2(true) } -// public func eyebrow(isHidden: Bool) { -// -// stack.stackModel?.molecules[0].gone = isHidden -// -// if isHidden { -// accessibilityElements = [headline, body, link] -// } else { -// accessibilityElements = [eyebrow, headline, body, link] -// } -// -// stack.restack() -// } - //-------------------------------------------------- // MARK: - MoleculeViewProtocol //--------------------------------------------------