Making further improvements from design specs.
This commit is contained in:
parent
420a874711
commit
59008f87d0
@ -69,9 +69,6 @@ import UIKit
|
|||||||
container.trailingAnchor.constraint(equalTo: dropDownCaretView.trailingAnchor, constant: 16).isActive = true
|
container.trailingAnchor.constraint(equalTo: dropDownCaretView.trailingAnchor, constant: 16).isActive = true
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,9 +50,7 @@ import UIKit
|
|||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
|
|
||||||
public var errorMessage: String?
|
public var errorMessage: String?
|
||||||
|
public var standardMessage: String?
|
||||||
/// Determines whther the feedback label will clear itself after user interaction or display update.
|
|
||||||
public var affixFeedback: Bool = false
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
@ -67,7 +65,6 @@ import UIKit
|
|||||||
|
|
||||||
self.entryFieldContainer.isEnabled = enabled
|
self.entryFieldContainer.isEnabled = enabled
|
||||||
self.feedbackLabel.textColor = enabled ? .black : .mfSilver()
|
self.feedbackLabel.textColor = enabled ? .black : .mfSilver()
|
||||||
self.titleLabel.textColor = enabled ? .mfBattleshipGrey() : .mfSilver()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,11 +242,10 @@ import UIKit
|
|||||||
titleLabel.reset()
|
titleLabel.reset()
|
||||||
feedbackLabel.reset()
|
feedbackLabel.reset()
|
||||||
entryFieldContainer.reset()
|
entryFieldContainer.reset()
|
||||||
titleLabel.textColor = .mfBattleshipGrey()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Molecular
|
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||||
extension EntryField {
|
extension EntryField {
|
||||||
|
|
||||||
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
@objc override open func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||||
|
|||||||
@ -215,7 +215,7 @@ import UIKit
|
|||||||
/// Executes on UITextField.textDidChangeNotification
|
/// Executes on UITextField.textDidChangeNotification
|
||||||
@objc func valueChanged() {
|
@objc func valueChanged() {
|
||||||
|
|
||||||
if !showError && !affixFeedback {
|
if !showError {
|
||||||
feedback = ""
|
feedback = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,7 @@ public protocol TextFieldDidDeleteProtocol: class {
|
|||||||
public func initialSetup() {
|
public func initialSetup() {
|
||||||
|
|
||||||
if !initialSetupPerformed {
|
if !initialSetupPerformed {
|
||||||
|
tintColor = .black
|
||||||
initialSetupPerformed = true
|
initialSetupPerformed = true
|
||||||
setupView()
|
setupView()
|
||||||
}
|
}
|
||||||
@ -64,7 +65,8 @@ public protocol TextFieldDidDeleteProtocol: class {
|
|||||||
return .zero
|
return .zero
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.caretRect(for: position)
|
let caretRect = super.caretRect(for: position)
|
||||||
|
return CGRect(origin: caretRect.origin, size: CGSize(width: 1, height: caretRect.height))
|
||||||
}
|
}
|
||||||
|
|
||||||
open override func deleteBackward() {
|
open override func deleteBackward() {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import UIKit
|
|||||||
return layer
|
return layer
|
||||||
}()
|
}()
|
||||||
|
|
||||||
/// Total control overthe drawn top,bottom, left and right borders.
|
/// Total control over the drawn top, bottom, left and right borders.
|
||||||
public var disableAllBorders = false {
|
public var disableAllBorders = false {
|
||||||
didSet {
|
didSet {
|
||||||
bottomBar?.isHidden = disableAllBorders
|
bottomBar?.isHidden = disableAllBorders
|
||||||
@ -33,9 +33,8 @@ import UIKit
|
|||||||
private(set) var fieldState: FieldState = .original {
|
private(set) var fieldState: FieldState = .original {
|
||||||
didSet (oldState) {
|
didSet (oldState) {
|
||||||
// Will not update if new state is the same as old.
|
// Will not update if new state is the same as old.
|
||||||
if fieldState != oldState {
|
guard fieldState != oldState else { return }
|
||||||
fieldState.setStateUI(for: self)
|
fieldState.setStateUI(for: self)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +99,12 @@ import UIKit
|
|||||||
_isSelected = selected
|
_isSelected = selected
|
||||||
_isLocked = false
|
_isLocked = false
|
||||||
_isEnabled = true
|
_isEnabled = true
|
||||||
_showError = false
|
|
||||||
|
|
||||||
fieldState = selected ? .selected : .original
|
if selected && showError {
|
||||||
|
fieldState = .selectedError
|
||||||
|
} else {
|
||||||
|
fieldState = selected ? .selected : .original
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,11 +183,13 @@ import UIKit
|
|||||||
public enum FieldState {
|
public enum FieldState {
|
||||||
case original
|
case original
|
||||||
case error
|
case error
|
||||||
|
case selectedError
|
||||||
case selected
|
case selected
|
||||||
case locked
|
case locked
|
||||||
case disabled
|
case disabled
|
||||||
|
|
||||||
public func setStateUI(for formField: EntryFieldContainer) {
|
public func setStateUI(for formField: EntryFieldContainer) {
|
||||||
|
|
||||||
switch self {
|
switch self {
|
||||||
case .original:
|
case .original:
|
||||||
formField.originalUI()
|
formField.originalUI()
|
||||||
@ -193,6 +197,9 @@ import UIKit
|
|||||||
case .error:
|
case .error:
|
||||||
formField.errorUI()
|
formField.errorUI()
|
||||||
|
|
||||||
|
case .selectedError:
|
||||||
|
formField.selectedErrorUI()
|
||||||
|
|
||||||
case .selected:
|
case .selected:
|
||||||
formField.selectedUI()
|
formField.selectedUI()
|
||||||
|
|
||||||
@ -223,6 +230,15 @@ import UIKit
|
|||||||
refreshUI(bottomBarSize: 4)
|
refreshUI(bottomBarSize: 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open func selectedErrorUI() {
|
||||||
|
|
||||||
|
isUserInteractionEnabled = true
|
||||||
|
hideBorders = false
|
||||||
|
borderStrokeColor = .black
|
||||||
|
bottomBar?.backgroundColor = UIColor.mfPumpkin().cgColor
|
||||||
|
refreshUI(bottomBarSize: 4)
|
||||||
|
}
|
||||||
|
|
||||||
open func selectedUI() {
|
open func selectedUI() {
|
||||||
|
|
||||||
isUserInteractionEnabled = true
|
isUserInteractionEnabled = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user