Digital ACT-191 ONEAPP-6830 story: refactored code

This commit is contained in:
vasavk 2024-03-21 21:35:14 +05:30
parent 2b0390b813
commit abbaa6ffb9

View File

@ -40,30 +40,28 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
.numberPublisher .numberPublisher
.sink { [weak self] number in .sink { [weak self] number in
guard let number else { guard let number else {
self?.component.numberOfSlides = nil
return return
} }
self?.component.numberOfSlides = number.intValue self?.component.numberOfSlides = number.intValue
self?.component.position = Int(self?.positionTextField.text ?? "1") self?.component.position = Int(self?.positionTextField.text ?? "1") ?? 1
}.store(in: &subscribers) }.store(in: &subscribers)
positionTextField positionTextField
.numberPublisher .numberPublisher
.sink { [weak self] number in .sink { [weak self] number in
guard let number else { guard let number else {
self?.component.position = nil
return return
} }
self?.component.position = number.intValue self?.component.position = number.intValue
}.store(in: &subscribers) }.store(in: &subscribers)
} }
func setupModel() { func setupModel() {
//setup UI //setup UI
component.numberOfSlides = 8 component.numberOfSlides = 8
surfacePickerSelectorView.text = component.surface.rawValue surfacePickerSelectorView.text = component.surface.rawValue
slidesTextField.text = String(component.numberOfSlides ?? 1) slidesTextField.text = String(component.numberOfSlides)
positionTextField.text = String(component.position)
//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.onScrubberDidChange = { [weak self] scrubberId in
@ -80,7 +78,7 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.selectedLayout = item self?.component.selectedLayout = item
self?.component.position = Int(self?.positionTextField.text ?? "1") self?.component.position = Int(self?.positionTextField.text ?? "1") ?? 1
} }
} }
} }