diff --git a/VDSSample/ViewControllers/NotificationViewController.swift b/VDSSample/ViewControllers/NotificationViewController.swift index ffc468e..075897c 100644 --- a/VDSSample/ViewControllers/NotificationViewController.swift +++ b/VDSSample/ViewControllers/NotificationViewController.swift @@ -73,31 +73,34 @@ class NotificationViewController: BaseViewController { print("onCloseClick: \(notification.title)") } - titleTextField.textPublisher.sink { newString in + titleTextField.textPublisher.sink { [weak self] newString in + guard let self else { return } self.component.title = newString self.notification.title = newString }.store(in: &subscribers) - subTitleTextField.textPublisher.sink { newString in + subTitleTextField.textPublisher.sink { [weak self] newString in + guard let self else { return } self.component.subTitle = newString self.notification.subTitle = newString }.store(in: &subscribers) buttonGroupToggle.onChange = { [weak self] toggle in + guard let self else { return } if toggle.isOn { - self?.component.primaryButtonModel = nil - self?.component.secondaryButtonModel = nil - self?.notification.primaryButtonModel = nil - self?.notification.secondaryButtonModel = nil + self.component.primaryButtonModel = nil + self.component.secondaryButtonModel = nil + self.notification.primaryButtonModel = nil + self.notification.secondaryButtonModel = nil - self?.label.text = "" + self.label.text = "" } else { - self?.setupButtons(with: self?.firstButtonDefaultText, secondButtonText: self?.secondButtonDefaultText) + self.setupButtons(with: self.firstButtonDefaultText, secondButtonText: self.secondButtonDefaultText) } } - firstButtonTextField.textPublisher.sink { newString in - + firstButtonTextField.textPublisher.sink { [weak self] newString in + guard let self else { return } if newString.isEmpty { self.component.primaryButtonModel = nil self.component.secondaryButtonModel = nil @@ -107,29 +110,33 @@ class NotificationViewController: BaseViewController { }.store(in: &subscribers) - secondButtonTextField.textPublisher.sink { newString in + secondButtonTextField.textPublisher.sink { [weak self] newString in + guard let self else { return } if !(self.firstButtonTextField.text?.isEmpty ?? true){ self.setupButtons(secondButtonText: newString) } }.store(in: &subscribers) hideCloseButtonToggle.onChange = { [weak self] toggle in - self?.component.hideCloseButton = toggle.isOn - self?.notification.hideCloseButton = toggle.isOn + guard let self else { return } + self.component.hideCloseButton = toggle.isOn + self.notification.hideCloseButton = toggle.isOn } } func setupPicker() { surfacePickerSelectorView.onPickerDidSelect = { [weak self] item in - self?.component.surface = item - self?.notification.surface = item - self?.contentTopView.backgroundColor = item.color + guard let self else { return } + 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 + guard let self else { return } + self.component.style = item + self.notification.style = item } layoutTypePickerSelectorView.onPickerDidSelect = { [weak self] item in