Digital ACT-191 ONEAPP-9311 story: Check the default value and update it to max or min on button icon presses.
This commit is contained in:
parent
29d00ec352
commit
161f690488
@ -47,7 +47,7 @@ open class InputStepper: EntryFieldBase {
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Default value of the input stepper, defaults to '0'.
|
||||
open var defaultValue:Int = 0 { didSet { setNeedsUpdate() } }
|
||||
|
||||
@ -76,7 +76,7 @@ open class InputStepper: EntryFieldBase {
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// The size of the input stepper. Defaults to 'large'.
|
||||
open var size: Size {
|
||||
get { return _size }
|
||||
@ -88,7 +88,7 @@ open class InputStepper: EntryFieldBase {
|
||||
|
||||
/// Accepts any text or character to appear next to input stepper value.
|
||||
open var trailingText: String? { didSet { setNeedsUpdate() } }
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
@ -142,7 +142,6 @@ open class InputStepper: EntryFieldBase {
|
||||
isAccessibilityElement = false
|
||||
accessibilityLabel = "Input Stepper"
|
||||
containerView.isEnabled = false
|
||||
|
||||
decrementButton.onClick = { _ in self.decrementButtonClick() }
|
||||
incrementButton.onClick = { _ in self.incrementButtonClick() }
|
||||
}
|
||||
@ -155,7 +154,6 @@ open class InputStepper: EntryFieldBase {
|
||||
$0.spacing = VDSLayout.space3X
|
||||
$0.backgroundColor = .clear
|
||||
}
|
||||
|
||||
controlStackView.addArrangedSubview(decrementButton)
|
||||
controlStackView.addArrangedSubview(textLabel)
|
||||
controlStackView.addArrangedSubview(incrementButton)
|
||||
@ -169,8 +167,8 @@ open class InputStepper: EntryFieldBase {
|
||||
decrementButton.surface = surface
|
||||
incrementButton.surface = surface
|
||||
textLabel.surface = surface
|
||||
updateButtonStates()
|
||||
statusIcon.isHidden = true
|
||||
updateButtonStates()
|
||||
}
|
||||
|
||||
/// Resets to default settings.
|
||||
@ -189,14 +187,19 @@ open class InputStepper: EntryFieldBase {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Methods
|
||||
//--------------------------------------------------
|
||||
internal func checkDefaultValue() {
|
||||
defaultValue = defaultValue > _maxValue ? _maxValue : defaultValue < _minValue ? _minValue : defaultValue
|
||||
}
|
||||
|
||||
internal func decrementButtonClick() {
|
||||
defaultValue = defaultValue - 1
|
||||
checkDefaultValue()
|
||||
updateButtonStates()
|
||||
}
|
||||
|
||||
internal func incrementButtonClick() {
|
||||
defaultValue = defaultValue + 1
|
||||
checkDefaultValue()
|
||||
updateButtonStates()
|
||||
}
|
||||
|
||||
@ -215,12 +218,12 @@ open class InputStepper: EntryFieldBase {
|
||||
let value = size == .large ? 6.0 : VDSLayout.space1X
|
||||
updateConstraintsToFieldStackView(value: value)
|
||||
|
||||
// textLabel.textStyle = size == .large ? .boldBodyLarge : .boldBodySmall
|
||||
// textLabel.heightAnchor.constraint(equalToConstant: size == .large ? 44 : 32).activate()
|
||||
|
||||
// decrementButton.customContainerSize = size == .large ? 32 : 24
|
||||
// incrementButton.customContainerSize = size == .large ? 32 : 24
|
||||
|
||||
// textLabel.textStyle = size == .large ? .boldBodyLarge : .boldBodySmall
|
||||
// textLabel.heightAnchor.constraint(equalToConstant: size == .large ? 44 : 32).activate()
|
||||
|
||||
// decrementButton.customContainerSize = size == .large ? 32 : 24
|
||||
// incrementButton.customContainerSize = size == .large ? 32 : 24
|
||||
|
||||
}
|
||||
|
||||
internal func setControlWidth(_ text: String?) {
|
||||
@ -233,5 +236,5 @@ open class InputStepper: EntryFieldBase {
|
||||
// Use EntryFieldBase width
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user