Digital ACT-191 ONEAPP-9311 story: changes as per review notes
This commit is contained in:
parent
c120c746d2
commit
06b0c80a58
@ -286,7 +286,7 @@ extension DatePicker {
|
||||
|
||||
// update containerview
|
||||
_ = responder?.becomeFirstResponder()
|
||||
updateContainerView(flag: true)
|
||||
updateContainerView()
|
||||
|
||||
// animate the calendar to show
|
||||
UIView.animate(withDuration: 0.5,
|
||||
|
||||
@ -288,7 +288,7 @@ extension DropdownSelect: UIPickerViewDelegate, UIPickerViewDataSource {
|
||||
dropdownField.resignFirstResponder()
|
||||
}
|
||||
optionsPicker.isHidden = !optionsPicker.isHidden
|
||||
updateContainerView(flag: true)
|
||||
updateContainerView()
|
||||
updateErrorLabel()
|
||||
}
|
||||
|
||||
|
||||
@ -67,9 +67,6 @@ open class InputStepper: EntryFieldBase {
|
||||
}
|
||||
}
|
||||
|
||||
/// Default value of the input stepper, defaults to '0'.
|
||||
open var defaultValue:Int = 0 { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Allows an id to be passed to input stepper.
|
||||
open var id: Int? { didSet { setNeedsUpdate() } }
|
||||
|
||||
@ -112,6 +109,12 @@ open class InputStepper: EntryFieldBase {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
/// Default Int value of the input stepper, defaults to '0'.
|
||||
internal var defaultIntValue: Int {
|
||||
guard let intValue = defaultValue as? Int else { return 0 }
|
||||
return intValue
|
||||
}
|
||||
|
||||
/// This is the view that will be wrapped with the border for userInteraction.
|
||||
/// The only subview of this view is the stepperStackView.
|
||||
internal var stepperContainerView = View().with {
|
||||
@ -222,11 +225,9 @@ open class InputStepper: EntryFieldBase {
|
||||
open override func updateView() {
|
||||
super.updateView()
|
||||
statusIcon.isHidden = true
|
||||
updateConstraintsToFieldStackView(flag: false)
|
||||
updateContainerView(flag: false)
|
||||
|
||||
// Update label text, style, color, ande surface.
|
||||
textLabel.text = String(defaultValue) + " " + (trailingText ?? "")
|
||||
textLabel.text = String(defaultIntValue) + " " + (trailingText ?? "")
|
||||
textLabel.textStyle = size == .large ? .boldBodyLarge : .boldBodySmall
|
||||
textLabel.textColorConfiguration = !isEnabled ? labelDisabledColorConfiguration.eraseToAnyColorable() : labelColorConfiguration.eraseToAnyColorable()
|
||||
textLabel.surface = surface
|
||||
@ -237,6 +238,7 @@ open class InputStepper: EntryFieldBase {
|
||||
// Update stepper container border and corner radius.
|
||||
setControlWidth(controlWidth)
|
||||
updateControlWidthPercentage()
|
||||
updateStepperView()
|
||||
setNeedsLayout()
|
||||
}
|
||||
|
||||
@ -272,7 +274,6 @@ open class InputStepper: EntryFieldBase {
|
||||
controlWidth = "auto"
|
||||
controlWidthPercentage = nil
|
||||
widthPercentage = nil
|
||||
defaultValue = 0
|
||||
id = nil
|
||||
minValue = 0
|
||||
maxValue = 99
|
||||
@ -312,19 +313,19 @@ open class InputStepper: EntryFieldBase {
|
||||
// MARK: - Private Methods
|
||||
//--------------------------------------------------
|
||||
internal func checkDefaultValue() {
|
||||
if let _minValue = minValue, let _maxValue = maxValue {
|
||||
defaultValue = defaultValue > _maxValue ? _maxValue : defaultValue < _minValue ? _minValue : defaultValue
|
||||
if let minValue, let maxValue {
|
||||
defaultValue = defaultIntValue > maxValue ? maxValue : defaultIntValue < minValue ? minValue : defaultIntValue
|
||||
}
|
||||
}
|
||||
|
||||
internal func decrementButtonClick() {
|
||||
defaultValue = defaultValue - 1
|
||||
defaultValue = defaultIntValue - 1
|
||||
checkDefaultValue()
|
||||
updateButtonStates()
|
||||
}
|
||||
|
||||
internal func incrementButtonClick() {
|
||||
defaultValue = defaultValue + 1
|
||||
defaultValue = defaultIntValue + 1
|
||||
checkDefaultValue()
|
||||
updateButtonStates()
|
||||
}
|
||||
@ -339,8 +340,8 @@ open class InputStepper: EntryFieldBase {
|
||||
decrementButton.isEnabled = false
|
||||
incrementButton.isEnabled = false
|
||||
} else {
|
||||
decrementButton.isEnabled = defaultValue > minValue ?? 0 ? true : false
|
||||
incrementButton.isEnabled = defaultValue < maxValue ?? 99 ? true : false
|
||||
decrementButton.isEnabled = defaultIntValue > minValue ?? 0 ? true : false
|
||||
incrementButton.isEnabled = defaultIntValue < maxValue ?? 99 ? true : false
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,4 +407,17 @@ open class InputStepper: EntryFieldBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func updateStepperView() {
|
||||
fieldStackView.removeConstraints()
|
||||
fieldStackView.pinTop().pinLeading().pinBottom().pinTrailingLessThanOrEqualTo()
|
||||
containerView.backgroundColor = .clear
|
||||
containerView.layer.borderColor = nil
|
||||
containerView.layer.borderWidth = 0
|
||||
containerView.layer.cornerRadius = 0
|
||||
fieldStackView.backgroundColor = containerBackgroundColor
|
||||
fieldStackView.layer.borderColor = borderColorConfiguration.getColor(self).cgColor
|
||||
fieldStackView.layer.borderWidth = VDSFormControls.borderWidth
|
||||
fieldStackView.layer.cornerRadius = containerView.frame.size.height / 2
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
get { fatalError("must be read from subclass")}
|
||||
}
|
||||
|
||||
// open var defaultValue: AnyHashable? { didSet { setNeedsUpdate() } }
|
||||
open var defaultValue: AnyHashable? { didSet { setNeedsUpdate() } }
|
||||
|
||||
open var isRequired: Bool = false { didSet { setNeedsUpdate() } }
|
||||
|
||||
@ -356,7 +356,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
open override func updateView() {
|
||||
super.updateView()
|
||||
updateRules()
|
||||
updateContainerView(flag: true)
|
||||
updateContainerView()
|
||||
updateContainerWidth()
|
||||
updateTitleLabel()
|
||||
updateErrorLabel()
|
||||
@ -382,7 +382,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
transparentBackground = false
|
||||
width = nil
|
||||
inputId = nil
|
||||
// defaultValue = nil
|
||||
defaultValue = nil
|
||||
isRequired = false
|
||||
isReadOnly = false
|
||||
onChange = nil
|
||||
@ -536,35 +536,13 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
||||
}
|
||||
}
|
||||
|
||||
internal func updateContainerView(flag: Bool) {
|
||||
if flag {
|
||||
containerView.backgroundColor = containerBackgroundColor
|
||||
containerView.layer.borderColor = borderColorConfiguration.getColor(self).cgColor
|
||||
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
||||
containerView.layer.cornerRadius = VDSFormControls.borderRadius
|
||||
} else {
|
||||
containerView.backgroundColor = .clear
|
||||
containerView.layer.borderColor = nil
|
||||
containerView.layer.borderWidth = 0
|
||||
containerView.layer.cornerRadius = 0
|
||||
fieldStackView.backgroundColor = containerBackgroundColor
|
||||
fieldStackView.layer.borderColor = borderColorConfiguration.getColor(self).cgColor
|
||||
fieldStackView.layer.borderWidth = VDSFormControls.borderWidth
|
||||
fieldStackView.layer.cornerRadius = containerView.frame.size.height / 2
|
||||
}
|
||||
internal func updateContainerView() {
|
||||
containerView.backgroundColor = containerBackgroundColor
|
||||
containerView.layer.borderColor = borderColorConfiguration.getColor(self).cgColor
|
||||
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
||||
containerView.layer.cornerRadius = VDSFormControls.borderRadius
|
||||
}
|
||||
|
||||
/// Update constraints to containerStackView which has horizontal stack in which user interacts.
|
||||
internal func updateConstraintsToFieldStackView(flag: Bool) {
|
||||
fieldStackView.removeFromSuperview()
|
||||
containerView.addSubview(fieldStackView)
|
||||
if flag {
|
||||
fieldStackView.pinToSuperView(.uniform(VDSLayout.space3X))
|
||||
} else {
|
||||
fieldStackView.pinTop().pinLeading().pinBottom().pinTrailingLessThanOrEqualTo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal func updateContainerWidth() {
|
||||
widthConstraint?.deactivate()
|
||||
trailingLessThanEqualsConstraint?.deactivate()
|
||||
|
||||
@ -371,7 +371,7 @@ open class InputField: EntryFieldBase {
|
||||
extension InputField: UITextFieldDelegate {
|
||||
open func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||
fieldType.handler().textFieldDidBeginEditing(self, textField: textField)
|
||||
updateContainerView(flag: true)
|
||||
updateContainerView()
|
||||
updateErrorLabel()
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user