form engtry.
This commit is contained in:
parent
f14614514d
commit
8d1ac1e94a
@ -34,6 +34,8 @@ import UIKit
|
|||||||
public var isValid = false
|
public var isValid = false
|
||||||
public var fieldKey: String?
|
public var fieldKey: String?
|
||||||
|
|
||||||
|
/// Determines if a border should be drawn.
|
||||||
|
public var hideBorder = false
|
||||||
public var showErrorMessage = false
|
public var showErrorMessage = false
|
||||||
|
|
||||||
public var errorMessage: String? {
|
public var errorMessage: String? {
|
||||||
@ -60,22 +62,6 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determines if a border should be drawn.
|
|
||||||
public var hideBorder = false {
|
|
||||||
didSet { setNeedsDisplay() }
|
|
||||||
}
|
|
||||||
|
|
||||||
public var isLocked = false {
|
|
||||||
didSet {
|
|
||||||
isUserInteractionEnabled = isLocked
|
|
||||||
borderStrokeColor = isLocked ? .clear : UIColor.mfSilver()
|
|
||||||
bottomBar?.backgroundColor = isLocked ? .clear : .black
|
|
||||||
bottomBarHeightConstraint?.constant = 1
|
|
||||||
|
|
||||||
fieldContainer?.setNeedsDisplay()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public var descriptionText: String? {
|
public var descriptionText: String? {
|
||||||
get { return descriptionLabel?.text }
|
get { return descriptionLabel?.text }
|
||||||
set {
|
set {
|
||||||
@ -313,6 +299,47 @@ import UIKit
|
|||||||
descriptionLabelTrailing?.constant = constant
|
descriptionLabelTrailing?.constant = constant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Form Appearance
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
public enum Appearance {
|
||||||
|
case original
|
||||||
|
case error
|
||||||
|
case locked
|
||||||
|
case selected
|
||||||
|
}
|
||||||
|
|
||||||
|
public func fieldAppearance(_ state: Appearance) {
|
||||||
|
|
||||||
|
switch state {
|
||||||
|
case .original:
|
||||||
|
isUserInteractionEnabled = true
|
||||||
|
borderStrokeColor = .mfSilver()
|
||||||
|
bottomBar?.backgroundColor = .black
|
||||||
|
bottomBarHeightConstraint?.constant = 1
|
||||||
|
|
||||||
|
case .error:
|
||||||
|
isUserInteractionEnabled = true
|
||||||
|
bottomBarHeightConstraint?.constant = 4
|
||||||
|
|
||||||
|
case .locked:
|
||||||
|
isUserInteractionEnabled = false
|
||||||
|
hideBorder = true
|
||||||
|
bottomBar?.backgroundColor = .clear
|
||||||
|
bottomBarHeightConstraint?.constant = 1
|
||||||
|
|
||||||
|
case .selected:
|
||||||
|
isUserInteractionEnabled = true
|
||||||
|
borderStrokeColor = .mfSilver()
|
||||||
|
bottomBar?.backgroundColor = .black
|
||||||
|
bottomBarHeightConstraint?.constant = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldContainer?.setNeedsDisplay()
|
||||||
|
layoutIfNeeded()
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -322,17 +349,12 @@ import UIKit
|
|||||||
showErrorMessage = show
|
showErrorMessage = show
|
||||||
|
|
||||||
if show {
|
if show {
|
||||||
|
|
||||||
feedbackLabel?.text = errorMessage
|
feedbackLabel?.text = errorMessage
|
||||||
|
fieldAppearance(.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open func resetEntryAppearance() {
|
|
||||||
|
|
||||||
borderStrokeColor = .mfSilver()
|
|
||||||
bottomBar?.backgroundColor = .black
|
|
||||||
bottomBarHeightConstraint?.constant = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
open func showDashSeperatorView(_ dash: Bool) {
|
open func showDashSeperatorView(_ dash: Bool) {
|
||||||
|
|
||||||
// Never hide seperator view because it could be possiblely used by other classes for positioning
|
// Never hide seperator view because it could be possiblely used by other classes for positioning
|
||||||
|
|||||||
@ -237,7 +237,7 @@ import UIKit
|
|||||||
|
|
||||||
if isValid {
|
if isValid {
|
||||||
clearError()
|
clearError()
|
||||||
separatorView?.backgroundColor = .black
|
bottomBar?.backgroundColor = .black
|
||||||
} else if let errMessage = errorMessage {
|
} else if let errMessage = errorMessage {
|
||||||
feedback = errMessage
|
feedback = errMessage
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user