Digital ACT-191 ONEAPP-6830 story: refactored code
This commit is contained in:
parent
2b0390b813
commit
abbaa6ffb9
@ -29,7 +29,7 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
|
||||
setupModel()
|
||||
}
|
||||
|
||||
override func setupForm(){
|
||||
override func setupForm() {
|
||||
super.setupForm()
|
||||
addFormRow(label: "Surface", view: surfacePickerSelectorView)
|
||||
addFormRow(label: "Layout", view: layoutPickerSelectorView)
|
||||
@ -40,30 +40,28 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
guard let number else {
|
||||
self?.component.numberOfSlides = nil
|
||||
return
|
||||
}
|
||||
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)
|
||||
|
||||
positionTextField
|
||||
.numberPublisher
|
||||
.sink { [weak self] number in
|
||||
guard let number else {
|
||||
self?.component.position = nil
|
||||
return
|
||||
}
|
||||
self?.component.position = number.intValue
|
||||
}.store(in: &subscribers)
|
||||
|
||||
}
|
||||
|
||||
func setupModel() {
|
||||
//setup UI
|
||||
component.numberOfSlides = 8
|
||||
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
|
||||
component.onScrubberDidChange = { [weak self] scrubberId in
|
||||
@ -72,7 +70,7 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
|
||||
}
|
||||
}
|
||||
|
||||
func setupPicker(){
|
||||
func setupPicker() {
|
||||
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.surface = item
|
||||
self?.contentTopView.backgroundColor = item.color
|
||||
@ -80,7 +78,7 @@ class CarouselScrollbarViewConttroller: BaseViewController<CarouselScrollbar> {
|
||||
|
||||
layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in
|
||||
self?.component.selectedLayout = item
|
||||
self?.component.position = Int(self?.positionTextField.text ?? "1")
|
||||
self?.component.position = Int(self?.positionTextField.text ?? "1") ?? 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user