added fullWidth notification at the top of the viewcontroller view stack to mimic "fullBleed".

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-02-14 10:49:48 -06:00
parent 79ce6dd592
commit 44d3f9435d

View File

@ -33,14 +33,21 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
PickerSelectorView(title: "vertical", picker: self.picker, items: Notification.Layout.allCases) PickerSelectorView(title: "vertical", picker: self.picker, items: Notification.Layout.allCases)
}() }()
lazy var typePickerSelectorView = { // lazy var typePickerSelectorView = {
PickerSelectorView(title: "inLine", picker: self.picker, items: Notification.Type.allCases) // PickerSelectorView(title: "inLine", picker: self.picker, items: Notification.Type.allCases)
}() // }()
var notification = Notification()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
stackView.insertArrangedSubview(notification, at: 0)
addContentTopView(view: component) addContentTopView(view: component)
notification.title = titleDefaultText
notification.subTitle = subtitleDefaultText
component.title = titleDefaultText component.title = titleDefaultText
component.subTitle = subtitleDefaultText component.subTitle = subtitleDefaultText
titleTextField.text = titleDefaultText titleTextField.text = titleDefaultText
@ -58,7 +65,7 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
addFormRow(label: "Surface", view: surfacePickerSelectorView) addFormRow(label: "Surface", view: surfacePickerSelectorView)
addFormRow(label: "Style", view: notificationTypePickerSelectorView) addFormRow(label: "Style", view: notificationTypePickerSelectorView)
addFormRow(label: "Layout", view: layoutTypePickerSelectorView) addFormRow(label: "Layout", view: layoutTypePickerSelectorView)
addFormRow(label: "Type", view: typePickerSelectorView) // addFormRow(label: "Type", view: typePickerSelectorView)
addFormRow(label: "Title", view: titleTextField) addFormRow(label: "Title", view: titleTextField)
addFormRow(label: "SubTitle", view: subTitleTextField) addFormRow(label: "SubTitle", view: subTitleTextField)
addFormRow(label: "Hide Button Group", view: buttonGroupToggle) addFormRow(label: "Hide Button Group", view: buttonGroupToggle)
@ -73,16 +80,21 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
titleTextField.textPublisher.sink { newString in titleTextField.textPublisher.sink { newString in
self.component.title = newString self.component.title = newString
self.notification.title = newString
}.store(in: &subscribers) }.store(in: &subscribers)
subTitleTextField.textPublisher.sink { newString in subTitleTextField.textPublisher.sink { newString in
self.component.subTitle = newString self.component.subTitle = newString
self.notification.subTitle = newString
}.store(in: &subscribers) }.store(in: &subscribers)
buttonGroupToggle.onChange = { [weak self] toggle in buttonGroupToggle.onChange = { [weak self] toggle in
if toggle.isOn { if toggle.isOn {
self?.component.primaryButtonModel = nil self?.component.primaryButtonModel = nil
self?.component.secondaryButtonModel = nil self?.component.secondaryButtonModel = nil
self?.notification.primaryButtonModel = nil
self?.notification.secondaryButtonModel = nil
self?.label.text = "" self?.label.text = ""
} else { } else {
self?.setupButtons(with: self?.firstButtonDefaultText, secondButtonText: self?.secondButtonDefaultText) self?.setupButtons(with: self?.firstButtonDefaultText, secondButtonText: self?.secondButtonDefaultText)
@ -108,6 +120,7 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
hideCloseButtonToggle.onChange = { [weak self] toggle in hideCloseButtonToggle.onChange = { [weak self] toggle in
self?.component.hideCloseButton = toggle.isOn self?.component.hideCloseButton = toggle.isOn
self?.notification.hideCloseButton = toggle.isOn
} }
} }
@ -115,28 +128,31 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
func setupPicker() { func setupPicker() {
surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.surface = item self?.component.surface = item
self?.notification.surface = item
self?.contentTopView.backgroundColor = item.color self?.contentTopView.backgroundColor = item.color
} }
notificationTypePickerSelectorView.onPickerDidSelect = { [weak self] item in notificationTypePickerSelectorView.onPickerDidSelect = { [weak self] item in
self?.component.style = item self?.component.style = item
self?.notification.style = item
} }
layoutTypePickerSelectorView.onPickerDidSelect = { [weak self] item in layoutTypePickerSelectorView.onPickerDidSelect = { [weak self] item in
guard let self else { return } guard let self else { return }
self.component.layout = item self.component.layout = item
self.notification.layout = item
if self.component.layout != item { if self.component.layout != item {
self.layoutTypePickerSelectorView.set(item: self.component.layout) self.layoutTypePickerSelectorView.set(item: self.component.layout)
} }
} }
typePickerSelectorView.onPickerDidSelect = { [weak self] item in // typePickerSelectorView.onPickerDidSelect = { [weak self] item in
guard let self else { return } // guard let self else { return }
self.component.type = item // self.component.type = item
if self.component.type != item { // if self.component.type != item {
self.layoutTypePickerSelectorView.set(item: self.component.layout) // self.layoutTypePickerSelectorView.set(item: self.component.layout)
} // }
} // }
} }
func setupButtons(with firstButtonText: String? = nil, secondButtonText: String? = nil) { func setupButtons(with firstButtonText: String? = nil, secondButtonText: String? = nil) {
@ -144,12 +160,18 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
component.primaryButtonModel = .init(text: firstButtonText, onClick: { [weak self] button in component.primaryButtonModel = .init(text: firstButtonText, onClick: { [weak self] button in
self?.label.text = "\(button.text!) button click" 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 { if let secondButtonText {
component.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in component.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in
self?.label.text = "\(button.text!) button click" self?.label.text = "\(button.text!) button click"
}) })
notification.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in
self?.label.text = "\(button.text!) button click"
})
} }
} }
} }