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
|
// update containerview
|
||||||
_ = responder?.becomeFirstResponder()
|
_ = responder?.becomeFirstResponder()
|
||||||
updateContainerView(flag: true)
|
updateContainerView()
|
||||||
|
|
||||||
// animate the calendar to show
|
// animate the calendar to show
|
||||||
UIView.animate(withDuration: 0.5,
|
UIView.animate(withDuration: 0.5,
|
||||||
|
|||||||
@ -288,7 +288,7 @@ extension DropdownSelect: UIPickerViewDelegate, UIPickerViewDataSource {
|
|||||||
dropdownField.resignFirstResponder()
|
dropdownField.resignFirstResponder()
|
||||||
}
|
}
|
||||||
optionsPicker.isHidden = !optionsPicker.isHidden
|
optionsPicker.isHidden = !optionsPicker.isHidden
|
||||||
updateContainerView(flag: true)
|
updateContainerView()
|
||||||
updateErrorLabel()
|
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.
|
/// Allows an id to be passed to input stepper.
|
||||||
open var id: Int? { didSet { setNeedsUpdate() } }
|
open var id: Int? { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
@ -112,6 +109,12 @@ open class InputStepper: EntryFieldBase {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// 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.
|
/// This is the view that will be wrapped with the border for userInteraction.
|
||||||
/// The only subview of this view is the stepperStackView.
|
/// The only subview of this view is the stepperStackView.
|
||||||
internal var stepperContainerView = View().with {
|
internal var stepperContainerView = View().with {
|
||||||
@ -222,11 +225,9 @@ open class InputStepper: EntryFieldBase {
|
|||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
statusIcon.isHidden = true
|
statusIcon.isHidden = true
|
||||||
updateConstraintsToFieldStackView(flag: false)
|
|
||||||
updateContainerView(flag: false)
|
|
||||||
|
|
||||||
// Update label text, style, color, ande surface.
|
// Update label text, style, color, ande surface.
|
||||||
textLabel.text = String(defaultValue) + " " + (trailingText ?? "")
|
textLabel.text = String(defaultIntValue) + " " + (trailingText ?? "")
|
||||||
textLabel.textStyle = size == .large ? .boldBodyLarge : .boldBodySmall
|
textLabel.textStyle = size == .large ? .boldBodyLarge : .boldBodySmall
|
||||||
textLabel.textColorConfiguration = !isEnabled ? labelDisabledColorConfiguration.eraseToAnyColorable() : labelColorConfiguration.eraseToAnyColorable()
|
textLabel.textColorConfiguration = !isEnabled ? labelDisabledColorConfiguration.eraseToAnyColorable() : labelColorConfiguration.eraseToAnyColorable()
|
||||||
textLabel.surface = surface
|
textLabel.surface = surface
|
||||||
@ -237,6 +238,7 @@ open class InputStepper: EntryFieldBase {
|
|||||||
// Update stepper container border and corner radius.
|
// Update stepper container border and corner radius.
|
||||||
setControlWidth(controlWidth)
|
setControlWidth(controlWidth)
|
||||||
updateControlWidthPercentage()
|
updateControlWidthPercentage()
|
||||||
|
updateStepperView()
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +274,6 @@ open class InputStepper: EntryFieldBase {
|
|||||||
controlWidth = "auto"
|
controlWidth = "auto"
|
||||||
controlWidthPercentage = nil
|
controlWidthPercentage = nil
|
||||||
widthPercentage = nil
|
widthPercentage = nil
|
||||||
defaultValue = 0
|
|
||||||
id = nil
|
id = nil
|
||||||
minValue = 0
|
minValue = 0
|
||||||
maxValue = 99
|
maxValue = 99
|
||||||
@ -312,19 +313,19 @@ open class InputStepper: EntryFieldBase {
|
|||||||
// MARK: - Private Methods
|
// MARK: - Private Methods
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
internal func checkDefaultValue() {
|
internal func checkDefaultValue() {
|
||||||
if let _minValue = minValue, let _maxValue = maxValue {
|
if let minValue, let maxValue {
|
||||||
defaultValue = defaultValue > _maxValue ? _maxValue : defaultValue < _minValue ? _minValue : defaultValue
|
defaultValue = defaultIntValue > maxValue ? maxValue : defaultIntValue < minValue ? minValue : defaultIntValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func decrementButtonClick() {
|
internal func decrementButtonClick() {
|
||||||
defaultValue = defaultValue - 1
|
defaultValue = defaultIntValue - 1
|
||||||
checkDefaultValue()
|
checkDefaultValue()
|
||||||
updateButtonStates()
|
updateButtonStates()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func incrementButtonClick() {
|
internal func incrementButtonClick() {
|
||||||
defaultValue = defaultValue + 1
|
defaultValue = defaultIntValue + 1
|
||||||
checkDefaultValue()
|
checkDefaultValue()
|
||||||
updateButtonStates()
|
updateButtonStates()
|
||||||
}
|
}
|
||||||
@ -339,8 +340,8 @@ open class InputStepper: EntryFieldBase {
|
|||||||
decrementButton.isEnabled = false
|
decrementButton.isEnabled = false
|
||||||
incrementButton.isEnabled = false
|
incrementButton.isEnabled = false
|
||||||
} else {
|
} else {
|
||||||
decrementButton.isEnabled = defaultValue > minValue ?? 0 ? true : false
|
decrementButton.isEnabled = defaultIntValue > minValue ?? 0 ? true : false
|
||||||
incrementButton.isEnabled = defaultValue < maxValue ?? 99 ? 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")}
|
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() } }
|
open var isRequired: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
@ -356,7 +356,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
updateRules()
|
updateRules()
|
||||||
updateContainerView(flag: true)
|
updateContainerView()
|
||||||
updateContainerWidth()
|
updateContainerWidth()
|
||||||
updateTitleLabel()
|
updateTitleLabel()
|
||||||
updateErrorLabel()
|
updateErrorLabel()
|
||||||
@ -382,7 +382,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
transparentBackground = false
|
transparentBackground = false
|
||||||
width = nil
|
width = nil
|
||||||
inputId = nil
|
inputId = nil
|
||||||
// defaultValue = nil
|
defaultValue = nil
|
||||||
isRequired = false
|
isRequired = false
|
||||||
isReadOnly = false
|
isReadOnly = false
|
||||||
onChange = nil
|
onChange = nil
|
||||||
@ -536,33 +536,11 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func updateContainerView(flag: Bool) {
|
internal func updateContainerView() {
|
||||||
if flag {
|
|
||||||
containerView.backgroundColor = containerBackgroundColor
|
containerView.backgroundColor = containerBackgroundColor
|
||||||
containerView.layer.borderColor = borderColorConfiguration.getColor(self).cgColor
|
containerView.layer.borderColor = borderColorConfiguration.getColor(self).cgColor
|
||||||
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
containerView.layer.borderWidth = VDSFormControls.borderWidth
|
||||||
containerView.layer.cornerRadius = VDSFormControls.borderRadius
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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() {
|
internal func updateContainerWidth() {
|
||||||
|
|||||||
@ -371,7 +371,7 @@ open class InputField: EntryFieldBase {
|
|||||||
extension InputField: UITextFieldDelegate {
|
extension InputField: UITextFieldDelegate {
|
||||||
open func textFieldDidBeginEditing(_ textField: UITextField) {
|
open func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||||
fieldType.handler().textFieldDidBeginEditing(self, textField: textField)
|
fieldType.handler().textFieldDidBeginEditing(self, textField: textField)
|
||||||
updateContainerView(flag: true)
|
updateContainerView()
|
||||||
updateErrorLabel()
|
updateErrorLabel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user