formatting updates. Adding identifier for easier testing.

This commit is contained in:
Kevin G Christiano 2020-12-03 14:22:06 -05:00
parent acebc936d7
commit 1a60d36e2d
21 changed files with 122 additions and 89 deletions

View File

@ -2154,6 +2154,7 @@
D2B18B7D236090D500A9AEDC /* BaseClasses */ = { D2B18B7D236090D500A9AEDC /* BaseClasses */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
0A5D59C323AD488600EFD9E9 /* Protocols */,
0A6682B3243769C700AD3CA1 /* TextView.swift */, 0A6682B3243769C700AD3CA1 /* TextView.swift */,
C003506023AA94CD00B6AC29 /* Button.swift */, C003506023AA94CD00B6AC29 /* Button.swift */,
D2B18B7E2360913400A9AEDC /* Control.swift */, D2B18B7E2360913400A9AEDC /* Control.swift */,
@ -2164,7 +2165,6 @@
BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */, BB105858248DEFF60069D008 /* UICollectionViewLeftAlignedLayout.swift */,
D21B7F70243BAC1600051ABF /* CollectionViewCell.swift */, D21B7F70243BAC1600051ABF /* CollectionViewCell.swift */,
D264FAA92440F97600D98315 /* CollectionView.swift */, D264FAA92440F97600D98315 /* CollectionView.swift */,
0A5D59C323AD488600EFD9E9 /* Protocols */,
0A7918F423F5E7EA00772FF4 /* ImageView.swift */, 0A7918F423F5E7EA00772FF4 /* ImageView.swift */,
D272F5F82473163100BD1A8F /* BarButtonItem.swift */, D272F5F82473163100BD1A8F /* BarButtonItem.swift */,
D2EC7BDC2527B83700F540AF /* SectionHeaderFooterView.swift */, D2EC7BDC2527B83700F540AF /* SectionHeaderFooterView.swift */,

View File

@ -18,6 +18,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
public static var identifier: String = "button" public static var identifier: String = "button"
public var backgroundColor: Color? public var backgroundColor: Color?
public var accessibilityIdentifier: String?
public var title: String public var title: String
public var action: ActionModelProtocol public var action: ActionModelProtocol
public var enabled: Bool = true public var enabled: Bool = true
@ -172,6 +173,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case backgroundColor case backgroundColor
case accessibilityIdentifier
case title case title
case inverted case inverted
case action case action
@ -195,6 +197,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
title = try typeContainer.decode(String.self, forKey: .title) title = try typeContainer.decode(String.self, forKey: .title)
action = try typeContainer.decodeModel(codingKey: .action) action = try typeContainer.decodeModel(codingKey: .action)
@ -252,6 +255,7 @@ public class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupW
try container.encode(inverted, forKey: .inverted) try container.encode(inverted, forKey: .inverted)
try container.encodeModel(action, forKey: .action) try container.encodeModel(action, forKey: .action)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
try container.encodeIfPresent(enabledFillColor, forKey: .fillColor) try container.encodeIfPresent(enabledFillColor, forKey: .fillColor)
try container.encodeIfPresent(enabledTextColor, forKey: .textColor) try container.encodeIfPresent(enabledTextColor, forKey: .textColor)
try container.encodeIfPresent(enabledBorderColor, forKey: .borderColor) try container.encodeIfPresent(enabledBorderColor, forKey: .borderColor)

View File

@ -127,7 +127,6 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol {
} }
public func updateCaretSpacing(_ spacing: CGFloat) { public func updateCaretSpacing(_ spacing: CGFloat) {
caretSpacingConstraint?.constant = spacing caretSpacingConstraint?.constant = spacing
} }
@ -151,15 +150,9 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol {
setTitle(model.title, for: .normal) setTitle(model.title, for: .normal)
} }
public func needsToBeConstrained() -> Bool { public func needsToBeConstrained() -> Bool { true }
return true
}
open func horizontalAlignment() -> UIStackView.Alignment { open func horizontalAlignment() -> UIStackView.Alignment { .leading }
return .leading
}
open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { 10.5 }
return 10.5
}
} }

View File

@ -17,6 +17,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea
public static var identifier: String = "caretLink" public static var identifier: String = "caretLink"
public var backgroundColor: Color? public var backgroundColor: Color?
public var accessibilityIdentifier: String?
public var title: String public var title: String
public var action: ActionModelProtocol public var action: ActionModelProtocol
public var enabledColor: Color = Color(uiColor: .mvmBlack) public var enabledColor: Color = Color(uiColor: .mvmBlack)
@ -41,6 +42,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case backgroundColor case backgroundColor
case accessibilityIdentifier
case title case title
case action case action
case enabledColor_inverted case enabledColor_inverted
@ -60,6 +62,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea
let typeContainer = try decoder.container(keyedBy: CodingKeys.self) let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
title = try typeContainer.decode(String.self, forKey: .title) title = try typeContainer.decode(String.self, forKey: .title)
if let enabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor_inverted) { if let enabledColor_inverted = try typeContainer.decodeIfPresent(Color.self, forKey: .enabledColor_inverted) {
@ -94,6 +97,7 @@ public class CaretLinkModel: ButtonModelProtocol, MoleculeModelProtocol, Enablea
try container.encode(moleculeName, forKey: .moleculeName) try container.encode(moleculeName, forKey: .moleculeName)
try container.encode(title, forKey: .title) try container.encode(title, forKey: .title)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
try container.encodeModel(action, forKey: .action) try container.encodeModel(action, forKey: .action)
try container.encode(enabled, forKey: .enabledColor) try container.encode(enabled, forKey: .enabledColor)
try container.encodeIfPresent(disabledColor, forKey: .disabledColor) try container.encodeIfPresent(disabledColor, forKey: .disabledColor)

View File

@ -18,7 +18,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
var size = MVMCoreUIUtility.getWidth() var size = MVMCoreUIUtility.getWidth()
var buttonModel: ButtonModel? { var buttonModel: ButtonModel? {
get { return model as? ButtonModel } get { model as? ButtonModel }
} }
/// Need to re-style on set. /// Need to re-style on set.
@ -47,12 +47,12 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
//-------------------------------------------------- //--------------------------------------------------
public var enabledTitleColor: UIColor? { public var enabledTitleColor: UIColor? {
get { return titleColor(for: .normal) } get { titleColor(for: .normal) }
set { setTitleColor(newValue, for: .normal) } set { setTitleColor(newValue, for: .normal) }
} }
public var disabledTitleColor: UIColor? { public var disabledTitleColor: UIColor? {
get { return titleColor(for: .disabled) } get { titleColor(for: .disabled) }
set { setTitleColor(newValue, for: .disabled) } set { setTitleColor(newValue, for: .disabled) }
} }
@ -228,9 +228,7 @@ open class PillButton: Button, MVMCoreUIViewConstrainingProtocol {
// MARK: - MVMCoreUIViewConstrainingProtocol // MARK: - MVMCoreUIViewConstrainingProtocol
//-------------------------------------------------- //--------------------------------------------------
open func horizontalAlignment() -> UIStackView.Alignment { open func horizontalAlignment() -> UIStackView.Alignment { .center }
return .center
}
public func enableField(_ enable: Bool) { public func enableField(_ enable: Bool) {
isEnabled = enable isEnabled = enable

View File

@ -16,6 +16,7 @@ import Foundation
public static var identifier: String = "dashLine" public static var identifier: String = "dashLine"
public var backgroundColor: Color? public var backgroundColor: Color?
public var accessibilityIdentifier: String?
public var dashColor: Color = Color(uiColor: .mvmCoolGray3) public var dashColor: Color = Color(uiColor: .mvmCoolGray3)
public var dashColor_inverted: Color = Color(uiColor: .mvmWhite) public var dashColor_inverted: Color = Color(uiColor: .mvmWhite)
public var isHidden: Bool = false public var isHidden: Bool = false
@ -36,6 +37,7 @@ import Foundation
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case backgroundColor case backgroundColor
case accessibilityIdentifier
case dashColor_inverted case dashColor_inverted
case dashColor case dashColor
case isHidden case isHidden
@ -57,6 +59,7 @@ import Foundation
} }
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
if let isHidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .isHidden) { if let isHidden = try typeContainer.decodeIfPresent(Bool.self, forKey: .isHidden) {
self.isHidden = isHidden self.isHidden = isHidden
@ -69,5 +72,6 @@ import Foundation
try container.encode(dashColor, forKey: .dashColor) try container.encode(dashColor, forKey: .dashColor)
try container.encode(isHidden, forKey: .isHidden) try container.encode(isHidden, forKey: .isHidden)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
} }
} }

View File

@ -17,7 +17,7 @@ import UIKit
private let stack = Stack<StackModel>() private let stack = Stack<StackModel>()
var multiProgressModel: MultiProgressBarModel? { var multiProgressModel: MultiProgressBarModel? {
get { return model as? MultiProgressBarModel } get { model as? MultiProgressBarModel }
} }
var roundedCorners: Bool = false { var roundedCorners: Bool = false {
@ -85,7 +85,7 @@ import UIKit
//-------------------------------------------------- //--------------------------------------------------
/// Creates the bars /// Creates the bars
open func set(with progressList: Array<SingleProgressBarModel>, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { open func set(with progressList: [SingleProgressBarModel], _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
stack.removeAllItemViews() stack.removeAllItemViews()
guard let stackModel = stack.stackModel else { return } guard let stackModel = stack.stackModel else { return }
@ -103,7 +103,6 @@ import UIKit
stack.set(with: stackModel, delegateObject, additionalData) stack.set(with: stackModel, delegateObject, additionalData)
} }
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) super.set(with: model, delegateObject, additionalData)
@ -115,6 +114,6 @@ import UIKit
} }
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
return (model as? MultiProgressBarModel)?.thickness ?? 8 (model as? MultiProgressBarModel)?.thickness ?? 8
} }
} }

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved. // Copyright © 2020 Verizon Wireless. All rights reserved.
// //
import Foundation
@objcMembers open class TabBar: UITabBar, MoleculeViewProtocol, TabBarProtocol, UITabBarDelegate { @objcMembers open class TabBar: UITabBar, MoleculeViewProtocol, TabBarProtocol, UITabBarDelegate {
@ -15,9 +14,7 @@ import Foundation
public let line = Line() public let line = Line()
required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { required public init(model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? TabBarModel else { guard let model = model as? TabBarModel else { fatalError("model is not TabBarModel") }
fatalError("model is not TabBarModel")
}
self.model = model self.model = model
super.init(frame: .zero) super.init(frame: .zero)
@ -32,7 +29,7 @@ import Foundation
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
guard let model = model as? TabBarModel else { return } guard let model = model as? TabBarModel else { return }
self.model = model self.model = model
@ -100,10 +97,7 @@ import Foundation
}) })
} }
public func currentTabIndex() -> Int { public func currentTabIndex() -> Int { model.selectedTab }
return model.selectedTab
}
} }
extension UITabBarItem: MFButtonProtocol { extension UITabBarItem: MFButtonProtocol { }
}

View File

@ -6,11 +6,10 @@
// Copyright © 2020 Verizon Wireless. All rights reserved. // Copyright © 2020 Verizon Wireless. All rights reserved.
// //
import Foundation
extension MVMCoreUITopAlertExpandableView: MoleculeViewProtocol { extension MVMCoreUITopAlertExpandableView: MoleculeViewProtocol {
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
defaultSetup() defaultSetup()
guard let model = model as? CollapsableNotificationModel else { return } guard let model = model as? CollapsableNotificationModel else { return }
backgroundColor = model.backgroundColor?.uiColor ?? .mvmGreen backgroundColor = model.backgroundColor?.uiColor ?? .mvmGreen
@ -30,6 +29,10 @@ extension MVMCoreUITopAlertExpandableView: MoleculeViewProtocol {
MVMCoreUITopAlertBaseView.addAction(to: button, actionMap: topActionMap, additionalData: nil) MVMCoreUITopAlertBaseView.addAction(to: button, actionMap: topActionMap, additionalData: nil)
shortView?.label?.accessibilityTraits = .button shortView?.label?.accessibilityTraits = .button
} }
if let accessibilityIdentifier = model.accessibilityIdentifier {
self.accessibilityIdentifier = accessibilityIdentifier
}
} }
} }

View File

@ -6,17 +6,24 @@
// Copyright © 2020 Verizon Wireless. All rights reserved. // Copyright © 2020 Verizon Wireless. All rights reserved.
// //
import Foundation
extension MVMCoreUITopAlertMainView: MoleculeViewProtocol { extension MVMCoreUITopAlertMainView: MoleculeViewProtocol {
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) {
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
defaultSetup() defaultSetup()
guard let model = model as? NotificationModel else { return } guard let model = model as? NotificationModel else { return }
backgroundColor = model.backgroundColor?.uiColor ?? .mvmGreen backgroundColor = model.backgroundColor?.uiColor ?? .mvmGreen
var actionMap = model.button?.action.toJSON() var actionMap = model.button?.action.toJSON()
if let title = model.button?.title { if let title = model.button?.title {
actionMap?.updateValue(title, forKey: KeyTitle) actionMap?.updateValue(title, forKey: KeyTitle)
} }
if let accessibilityIdentifier = model.accessibilityIdentifier {
self.accessibilityIdentifier = accessibilityIdentifier
}
setupCloseButton(model.closeButton != nil, animationDelegate: MVMCoreUITopAlertView.sharedGlobal()?.animationDelegate) setupCloseButton(model.closeButton != nil, animationDelegate: MVMCoreUITopAlertView.sharedGlobal()?.animationDelegate)
setup(withMessage: model.headline.text, subMessage: model.body?.text, color: model.headline.textColor?.uiColor ?? .white, actionMap: actionMap, additionalData: nil) setup(withMessage: model.headline.text, subMessage: model.body?.text, color: model.headline.textColor?.uiColor ?? .white, actionMap: actionMap, additionalData: nil)
} }

View File

@ -6,52 +6,72 @@
// Copyright © 2020 Verizon Wireless. All rights reserved. // Copyright © 2020 Verizon Wireless. All rights reserved.
// //
import Foundation
open class NotificationModel: MoleculeModelProtocol { open class NotificationModel: MoleculeModelProtocol {
public class var identifier: String { //--------------------------------------------------
return "notification" // MARK: - Properties
} //--------------------------------------------------
public class var identifier: String { "notification" }
public var accessibilityIdentifier: String?
public var backgroundColor: Color? public var backgroundColor: Color?
public var headline: LabelModel public var headline: LabelModel
public var body: LabelModel? public var body: LabelModel?
public var button: ButtonModel? public var button: ButtonModel?
public var closeButton: NotificationXButtonModel? public var closeButton: NotificationXButtonModel?
//--------------------------------------------------
// MARK: - Initializer
//--------------------------------------------------
public init(with headline: LabelModel) { public init(with headline: LabelModel) {
self.headline = headline self.headline = headline
} }
//--------------------------------------------------
// MARK: - Default
//--------------------------------------------------
open func setDefault() { open func setDefault() {
if backgroundColor == nil { if backgroundColor == nil {
backgroundColor = Color(uiColor: .mvmGreen()) backgroundColor = Color(uiColor: .mvmGreen)
} }
if headline.textColor == nil { if headline.textColor == nil {
headline.textColor = Color(uiColor: .white) headline.textColor = Color(uiColor: .mvmWhite)
} }
if body?.textColor == nil { if body?.textColor == nil {
body?.textColor = Color(uiColor: .white) body?.textColor = Color(uiColor: .mvmWhite)
} }
if button?.style == nil { if button?.style == nil {
button?.style = .secondary button?.style = .secondary
} }
button?.size = .tiny button?.size = .tiny
button?.enabledTextColor = Color(uiColor: .white) button?.enabledTextColor = Color(uiColor: .mvmWhite)
button?.enabledBorderColor = Color(uiColor: .white) button?.enabledBorderColor = Color(uiColor: .mvmWhite)
} }
//--------------------------------------------------
// MARK: - Coding Keys
//--------------------------------------------------
private enum CodingKeys: String, CodingKey { private enum CodingKeys: String, CodingKey {
case moleculeName case moleculeName
case backgroundColor case backgroundColor
case accessibilityIdentifier
case headline case headline
case body case body
case button case button
case closeButton case closeButton
} }
//--------------------------------------------------
// 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)
backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor)
accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier)
headline = try typeContainer.decode(LabelModel.self, forKey: .headline) headline = try typeContainer.decode(LabelModel.self, forKey: .headline)
body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body) body = try typeContainer.decodeIfPresent(LabelModel.self, forKey: .body)
button = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .button) button = try typeContainer.decodeIfPresent(ButtonModel.self, forKey: .button)
@ -63,6 +83,7 @@ open class NotificationModel: MoleculeModelProtocol {
var container = encoder.container(keyedBy: CodingKeys.self) var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(moleculeName, forKey: .moleculeName) try container.encode(moleculeName, forKey: .moleculeName)
try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor)
try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier)
try container.encode(headline, forKey: .headline) try container.encode(headline, forKey: .headline)
try container.encodeIfPresent(body, forKey: .body) try container.encodeIfPresent(body, forKey: .body)
try container.encodeIfPresent(button, forKey: .button) try container.encodeIfPresent(button, forKey: .button)

View File

@ -16,7 +16,7 @@ open class Stack<T>: Container where T: (StackModelProtocol & MoleculeModelProto
open var stackItems: [UIView] = [] open var stackItems: [UIView] = []
open var stackModel: T? { open var stackModel: T? {
get { return model as? T } get { model as? T }
} }
//-------------------------------------------------- //--------------------------------------------------

View File

@ -8,6 +8,7 @@
public typealias BarButtonAction = (BarButtonItem) -> () public typealias BarButtonAction = (BarButtonItem) -> ()
@objc class ActionDelegate: NSObject { @objc class ActionDelegate: NSObject {
var buttonAction: BarButtonAction? var buttonAction: BarButtonAction?
@objc func callActionBlock(_ sender: BarButtonItem) { @objc func callActionBlock(_ sender: BarButtonItem) {
@ -16,7 +17,6 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
} }
@objcMembers open class BarButtonItem: UIBarButtonItem, MFButtonProtocol { @objcMembers open class BarButtonItem: UIBarButtonItem, MFButtonProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Delegate // MARK: - Delegate
//-------------------------------------------------- //--------------------------------------------------
@ -43,4 +43,3 @@ public typealias BarButtonAction = (BarButtonItem) -> ()
} }
} }
} }

View File

@ -65,7 +65,7 @@ public typealias ButtonAction = (Button) -> ()
/// Adds a block to be performed for the given event. /// Adds a block to be performed for the given event.
open func addActionBlock(event: Event, _ buttonBlock: @escaping ButtonAction) { open func addActionBlock(event: Event, _ buttonBlock: @escaping ButtonAction) {
self.buttonAction = buttonBlock self.buttonAction = buttonBlock
addTarget(self, action: #selector(callActionBlock(_:)), for: event) addTarget(self, action: #selector(callActionBlock), for: event)
} }
@objc func callActionBlock(_ sender: Button) { @objc func callActionBlock(_ sender: Button) {
@ -103,6 +103,10 @@ public typealias ButtonAction = (Button) -> ()
self.backgroundColor = backgroundColor.uiColor self.backgroundColor = backgroundColor.uiColor
} }
if let accessibilityIdentifier = model.accessibilityIdentifier {
self.accessibilityIdentifier = accessibilityIdentifier
}
if let model = model as? EnableableModelProtocol { if let model = model as? EnableableModelProtocol {
isEnabled = model.enabled isEnabled = model.enabled
} }
@ -119,16 +123,12 @@ public typealias ButtonAction = (Button) -> ()
// MARK: Overridables // MARK: Overridables
// Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead. // Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead.
open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model.moleculeName model.moleculeName
} }
open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil }
return nil
}
open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { nil }
return nil
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Accessibility // MARK: - Accessibility
@ -160,6 +160,6 @@ extension Button: MVMCoreViewProtocol {
extension Button: AppleGuidelinesProtocol { extension Button: AppleGuidelinesProtocol {
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return Self.acceptablyOutsideBounds(point: point, bounds: bounds) Self.acceptablyOutsideBounds(point: point, bounds: bounds)
} }
} }

View File

@ -51,9 +51,14 @@ import UIKit
// MARK:- MoleculeViewProtocol // MARK:- MoleculeViewProtocol
open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
self.model = model self.model = model
if let backgroundColor = model.backgroundColor { if let backgroundColor = model.backgroundColor {
self.backgroundColor = backgroundColor.uiColor self.backgroundColor = backgroundColor.uiColor
} }
if let accessibilityIdentifier = model.accessibilityIdentifier {
self.accessibilityIdentifier = accessibilityIdentifier
}
} }
open func reset() { open func reset() {
@ -63,22 +68,18 @@ import UIKit
// MARK: Overridables // MARK: Overridables
// Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead. // Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead.
open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model.moleculeName model.moleculeName
} }
open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil }
return nil
}
open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { nil }
return nil
}
} }
// MARK: - AppleGuidelinesProtocol // MARK: - AppleGuidelinesProtocol
extension Control: AppleGuidelinesProtocol { extension Control: AppleGuidelinesProtocol {
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool { override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return Self.acceptablyOutsideBounds(point: point, bounds: bounds) Self.acceptablyOutsideBounds(point: point, bounds: bounds)
} }
} }

View File

@ -53,33 +53,35 @@ open class ImageView: UIImageView, MoleculeViewProtocol {
} }
public func reset() { public func reset() {
backgroundColor = .clear backgroundColor = .clear
} }
public func setAsMolecule() { } public func setAsMolecule() { }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - ModelMoleculeViewProtocol // MARK: - ModelMoleculeViewProtocol
//-------------------------------------------------- //--------------------------------------------------
public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable : Any]?) { public func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
self.model = model self.model = model
if let backgroundColor = model.backgroundColor { if let backgroundColor = model.backgroundColor {
self.backgroundColor = backgroundColor.uiColor self.backgroundColor = backgroundColor.uiColor
} }
if let accessibilityIdentifier = model.accessibilityIdentifier {
self.accessibilityIdentifier = accessibilityIdentifier
}
} }
open class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { open class func nameForReuse(_ model: MoleculeModelProtocol?, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model?.moleculeName model?.moleculeName
} }
open class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open class func estimatedHeight(forRow molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil }
return nil
}
open class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { open class func requiredModules(_ molecule: MoleculeModelProtocol?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { nil }
return nil
}
} }
// MARK:- MVMCoreViewProtocol // MARK:- MVMCoreViewProtocol
@ -94,4 +96,3 @@ extension ImageView: MVMCoreViewProtocol {
MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0) MVMCoreUIUtility.setMarginsFor(self, leading: 0, top: 0, trailing: 0, bottom: 0)
} }
} }

View File

@ -6,7 +6,6 @@
// Copyright © 2020 Verizon Wireless. All rights reserved. // Copyright © 2020 Verizon Wireless. All rights reserved.
// //
import Foundation
@objcMembers open class SectionHeaderFooterView: UITableViewHeaderFooterView, MoleculeViewProtocol { @objcMembers open class SectionHeaderFooterView: UITableViewHeaderFooterView, MoleculeViewProtocol {
//-------------------------------------------------- //--------------------------------------------------
@ -43,10 +42,16 @@ import Foundation
//-------------------------------------------------- //--------------------------------------------------
open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) { open func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
self.model = model self.model = model
if let backgroundColor = model.backgroundColor { if let backgroundColor = model.backgroundColor {
contentView.backgroundColor = backgroundColor.uiColor contentView.backgroundColor = backgroundColor.uiColor
} }
if let accessibilityIdentifier = model.accessibilityIdentifier {
self.accessibilityIdentifier = accessibilityIdentifier
}
} }
open func reset() { open func reset() {
@ -56,16 +61,12 @@ import Foundation
// MARK: Overridables // MARK: Overridables
// Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead. // Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead.
open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? {
return model.moleculeName model.moleculeName
} }
open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil }
return nil
}
open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? { nil }
return nil
}
} }
// MARK:- MVMCoreViewProtocol // MARK:- MVMCoreViewProtocol

View File

@ -11,7 +11,7 @@ import Foundation
@objcMembers open class TableView: UITableView { @objcMembers open class TableView: UITableView {
/// A block that gets called on tableview frame changes /// A block that gets called on tableview frame changes
public var frameChangeAction: (() -> Void)? public var frameChangeAction: (() -> ())?
private var previousFrame = CGRect.zero private var previousFrame = CGRect.zero

View File

@ -93,6 +93,10 @@ extension TextField: MoleculeViewProtocol {
if let color = model.backgroundColor?.uiColor { if let color = model.backgroundColor?.uiColor {
backgroundColor = color backgroundColor = color
} }
if let accessibilityIdentifier = model.accessibilityIdentifier {
self.accessibilityIdentifier = accessibilityIdentifier
}
} }
open func reset() { open func reset() {

View File

@ -106,8 +106,8 @@ import UIKit
open func reset() { open func reset() {
fontStyle = Styler.Font.RegularBodyLarge fontStyle = .RegularBodyLarge
placeholderFontStyle = Styler.Font.RegularMicro placeholderFontStyle = .RegularMicro
placeholderTextColor = .mvmCoolGray3 placeholderTextColor = .mvmCoolGray3
textColor = .mvmBlack textColor = .mvmBlack
isEnabled = true isEnabled = true

View File

@ -59,8 +59,8 @@ import UIKit
self.backgroundColor = backgroundColor.uiColor self.backgroundColor = backgroundColor.uiColor
} }
if let identifier = model.accessibilityIdentifier { if let accessibilityIdentifier = model.accessibilityIdentifier {
accessibilityIdentifier = identifier self.accessibilityIdentifier = accessibilityIdentifier
} }
} }