From 72046c299c6b0dcf0c7995f71d7fd4b03b54e605 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Tue, 13 Feb 2024 22:52:32 +0530 Subject: [PATCH 1/3] Added type picker --- .../NotificationViewController.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/VDSSample/ViewControllers/NotificationViewController.swift b/VDSSample/ViewControllers/NotificationViewController.swift index 6bf5a09..e23c79b 100644 --- a/VDSSample/ViewControllers/NotificationViewController.swift +++ b/VDSSample/ViewControllers/NotificationViewController.swift @@ -33,6 +33,10 @@ class NotificationViewController: BaseViewController { PickerSelectorView(title: "vertical", picker: self.picker, items: Notification.Layout.allCases) }() + lazy var typePickerSelectorView = { + PickerSelectorView(title: "inLine", picker: self.picker, items: Notification.Type.allCases) + }() + override func viewDidLoad() { super.viewDidLoad() addContentTopView(view: component) @@ -54,6 +58,7 @@ class NotificationViewController: BaseViewController { addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Style", view: notificationTypePickerSelectorView) addFormRow(label: "Layout", view: layoutTypePickerSelectorView) + addFormRow(label: "Type", view: typePickerSelectorView) addFormRow(label: "Title", view: titleTextField) addFormRow(label: "SubTitle", view: subTitleTextField) addFormRow(label: "Hide Button Group", view: buttonGroupToggle) @@ -124,6 +129,14 @@ class NotificationViewController: BaseViewController { self.layoutTypePickerSelectorView.set(item: self.component.layout) } } + + typePickerSelectorView.onPickerDidSelect = { [weak self] item in + guard let self else { return } + self.component.type = item + if self.component.type != item { + self.layoutTypePickerSelectorView.set(item: self.component.layout) + } + } } func setupButtons(with firstButtonText: String? = nil, secondButtonText: String? = nil) { From 79ce6dd5925b6cd841fcca8077bd6053c46fd248 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 14 Feb 2024 10:49:09 -0600 Subject: [PATCH 2/3] allow access to primary stackview Signed-off-by: Matt Bruce --- VDSSample/ViewControllers/BaseViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDSSample/ViewControllers/BaseViewController.swift b/VDSSample/ViewControllers/BaseViewController.swift index 3fd5137..3c31212 100644 --- a/VDSSample/ViewControllers/BaseViewController.swift +++ b/VDSSample/ViewControllers/BaseViewController.swift @@ -150,7 +150,7 @@ public class BaseViewController: UIViewController, Initable , public var formStackView = FormSection() - lazy var stackView = UIStackView().with { + public lazy var stackView = UIStackView().with { $0.axis = .vertical $0.distribution = .fill $0.alignment = .fill From 44d3f9435d06f78df86a230b17d47736c0fd845c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 14 Feb 2024 10:49:48 -0600 Subject: [PATCH 3/3] added fullWidth notification at the top of the viewcontroller view stack to mimic "fullBleed". Signed-off-by: Matt Bruce --- .../NotificationViewController.swift | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/VDSSample/ViewControllers/NotificationViewController.swift b/VDSSample/ViewControllers/NotificationViewController.swift index e23c79b..5472a41 100644 --- a/VDSSample/ViewControllers/NotificationViewController.swift +++ b/VDSSample/ViewControllers/NotificationViewController.swift @@ -33,14 +33,21 @@ class NotificationViewController: BaseViewController { PickerSelectorView(title: "vertical", picker: self.picker, items: Notification.Layout.allCases) }() - lazy var typePickerSelectorView = { - PickerSelectorView(title: "inLine", picker: self.picker, items: Notification.Type.allCases) - }() +// lazy var typePickerSelectorView = { +// PickerSelectorView(title: "inLine", picker: self.picker, items: Notification.Type.allCases) +// }() + + var notification = Notification() override func viewDidLoad() { super.viewDidLoad() + + stackView.insertArrangedSubview(notification, at: 0) addContentTopView(view: component) + notification.title = titleDefaultText + notification.subTitle = subtitleDefaultText + component.title = titleDefaultText component.subTitle = subtitleDefaultText titleTextField.text = titleDefaultText @@ -58,7 +65,7 @@ class NotificationViewController: BaseViewController { addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Style", view: notificationTypePickerSelectorView) addFormRow(label: "Layout", view: layoutTypePickerSelectorView) - addFormRow(label: "Type", view: typePickerSelectorView) +// addFormRow(label: "Type", view: typePickerSelectorView) addFormRow(label: "Title", view: titleTextField) addFormRow(label: "SubTitle", view: subTitleTextField) addFormRow(label: "Hide Button Group", view: buttonGroupToggle) @@ -73,16 +80,21 @@ class NotificationViewController: BaseViewController { titleTextField.textPublisher.sink { newString in self.component.title = newString + self.notification.title = newString }.store(in: &subscribers) subTitleTextField.textPublisher.sink { newString in self.component.subTitle = newString + self.notification.subTitle = newString }.store(in: &subscribers) buttonGroupToggle.onChange = { [weak self] toggle in if toggle.isOn { self?.component.primaryButtonModel = nil self?.component.secondaryButtonModel = nil + self?.notification.primaryButtonModel = nil + self?.notification.secondaryButtonModel = nil + self?.label.text = "" } else { self?.setupButtons(with: self?.firstButtonDefaultText, secondButtonText: self?.secondButtonDefaultText) @@ -108,6 +120,7 @@ class NotificationViewController: BaseViewController { hideCloseButtonToggle.onChange = { [weak self] toggle in self?.component.hideCloseButton = toggle.isOn + self?.notification.hideCloseButton = toggle.isOn } } @@ -115,28 +128,31 @@ class NotificationViewController: BaseViewController { func setupPicker() { surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.surface = item + self?.notification.surface = item self?.contentTopView.backgroundColor = item.color } notificationTypePickerSelectorView.onPickerDidSelect = { [weak self] item in self?.component.style = item + self?.notification.style = item } layoutTypePickerSelectorView.onPickerDidSelect = { [weak self] item in guard let self else { return } self.component.layout = item + self.notification.layout = item if self.component.layout != item { self.layoutTypePickerSelectorView.set(item: self.component.layout) } } - typePickerSelectorView.onPickerDidSelect = { [weak self] item in - guard let self else { return } - self.component.type = item - if self.component.type != item { - self.layoutTypePickerSelectorView.set(item: self.component.layout) - } - } +// typePickerSelectorView.onPickerDidSelect = { [weak self] item in +// guard let self else { return } +// self.component.type = item +// if self.component.type != item { +// self.layoutTypePickerSelectorView.set(item: self.component.layout) +// } +// } } func setupButtons(with firstButtonText: String? = nil, secondButtonText: String? = nil) { @@ -144,12 +160,18 @@ class NotificationViewController: BaseViewController { component.primaryButtonModel = .init(text: firstButtonText, onClick: { [weak self] button in self?.label.text = "\(button.text!) button click" }) + notification.primaryButtonModel = .init(text: firstButtonText, onClick: { [weak self] button in + self?.label.text = "\(button.text!) button click" + }) } if let secondButtonText { component.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in self?.label.text = "\(button.text!) button click" }) + notification.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in + self?.label.text = "\(button.text!) button click" + }) } } }