latest changes for entry.
This commit is contained in:
parent
ce0ffeda29
commit
df1a2a0da0
@ -25,7 +25,7 @@
|
|||||||
01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
|
01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; };
|
0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; };
|
||||||
0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; };
|
0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; };
|
||||||
0A21DB7F235DECC500C160A2 /* FormEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A21DB7E235DECC500C160A2 /* FormEntryField.swift */; };
|
0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A21DB7E235DECC500C160A2 /* EntryField.swift */; };
|
||||||
0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */; };
|
0A21DB83235DFBC500C160A2 /* MdnEntryField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */; };
|
||||||
0A21DB84235E06EF00C160A2 /* MFTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24C21E6A177003B2FB9 /* MFTextField.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
0A21DB84235E06EF00C160A2 /* MFTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24C21E6A177003B2FB9 /* MFTextField.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF24221E6A176003B2FB9 /* MFTextField.m */; };
|
0A21DB85235E06EF00C160A2 /* MFTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF24221E6A176003B2FB9 /* MFTextField.m */; };
|
||||||
@ -225,7 +225,7 @@
|
|||||||
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.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>"; };
|
01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = "<group>"; };
|
||||||
0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = "<group>"; };
|
0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = "<group>"; };
|
||||||
0A21DB7E235DECC500C160A2 /* FormEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormEntryField.swift; sourceTree = "<group>"; };
|
0A21DB7E235DECC500C160A2 /* EntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntryField.swift; sourceTree = "<group>"; };
|
||||||
0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MdnEntryField.swift; sourceTree = "<group>"; };
|
0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MdnEntryField.swift; sourceTree = "<group>"; };
|
||||||
0A21DB93235E24ED00C160A2 /* DigitEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitEntryField.swift; sourceTree = "<group>"; };
|
0A21DB93235E24ED00C160A2 /* DigitEntryField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DigitEntryField.swift; sourceTree = "<group>"; };
|
||||||
0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = "<group>"; };
|
0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = "<group>"; };
|
||||||
@ -783,7 +783,7 @@
|
|||||||
D29DF24A21E6A177003B2FB9 /* MFDigitTextField.xib */,
|
D29DF24A21E6A177003B2FB9 /* MFDigitTextField.xib */,
|
||||||
0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */,
|
0A41BA7E23453A6400D4C0BC /* TextEntryField.swift */,
|
||||||
0A8321AE2355FE9500CB7F00 /* DigitBox.swift */,
|
0A8321AE2355FE9500CB7F00 /* DigitBox.swift */,
|
||||||
0A21DB7E235DECC500C160A2 /* FormEntryField.swift */,
|
0A21DB7E235DECC500C160A2 /* EntryField.swift */,
|
||||||
0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */,
|
0A21DB82235DFBC500C160A2 /* MdnEntryField.swift */,
|
||||||
0A21DB93235E24ED00C160A2 /* DigitEntryField.swift */,
|
0A21DB93235E24ED00C160A2 /* DigitEntryField.swift */,
|
||||||
0A6BF4712360C56C0028F841 /* DropdownEntryField.swift */,
|
0A6BF4712360C56C0028F841 /* DropdownEntryField.swift */,
|
||||||
@ -1078,7 +1078,7 @@
|
|||||||
D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */,
|
D29DF17C21E69E1F003B2FB9 /* MFTextButton.m in Sources */,
|
||||||
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
|
D29DF2C521E7BF57003B2FB9 /* MFTabBarSwipeAnimator.m in Sources */,
|
||||||
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
|
D29DF2B421E7B76D003B2FB9 /* MFLoadingSpinner.m in Sources */,
|
||||||
0A21DB7F235DECC500C160A2 /* FormEntryField.swift in Sources */,
|
0A21DB7F235DECC500C160A2 /* EntryField.swift in Sources */,
|
||||||
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */,
|
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */,
|
||||||
D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */,
|
D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */,
|
||||||
D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */,
|
D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */,
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import UIKit
|
|||||||
@objc optional func textFieldDidDelete(_ textField: UITextField?)
|
@objc optional func textFieldDidDelete(_ textField: UITextField?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class DigitBox: UITextField, MVMCoreViewProtocol {
|
@objcMembers open class DigitBox: UITextField, MVMCoreViewProtocol {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
@ -77,7 +78,6 @@ import UIKit
|
|||||||
backgroundColor = .white
|
backgroundColor = .white
|
||||||
textAlignment = .center
|
textAlignment = .center
|
||||||
keyboardType = .numberPad
|
keyboardType = .numberPad
|
||||||
// layer.borderWidth = 1
|
|
||||||
showErrorState(false)
|
showErrorState(false)
|
||||||
|
|
||||||
widthConstraint = widthAnchor.constraint(equalToConstant: 39)
|
widthConstraint = widthAnchor.constraint(equalToConstant: 39)
|
||||||
@ -157,8 +157,8 @@ import UIKit
|
|||||||
})
|
})
|
||||||
|
|
||||||
sizeObject?.performBlockBase(onSize: size)
|
sizeObject?.performBlockBase(onSize: size)
|
||||||
// self.widthConstraint?.constant = digitWidth
|
self.widthConstraint?.constant = digitWidth
|
||||||
// self.heightConstraint?.constant = digitHeight
|
self.heightConstraint?.constant = digitHeight
|
||||||
self.previousSize = size
|
self.previousSize = size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,16 +9,9 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of TextEntryField due to the conveniences provided.
|
* Subclass of TextEntryField as it is to use similar logic as a singular textField but appear separate..
|
||||||
*/
|
*/
|
||||||
@objcMembers open class DigitEntryField: TextEntryField, DigitBoxDelegate {
|
@objcMembers open class DigitEntryField: TextEntryField, DigitBoxDelegate {
|
||||||
//--------------------------------------------------
|
|
||||||
// MARK: - Outlets
|
|
||||||
//--------------------------------------------------
|
|
||||||
|
|
||||||
/// UI Container of digitFields
|
|
||||||
public private(set) var digitFieldsStack: UIStackView?
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -122,8 +115,8 @@ import UIKit
|
|||||||
digitFields.forEach {
|
digitFields.forEach {
|
||||||
$0.borderStrokeColor = .mfPumpkin()
|
$0.borderStrokeColor = .mfPumpkin()
|
||||||
$0.bottomBar.backgroundColor = UIColor.mfPumpkin().cgColor
|
$0.bottomBar.backgroundColor = UIColor.mfPumpkin().cgColor
|
||||||
|
$0.showErrorState(true)
|
||||||
}
|
}
|
||||||
self.digitFields.forEach { $0.showErrorState(true) }
|
|
||||||
case .lock:
|
case .lock:
|
||||||
digitFields.forEach {
|
digitFields.forEach {
|
||||||
$0.isUserInteractionEnabled = false
|
$0.isUserInteractionEnabled = false
|
||||||
@ -150,7 +143,6 @@ import UIKit
|
|||||||
|
|
||||||
public override init(frame: CGRect) {
|
public override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
setup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init() {
|
public convenience init() {
|
||||||
@ -161,14 +153,11 @@ import UIKit
|
|||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
|
|
||||||
self.numberOfDigits = numberOfDigits
|
self.numberOfDigits = numberOfDigits
|
||||||
setup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(numberOfDigits: Int, bothDelegates delegate: (UITextFieldDelegate & TextFieldDelegate)?, size: CGFloat? = nil) {
|
public init(numberOfDigits: Int, bothDelegates delegate: (UITextFieldDelegate & TextFieldDelegate)?, size: CGFloat? = nil) {
|
||||||
super.init(bothDelegates: delegate)
|
|
||||||
|
|
||||||
self.numberOfDigits = numberOfDigits
|
self.numberOfDigits = numberOfDigits
|
||||||
setup()
|
super.init(bothDelegates: delegate)
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init?(coder: NSCoder) {
|
required public init?(coder: NSCoder) {
|
||||||
@ -180,7 +169,9 @@ import UIKit
|
|||||||
// MARK: - Setup
|
// MARK: - Setup
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open func setup() {
|
public override func setupFieldContainerContent(_ container: UIView) {
|
||||||
|
|
||||||
|
// textField.removeFromSuperview()
|
||||||
|
|
||||||
alignCenterHorizontal()
|
alignCenterHorizontal()
|
||||||
isAccessibilityElement = false
|
isAccessibilityElement = false
|
||||||
@ -188,14 +179,8 @@ import UIKit
|
|||||||
bottomBar.backgroundColor = UIColor.clear.cgColor
|
bottomBar.backgroundColor = UIColor.clear.cgColor
|
||||||
bottomBar.frame = CGRect(x: 0, y: fieldContainer.bounds.height, width: 0, height: 0)
|
bottomBar.frame = CGRect(x: 0, y: fieldContainer.bounds.height, width: 0, height: 0)
|
||||||
setupDigitFieldsView(size: MVMCoreUISplitViewController.getDetailViewWidth())
|
setupDigitFieldsView(size: MVMCoreUISplitViewController.getDetailViewWidth())
|
||||||
}
|
|
||||||
|
|
||||||
open override func setupFieldContainerContent(_ container: UIView) {
|
|
||||||
|
|
||||||
// Will not be using textField.
|
|
||||||
// TODO: May subclass from FormEntry if minimal overriding.
|
|
||||||
textField.removeFromSuperview()
|
textField.removeFromSuperview()
|
||||||
setupDigitFieldsView(size: MVMCoreUIUtility.getWidth())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createDigitField() -> DigitBox {
|
private func createDigitField() -> DigitBox {
|
||||||
@ -209,16 +194,8 @@ import UIKit
|
|||||||
|
|
||||||
func setupDigitFieldsView(size: CGFloat) {
|
func setupDigitFieldsView(size: CGFloat) {
|
||||||
|
|
||||||
self.digitFieldsStack?.subviews.forEach { $0.removeFromSuperview() }
|
|
||||||
digitFieldsStack?.removeFromSuperview()
|
|
||||||
|
|
||||||
var accessibleElements: [Any] = [titleLabel]
|
var accessibleElements: [Any] = [titleLabel]
|
||||||
|
|
||||||
// Remove all current views in UI.
|
|
||||||
if let stackViews = digitFieldsStack?.subviews, !stackViews.isEmpty {
|
|
||||||
stackViews.forEach { $0.removeFromSuperview() }
|
|
||||||
}
|
|
||||||
|
|
||||||
if numberOfDigits > 0 {
|
if numberOfDigits > 0 {
|
||||||
let digitFields = [DigitBox](repeating: createDigitField(), count: numberOfDigits)
|
let digitFields = [DigitBox](repeating: createDigitField(), count: numberOfDigits)
|
||||||
self.digitFields = digitFields
|
self.digitFields = digitFields
|
||||||
@ -227,25 +204,22 @@ import UIKit
|
|||||||
var prevBox: DigitBox?
|
var prevBox: DigitBox?
|
||||||
|
|
||||||
for (index, box) in digitFields.enumerated() {
|
for (index, box) in digitFields.enumerated() {
|
||||||
// $0.updateView(size)
|
|
||||||
accessibleElements.append(box)
|
accessibleElements.append(box)
|
||||||
fieldContainer.addSubview(box)
|
fieldContainer.addSubview(box)
|
||||||
|
|
||||||
box.widthAnchor.constraint(equalToConstant: 39).isActive = true
|
|
||||||
box.heightAnchor.constraint(equalToConstant: 44).isActive = true
|
|
||||||
|
|
||||||
box.topAnchor.constraint(equalTo: fieldContainer.topAnchor).isActive = true
|
box.topAnchor.constraint(equalTo: fieldContainer.topAnchor).isActive = true
|
||||||
fieldContainer.bottomAnchor.constraint(equalTo: box.bottomAnchor).isActive = true
|
fieldContainer.bottomAnchor.constraint(equalTo: box.bottomAnchor).isActive = true
|
||||||
|
box.centerYAnchor.constraint(equalTo: fieldContainer.centerYAnchor).isActive = true
|
||||||
|
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
box.leadingAnchor.constraint(equalTo: fieldContainer.leadingAnchor).isActive = true
|
box.leadingAnchor.constraint(equalTo: fieldContainer.leadingAnchor).isActive = true
|
||||||
|
|
||||||
} else if index == digitFields.count - 1 {
|
} else if index == digitFields.count - 1 {
|
||||||
|
|
||||||
box.leadingAnchor.constraint(equalTo: prevBox!.trailingAnchor, constant: space).isActive = true
|
box.leadingAnchor.constraint(equalTo: prevBox!.trailingAnchor, constant: space).isActive = true
|
||||||
fieldContainer.trailingAnchor.constraint(greaterThanOrEqualTo: box.trailingAnchor).isActive = true
|
fieldContainer.trailingAnchor.constraint(greaterThanOrEqualTo: box.trailingAnchor).isActive = true
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
box.leadingAnchor.constraint(equalTo: prevBox!.trailingAnchor).isActive = true
|
box.leadingAnchor.constraint(equalTo: prevBox!.trailingAnchor, constant: space).isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
prevBox = box
|
prevBox = box
|
||||||
@ -269,7 +243,6 @@ import UIKit
|
|||||||
|
|
||||||
if !self.digitFields.isEmpty {
|
if !self.digitFields.isEmpty {
|
||||||
|
|
||||||
self.digitFieldsStack?.subviews.forEach { $0.removeFromSuperview() }
|
|
||||||
self.digitFields.forEach { $0.updateView(size) }
|
self.digitFields.forEach { $0.updateView(size) }
|
||||||
self.layoutIfNeeded()
|
self.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,6 @@ import UIKit
|
|||||||
|
|
||||||
public override init(frame: CGRect) {
|
public override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
setup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init() {
|
public convenience init() {
|
||||||
@ -64,7 +63,6 @@ import UIKit
|
|||||||
public override init(bothDelegates: (UITextFieldDelegate & TextFieldDelegate)?) {
|
public override init(bothDelegates: (UITextFieldDelegate & TextFieldDelegate)?) {
|
||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
|
|
||||||
setup()
|
|
||||||
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: bothDelegates)
|
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: bothDelegates)
|
||||||
setBothTextDelegates(to: bothDelegates)
|
setBothTextDelegates(to: bothDelegates)
|
||||||
}
|
}
|
||||||
@ -78,17 +76,7 @@ import UIKit
|
|||||||
// MARK: - Setup
|
// MARK: - Setup
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private func setup() {
|
public override func setupFieldContainerContent(_ container: UIView) {
|
||||||
|
|
||||||
let tapOnCaret = UITapGestureRecognizer(target: self, action: #selector(startEditing))
|
|
||||||
dropDownCaretView.addGestureRecognizer(tapOnCaret)
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
|
||||||
// MARK: - Lifecycle
|
|
||||||
//--------------------------------------------------
|
|
||||||
|
|
||||||
open override func setupFieldContainerContent(_ container: UIView) {
|
|
||||||
super.setupFieldContainerContent(container)
|
super.setupFieldContainerContent(container)
|
||||||
|
|
||||||
container.addSubview(dropDownCaretView)
|
container.addSubview(dropDownCaretView)
|
||||||
@ -101,6 +89,9 @@ import UIKit
|
|||||||
container.bottomAnchor.constraint(greaterThanOrEqualTo: dropDownCaretView.bottomAnchor, constant: 13).isActive = true
|
container.bottomAnchor.constraint(greaterThanOrEqualTo: dropDownCaretView.bottomAnchor, constant: 13).isActive = true
|
||||||
|
|
||||||
dropDownCaretView.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true
|
dropDownCaretView.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true
|
||||||
|
|
||||||
|
let caretTap = UITapGestureRecognizer(target: self, action: #selector(startEditing))
|
||||||
|
dropDownCaretView.addGestureRecognizer(caretTap)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -206,9 +197,7 @@ extension DropdownEntryField {
|
|||||||
override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
|
|
||||||
guard let dictionary = json,
|
guard let dictionary = json, !dictionary.isEmpty else { return }
|
||||||
!dictionary.isEmpty
|
|
||||||
else { return }
|
|
||||||
|
|
||||||
if let _ = dictionary[KeyType] as? String {
|
if let _ = dictionary[KeyType] as? String {
|
||||||
dropDownCaretView.isHidden = false
|
dropDownCaretView.isHidden = false
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// FormEntryField.swift
|
// EntryField.swift
|
||||||
// MVMCoreUI
|
// MVMCoreUI
|
||||||
//
|
//
|
||||||
// Created by Kevin Christiano on 10/21/19.
|
// Created by Kevin Christiano on 10/21/19.
|
||||||
@ -14,7 +14,7 @@ import UIKit
|
|||||||
*
|
*
|
||||||
* When subclassing, be sure to override setupFieldContainerContent(). In this method you will setup all the content bound to the field container.
|
* When subclassing, be sure to override setupFieldContainerContent(). In this method you will setup all the content bound to the field container.
|
||||||
*/
|
*/
|
||||||
@objcMembers open class FormEntryField: ViewConstrainingView {
|
@objcMembers open class EntryField: ViewConstrainingView {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -22,20 +22,9 @@ import UIKit
|
|||||||
public private(set) var titleLabel: Label = {
|
public private(set) var titleLabel: Label = {
|
||||||
let label = Label()
|
let label = Label()
|
||||||
label.font = MFStyler.fontB3()
|
label.font = MFStyler.fontB3()
|
||||||
label.textColor = UIColor.mfBattleshipGrey()
|
label.textColor = .mfBattleshipGrey()
|
||||||
label.isAccessibilityElement = true
|
label.isAccessibilityElement = true
|
||||||
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
label.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
||||||
return label
|
|
||||||
}()
|
|
||||||
|
|
||||||
public private(set) var feedbackLabel: Label = {
|
|
||||||
let label = Label()
|
|
||||||
label.font = MFStyler.fontForTextFieldUnderLabel()
|
|
||||||
label.textColor = .black
|
|
||||||
label.isAccessibilityElement = true
|
|
||||||
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
|
||||||
label.setContentCompressionResistancePriority(.required, for: .horizontal)
|
|
||||||
return label
|
return label
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -46,6 +35,15 @@ import UIKit
|
|||||||
return view
|
return view
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
public private(set) var feedbackLabel: Label = {
|
||||||
|
let label = Label()
|
||||||
|
label.font = MFStyler.fontForTextFieldUnderLabel()
|
||||||
|
label.textColor = .black
|
||||||
|
label.isAccessibilityElement = true
|
||||||
|
label.setContentCompressionResistancePriority(.required, for: .vertical)
|
||||||
|
return label
|
||||||
|
}()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Delegate
|
// MARK: - Delegate
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -90,6 +88,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the text of titleLabel
|
||||||
public var title: String? {
|
public var title: String? {
|
||||||
get { return titleLabel.text }
|
get { return titleLabel.text }
|
||||||
set {
|
set {
|
||||||
@ -101,7 +100,7 @@ import UIKit
|
|||||||
/// Override this to conveniently get/set the textfield(s).
|
/// Override this to conveniently get/set the textfield(s).
|
||||||
public var text: String? {
|
public var text: String? {
|
||||||
get { return nil }
|
get { return nil }
|
||||||
set { fatalError("You need to override FormEntryField's 'text' variable in your subclass.") }
|
set { fatalError("You need to override EntryField's 'text' variable in your subclass.") }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets feedback text in the textField.
|
/// Sets feedback text in the textField.
|
||||||
@ -149,7 +148,6 @@ import UIKit
|
|||||||
/// This must be overriden by a subclass.
|
/// This must be overriden by a subclass.
|
||||||
public override init(frame: CGRect) {
|
public override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
setupView()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init() {
|
public convenience init() {
|
||||||
@ -158,13 +156,13 @@ import UIKit
|
|||||||
|
|
||||||
public init(title: String) {
|
public init(title: String) {
|
||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
setupView()
|
|
||||||
titleLabel.text = title
|
titleLabel.text = title
|
||||||
}
|
}
|
||||||
|
|
||||||
required public init?(coder: NSCoder) {
|
required public init?(coder: NSCoder) {
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
fatalError("FormEntryField does not support xib.")
|
fatalError("EntryField does not support xib.")
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -225,7 +223,7 @@ import UIKit
|
|||||||
super.updateView(size)
|
super.updateView(size)
|
||||||
|
|
||||||
titleLabel.updateView(size)
|
titleLabel.updateView(size)
|
||||||
feedbackLabel.font = MFStyler.fontForTextFieldUnderLabel()
|
feedbackLabel.updateView(size)
|
||||||
refreshBorderUI()
|
refreshBorderUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +248,7 @@ import UIKit
|
|||||||
let size: CGFloat = appearance == .error ? 4 : 1
|
let size: CGFloat = appearance == .error ? 4 : 1
|
||||||
bottomBar.frame = CGRect(x: 0, y: fieldContainer.bounds.height - size, width: fieldContainer.bounds.width, height: size)
|
bottomBar.frame = CGRect(x: 0, y: fieldContainer.bounds.height - size, width: fieldContainer.bounds.width, height: size)
|
||||||
|
|
||||||
self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated?(self)
|
delegateObject?.moleculeDelegate?.moleculeLayoutUpdated?(self)
|
||||||
setNeedsDisplay()
|
setNeedsDisplay()
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
}
|
}
|
||||||
@ -353,21 +351,19 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Molecular
|
// MARK: - Molecular
|
||||||
extension FormEntryField {
|
extension EntryField {
|
||||||
|
|
||||||
override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||||
self.delegateObject = delegateObject
|
self.delegateObject = delegateObject
|
||||||
|
|
||||||
guard let dictionary = json,
|
guard let dictionary = json, !dictionary.isEmpty else { return }
|
||||||
!dictionary.isEmpty
|
|
||||||
else { return }
|
|
||||||
|
|
||||||
if let formText = dictionary[KeyLabel] as? String {
|
if let titleText = dictionary["title"] as? String {
|
||||||
title = formText
|
title = titleText
|
||||||
}
|
}
|
||||||
|
|
||||||
if let text = dictionary[KeyDisable] as? String, text.isEqual(StringY) || dictionary.boolForKey(KeyDisable) {
|
if let disable = dictionary[KeyDisable] as? String, disable.isEqual(StringY) || dictionary.boolForKey(KeyDisable) {
|
||||||
isEnabled = false
|
isEnabled = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +391,7 @@ extension FormEntryField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Form Validation
|
// MARK: - Form Validation
|
||||||
extension FormEntryField: FormValidationProtocol {
|
extension EntryField: FormValidationProtocol {
|
||||||
|
|
||||||
public func isValidField() -> Bool {
|
public func isValidField() -> Bool {
|
||||||
return isValid
|
return isValid
|
||||||
@ -411,7 +407,7 @@ extension FormEntryField: FormValidationProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Accessibility
|
// MARK: - Accessibility
|
||||||
extension FormEntryField {
|
extension EntryField {
|
||||||
|
|
||||||
@objc open func pushAccessibilityNotification() {
|
@objc open func pushAccessibilityNotification() {
|
||||||
// To Be Overriden
|
// To Be Overriden
|
||||||
@ -17,7 +17,7 @@ import MVMCore
|
|||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var isNationalMdn = true
|
public var isNationalMDN = true
|
||||||
public var shouldValidateMDN = false
|
public var shouldValidateMDN = false
|
||||||
|
|
||||||
private weak var outsiderTextDelegate: UITextFieldDelegate?
|
private weak var outsiderTextDelegate: UITextFieldDelegate?
|
||||||
@ -45,7 +45,6 @@ import MVMCore
|
|||||||
|
|
||||||
public override init(frame: CGRect) {
|
public override init(frame: CGRect) {
|
||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
setup()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public convenience init() {
|
public convenience init() {
|
||||||
@ -55,7 +54,6 @@ import MVMCore
|
|||||||
/// - parameter bothDelegates: Sets both MF/UI Text Field Delegates.
|
/// - parameter bothDelegates: Sets both MF/UI Text Field Delegates.
|
||||||
public override init(bothDelegates: (UITextFieldDelegate & TextFieldDelegate)?) {
|
public override init(bothDelegates: (UITextFieldDelegate & TextFieldDelegate)?) {
|
||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
setup()
|
|
||||||
setBothTextDelegates(to: bothDelegates)
|
setBothTextDelegates(to: bothDelegates)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +66,8 @@ import MVMCore
|
|||||||
// MARK: - Setup
|
// MARK: - Setup
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
private func setup() {
|
public override func setupFieldContainerContent(_ container: UIView) {
|
||||||
|
super.setupFieldContainerContent(container)
|
||||||
|
|
||||||
textField.keyboardType = .numberPad
|
textField.keyboardType = .numberPad
|
||||||
|
|
||||||
@ -86,11 +85,9 @@ import MVMCore
|
|||||||
|
|
||||||
public func hasValidMDN() -> Bool {
|
public func hasValidMDN() -> Bool {
|
||||||
|
|
||||||
guard let MDN = mdn,
|
guard let MDN = mdn, !MDN.isEmpty else { return true }
|
||||||
!MDN.isEmpty
|
|
||||||
else { return true }
|
|
||||||
|
|
||||||
if isNationalMdn {
|
if isNationalMDN {
|
||||||
return MVMCoreUIUtility.validateMDNString(MDN)
|
return MVMCoreUIUtility.validateMDNString(MDN)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +134,7 @@ import MVMCore
|
|||||||
var unformattedMDN = MVMCoreUIUtility.removeMdnFormat(MDN)
|
var unformattedMDN = MVMCoreUIUtility.removeMdnFormat(MDN)
|
||||||
|
|
||||||
// Sometimes user add extra 1 in front of mdn in their address book
|
// Sometimes user add extra 1 in front of mdn in their address book
|
||||||
if isNationalMdn,
|
if isNationalMDN,
|
||||||
let unformedMDN = unformattedMDN,
|
let unformedMDN = unformattedMDN,
|
||||||
unformedMDN.count == 11,
|
unformedMDN.count == 11,
|
||||||
unformedMDN[(unformedMDN.index(unformedMDN.startIndex, offsetBy: 0))] == "1" {
|
unformedMDN[(unformedMDN.index(unformedMDN.startIndex, offsetBy: 0))] == "1" {
|
||||||
@ -181,7 +178,7 @@ import MVMCore
|
|||||||
|
|
||||||
outsiderTextDelegate?.textFieldDidEndEditing?(textField)
|
outsiderTextDelegate?.textFieldDidEndEditing?(textField)
|
||||||
|
|
||||||
if validateAndColor() && isNationalMdn {
|
if validateAndColor() && isNationalMDN {
|
||||||
textField.text = MVMCoreUIUtility.formatMdn(textField.text)
|
textField.text = MVMCoreUIUtility.formatMdn(textField.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@objcMembers open class TextEntryField: FormEntryField, UITextFieldDelegate {
|
@objcMembers open class TextEntryField: EntryField, UITextFieldDelegate {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Outlets
|
// MARK: - Outlets
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -55,7 +55,7 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The text of this textField.
|
/// The text of this textField.
|
||||||
public override var text: String? {
|
public override var text: String? {
|
||||||
get { return textField.text }
|
get { return textField.text }
|
||||||
set {
|
set {
|
||||||
@ -173,20 +173,6 @@ import UIKit
|
|||||||
|
|
||||||
open func clearErrorState() {
|
open func clearErrorState() {
|
||||||
|
|
||||||
/*
|
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
|
||||||
self.separatorHeightConstraint.constant = 1;
|
|
||||||
self.separatorView.backgroundColor = [UIColor blackColor];
|
|
||||||
[self layoutIfNeeded];
|
|
||||||
self.errorShowing = NO;
|
|
||||||
self.label.textColor = [UIColor blackColor];
|
|
||||||
self.label.text = @"";
|
|
||||||
self.textField.accessibilityValue = nil;
|
|
||||||
[self setNeedsDisplay];
|
|
||||||
[self layoutIfNeeded];
|
|
||||||
}];
|
|
||||||
*/
|
|
||||||
|
|
||||||
textField.accessibilityValue = nil
|
textField.accessibilityValue = nil
|
||||||
updateUI(appearance: .original)
|
updateUI(appearance: .original)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -396,7 +396,6 @@ import MVMCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func updateView(_ size: CGFloat) {
|
public func updateView(_ size: CGFloat) {
|
||||||
|
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user