check property back to weak, remove unaided switch files which supposed replaced by mvmcoreuiswitch
This commit is contained in:
parent
ed7329cdcf
commit
d94bbc1dae
@ -44,10 +44,10 @@
|
||||
@property (nonatomic,getter=isEnabled) BOOL enabled;
|
||||
|
||||
// To set the placeholder and text
|
||||
@property (nullable, strong, nonatomic) NSString *text;
|
||||
@property (nullable, strong, nonatomic) NSString *formText;
|
||||
@property (nullable, strong, nonatomic) NSString *fieldKey;
|
||||
@property (nullable, strong, nonatomic) NSString *groupName;
|
||||
@property (nullable, weak, nonatomic) NSString *text;
|
||||
@property (nullable, weak, nonatomic) NSString *formText;
|
||||
@property (nullable, weak, nonatomic) NSString *fieldKey;
|
||||
@property (nullable, weak, nonatomic) NSString *groupName;
|
||||
|
||||
@property (nullable, weak, nonatomic) NSString *placeholder; // will move out in Feb release
|
||||
|
||||
|
||||
@ -1,95 +0,0 @@
|
||||
//
|
||||
// Switch.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Priya on 5/23/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers public class Switch: ViewConstrainingView, FormValidationFormFieldProtocol {
|
||||
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: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
isRequired = json?[KeyRequired] as? Bool ?? false
|
||||
self.delegateObject = delegateObject
|
||||
if let delegateObject = delegateObject {
|
||||
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 func formFieldGroupName() -> String? {
|
||||
return json?.optionalStringForKey("groupName")
|
||||
}
|
||||
|
||||
public override func needsToBeConstrained() -> Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
public override func alignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading
|
||||
}
|
||||
|
||||
public override static func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||
return MVMCoreUISwitch.getHeight()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,140 +0,0 @@
|
||||
//
|
||||
// SwitchLineItem.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Priya on 5/6/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers public class SwitchLineItem: ViewConstrainingView, FormValidationFormFieldProtocol {
|
||||
|
||||
|
||||
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: MVMCoreUIDelegateObject?, 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 alignment() -> UIStackView.Alignment {
|
||||
return UIStackView.Alignment.leading
|
||||
}
|
||||
|
||||
|
||||
public func isValidField() -> Bool {
|
||||
return mvmSwitch.isValidField()
|
||||
}
|
||||
|
||||
public func formFieldName() -> String? {
|
||||
return mvmSwitch.formFieldName()
|
||||
}
|
||||
|
||||
public func formFieldGroupName() -> String? {
|
||||
return mvmSwitch.formFieldGroupName()
|
||||
}
|
||||
|
||||
public func formFieldValue() -> Any? {
|
||||
return mvmSwitch.formFieldValue()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user