diff --git a/VDSSample/Protocols/PickerBase.swift b/VDSSample/Protocols/PickerBase.swift index d589d37..201b8d4 100644 --- a/VDSSample/Protocols/PickerBase.swift +++ b/VDSSample/Protocols/PickerBase.swift @@ -56,6 +56,7 @@ public class PickerSelectorView: UIStackView, Picker updateSelectedIndex() } } + public var items: [EnumType] { didSet { selectedIndex = 0 } } @@ -117,6 +118,13 @@ public class PickerSelectorView: UIStackView, Picker return label } + public func set(item: EnumType) { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.001) { [weak self] in + guard let self else { return } + self.text = "\(item.rawValue)" + } + } + private func title(for row: Int) -> String { guard let item = items[row].rawValue as? String else { return "" } return item diff --git a/VDSSample/ViewControllers/NotificationViewController.swift b/VDSSample/ViewControllers/NotificationViewController.swift index 4e62b3d..dae2c80 100644 --- a/VDSSample/ViewControllers/NotificationViewController.swift +++ b/VDSSample/ViewControllers/NotificationViewController.swift @@ -29,8 +29,8 @@ class NotificationViewController: BaseViewController { items: Notification.NotificationStyle.allCases) }() - lazy var buttonPositionTypePickerSelectorView = { - PickerSelectorView(title: "bottom", picker: self.picker, items: Notification.ButtonsPosition.allCases) + lazy var layoutTypePickerSelectorView = { + PickerSelectorView(title: "vertical", picker: self.picker, items: Notification.Layout.allCases) }() override func viewDidLoad() { @@ -54,7 +54,7 @@ class NotificationViewController: BaseViewController { func setupForm() { addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Style", view: notificationTypePickerSelectorView) - addFormRow(label: "Button Position", view: buttonPositionTypePickerSelectorView) + addFormRow(label: "Layout", view: layoutTypePickerSelectorView) addFormRow(label: "Title", view: titleTextField) addFormRow(label: "SubTitle", view: subTitleTextField) addFormRow(label: "Hide Button Group", view: buttonGroupToggle) @@ -113,8 +113,12 @@ class NotificationViewController: BaseViewController { self?.notificationView.type = item } - buttonPositionTypePickerSelectorView.onPickerDidSelect = { [weak self] item in - self?.notificationView.buttonPosition = item + layoutTypePickerSelectorView.onPickerDidSelect = { [weak self] item in + guard let self else { return } + self.notificationView.layout = item + if self.notificationView.layout != item { + self.layoutTypePickerSelectorView.set(item: self.notificationView.layout) + } } }