From e3eefe6f3e40fe34ae56c08be0d46b7542a68f20 Mon Sep 17 00:00:00 2001 From: vasavk Date: Tue, 11 Jun 2024 15:19:23 +0530 Subject: [PATCH] Digital ACT-191 ONEAPP-7013 story: pasing empty data and added width property --- .../CarouselScrollbarViewConttroller.swift | 2 +- .../CarouselViewController.swift | 55 +++++++++++++++---- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift b/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift index 63b0da4..943686d 100644 --- a/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift +++ b/VDSSample/ViewControllers/CarouselScrollbarViewConttroller.swift @@ -114,7 +114,7 @@ class CarouselScrollbarViewConttroller: BaseViewController { } layoutPickerSelectorView.onPickerDidSelect = { [weak self] item in - self?.component.selectedLayout = item + self?.component.layout = item self?.component.position = Int(self?.positionTextField.text ?? "1") ?? 1 } } diff --git a/VDSSample/ViewControllers/CarouselViewController.swift b/VDSSample/ViewControllers/CarouselViewController.swift index 1ac6268..d5779a8 100644 --- a/VDSSample/ViewControllers/CarouselViewController.swift +++ b/VDSSample/ViewControllers/CarouselViewController.swift @@ -20,13 +20,7 @@ class CarouselViewController: BaseViewController { picker: self.picker, items: Carousel.AspectRatio.allCases) }() - - lazy var layoutPickerSelectorView = { - PickerSelectorView(title: "1UP", - picker: self.picker, - items: UIDevice.isIPad ? Carousel.Layout.allCases : [Carousel.Layout.oneUP, Carousel.Layout.twoUP, Carousel.Layout.threeUP]) - }() - + lazy var paginationDisplayPickerSelectorView = { PickerSelectorView(title: "", picker: self.picker, @@ -45,6 +39,12 @@ class CarouselViewController: BaseViewController { items: Carousel.Gutter.allCases) }() + lazy var layoutPickerSelectorView = { + PickerSelectorView(title: "1UP", + picker: self.picker, + items: UIDevice.isIPad ? Carousel.Layout.allCases : [Carousel.Layout.oneUP, Carousel.Layout.twoUP, Carousel.Layout.threeUP]) + }() + lazy var paginationKindPickerSelectorView = { PickerSelectorView(title: "", picker: self.picker, @@ -64,7 +64,9 @@ class CarouselViewController: BaseViewController { }() var paginationFloatingSwitch = Toggle() - var paginationInsetField = TextField() + var paginationInsetField = NumericField() + var widthTextField = NumericField() + var percentageTextField = NumericField() override func viewDidLoad() { super.viewDidLoad() @@ -86,13 +88,41 @@ class CarouselViewController: BaseViewController { addFormRow(label: "Pagination Kind", view: paginationKindPickerSelectorView) addFormRow(label: "Pagination Float", view: paginationFloatingSwitch) addFormRow(label: "Pagination Inset", view: paginationInsetField) + addFormRow(label: "Slot Width", view: widthTextField) + addFormRow(label: "Percentage (1-100)", view: percentageTextField) addFormRow(label: "Slot Horizontal Alignment", view: horizAlignmtPickerSelectorView) addFormRow(label: "Slot Vertical Alignment", view: vertAlignmtPickerSelectorView) - + + widthTextField + .numberPublisher + .sink { [weak self] number in + if let number { + self?.component.width = .value(number.cgFloatValue) + self?.percentageTextField.text = "" + } else { + self?.component.width = nil + } + }.store(in: &subscribers) + + percentageTextField + .numberPublisher + .sink { [weak self] number in + if let number { + self?.component.width = .percentage(number.cgFloatValue) + self?.widthTextField.text = "" + } else { + self?.component.width = nil + } + }.store(in: &subscribers) + paginationInsetField - .textPublisher - .sink { [weak self] text in - self?.component.paginationInset = UIDevice.isIPad ? VDSLayout.space12X : VDSLayout.space8X + .numberPublisher + .sink { [weak self] number in + if let number { + self?.component.paginationInset = number.cgFloatValue + } else { + self?.component.paginationInset = UIDevice.isIPad ? VDSLayout.space12X : VDSLayout.space8X + } }.store(in: &subscribers) paginationFloatingSwitch.onChange = { [weak self] sender in @@ -113,6 +143,7 @@ class CarouselViewController: BaseViewController { paginationFloatingSwitch.isOn = true paginationInsetField.text = UIDevice.isIPad ? "12px" : "8px" paginationInsetField.isUserInteractionEnabled = false + component.data = [{},{},{},{},{},{},{},{},{},{},{},{}] } func setupPicker() {