generally functioning. some loose ends with TextField.

This commit is contained in:
Kevin G Christiano 2019-10-16 13:51:55 -04:00
parent d0cb4a987e
commit 19310bff89
5 changed files with 68 additions and 65 deletions

View File

@ -12,7 +12,7 @@ import UIKit
@objc optional func textFieldDidDelete(_ textField: UITextField?) @objc optional func textFieldDidDelete(_ textField: UITextField?)
} }
class DigitTextBox: UITextField, MVMCoreViewProtocol { @objcMembers open class DigitTextBox: UITextField, MVMCoreViewProtocol {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------
@ -38,7 +38,7 @@ class DigitTextBox: UITextField, MVMCoreViewProtocol {
// MARK: - Initializers // MARK: - Initializers
//-------------------------------------------------- //--------------------------------------------------
required init?(coder: NSCoder) { required public init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
@ -58,7 +58,7 @@ class DigitTextBox: UITextField, MVMCoreViewProtocol {
func setup() { func setup() {
if constraints.count == 0 { guard constraints.isEmpty else { return }
translatesAutoresizingMaskIntoConstraints = false translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .white backgroundColor = .white
@ -78,13 +78,12 @@ class DigitTextBox: UITextField, MVMCoreViewProtocol {
updateView(MVMCoreUISplitViewController.getDetailViewWidth()) updateView(MVMCoreUISplitViewController.getDetailViewWidth())
} }
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Methods // MARK: - Methods
//-------------------------------------------------- //--------------------------------------------------
override func deleteBackward() { override open func deleteBackward() {
super.deleteBackward() super.deleteBackward()
if let delegate = mfTextBoxDelegate { if let delegate = mfTextBoxDelegate {
@ -92,7 +91,7 @@ class DigitTextBox: UITextField, MVMCoreViewProtocol {
} }
} }
func updateView(_ size: CGFloat) { public func updateView(_ size: CGFloat) {
DispatchQueue.main.async { DispatchQueue.main.async {
if !MVMCoreGetterUtility.fequal(a: Float(size), b: Float(self.previousSize)) { if !MVMCoreGetterUtility.fequal(a: Float(size), b: Float(self.previousSize)) {

View File

@ -8,7 +8,7 @@
import UIKit import UIKit
class DigitTextField: TextField, UITextFieldDelegate, MFDigitTextBoxDelegate { @objcMembers open class DigitTextField: TextField, UITextFieldDelegate, MFDigitTextBoxDelegate {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Outlets // MARK: - Outlets
//-------------------------------------------------- //--------------------------------------------------

View File

@ -12,7 +12,7 @@ import UIKit
import MVMCore import MVMCore
@objcMembers class MdnTextField: TextField, UITextFieldDelegate, ABPeoplePickerNavigationControllerDelegate, CNContactPickerDelegate { @objcMembers open class MdnTextField: TextField, UITextFieldDelegate, ABPeoplePickerNavigationControllerDelegate, CNContactPickerDelegate {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Properties // MARK: - Properties
//-------------------------------------------------- //--------------------------------------------------
@ -25,7 +25,7 @@ import MVMCore
// MARK: - Initializers // MARK: - Initializers
//-------------------------------------------------- //--------------------------------------------------
public override init(frame: CGRect) { open override init(frame: CGRect) {
super.init(frame: .zero) super.init(frame: .zero)
setup() setup()
} }
@ -249,5 +249,4 @@ import MVMCore
return true return true
} }
} }

View File

@ -226,6 +226,7 @@ import UIKit
// MARK: - Lifecycle // MARK: - Lifecycle
//-------------------------------------------------- //--------------------------------------------------
/// Initial configuration of class and view.
override open func setupView() { override open func setupView() {
guard subviews.isEmpty else { return } guard subviews.isEmpty else { return }
@ -241,6 +242,8 @@ import UIKit
formLabel.textColor = UIColor.mfBattleshipGrey() formLabel.textColor = UIColor.mfBattleshipGrey()
formLabel.setContentHuggingPriority(UILayoutPriority(251), for: .horizontal) formLabel.setContentHuggingPriority(UILayoutPriority(251), for: .horizontal)
formLabel.setContentHuggingPriority(UILayoutPriority(251), for: .vertical) formLabel.setContentHuggingPriority(UILayoutPriority(251), for: .vertical)
formLabel.setContentCompressionResistancePriority(.required, for: .vertical)
formLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true
addSubview(formLabel) addSubview(formLabel)
@ -282,6 +285,7 @@ import UIKit
layoutMarginsGuide.bottomAnchor.constraint(equalTo: placeholderErrorLabel.bottomAnchor).isActive = true layoutMarginsGuide.bottomAnchor.constraint(equalTo: placeholderErrorLabel.bottomAnchor).isActive = true
} }
/// Configuration logic for the text container view.
private func constrainContent(_ parentView: UIView) { private func constrainContent(_ parentView: UIView) {
let backgroundView = UIView(frame: .zero) let backgroundView = UIView(frame: .zero)
@ -299,7 +303,8 @@ import UIKit
let textField = UITextField(frame: .zero) let textField = UITextField(frame: .zero)
self.textField = textField self.textField = textField
textField.translatesAutoresizingMaskIntoConstraints = false textField.translatesAutoresizingMaskIntoConstraints = false
textField.setContentHuggingPriority(.required, for: .vertical) textField.setContentCompressionResistancePriority(.required, for: .vertical)
textField.heightAnchor.constraint(equalToConstant: 24).isActive = true
textField.font = MFStyler.fontForTextField() textField.font = MFStyler.fontForTextField()
textField.smartQuotesType = .no textField.smartQuotesType = .no
textField.smartDashesType = .no textField.smartDashesType = .no
@ -311,7 +316,7 @@ import UIKit
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
textField.topAnchor.constraint(equalTo: parentView.topAnchor, constant: 10), textField.topAnchor.constraint(equalTo: parentView.topAnchor, constant: 10),
textField.leadingAnchor.constraint(equalTo: parentView.leadingAnchor, constant: 16), textField.leadingAnchor.constraint(equalTo: parentView.leadingAnchor, constant: 16),
parentView.trailingAnchor.constraint(equalTo: textField.trailingAnchor, constant: 10)]) parentView.bottomAnchor.constraint(equalTo: textField.bottomAnchor, constant: 10)])
let dropDownCarrotLabel = Label() let dropDownCarrotLabel = Label()
self.dropDownCarrotLabel = dropDownCarrotLabel self.dropDownCarrotLabel = dropDownCarrotLabel
@ -325,8 +330,8 @@ import UIKit
addSubview(dropDownCarrotLabel) addSubview(dropDownCarrotLabel)
textField.topAnchor.constraint(equalTo: parentView.topAnchor, constant: 10).isActive = true dropDownCarrotLabel.topAnchor.constraint(equalTo: parentView.topAnchor).isActive = true
textField.leadingAnchor.constraint(equalTo: textField.leadingAnchor, constant: 6).isActive = true dropDownCarrotLabel.leadingAnchor.constraint(equalTo: textField.trailingAnchor, constant: 6).isActive = true
parentView.trailingAnchor.constraint(equalTo: dropDownCarrotLabel.trailingAnchor, constant: 16).isActive = true parentView.trailingAnchor.constraint(equalTo: dropDownCarrotLabel.trailingAnchor, constant: 16).isActive = true
parentView.bottomAnchor.constraint(equalTo: dropDownCarrotLabel.bottomAnchor).isActive = true parentView.bottomAnchor.constraint(equalTo: dropDownCarrotLabel.bottomAnchor).isActive = true
dropDownCarrotWidth = dropDownCarrotLabel.widthAnchor.constraint(equalToConstant: 0) dropDownCarrotWidth = dropDownCarrotLabel.widthAnchor.constraint(equalToConstant: 0)
@ -346,6 +351,7 @@ import UIKit
parentView.bottomAnchor.constraint(equalTo: separatorView.bottomAnchor).isActive = true parentView.bottomAnchor.constraint(equalTo: separatorView.bottomAnchor).isActive = true
let dashLine = DashLine() let dashLine = DashLine()
dashLine.translatesAutoresizingMaskIntoConstraints = false
dashLine.backgroundColor = .white dashLine.backgroundColor = .white
dashLine.isHidden = true dashLine.isHidden = true
@ -355,8 +361,7 @@ import UIKit
dashLine.centerYAnchor.constraint(equalTo: separatorView.centerYAnchor), dashLine.centerYAnchor.constraint(equalTo: separatorView.centerYAnchor),
dashLine.centerXAnchor.constraint(equalTo: separatorView.centerXAnchor), dashLine.centerXAnchor.constraint(equalTo: separatorView.centerXAnchor),
dashLine.topAnchor.constraint(equalTo: separatorView.topAnchor), dashLine.topAnchor.constraint(equalTo: separatorView.topAnchor),
dashLine.leadingAnchor.constraint(equalTo: separatorView.leadingAnchor), dashLine.leadingAnchor.constraint(equalTo: separatorView.leadingAnchor)])
separatorView.bottomAnchor.constraint(equalTo: dashLine.bottomAnchor)])
} }
open override func updateView(_ size: CGFloat) { open override func updateView(_ size: CGFloat) {
@ -706,7 +711,7 @@ extension TextField {
setWithMap(json) setWithMap(json)
if let formValidationProtocol = delegateObject.formValidationProtocol { if let formValidationProtocol = delegateObject.formValidationProtocol {
mfTextFieldDelegate = FormValidator.getFormValidatorFor(delegate: formValidationProtocol) as? TextFieldDelegate mfTextFieldDelegate = FormValidator.getFormValidatorFor(delegate: formValidationProtocol)
} }
uiTextFieldDelegate = delegateObject.uiTextFieldDelegate uiTextFieldDelegate = delegateObject.uiTextFieldDelegate

View File

@ -31,7 +31,6 @@ open class DashLine: MFView {
required public init?(coder: NSCoder) { required public init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
fatalError("init(coder:) has not been implemented")
} }
//------------------------------------------------------ //------------------------------------------------------
@ -39,6 +38,7 @@ open class DashLine: MFView {
//------------------------------------------------------ //------------------------------------------------------
@objc override open func updateView(_ size: CGFloat) { @objc override open func updateView(_ size: CGFloat) {
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
self?.setNeedsDisplay() self?.setNeedsDisplay()
} }