Digital ACT-191 ONEAPP-6830 story: updating position label with callback text
This commit is contained in:
parent
bb7ddab8b8
commit
f02d57ceae
@ -21,10 +21,15 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
|
|||||||
|
|
||||||
var slidesTextField = NumericField()
|
var slidesTextField = NumericField()
|
||||||
var positionTextField = NumericField()
|
var positionTextField = NumericField()
|
||||||
|
var currentPositionLabel = Label().with { $0.textStyle = .boldBodyMedium }
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
addContentTopView(view: component)
|
let stack = UIStackView(arrangedSubviews: [component, currentPositionLabel]).with {
|
||||||
|
$0.axis = .vertical
|
||||||
|
$0.spacing = 25
|
||||||
|
}
|
||||||
|
addContentTopView(view: stack)
|
||||||
setupPicker()
|
setupPicker()
|
||||||
setupModel()
|
setupModel()
|
||||||
}
|
}
|
||||||
@ -58,22 +63,54 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
|
|||||||
|
|
||||||
func setupModel() {
|
func setupModel() {
|
||||||
//setup UI
|
//setup UI
|
||||||
component.numberOfSlides = 8
|
component.numberOfSlides = 4
|
||||||
surfacePickerSelectorView.text = component.surface.rawValue
|
surfacePickerSelectorView.text = component.surface.rawValue
|
||||||
slidesTextField.text = String(component.numberOfSlides)
|
slidesTextField.text = String(component.numberOfSlides)
|
||||||
positionTextField.text = String(component.position)
|
positionTextField.text = String(component.position)
|
||||||
|
updatedPositionLabel(position: component.position, callbackText:"")
|
||||||
|
|
||||||
//setup test page to show scrubber id was changed
|
//setup test page to show scrubber id was changed
|
||||||
component.onScrubberDidChange = { [weak self] scrubberId in
|
component.onScrubberDrag = { [weak self] scrubberId in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
positionTextField.text = String(scrubberId)
|
positionTextField.text = String(scrubberId)
|
||||||
|
updatedPositionLabel(position: component.position, callbackText:"onScrubberDrag")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// will be called when the thumb move forward.
|
||||||
|
component.onMoveForward = { [weak self] scrubberId in
|
||||||
|
guard let self else { return }
|
||||||
|
updatedPositionLabel(position: component.position, callbackText:"onMoveForward")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// will be called when the thumb move backward.
|
||||||
|
component.onMoveBackward = { [weak self] scrubberId in
|
||||||
|
guard let self else { return }
|
||||||
|
updatedPositionLabel(position: component.position, callbackText:"onMoveBackward")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// will be called when the thumb touch start.
|
||||||
|
component.onThumbTouchStart = { [weak self] scrubberId in
|
||||||
|
guard let self else { return }
|
||||||
|
updatedPositionLabel(position: component.position, callbackText:"onThumbTouchStart")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// will be called when the thumb touch end.
|
||||||
|
component.onThumbTouchEnd = { [weak self] scrubberId in
|
||||||
|
guard let self else { return }
|
||||||
|
updatedPositionLabel(position: component.position, callbackText:"onThumbTouchEnd")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updatedPositionLabel(position: Int?, callbackText: String) {
|
||||||
|
currentPositionLabel.text = "\(callbackText) Thumb position : \(position ?? 1)"
|
||||||
|
}
|
||||||
|
|
||||||
func setupPicker() {
|
func setupPicker() {
|
||||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
self?.component.surface = item
|
self?.component.surface = item
|
||||||
self?.contentTopView.backgroundColor = item.color
|
self?.contentTopView.backgroundColor = item.color
|
||||||
|
self?.currentPositionLabel.surface = item
|
||||||
}
|
}
|
||||||
|
|
||||||
layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user