This commit is contained in:
Pfeil, Scott Robert 2020-01-24 08:49:04 -05:00
parent 5d23b8329f
commit 1b4646df31
5 changed files with 39 additions and 15 deletions

View File

@ -305,6 +305,7 @@
D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99723D8D63C000B42E6 /* ActionDetailWithImageModel.swift */; };
D2E2A99A23D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99923D8D6B4000B42E6 /* HeadlineBodyButtonModel.swift */; };
D2E2A99C23D8D975000B42E6 /* ImageHeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2E2A99B23D8D975000B42E6 /* ImageHeadlineBodyModel.swift */; };
D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A209CD223A7E2810068F8B0 /* UIStackViewAlignment+Extension.swift */; };
D2FB151B23A2B65B00C20E10 /* MoleculeContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */; };
D2FB151D23A40F1500C20E10 /* MoleculeStackItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2FB151C23A40F1500C20E10 /* MoleculeStackItem.swift */; };
DB06250B2293456500B72DD3 /* LeftRightLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */; };
@ -1532,6 +1533,7 @@
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
D260106323D0C05000764D80 /* StackItemModel.swift in Sources */,
D2E2A99823D8D63C000B42E6 /* ActionDetailWithImageModel.swift in Sources */,
D2E2A99D23DA3217000B42E6 /* UIStackViewAlignment+Extension.swift in Sources */,
01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */,
0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */,
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */,

View File

@ -9,7 +9,7 @@
import Foundation
@objcMembers public class ProgressBarModel: MoleculeModelProtocol {
public static var identifier: String = "progressbar"
public static var identifier: String = "progressBar"
@Percent public var percent: CGFloat
public var progressColor: Color = Color(uiColor: .mfCerulean())
public var backgroundColor: Color? = Color(uiColor: .mfLightSilver())

View File

@ -12,8 +12,8 @@ public typealias ButtonAction = (Button) -> ()
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var model: MoleculeModelProtocol?
public var actionModel: ActionModelProtocol?
open var model: MoleculeModelProtocol?
open var actionModel: ActionModelProtocol?
private var initialSetupPerformed = false
@ -23,7 +23,7 @@ public typealias ButtonAction = (Button) -> ()
// MARK: - Delegate
//--------------------------------------------------
public weak var buttonDelegate: ButtonDelegateProtocol?
open weak var buttonDelegate: ButtonDelegateProtocol?
//--------------------------------------------------
// MARK: - Initializers
@ -48,6 +48,7 @@ public typealias ButtonAction = (Button) -> ()
// MARK: - Setup
//--------------------------------------------------
/// Required to be called any init. Ensures setupView() only gets called once
public func initialSetup() {
if !initialSetupPerformed {
@ -60,16 +61,17 @@ public typealias ButtonAction = (Button) -> ()
// MARK: - Methods
//--------------------------------------------------
public func addActionBlock( event: Event, _ buttonBlock: @escaping ButtonAction) {
/// Adds a block to be performed for the given event.
open func addActionBlock(event: Event, _ buttonBlock: @escaping ButtonAction) {
self.buttonAction = buttonBlock
addTarget(self, action: #selector(callActionBlock(_:)), for: event)
}
func callActionBlock(_ sender: Button) {
@objc private func callActionBlock(_ sender: Button) {
buttonAction?(self)
}
public func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
open func set(with actionModel: ActionModelProtocol, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
self.actionModel = actionModel
buttonDelegate = delegateObject?.buttonDelegate
@ -104,14 +106,13 @@ public typealias ButtonAction = (Button) -> ()
}
}
// MARK: - MVMCoreViewProtocol
extension Button: MVMCoreViewProtocol {
public func updateView(_ size: CGFloat) {}
open func updateView(_ size: CGFloat) {}
/// Will be called only once.
public func setupView() {
open func setupView() {
translatesAutoresizingMaskIntoConstraints = false
insetsLayoutMarginsFromSafeArea = false
titleLabel?.numberOfLines = 0
@ -121,7 +122,7 @@ extension Button: MVMCoreViewProtocol {
// MARK: - MVMCoreUIMoleculeViewProtocol
extension Button: MVMCoreUIMoleculeViewProtocol {
public func reset() {
open func reset() {
backgroundColor = .clear
}
}

View File

@ -13,7 +13,7 @@ import UIKit
// MARK: - Properties
//--------------------------------------------------
open var json: [AnyHashable: Any]?
public var model: MoleculeModelProtocol?
open var model: MoleculeModelProtocol?
private var initialSetupPerformed = false
@ -78,10 +78,10 @@ extension Control: AppleGuidelinesProtocol {
// MARK: - MVMCoreViewProtocol
extension Control: MVMCoreViewProtocol {
public func updateView(_ size: CGFloat) {}
open func updateView(_ size: CGFloat) {}
/// Will be called only once.
public func setupView() {
open func setupView() {
translatesAutoresizingMaskIntoConstraints = false
insetsLayoutMarginsFromSafeArea = false
}
@ -97,7 +97,7 @@ extension Control: MVMCoreUIMoleculeViewProtocol {
}
}
public func reset() {
open func reset() {
backgroundColor = .clear
}
}

View File

@ -30,6 +30,11 @@ import Foundation
try container.encode(alignment.rawValueString, forKey: .alignment)
}
*/
enum AlignmentError: Error {
case notAnAlignment
}
extension UIStackView.Alignment: RawRepresentable {
init?(rawValue: String) {
@ -70,3 +75,19 @@ extension UIStackView.Alignment: RawRepresentable {
}
}
}
extension UIStackView.Alignment: Codable {
public init(from decoder: Decoder) throws {
let typeContainer = try decoder.singleValueContainer()
let string = try typeContainer.decode(String.self)
guard let alignment = UIStackView.Alignment(rawValue: string) else {
throw AlignmentError.notAnAlignment
}
self = alignment
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawValueString)
}
}