shaping up to be more responsive.

This commit is contained in:
Kevin G Christiano 2019-11-13 16:17:10 -05:00
parent 87b0316d47
commit fca540afc2
7 changed files with 78 additions and 15 deletions

View File

@ -142,9 +142,10 @@ import UIKit
showError = show
borderStrokeColor = show ? .mfPumpkin() : .mfSilver()
bottomBar.backgroundColor = show ? UIColor.mfPumpkin().cgColor : UIColor.black.cgColor
let barHeight: CGFloat = show ? 4 : 1
bottomBar.frame = CGRect(x: 0, y: bounds.height - barHeight, width: bounds.width, height: barHeight)
bottomBar.backgroundColor = show ? UIColor.mfPumpkin().cgColor : UIColor.black.cgColor
setNeedsDisplay()
layoutIfNeeded()

View File

@ -21,6 +21,10 @@ import UIKit
public var digitFields: [DigitBox] = []
//--------------------------------------------------
// MARK: - Property Observers
//--------------------------------------------------
public override var isEnabled: Bool {
didSet {
titleLabel.textColor = self.isEnabled ? .mfBattleshipGrey() : .mfSilver()

View File

@ -37,6 +37,10 @@ import UIKit
public var dropDownIsDisplayed = false
//--------------------------------------------------
// MARK: - Property Observers
//--------------------------------------------------
public override var isEnabled: Bool {
didSet { showDropDown(isEnabled) }
}
@ -212,8 +216,8 @@ extension DropdownEntryField {
var accessibilityString = accessibilityString ?? ""
if dropDownIsDisplayed, let txtPickerItem = MVMCoreUIUtility.hardcodedString(withKey: "textfield_picker_item") {
accessibilityString += txtPickerItem
if dropDownIsDisplayed, let textPickerItem = MVMCoreUIUtility.hardcodedString(withKey: "textfield_picker_item") {
accessibilityString += textPickerItem
} else if let txtRegular = MVMCoreUIUtility.hardcodedString(withKey: "textfield_regular") {
accessibilityString += txtRegular

View File

@ -56,15 +56,24 @@ import UIKit
public var isValid = false
public var fieldKey: String?
public var errorMessage: String?
//--------------------------------------------------
// MARK: - Property Observers
//--------------------------------------------------
/// Toggles error or original UI.
public var showError = false {
didSet {
entryContainer.showError = showError
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.entryContainer.showError = self.showError
self.feedback = self.errorMessage
}
}
}
public var errorMessage: String?
/// Toggles original or disabled UI.
public var isEnabled = true {
didSet {
@ -86,7 +95,17 @@ import UIKit
guard let self = self else { return }
self.isUserInteractionEnabled = !self.isLocked
self.entryContainer.lockedUI()
self.entryContainer.isLocked = self.isLocked
}
}
}
public var isSelected = false {
didSet {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
self.entryContainer.isSelected = self.isSelected
}
}
}

View File

@ -22,6 +22,10 @@ import MVMCore
private weak var outsiderTextDelegate: UITextFieldDelegate?
//--------------------------------------------------
// MARK: - Property Observers
//--------------------------------------------------
public var mdn: String? {
get { return MVMCoreUIUtility.removeMdnFormat(text) }
set { text = MVMCoreUIUtility.formatMdn(newValue) }

View File

@ -40,10 +40,15 @@ import UIKit
// MARK: - Properties
//--------------------------------------------------
public var textColor: (enabled: UIColor?, disabled: UIColor?)
/// Set enabled and disabled colors to be utilized when setting this texfield's isEnabled property.
public var textColor: (enabled: UIColor?, disabled: UIColor?) = (.black, .mfSilver())
public var observingForChange = false
//--------------------------------------------------
// MARK: - Property Observers
//--------------------------------------------------
public override var isEnabled: Bool {
didSet {
DispatchQueue.main.async { [weak self] in
@ -91,6 +96,7 @@ import UIKit
NotificationCenter.default.addObserver(self, selector: #selector(valueChanged), name: UITextField.textDidChangeNotification, object: textField)
NotificationCenter.default.addObserver(self, selector: #selector(endInputing), name: UITextField.textDidEndEditingNotification, object: textField)
NotificationCenter.default.addObserver(self, selector: #selector(startEditing), name: UITextField.textDidBeginEditingNotification, object: textField)
} else if mfTextFieldDelegate == nil && observingForChange {
observingForChange = false
NotificationCenter.default.removeObserver(self, name: UITextField.textDidChangeNotification, object: textField)
@ -190,9 +196,16 @@ import UIKit
}
}
@objc func dismissTextFieldResponder(_ sender: Any?) {
override open func resignFirstResponder() -> Bool {
textField.resignFirstResponder()
return true
}
@objc func dismissTextFieldResponder(_ sender: Any?) {
_ = textField.resignFirstResponder()
}
//--------------------------------------------------

View File

@ -11,7 +11,7 @@ import UIKit
@objcMembers open class FormView: View {
//--------------------------------------------------
// MARK: - Properties
// MARK: - Drawing Properties
//--------------------------------------------------
public var bottomBar: CAShapeLayer = {
@ -22,14 +22,19 @@ import UIKit
return layer
}()
public var borderStrokeColor: UIColor = .mfSilver()
public var borderPath: UIBezierPath = UIBezierPath()
/// Determines if a border should be drawn.
public var hideBorder = false
public var borderStrokeColor: UIColor = .mfSilver()
private var borderPath: UIBezierPath = UIBezierPath()
//--------------------------------------------------
// MARK: - Property Observers
//--------------------------------------------------
public var showError = false {
didSet {
_ = showError ? errorUI() : originalUI()
showError ? errorUI() : originalUI()
}
}
@ -39,10 +44,23 @@ import UIKit
}
}
public var isLocked = false {
didSet {
isLocked ? lockedUI() : originalUI()
}
}
public var isSelected = false {
didSet {
isSelected ? selectedUI() : originalUI()
}
}
//--------------------------------------------------
// MARK: - Delegate
//--------------------------------------------------
/// Holds reference to delegateObject to inform molecular tableView of an update.
weak var delegateObject: MVMCoreUIDelegateObject?
//--------------------------------------------------
@ -145,7 +163,7 @@ import UIKit
open func refreshUI(bottomBarSize: CGFloat? = nil) {
let size: CGFloat = showError ? 4 : 1
let size: CGFloat = bottomBarSize ?? (showError ? 4 : 1)
bottomBar.frame = CGRect(x: 0, y: bounds.height - size, width: bounds.width, height: size)
delegateObject?.moleculeDelegate?.moleculeLayoutUpdated?(self)