Merge branch 'feature/coding' into feature/unordered_numbered_list_from_coding

This commit is contained in:
panxi 2020-01-13 17:03:00 -05:00
commit 53e00a7654
15 changed files with 172 additions and 29 deletions

View File

@ -104,6 +104,7 @@
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */; };
94C661D923CCF4B400D9FE5B /* LeftRightLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9402C34F23A2CEA3004B974C /* LeftRightLabelModel.swift */; };
94C661DA23CCF4FB00D9FE5B /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA33B33239813C50067DD0F /* UIColor+Extension.swift */; };
C003506123AA94CD00B6AC29 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = C003506023AA94CD00B6AC29 /* Button.swift */; };
C7192E7D23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */; };
C695A67F23C9830600BFB94E /* UnOrderedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */; };
C695A68123C9830D00BFB94E /* NumberedListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C695A68023C9830D00BFB94E /* NumberedListModel.swift */; };
@ -376,6 +377,7 @@
94C2D9A623872DA90006CF46 /* LabelAttributeColorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeColorModel.swift; sourceTree = "<group>"; };
94C2D9A823872E5E0006CF46 /* LabelAttributeImageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeImageModel.swift; sourceTree = "<group>"; };
94C2D9AA23872EB50006CF46 /* LabelAttributeActionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelAttributeActionModel.swift; sourceTree = "<group>"; };
C003506023AA94CD00B6AC29 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = "<group>"; };
C7192E7C23C301750050C2A0 /* HeadLineBodyCaretLinkImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadLineBodyCaretLinkImage.swift; sourceTree = "<group>"; };
C695A67E23C9830600BFB94E /* UnOrderedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnOrderedListModel.swift; sourceTree = "<group>"; };
C695A68023C9830D00BFB94E /* NumberedListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NumberedListModel.swift; sourceTree = "<group>"; };
@ -1244,6 +1246,7 @@
D2B18B7D236090D500A9AEDC /* BaseClasses */ = {
isa = PBXGroup;
children = (
C003506023AA94CD00B6AC29 /* Button.swift */,
D2B18B7E2360913400A9AEDC /* Control.swift */,
D2B18B802360945C00A9AEDC /* View.swift */,
0AE14F63238315D2005417F8 /* TextField.swift */,
@ -1580,6 +1583,8 @@
012A88F123985E0100FE3DA1 /* Color.swift in Sources */,
012A889C23889E8400FE3DA1 /* TemplateModelProtocol.swift in Sources */,
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
C003506123AA94CD00B6AC29 /* Button.swift in Sources */,
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */,
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */,
0A6BF4722360C56C0028F841 /* BaseDropdownEntryField.swift in Sources */,

View File

@ -45,10 +45,8 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI
super.layoutSubviews()
}
public func setEnabled(_ enabled: Bool) {
super.isEnabled = enabled
changeCaretColor()
override public var isEnabled: Bool {
didSet { changeCaretColor() }
}
public func updateView(_ size: CGFloat) { }
@ -85,7 +83,7 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI
caretView.widthAnchor.constraint(equalToConstant: width).isActive = true
caretView.heightAnchor.constraint(equalToConstant: height).isActive = true
let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 4.0)
let caretLabelSpacing = NSLayoutConstraint(item: caretView, attribute: .left, relatedBy: .equal, toItem: titleLabel, attribute: .right, multiplier: 1.0, constant: 4)
caretLabelSpacing.isActive = true
caretSpacingConstraint = caretLabelSpacing
@ -119,6 +117,14 @@ open class CaretButton: MFCustomButton, MVMCoreUIMoleculeViewProtocol, MVMCoreUI
guard let dictionary = json else { return }
if let title = dictionary.optionalStringForKey(KeyTitle) {
setTitle(title, for: .normal)
}
if let disableButtonAsAny = dictionary[KeyDisableButton], let isDisabled = disableButtonAsAny as? Bool {
isEnabled = !isDisabled
}
if let backgroundColorHex = dictionary[KeyBackgroundColor] as? String {
backgroundColor = UIColor.mfGet(forHex: backgroundColorHex)
}

View File

@ -454,7 +454,7 @@ import MVMCore
isEnabled(enabled)
}
if let actionMap = dictionary.optionalDictionaryForKey("actionMap") {
if let actionMap = dictionary.optionalDictionaryForKey("action") {
actionBlock = { MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject) }
}
}

View File

@ -19,6 +19,8 @@ open class DashLine: View {
get { return model as? DashLineModel }
}
// Legacy
@objc public var dashColor: UIColor?
@objc private var dashLayer: CAShapeLayer?
//------------------------------------------------------
@ -35,7 +37,6 @@ open class DashLine: View {
required public init?(coder: NSCoder) {
super.init(coder: coder)
fatalError("DashLine xib not supported")
}
//------------------------------------------------------
@ -69,7 +70,7 @@ open class DashLine: View {
dashLayer.lineCap = .round
dashLayer.lineDashPattern = [NSNumber(value: 2), NSNumber(value: 2)]
dashLayer.path = path.cgPath
dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? UIColor.mfLighterGray().cgColor
dashLayer.strokeColor = dashModel?.dashColor.uiColor.cgColor ?? dashColor?.cgColor ?? UIColor.mfLighterGray().cgColor
dashLayer.fillColor = UIColor.clear.cgColor
dashLayer.backgroundColor = backgroundColor?.cgColor ?? UIColor.white.cgColor
self.dashLayer = dashLayer

View File

@ -171,7 +171,7 @@ const CGFloat SwitchShakeIntensity = 2;
[self setState:[json boolForKey:@"state"] animated:false];
NSDictionary *actionMap = [json dict:@"actionMap"];
NSDictionary *actionMap = [json dict:@"action"];
if (actionMap) {
[self addTarget:self action:@selector(addCustomAction) forControlEvents:UIControlEventTouchUpInside];
}

View File

@ -0,0 +1,133 @@
//
// Button.swift
// MVMCoreUI
//
// Created by Robinson, Blake on 12/18/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
public typealias ButtonBlock = (Button) -> ()
@objcMembers open class Button: UIButton, MFButtonProtocol {
//--------------------------------------------------
// MARK: - Properties
//--------------------------------------------------
public var json: [AnyHashable: Any]?
public var actionMap: [AnyHashable: Any]?
private var initialSetupPerformed = false
private var buttonBlock: ButtonBlock?
//--------------------------------------------------
// MARK: - Delegate
//--------------------------------------------------
public weak var buttonDelegate: ButtonDelegateProtocol?
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------
public override init(frame: CGRect) {
super.init(frame: .zero)
initialSetup()
}
public convenience init() {
self.init(frame: .zero)
initialSetup()
}
public required init?(coder: NSCoder) {
super.init(coder: coder)
fatalError("Button does not support xib.")
}
//--------------------------------------------------
// MARK: - Setup
//--------------------------------------------------
public func initialSetup() {
if !initialSetupPerformed {
initialSetupPerformed = true
setupView()
}
}
//--------------------------------------------------
// MARK: - Methods
//--------------------------------------------------
public func addBlock( event: Event, _ buttonBlock: @escaping ButtonBlock) {
self.buttonBlock = buttonBlock
addTarget(self, action: #selector(callBlock(_:)), for: event)
}
func callBlock(_ sender: Button) {
buttonBlock?(self)
}
public func setWithActionMap(_ actionMap: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
self.actionMap = actionMap
buttonDelegate = delegateObject?.buttonDelegate
addBlock(event: .touchUpInside) { [weak self] sender in
guard let self = self else { return }
if self.buttonDelegate?.button?(self, shouldPerformActionWithMap: actionMap, additionalData: additionalData) ?? true {
MVMCoreActionHandler.shared()?.handleAction(with: actionMap, additionalData: additionalData, delegateObject: delegateObject)
}
}
}
}
// MARK: - MVMCoreUIMoleculeViewProtocol
extension Button: MVMCoreUIMoleculeViewProtocol {
public func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
self.json = json
guard let dictionary = json else { return }
if let backgroundColorString = dictionary[KeyBackgroundColor] as? String {
backgroundColor = UIColor.mfGet(forHex: backgroundColorString)
}
if let title = dictionary[KeyTitle] as? String {
setTitle(title, for: .normal)
}
}
public func reset() {
backgroundColor = .clear
}
}
// MARK: - MVMCoreViewProtocol
extension Button: MVMCoreViewProtocol {
public func updateView(_ size: CGFloat) {}
/// Will be called only once.
public func setupView() {
translatesAutoresizingMaskIntoConstraints = false
insetsLayoutMarginsFromSafeArea = false
titleLabel?.numberOfLines = 0
titleLabel?.lineBreakMode = .byWordWrapping
}
}
// MARK: AppleGuidelinesProtocol
extension Button: AppleGuidelinesProtocol {
override open func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return Self.acceptablyOutsideBounds(point: point, bounds: bounds)
}
}

View File

@ -10,7 +10,7 @@ import Foundation
@objcMembers public class StackPageTemplateModel: TemplateModelProtocol {
public static var identifier: String = "moleculeStack"
public static var identifier: String = "stack"
public var pageType: String

View File

@ -39,8 +39,6 @@ import UIKit
open override func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
super.setWithModel(model, delegateObject, additionalData)
// guard let headlineModel = model as? headlinebodyswitch
// headlineBody.setWithModel(mode, <#T##delegateObject: MVMCoreUIDelegateObject?##MVMCoreUIDelegateObject?#>, <#T##additionalData: [String : AnyHashable]?##[String : AnyHashable]?#>)
}
public static func estimatedHeight(forRow molecule: MoleculeProtocol?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -52,7 +50,7 @@ import UIKit
open override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData)
}
open class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {

View File

@ -37,8 +37,8 @@ import UIKit
// MARK: - MVMCoreUIMoleculeViewProtocol
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
headlineBodyTextButton.setWithJSON(json?.optionalDictionaryForKey("headlineBodyTextButton"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData)
headlineBodyTextButton.setWithJSON(json?.optionalDictionaryForKey("headlineBodyLink"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData)
}
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {

View File

@ -38,7 +38,7 @@ import UIKit
public override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("switch"), delegateObject: delegateObject, additionalData: additionalData)
mvmSwitch.setWithJSON(json?.optionalDictionaryForKey("toggle"), delegateObject: delegateObject, additionalData: additionalData)
}
public override class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {

View File

@ -37,7 +37,7 @@ public class StandardHeaderView: MoleculeContainer {
// MARK: - MVMCoreUIMoleculeViewProtocol
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
if let separatorJSON = json?.optionalDictionaryForKey("separator") {
if let separatorJSON = json?.optionalDictionaryForKey("line") {
line?.setWithJSON(separatorJSON, delegateObject: delegateObject, additionalData: additionalData)
}
}

View File

@ -66,7 +66,7 @@ import UIKit
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
headlineBody.setWithJSON(json?.optionalDictionaryForKey("headlineBody"), delegateObject: delegateObject, additionalData: additionalData)
textButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData)
textButton.setWithJSON(json?.optionalDictionaryForKey("link"), delegateObject: delegateObject, additionalData: additionalData)
}
open override func reset() {

View File

@ -9,7 +9,7 @@
import Foundation
@objcMembers public class MoleculeStackModel: ContainerModel, MoleculeProtocol {
public static var identifier: String = "moleculeStack"
public static var identifier: String = "stack"
public var backgroundColor: Color?
public var molecules: [StackItemModel]
public var axis: NSLayoutConstraint.Axis = .vertical

View File

@ -29,9 +29,9 @@
@"label": Label.class,
@"line": Line.class,
@"button": PrimaryButton.class,
@"textButton": MFTextButton.class,
@"link": MFTextButton.class,
@"header": StandardHeaderView.class,
@"moleculeStack": MoleculeStackView.class,
@"stack": MoleculeStackView.class,
@"twoButtonView": TwoButtonView.class,
@"footer": StandardFooterView.class,
@"caretView": CaretView.class,
@ -44,7 +44,7 @@
@"itemDropdownEntryField": ItemDropdownEntryField.class,
@"dateDropdownEntryField": DateDropdownEntryField.class,
@"checkbox": Checkbox.class,
@"checkboxWithLabel": CheckboxWithLabelView.class,
@"checkboxLabel": CheckboxWithLabelView.class,
@"cornerLabels" : CornerLabels.class,
@"progressbar": ProgressBar.class,
@"circleProgress": GraphView.class,
@ -53,7 +53,7 @@
@"radioButtonLabel": RadioButtonLabel.class,
@"listItem": MoleculeTableViewCell.class,
@"accordionListItem": AccordionMoleculeTableViewCell.class,
@"switch": MVMCoreUISwitch.class,
@"toggle": MVMCoreUISwitch.class,
@"leftRightLabelView": LeftRightLabelView.class,
@"actionDetailWithImage": ActionDetailWithImage.class,
@"image": MFLoadImageView.class,
@ -64,10 +64,10 @@
@"barsPager": MVMCoreUIPageControl.class,
@"scroller": Scroller.class,
@"imageHeadlineBody": ImageHeadlineBody.class,
@"labelSwitch": LabelSwitch.class,
@"headlineBodySwitch": HeadlineBodySwitch.class,
@"headlineBodyTextButton": HeadlineBodyTextButton.class,
@"headlineBodyTextButtonSwitch": HeadlineBodyTextButtonSwitch.class,
@"labelToggle": LabelSwitch.class,
@"headlineBodyToggle": HeadlineBodySwitch.class,
@"headlineBodyLink": HeadlineBodyTextButton.class,
@"headlineBodyLinkToggle": HeadlineBodyTextButtonSwitch.class,
@"tabsListItem": TabsTableViewCell.class,
@"dropDownListItem": DropDownFilterTableViewCell.class,
@"headlineBodyButton": HeadlineBodyButton.class,

View File

@ -19,9 +19,9 @@
static NSMutableDictionary *viewControllerMapping;
dispatch_once(&onceToken, ^{
viewControllerMapping = [@{
@"moleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]],
@"stack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]],
@"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]],
@"moleculeList" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]],
@"list" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]],
@"threeLayer" :
[[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[ThreeLayerTemplate class]]
} mutableCopy];