latest text.
This commit is contained in:
parent
e92616a7f5
commit
7e1d23db3d
@ -25,8 +25,8 @@
|
||||
0A8321A82355062F00CB7F00 /* MdnTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8321A72355062F00CB7F00 /* MdnTextField.swift */; };
|
||||
0A8321AF2355FE9500CB7F00 /* DigitTextBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8321AE2355FE9500CB7F00 /* DigitTextBox.swift */; };
|
||||
0A8321C523563D3500CB7F00 /* MFTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF24221E6A176003B2FB9 /* MFTextField.m */; };
|
||||
0A8321C623563D3800CB7F00 /* MFTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24C21E6A177003B2FB9 /* MFTextField.h */; };
|
||||
0A8321C723563D4000CB7F00 /* MFMdnTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */; };
|
||||
0A8321C623563D3800CB7F00 /* MFTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24C21E6A177003B2FB9 /* MFTextField.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0A8321C723563D4000CB7F00 /* MFMdnTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0A8321C823563D4300CB7F00 /* MFMdnTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF24921E6A177003B2FB9 /* MFMdnTextField.m */; };
|
||||
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; };
|
||||
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
|
||||
|
||||
@ -8,14 +8,130 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class DigitTextBox: UITextField {
|
||||
|
||||
/*
|
||||
// Only override draw() if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
override func draw(_ rect: CGRect) {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@objc protocol MFDigitTextBoxDelegate: NSObjectProtocol {
|
||||
@objc optional func textFieldDidDelete(_ textField: UITextField?)
|
||||
}
|
||||
|
||||
class DigitTextBox: UITextField, MVMCoreViewProtocol {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Outlets
|
||||
//--------------------------------------------------
|
||||
|
||||
private weak var bottomBar: SeparatorView?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
weak var mfTextBoxDelegate: MFDigitTextBoxDelegate?
|
||||
|
||||
private var previousSize: CGFloat = 0.0
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Constraints
|
||||
//--------------------------------------------------
|
||||
|
||||
private weak var widthConstraint: NSLayoutConstraint?
|
||||
private weak var heightConstraint: NSLayoutConstraint?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//--------------------------------------------------
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setup()
|
||||
}
|
||||
|
||||
public convenience init() {
|
||||
self.init(frame: .zero)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Lifecycle
|
||||
//--------------------------------------------------
|
||||
|
||||
func setup() {
|
||||
|
||||
if constraints.count == 0 {
|
||||
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
backgroundColor = .white
|
||||
textAlignment = .center
|
||||
keyboardType = .numberPad
|
||||
layer.borderWidth = 1
|
||||
hideError()
|
||||
|
||||
widthConstraint = widthAnchor.constraint(equalToConstant: 40)
|
||||
widthConstraint?.isActive = true
|
||||
|
||||
heightConstraint = heightAnchor.constraint(equalToConstant: 60)
|
||||
heightConstraint?.isActive = true
|
||||
|
||||
bottomBar = SeparatorView.separatorAdd(to: self, position: SeparatorPositionBot)
|
||||
bottomBar?.setAsMedium()
|
||||
|
||||
updateView(MVMCoreUISplitViewController.getDetailViewWidth())
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Methods
|
||||
//--------------------------------------------------
|
||||
|
||||
override func deleteBackward() {
|
||||
super.deleteBackward()
|
||||
|
||||
if let delegate = mfTextBoxDelegate {
|
||||
delegate.textFieldDidDelete?(self)
|
||||
}
|
||||
}
|
||||
|
||||
func updateView(_ size: CGFloat) {
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if !MVMCoreGetterUtility.fequal(a: Float(size), b: Float(self.previousSize)) {
|
||||
MFStyler.styleTextField(self)
|
||||
self.font = MFFonts.mfFont55Rg(28)
|
||||
|
||||
var digitWidth: CGFloat = 0
|
||||
var digitHeight: CGFloat = 0
|
||||
|
||||
let sizeObject = MFSizeObject(standardBlock: {
|
||||
digitWidth = 39
|
||||
digitHeight = 44
|
||||
|
||||
}, smalliPhone: {
|
||||
digitWidth = 35
|
||||
digitHeight = 38
|
||||
|
||||
}, standardiPadPortraitBlock: {
|
||||
digitWidth = 59
|
||||
digitHeight = 74
|
||||
})
|
||||
|
||||
sizeObject?.performBlockBase(onSize: size)
|
||||
self.widthConstraint?.constant = digitWidth
|
||||
self.heightConstraint?.constant = digitHeight
|
||||
self.previousSize = size
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setAsError() {
|
||||
|
||||
layer.borderColor = UIColor.mfPumpkin().cgColor
|
||||
bottomBar?.backgroundColor = UIColor.mfPumpkin()
|
||||
bottomBar?.height?.constant = 4
|
||||
}
|
||||
|
||||
func hideError() {
|
||||
layer.borderColor = UIColor.mfSilver().cgColor
|
||||
bottomBar?.setAsMedium()
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,6 +118,8 @@
|
||||
}];
|
||||
}
|
||||
|
||||
// CONTINUE
|
||||
|
||||
- (void)updateView:(CGFloat)size {
|
||||
[super updateView:size];
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
|
||||
@ -11,11 +11,11 @@ import UIKit
|
||||
|
||||
@objc public protocol TextFieldDelegate: NSObjectProtocol {
|
||||
/// Called when the entered text becomes valid based on the validation block
|
||||
@objc optional func entryIsValid(_ textfield: TextField?)
|
||||
@objc optional func isValid(_ textfield: TextField?)
|
||||
/// Called when the entered text becomes invalid based on the validation block
|
||||
@objc optional func entryIsInvalid(_ textfield: TextField?)
|
||||
@objc optional func isInvalid(_ textfield: TextField?)
|
||||
/// Dismisses the keyboard.
|
||||
@objc optional func dismissFieldInput(_ sender: Any?)
|
||||
@objc optional func dismissField(_ sender: Any?)
|
||||
}
|
||||
|
||||
@objcMembers open class TextField: ViewConstrainingView {
|
||||
@ -650,13 +650,13 @@ import UIKit
|
||||
}
|
||||
|
||||
if let mfTextFieldDelegate = mfTextFieldDelegate {
|
||||
mfTextFieldDelegate.entryIsInvalid?(self)
|
||||
mfTextFieldDelegate.isInvalid?(self)
|
||||
}
|
||||
} else if !previousValidity && isValid {
|
||||
hideError()
|
||||
|
||||
if let mfTextFieldDelegate = mfTextFieldDelegate {
|
||||
mfTextFieldDelegate.entryIsValid?(self)
|
||||
mfTextFieldDelegate.isValid?(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,3 +37,34 @@ import Foundation
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Temporary: Looking to either combine or separate entirely with MFTextFieldDelegate.
|
||||
extension FormValidator: TextFieldDelegate {
|
||||
|
||||
public func dismissField(_ sender: Any?) {
|
||||
|
||||
if let delegate = delegate as? MFTextFieldDelegate {
|
||||
delegate.dismissFieldInput?(sender)
|
||||
}
|
||||
}
|
||||
|
||||
@nonobjc public func isValid(_ textfield: MFTextField?) {
|
||||
|
||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||
self.enableByValidation()
|
||||
if let delegate = self.delegate as? MFTextFieldDelegate {
|
||||
delegate.entryIsValid?(textfield)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public func isInvalid(_ textfield: MFTextField?) {
|
||||
|
||||
MVMCoreDispatchUtility.performBlock(onMainThread: {
|
||||
self.enableByValidation()
|
||||
if let delegate = self.delegate as? MFTextFieldDelegate {
|
||||
delegate.entryIsInvalid?(textfield)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user