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
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 }

View File

@ -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
}

View File

@ -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

View File

@ -15,10 +15,11 @@ open class Stack<T>: 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<T>: 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.

View File

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

View File

@ -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)

View File

@ -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)

View File

@ -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";