From f02d57ceaec71f87393369299dd65799f7f4b335 Mon Sep 17 00:00:00 2001 From: vasavk Date: Wed, 27 Mar 2024 16:04:16 +0530 Subject: [PATCH] Digital ACT-191 ONEAPP-6830 story: updating position label with callback text --- .../CarouselScrollbarViewConttroller.swift | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift b/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift index 45a9ac2..941172f 100644 --- a/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift +++ b/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift @@ -21,10 +21,15 @@ class CarouselScrollbarViewConttroller: BaseViewController { var slidesTextField = NumericField() var positionTextField = NumericField() - + var currentPositionLabel = Label().with { $0.textStyle = .boldBodyMedium } + override func viewDidLoad() { super.viewDidLoad() - addContentTopView(view: component) + let stack = UIStackView(arrangedSubviews: [component, currentPositionLabel]).with { + $0.axis = .vertical + $0.spacing = 25 + } + addContentTopView(view: stack) setupPicker() setupModel() } @@ -58,22 +63,54 @@ class CarouselScrollbarViewConttroller: BaseViewController { func setupModel() { //setup UI - component.numberOfSlides = 8 + component.numberOfSlides = 4 surfacePickerSelectorView.text = component.surface.rawValue slidesTextField.text = String(component.numberOfSlides) positionTextField.text = String(component.position) - + updatedPositionLabel(position: component.position, callbackText:"") + //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 } 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() { surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.surface = item self?.contentTopView.backgroundColor = item.color + self?.currentPositionLabel.surface = item } layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in