EntryField updates
This commit is contained in:
parent
98e4f3d621
commit
1f8cf7c4d0
@ -64,7 +64,13 @@ import UIKit
|
|||||||
super.setupFieldContainerContent(container)
|
super.setupFieldContainerContent(container)
|
||||||
|
|
||||||
container.addSubview(dropDownCaretView)
|
container.addSubview(dropDownCaretView)
|
||||||
accessoryView = dropDownCaretView
|
|
||||||
|
textFieldTrailingConstraint?.isActive = false
|
||||||
|
textFieldTrailingConstraint = dropDownCaretView.leadingAnchor.constraint(equalTo: textField.trailingAnchor, constant: 6)
|
||||||
|
textFieldTrailingConstraint?.isActive = true
|
||||||
|
|
||||||
|
container.trailingAnchor.constraint(equalTo: dropDownCaretView.trailingAnchor, constant: 16).isActive = true
|
||||||
|
dropDownCaretView.centerYAnchor.constraint(equalTo: container.centerYAnchor).isActive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
public override func set(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [AnyHashable: Any]?) {
|
||||||
|
|||||||
@ -76,6 +76,15 @@ import UIKit
|
|||||||
public var digitBoxes: [DigitBox] = []
|
public var digitBoxes: [DigitBox] = []
|
||||||
private var selectedDigitBox: DigitBox?
|
private var selectedDigitBox: DigitBox?
|
||||||
|
|
||||||
|
public lazy var errorImage: UIImageView = {
|
||||||
|
let image = MVMCoreUIUtility.imageNamed("alert_standard")
|
||||||
|
let imageView = UIImageView(image: image)
|
||||||
|
imageView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
imageView.heightAnchor.constraint(equalToConstant: 20).isActive = true
|
||||||
|
imageView.widthAnchor.constraint(equalToConstant: 20).isActive = true
|
||||||
|
return imageView
|
||||||
|
}()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -205,6 +214,7 @@ import UIKit
|
|||||||
|
|
||||||
isAccessibilityElement = false
|
isAccessibilityElement = false
|
||||||
entryFieldContainer.disableAllBorders = true
|
entryFieldContainer.disableAllBorders = true
|
||||||
|
usesAccessoryView = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func createDigitField() -> DigitBox {
|
@objc private func createDigitField() -> DigitBox {
|
||||||
|
|||||||
@ -48,14 +48,6 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
public var isValid: Bool = false
|
public var isValid: Bool = false
|
||||||
public var errorMessage: String?
|
|
||||||
public var standardMessage: String? {
|
|
||||||
didSet {
|
|
||||||
if !showError {
|
|
||||||
feedback = standardMessage
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Computed Properties
|
// MARK: - Computed Properties
|
||||||
@ -75,7 +67,7 @@ import UIKit
|
|||||||
public var showError: Bool {
|
public var showError: Bool {
|
||||||
get { return entryFieldContainer.showError }
|
get { return entryFieldContainer.showError }
|
||||||
set (error) {
|
set (error) {
|
||||||
self.feedback = error ? self.errorMessage : self.standardMessage
|
self.feedback = error ? entryFieldModel?.errorMessage : entryFieldModel?.informativeMessage
|
||||||
self.entryFieldContainer.showError = error
|
self.entryFieldContainer.showError = error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,6 +113,10 @@ import UIKit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var entryFieldModel: EntryFieldModel? {
|
||||||
|
return model as? EntryFieldModel
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Constraints
|
// MARK: - Constraints
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -242,6 +238,7 @@ import UIKit
|
|||||||
titleLabel.textColor = .mvmBlack
|
titleLabel.textColor = .mvmBlack
|
||||||
feedbackLabel.font = Styler.Font.RegularMicro.getFont()
|
feedbackLabel.font = Styler.Font.RegularMicro.getFont()
|
||||||
feedbackLabel.textColor = .mvmBlack
|
feedbackLabel.textColor = .mvmBlack
|
||||||
|
feedbackLabel.text = nil
|
||||||
entryFieldContainer.reset()
|
entryFieldContainer.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +252,6 @@ import UIKit
|
|||||||
|
|
||||||
title = model.title
|
title = model.title
|
||||||
feedback = model.feedback
|
feedback = model.feedback
|
||||||
errorMessage = model.errorMessage
|
|
||||||
isEnabled = model.enabled
|
isEnabled = model.enabled
|
||||||
|
|
||||||
if let isLocked = model.locked {
|
if let isLocked = model.locked {
|
||||||
|
|||||||
@ -22,7 +22,8 @@ import Foundation
|
|||||||
public var backgroundColor: Color?
|
public var backgroundColor: Color?
|
||||||
public var title: String = ""
|
public var title: String = ""
|
||||||
public var feedback: String?
|
public var feedback: String?
|
||||||
public var errorMessage: String = ""
|
public var errorMessage: String?
|
||||||
|
public var informativeMessage: String?
|
||||||
public var enabled: Bool = true
|
public var enabled: Bool = true
|
||||||
public var locked: Bool?
|
public var locked: Bool?
|
||||||
public var selected: Bool?
|
public var selected: Bool?
|
||||||
@ -86,6 +87,7 @@ import Foundation
|
|||||||
}
|
}
|
||||||
|
|
||||||
feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback)
|
feedback = try typeContainer.decodeIfPresent(String.self, forKey: .feedback)
|
||||||
|
informativeMessage = feedback
|
||||||
|
|
||||||
if let errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) {
|
if let errorMessage = try typeContainer.decodeIfPresent(String.self, forKey: .errorMessage) {
|
||||||
self.errorMessage = errorMessage
|
self.errorMessage = errorMessage
|
||||||
|
|||||||
@ -86,6 +86,28 @@ import MVMCore
|
|||||||
textField.inputAccessoryView = toolbar
|
textField.inputAccessoryView = toolbar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func constrainAccessoryView() {
|
||||||
|
|
||||||
|
guard let accessoryView = accessoryView else { return }
|
||||||
|
|
||||||
|
entryFieldContainer.addSubview(accessoryView)
|
||||||
|
|
||||||
|
textFieldTrailingConstraint?.isActive = false
|
||||||
|
textFieldTrailingConstraint = accessoryView.leadingAnchor.constraint(equalTo: textField.trailingAnchor, constant: Padding.Two)
|
||||||
|
textFieldTrailingConstraint?.isActive = true
|
||||||
|
|
||||||
|
accessoryViewTrailingConstraint = entryFieldContainer.trailingAnchor.constraint(equalTo: accessoryView.trailingAnchor, constant: Padding.Four)
|
||||||
|
accessoryViewTrailingConstraint?.isActive = true
|
||||||
|
accessoryView.centerYAnchor.constraint(equalTo: entryFieldContainer.centerYAnchor).isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
public func unconstrainAccessoryView() {
|
||||||
|
|
||||||
|
textFieldTrailingConstraint = entryFieldContainer.trailingAnchor.constraint(equalTo: textField.trailingAnchor, constant: Padding.Four)
|
||||||
|
textFieldTrailingConstraint?.isActive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Methods
|
// MARK: - Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -114,7 +136,7 @@ import MVMCore
|
|||||||
showError = false
|
showError = false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
errorMessage = errorMessage ?? MVMCoreUIUtility.hardcodedString(withKey: "textfield_phone_format_error_message")
|
entryFieldModel?.errorMessage = entryFieldModel?.errorMessage ?? MVMCoreUIUtility.hardcodedString(withKey: "textfield_phone_format_error_message")
|
||||||
showError = true
|
showError = true
|
||||||
UIAccessibility.post(notification: .layoutChanged, argument: textField)
|
UIAccessibility.post(notification: .layoutChanged, argument: textField)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,10 +36,6 @@ import UIKit
|
|||||||
return textField
|
return textField
|
||||||
}()
|
}()
|
||||||
|
|
||||||
public var accessoryView: View? {
|
|
||||||
didSet { accessoryView == nil ? removeAccessoryView() : constrainAccessoryView() }
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Stored Properties
|
// MARK: - Stored Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -52,6 +48,8 @@ import UIKit
|
|||||||
/// Validate on each entry in the textField. Default: true
|
/// Validate on each entry in the textField. Default: true
|
||||||
public var validateEachCharacter: Bool = true
|
public var validateEachCharacter: Bool = true
|
||||||
|
|
||||||
|
var usesAccessoryView: Bool = true
|
||||||
|
|
||||||
/// Validate when user resigns editing. Default: true
|
/// Validate when user resigns editing. Default: true
|
||||||
public var validateWhenDoneEditing: Bool = true
|
public var validateWhenDoneEditing: Bool = true
|
||||||
|
|
||||||
@ -82,7 +80,7 @@ import UIKit
|
|||||||
set (error) {
|
set (error) {
|
||||||
|
|
||||||
if error {
|
if error {
|
||||||
textField.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textfield_error_message") ?? "", textField.text ?? "", errorMessage ?? "")
|
textField.accessibilityValue = String(format: MVMCoreUIUtility.hardcodedString(withKey: "textfield_error_message") ?? "", textField.text ?? "", entryFieldModel?.errorMessage ?? "")
|
||||||
} else {
|
} else {
|
||||||
textField.accessibilityValue = nil
|
textField.accessibilityValue = nil
|
||||||
}
|
}
|
||||||
@ -141,27 +139,6 @@ import UIKit
|
|||||||
public var textFieldTrailingConstraint: NSLayoutConstraint?
|
public var textFieldTrailingConstraint: NSLayoutConstraint?
|
||||||
public var accessoryViewTrailingConstraint: NSLayoutConstraint?
|
public var accessoryViewTrailingConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
public func constrainAccessoryView() {
|
|
||||||
|
|
||||||
textFieldTrailingConstraint?.isActive = false
|
|
||||||
textFieldTrailingConstraint = accessoryView?.leadingAnchor.constraint(equalTo: textField.trailingAnchor, constant: Padding.Two)
|
|
||||||
textFieldTrailingConstraint?.isActive = true
|
|
||||||
|
|
||||||
if let accessoryView = accessoryView {
|
|
||||||
accessoryViewTrailingConstraint = entryFieldContainer.trailingAnchor.constraint(equalTo: accessoryView.trailingAnchor, constant: Padding.Four)
|
|
||||||
accessoryViewTrailingConstraint?.isActive = true
|
|
||||||
accessoryView.centerYAnchor.constraint(equalTo: entryFieldContainer.centerYAnchor).isActive = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func removeAccessoryView() {
|
|
||||||
|
|
||||||
accessoryView?.removeFromSuperview()
|
|
||||||
|
|
||||||
textFieldTrailingConstraint = entryFieldContainer.trailingAnchor.constraint(equalTo: textField.trailingAnchor, constant: Padding.Four)
|
|
||||||
textFieldTrailingConstraint?.isActive = true
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
23
MVMCoreUI/SupportingFiles/Media.xcassets/alert_standard.imageset/Contents.json
vendored
Normal file
23
MVMCoreUI/SupportingFiles/Media.xcassets/alert_standard.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "alert_standard @1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "alert_standard @2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"filename" : "alert_standard @3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
MVMCoreUI/SupportingFiles/Media.xcassets/alert_standard.imageset/alert_standard @1x.png
vendored
Normal file
BIN
MVMCoreUI/SupportingFiles/Media.xcassets/alert_standard.imageset/alert_standard @1x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 279 B |
BIN
MVMCoreUI/SupportingFiles/Media.xcassets/alert_standard.imageset/alert_standard @2x.png
vendored
Normal file
BIN
MVMCoreUI/SupportingFiles/Media.xcassets/alert_standard.imageset/alert_standard @2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 525 B |
BIN
MVMCoreUI/SupportingFiles/Media.xcassets/alert_standard.imageset/alert_standard @3x.png
vendored
Normal file
BIN
MVMCoreUI/SupportingFiles/Media.xcassets/alert_standard.imageset/alert_standard @3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 771 B |
Loading…
Reference in New Issue
Block a user