From fb292038f37eb6917b9f05c8eb95661a80a18cd8 Mon Sep 17 00:00:00 2001 From: Vasavi Kanamarlapudi Date: Fri, 27 Sep 2024 18:57:14 +0530 Subject: [PATCH] Digital ACT-191 ONEAPP-10928 story: updating flags for hide close button, single butting for dialog, show/hide footer on modal --- .../ViewControllers/ModalViewController.swift | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/VDSSample/ViewControllers/ModalViewController.swift b/VDSSample/ViewControllers/ModalViewController.swift index 351e97d..9d2764a 100644 --- a/VDSSample/ViewControllers/ModalViewController.swift +++ b/VDSSample/ViewControllers/ModalViewController.swift @@ -17,10 +17,6 @@ class ModalViewController: BaseViewController { var fullScreenDialogSwitch = Toggle() var singleButtonSwitch = Toggle() var hideCloseSwitch = Toggle() - var disableAnimationSwitch = Toggle() - var disableOutsideSwitch = Toggle() - var openedSwitch = Toggle() - var enableBackSwitch = Toggle() var titleTextField = TextField() var bodyTextField = TextField() @@ -42,18 +38,35 @@ class ModalViewController: BaseViewController { addFormRow(label: "Full Screen Dialog", view: fullScreenDialogSwitch, pinTrailing: false) addFormRow(label: "Single Button", view: singleButtonSwitch, pinTrailing: false) addFormRow(label: "Hide Close Button", view: hideCloseSwitch, pinTrailing: false) - addFormRow(label: "Disable Animation", view: disableAnimationSwitch, pinTrailing: false) - addFormRow(label: "Disable Outside Click", view: disableOutsideSwitch, pinTrailing: false) - addFormRow(label: "Opened", view: openedSwitch, pinTrailing: false) addFormRow(label: "Modal Title", view: titleTextField) addFormRow(label: "Modal Body", view: bodyTextField) - addFormRow(label: "Enable Back Button", view: enableBackSwitch, pinTrailing: false) addFormRow(label: "Max Height", view: heightTextField) addFormRow(label: "Max Width", view: widthTextField) fullScreenDialogSwitch.publisher(for: .valueChanged).sink { [weak self] control in self?.component.fullScreenDialog = control.isOn }.store(in: &subscribers) + + showFooterSwitch.publisher(for: .valueChanged).sink { [weak self] control in + guard let self else { return } + if control.isOn { + showFooter(with: singleButtonSwitch.isOn) + } else { + self.component.buttonData = nil + } + }.store(in: &subscribers) + + singleButtonSwitch.publisher(for: .valueChanged).sink { [weak self] control in + guard let self else { return } + if control.isOn { + showFooterSwitch.isOn = true + } + showFooter(with: control.isOn) + }.store(in: &subscribers) + + hideCloseSwitch.publisher(for: .valueChanged).sink { [weak self] control in + self?.component.hideCloseButton = control.isOn + }.store(in: &subscribers) titleTextField .textPublisher @@ -69,6 +82,19 @@ class ModalViewController: BaseViewController { } + func showFooter(with singleButton: Bool) { + if singleButton { + component.buttonData = [ + Button().with{ $0.use = .secondary; $0.text = "Close"; $0.onClick = { button in self.dismiss(animated: true); print("\(button.text!) clicked")} ; $0.size = .large } + ] + } else { + component.buttonData = [ + Button().with{ $0.use = .primary; $0.text = "In-store Pickup"; $0.onClick = { button in print("\(button.text!) clicked")}; $0.size = .large }, + Button().with{ $0.use = .secondary; $0.text = "Close"; $0.onClick = { button in self.dismiss(animated: true); print("\(button.text!) clicked")} ; $0.size = .large } + ] + } + } + func setupModel() { component.title = "Choose free 2-day shipping or In-store Pickup" component.content = "Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed. \n \n Order online, pickup in store, or get free 2-day shipping. Free 2-day shipping available for device and accessory orders of $49 or more. Free 2-day shipping when you order online M-F by 8PM EST. In-Store Pickup is available across the U.S. at participating Verizon Wireless stores. Please bring photo ID and credit/debit card only if used as payment. Order will be held for 3 days from the time if was placed." @@ -83,6 +109,7 @@ class ModalViewController: BaseViewController { surfacePickerSelectorView.text = component.surface.rawValue titleTextField.text = component.title bodyTextField.text = component.content + showFooterSwitch.isOn = true } //Picker