Merge branch 'develop' into feature/kevin
# Conflicts: # MVMCoreUI.xcodeproj/project.pbxproj
This commit is contained in:
commit
3b66bcfdc3
@ -10,9 +10,11 @@
|
||||
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; };
|
||||
0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; };
|
||||
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; };
|
||||
016A1071228122180009D605 /* SwitchLineItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 016A1070228122180009D605 /* SwitchLineItem.swift */; };
|
||||
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; };
|
||||
0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; };
|
||||
01CA51B5229716F60071A6EE /* Switch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01CA51B4229716F60071A6EE /* Switch.swift */; };
|
||||
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; };
|
||||
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; };
|
||||
01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -171,9 +173,11 @@
|
||||
0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = "<group>"; };
|
||||
0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = "<group>"; };
|
||||
0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = "<group>"; };
|
||||
016A1070228122180009D605 /* SwitchLineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwitchLineItem.swift; sourceTree = "<group>"; };
|
||||
0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = "<group>"; };
|
||||
0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = "<group>"; };
|
||||
0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = "<group>"; };
|
||||
01CA51B4229716F60071A6EE /* Switch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Switch.swift; sourceTree = "<group>"; };
|
||||
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = "<group>"; };
|
||||
01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = "<group>"; };
|
||||
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = "<group>"; };
|
||||
@ -444,6 +448,8 @@
|
||||
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */,
|
||||
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */,
|
||||
D282AACA2243C61700C46919 /* ButtonView.swift */,
|
||||
016A1070228122180009D605 /* SwitchLineItem.swift */,
|
||||
01CA51B4229716F60071A6EE /* Switch.swift */,
|
||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */,
|
||||
D2A514662213885800345BFB /* StandardHeaderView.swift */,
|
||||
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */,
|
||||
@ -920,6 +926,7 @@
|
||||
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
||||
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
|
||||
D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */,
|
||||
016A1071228122180009D605 /* SwitchLineItem.swift in Sources */,
|
||||
D29DF29521E7ADB8003B2FB9 /* ProgrammaticScrollViewController.m in Sources */,
|
||||
D29DF16121E69996003B2FB9 /* MFViewController.m in Sources */,
|
||||
D2E1FAE12268E81D00AEFD8C /* MoleculeListTemplate.swift in Sources */,
|
||||
@ -940,6 +947,7 @@
|
||||
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
|
||||
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
|
||||
DBC4391B224421A0001AB423 /* CaretButton.swift in Sources */,
|
||||
01CA51B5229716F60071A6EE /* Switch.swift in Sources */,
|
||||
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */,
|
||||
D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */,
|
||||
D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */,
|
||||
|
||||
87
MVMCoreUI/Molecules/Switch.swift
Normal file
87
MVMCoreUI/Molecules/Switch.swift
Normal file
@ -0,0 +1,87 @@
|
||||
//
|
||||
// Switch.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Priya on 5/23/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers public class Switch: ViewConstrainingView, FormValidationProtocol{
|
||||
public var mvmSwitch = MVMCoreUISwitch()
|
||||
var isRequired = false
|
||||
var delegateObject: DelegateObject?
|
||||
|
||||
@objc func switchChanged() {
|
||||
let delegate = delegateObject as? MVMCoreUIDelegateObject
|
||||
if let delegate = delegate {
|
||||
let formValidator = delegate.formValidationProtocol?.formValidatorModel?()
|
||||
formValidator?.enableByValidation()
|
||||
}
|
||||
}
|
||||
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
mvmSwitch.addTarget(self, action: #selector(Switch.switchChanged), for: .valueChanged)
|
||||
self.clipsToBounds = true
|
||||
addSubview(mvmSwitch)
|
||||
mvmSwitch.translatesAutoresizingMaskIntoConstraints = false
|
||||
setupContainerConstraints()
|
||||
}
|
||||
|
||||
public override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
mvmSwitch.updateView(size)
|
||||
}
|
||||
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
isRequired = json?[KeyRequired] as? Bool ?? false
|
||||
self.delegateObject = delegateObject
|
||||
if let delegateObject = delegateObject as? MVMCoreUIDelegateObject {
|
||||
FormValidator.setupValidation(molecule: self, delegate: delegateObject.formValidationProtocol)
|
||||
}
|
||||
if let onColorString = json?.optionalStringForKey("onTintColor") {
|
||||
mvmSwitch.onTintColor = .mfGet(forHex: onColorString)
|
||||
}
|
||||
if let offColorString = json?.optionalStringForKey("offTintColor") {
|
||||
mvmSwitch.offTintColor = .mfGet(forHex: offColorString)
|
||||
}
|
||||
if let onKnobColorString = json?.optionalStringForKey("onKnobTintColor") {
|
||||
mvmSwitch.onKnobTintColor = .mfGet(forHex: onKnobColorString)
|
||||
}
|
||||
if let offKnobColorString = json?.optionalStringForKey("offKnobTintColor") {
|
||||
mvmSwitch.offKnobTintColor = .mfGet(forHex: offKnobColorString)
|
||||
}
|
||||
mvmSwitch.setState(json?.optionalBoolForKey("state") ?? false, animated: true)
|
||||
}
|
||||
|
||||
func setupContainerConstraints() {
|
||||
mvmSwitch.topAnchor.constraint(equalTo: topAnchor).isActive = true
|
||||
mvmSwitch.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||
mvmSwitch.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
|
||||
mvmSwitch.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
|
||||
}
|
||||
|
||||
public func isValidField() -> Bool {
|
||||
return (isRequired == false) ? true : mvmSwitch.isOn
|
||||
}
|
||||
|
||||
public func formFieldName() -> String? {
|
||||
return json?.optionalStringForKey(KeyFieldKey)
|
||||
}
|
||||
|
||||
public func formFieldValue() -> Any? {
|
||||
return mvmSwitch.isOn
|
||||
}
|
||||
|
||||
public override func needsToBeConstrained() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
public override func moleculeAlignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading
|
||||
}
|
||||
}
|
||||
|
||||
121
MVMCoreUI/Molecules/SwitchLineItem.swift
Normal file
121
MVMCoreUI/Molecules/SwitchLineItem.swift
Normal file
@ -0,0 +1,121 @@
|
||||
//
|
||||
// SwitchLineItem.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Priya on 5/6/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers public class SwitchLineItem: ViewConstrainingView, FormValidationProtocol{
|
||||
public var mvmSwitch = Switch()
|
||||
public var label = Label()
|
||||
public var leftContainerView = UIView()
|
||||
public var mfTextButton = MFTextButton(nil, constrainHeight: true, forWidth: 0)
|
||||
var isRequired = false
|
||||
var delegateObject: DelegateObject?
|
||||
|
||||
@objc func switchChanged() {
|
||||
let delegate = delegateObject as? MVMCoreUIDelegateObject
|
||||
if let delegate = delegate {
|
||||
let formValidator = delegate.formValidationProtocol?.formValidatorModel?()
|
||||
formValidator?.enableByValidation()
|
||||
}
|
||||
}
|
||||
|
||||
open override func setupView() {
|
||||
super.setupView()
|
||||
leftContainerView.addSubview(label)
|
||||
leftContainerView.addSubview(mfTextButton)
|
||||
addSubview(leftContainerView)
|
||||
addSubview(mvmSwitch)
|
||||
|
||||
leftContainerView.translatesAutoresizingMaskIntoConstraints = false
|
||||
mvmSwitch.translatesAutoresizingMaskIntoConstraints = false
|
||||
mfTextButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
label.translatesAutoresizingMaskIntoConstraints = false
|
||||
setupContainerConstraints()
|
||||
}
|
||||
|
||||
public override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
label.updateView(size)
|
||||
mvmSwitch.updateView(size)
|
||||
mfTextButton.updateView(size)
|
||||
}
|
||||
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
mvmSwitch.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
label.setWithJSON(json?.optionalDictionaryForKey("label"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
mfTextButton.setWithJSON(json?.optionalDictionaryForKey("textButton"), delegateObject: delegateObject, additionalData: additionalData)
|
||||
if (label.text?.count ?? 0) <= 0 && (mfTextButton.titleLabel?.text?.count ?? 0) <= 0 {
|
||||
mvmSwitch.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0).isActive = true
|
||||
}
|
||||
}
|
||||
|
||||
func setupContainerConstraints() {
|
||||
leftContainerView.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||
|
||||
var constraint = leftContainerView.topAnchor.constraint(equalTo: topAnchor)
|
||||
constraint.priority = UILayoutPriority(249)
|
||||
constraint.isActive = true
|
||||
|
||||
mvmSwitch.topAnchor.constraint(greaterThanOrEqualTo: topAnchor).isActive = true
|
||||
|
||||
constraint = mvmSwitch.topAnchor.constraint(equalTo: topAnchor)
|
||||
constraint.priority = UILayoutPriority(249)
|
||||
constraint.isActive = true
|
||||
|
||||
trailingAnchor.constraint(equalTo: mvmSwitch.trailingAnchor).isActive = true
|
||||
|
||||
constraint = bottomAnchor.constraint(equalTo: mvmSwitch.bottomAnchor)
|
||||
constraint.priority = UILayoutPriority(249)
|
||||
constraint.isActive = true
|
||||
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: mvmSwitch.bottomAnchor).isActive = true
|
||||
|
||||
constraint = bottomAnchor.constraint(equalTo: leftContainerView.bottomAnchor)
|
||||
constraint.isActive = true
|
||||
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: leftContainerView.bottomAnchor).isActive = true
|
||||
leftContainerView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(leftContainerView, pinCenterX: false, pinCenterY: true)
|
||||
constraint = mvmSwitch.leadingAnchor.constraint(greaterThanOrEqualTo: leftContainerView.trailingAnchor)
|
||||
constraint.priority = UILayoutPriority(999)
|
||||
constraint.isActive = true
|
||||
NSLayoutConstraint.constraintPinSubview(mvmSwitch, pinCenterX: false, pinCenterY: true)
|
||||
|
||||
leftContainerView.topAnchor.constraint(equalTo: label.topAnchor).isActive = true
|
||||
leftContainerView.trailingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor).isActive = true
|
||||
|
||||
constraint = leftContainerView.trailingAnchor.constraint(equalTo: label.trailingAnchor)
|
||||
constraint.priority = UILayoutPriority(249)
|
||||
constraint.isActive = true
|
||||
|
||||
leftContainerView.trailingAnchor.constraint(greaterThanOrEqualTo: mfTextButton.trailingAnchor).isActive = true
|
||||
|
||||
constraint = leftContainerView.trailingAnchor.constraint(equalTo: mfTextButton.trailingAnchor)
|
||||
constraint.priority = UILayoutPriority(249)
|
||||
constraint.isActive = true
|
||||
|
||||
leftContainerView.bottomAnchor.constraint(equalTo: mfTextButton.bottomAnchor).isActive = true
|
||||
mfTextButton.leadingAnchor.constraint(equalTo: leftContainerView.leadingAnchor).isActive = true
|
||||
label.leadingAnchor.constraint(equalTo: leftContainerView.leadingAnchor).isActive = true
|
||||
mfTextButton.topAnchor.constraint(equalTo: label.bottomAnchor).isActive = true
|
||||
leftContainerView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
mvmSwitch.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
||||
}
|
||||
|
||||
public override func needsToBeConstrained() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
public override func moleculeAlignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,9 @@
|
||||
@"caretView": CaretView.class,
|
||||
@"caretButton": CaretButton.class,
|
||||
@"textField" : MFTextField.class,
|
||||
@"checkbox" : MVMCoreUICheckBox.class
|
||||
@"checkbox" : MVMCoreUICheckBox.class,
|
||||
@"switchLineItem" : SwitchLineItem.class,
|
||||
@"switch" : Switch.class
|
||||
} mutableCopy];
|
||||
});
|
||||
return mapping;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user