This commit is contained in:
Kevin G Christiano 2020-03-30 09:53:38 -04:00
parent 70100791e6
commit dcbfcf033f
8 changed files with 82 additions and 30 deletions

View File

@ -338,6 +338,7 @@ public typealias ActionBlockConfirmation = () -> (Bool)
// MARK:- MoleculeViewProtocol // MARK:- MoleculeViewProtocol
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.set(with: model, delegateObject, additionalData)
self.delegateObject = delegateObject self.delegateObject = delegateObject
guard let model = model as? ToggleModel else { return } guard let model = model as? ToggleModel else { return }

View File

@ -9,6 +9,10 @@
import Foundation import Foundation
@objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol { @objcMembers public class StackItemModel: ContainerModel, StackItemModelProtocol, MoleculeModelProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public static var identifier: String = "simpleStackItem" public static var identifier: String = "simpleStackItem"
public var moleculeName: String = StackItemModel.identifier public var moleculeName: String = StackItemModel.identifier
public var backgroundColor: Color? public var backgroundColor: Color?
@ -16,12 +20,18 @@ import Foundation
public var percent: Int? public var percent: Int?
public var gone: Bool = false 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) { public convenience init(spacing: CGFloat? = nil, percent: Int? = nil, horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil, gone: Bool? = nil) {
self.init() self.init()
self.horizontalAlignment = horizontalAlignment self.horizontalAlignment = horizontalAlignment
self.verticalAlignment = verticalAlignment self.verticalAlignment = verticalAlignment
self.spacing = spacing self.spacing = spacing
self.percent = percent self.percent = percent
if let gone = gone { if let gone = gone {
self.gone = gone self.gone = gone
} }

View File

@ -52,18 +52,18 @@ import UIKit
body.styleB2(true) body.styleB2(true)
} }
public func eyebrow(isHidden: Bool) { // public func eyebrow(isHidden: Bool) {
//
stack.stackModel?.molecules[0].gone = isHidden // stack.stackModel?.molecules[0].gone = isHidden
//
if isHidden { // if isHidden {
accessibilityElements = [headline, body, link] // accessibilityElements = [headline, body, link]
} else { // } else {
accessibilityElements = [eyebrow, headline, body, link] // accessibilityElements = [eyebrow, headline, body, link]
} // }
//
stack.restack() // stack.restack()
} // }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - MoleculeViewProtocol // MARK: - MoleculeViewProtocol

View File

@ -15,10 +15,11 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
//-------------------------------------------------- //--------------------------------------------------
open var contentView: UIView = MVMCoreUICommonViewsUtility.commonView() open var contentView: UIView = MVMCoreUICommonViewsUtility.commonView()
open var stackItems: [UIView] = []
open var stackModel: T? { open var stackModel: T? {
get { return model as? T } get { return model as? T }
} }
open var stackItems: [UIView] = []
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Helpers // MARK: - Helpers
@ -37,9 +38,7 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
guard let stackModel = stackModel else { return } guard let stackModel = stackModel else { return }
let stackItems = self.stackItems let stackItems = self.stackItems
self.stackItems = [] self.stackItems = []
let lastItemIndex = stackModel.molecules.lastIndex(where: { (item) -> Bool in let lastItemIndex = stackModel.molecules.lastIndex { !$0.gone }
return !item.gone
})
// Adds the views // Adds the views
let totalSpace = getTotalSpace() let totalSpace = getTotalSpace()
@ -48,7 +47,12 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
} }
isAccessibilityElement = false 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. /// Removes all stack items views from the view.

View File

@ -12,6 +12,7 @@ import UIKit
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
open var model: MoleculeModelProtocol? open var model: MoleculeModelProtocol?
private var initialSetupPerformed = false private var initialSetupPerformed = false

View File

@ -197,10 +197,13 @@ import UIKit
// MARK: - Caret View // MARK: - Caret View
/// Adds the standard mvm style caret to the accessory view /// Adds the standard mvm style caret to the accessory view
@objc public func addCaretViewAccessory() { @objc public func addCaretViewAccessory() {
guard accessoryView == nil else { return } guard accessoryView == nil else { return }
let caret = CaretView(lineWidth: 1) let caret = CaretView(lineWidth: 1)
caret.translatesAutoresizingMaskIntoConstraints = true caret.translatesAutoresizingMaskIntoConstraints = true
caret.isAccessibilityElement = true
caret.accessibilityHint = MVMCoreUIUtility.hardcodedString(withKey: "AccTabHint")
caret.size = .small(.vertical) caret.size = .small(.vertical)
if let size = caret.size?.dimensions() { if let size = caret.size?.dimensions() {
caret.frame = CGRect(origin: CGPoint.zero, size: size) caret.frame = CGRect(origin: CGPoint.zero, size: size)

View File

@ -9,6 +9,10 @@
import Foundation import Foundation
open class ContainerModel: ContainerModelProtocol, Codable { open class ContainerModel: ContainerModelProtocol, Codable {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var horizontalAlignment: UIStackView.Alignment? public var horizontalAlignment: UIStackView.Alignment?
public var verticalAlignment: UIStackView.Alignment? public var verticalAlignment: UIStackView.Alignment?
public var useHorizontalMargins: Bool? public var useHorizontalMargins: Bool?
@ -17,6 +21,10 @@ open class ContainerModel: ContainerModelProtocol, Codable {
public var topMarginPadding: CGFloat? public var topMarginPadding: CGFloat?
public var bottomMarginPadding: CGFloat? public var bottomMarginPadding: CGFloat?
//--------------------------------------------------
// MARK: - Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case verticalAlignment case verticalAlignment
case horizontalAlignment case horizontalAlignment
@ -26,6 +34,10 @@ open class ContainerModel: ContainerModelProtocol, Codable {
case bottomMarginPadding case bottomMarginPadding
} }
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public init() {} public init() {}
public convenience init(horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil) { public convenience init(horizontalAlignment: UIStackView.Alignment? = nil, verticalAlignment: UIStackView.Alignment? = nil) {
@ -34,6 +46,10 @@ open class ContainerModel: ContainerModelProtocol, Codable {
self.verticalAlignment = verticalAlignment self.verticalAlignment = verticalAlignment
} }
//--------------------------------------------------
// MARK: - Codec
//--------------------------------------------------
required public init(from decoder: Decoder) throws { required public init(from decoder: Decoder) throws {
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) { if let verticalAlignmentString = try typeContainer.decodeIfPresent(String.self, forKey: .verticalAlignment) {

View File

@ -6,56 +6,73 @@
Copyright © 2017 myverizon. All rights reserved. Copyright © 2017 myverizon. All rights reserved.
*/ */
//// Accessibility // MARK: Accessibility
"AccCloseButton" = "Close"; "AccCloseButton" = "Close";
"swipe_to_select_with_action_hint" = "swipe up or down to select action, then double tap to select."; "swipe_to_select_with_action_hint" = "swipe up or down to select action, then double tap to select.";
// Tab
// MARK: Tab
"AccTab" = ", tab"; "AccTab" = ", tab";
"AccTabHint" = "Double tap to select."; "AccTabHint" = "Double tap to select.";
"AccTabIndex" = ", %ld of %ld"; "AccTabIndex" = ", %ld of %ld";
// top alert
// MARK: Top alert
"toptabbar_tab_selected" = ", tab, Selected"; "toptabbar_tab_selected" = ", tab, Selected";
"AccTopAlertClosed" = "Top alert notification is closed."; "AccTopAlertClosed" = "Top alert notification is closed.";
"top_alert_notification" = "Top alert notification"; "top_alert_notification" = "Top alert notification";
// Textfield
// MARK: Textfield
"textfield_today_string" = "Today"; "textfield_today_string" = "Today";
"textfield_error_message" = "%@.\n The error message.\n %@"; "textfield_error_message" = "%@.\n The error message.\n %@";
"textfield_picker_item" = " picker item"; "textfield_picker_item" = " picker item";
"textfield_regular" = " regular"; "textfield_regular" = " regular";
"textfield_disabled_state" = "disabled"; "textfield_disabled_state" = "disabled";
// MDNTextfield
// MARK: MDNTextfield
"textfield_contacts_barbutton" = "My Contacts"; "textfield_contacts_barbutton" = "My Contacts";
"textfield_phone_format_error_message" = "Invalid phone number format."; "textfield_phone_format_error_message" = "Invalid phone number format.";
// DigitTextfield
// MARK: DigitTextfield
"mfdigittextfield_regular" = " regular"; "mfdigittextfield_regular" = " regular";
// Camera
// MARK: Camera
"AccCameraButton" = "Camera Button"; "AccCameraButton" = "Camera Button";
"AccCameraHint" = "Double tap to launch camera for scanning"; "AccCameraHint" = "Double tap to launch camera for scanning";
// Checkbox
// MARK: Checkbox
"checkbox_action_hint" = "Double tap to change state"; "checkbox_action_hint" = "Double tap to change state";
"checkbox_checked_state" = "Checked"; "checkbox_checked_state" = "Checked";
"checkbox_unchecked_state" = "Unchecked"; "checkbox_unchecked_state" = "Unchecked";
"checkbox_desc_state" = "%@ CheckBox %@"; "checkbox_desc_state" = "%@ CheckBox %@";
// Radio Button
// MARK: Radio Button
"radio_action_hint" = "Double tap to select"; "radio_action_hint" = "Double tap to select";
"radio_selected_state" = "Selected"; "radio_selected_state" = "Selected";
"radio_not_selected_state" = "Not Selected"; "radio_not_selected_state" = "Not Selected";
"radio_desc_state" = "Option"; "radio_desc_state" = "Option";
// Switch / Toggle
// MARK: Switch / Toggle
"mfswitch_buttonlabel" = "Switch Button"; "mfswitch_buttonlabel" = "Switch Button";
"Toggle_buttonlabel" = "Toggle Button"; "Toggle_buttonlabel" = "Toggle Button";
"AccOn" = "on"; "AccOn" = "on";
"AccOff" = "off"; "AccOff" = "off";
"AccToggleHint" = "double tap to toggle"; "AccToggleHint" = "double tap to toggle";
// Carousel
// MARK: Carousel
"MVMCoreUIPageControl_currentpage_index" = "page %ld of %ld"; "MVMCoreUIPageControl_currentpage_index" = "page %ld of %ld";
"MVMCoreUIPageControlslides_currentpage_index" = "slide %ld of %ld"; "MVMCoreUIPageControlslides_currentpage_index" = "slide %ld of %ld";
//Styler
// MARK: Styler
"CountDownDay" = " day"; "CountDownDay" = " day";
"CountDownHour" = " hour"; "CountDownHour" = " hour";
"CountDownMin" = " min"; "CountDownMin" = " min";