diff --git a/VDSSample/ViewControllers/NotificationViewController.swift b/VDSSample/ViewControllers/NotificationViewController.swift index 5501496..6fd3fbc 100644 --- a/VDSSample/ViewControllers/NotificationViewController.swift +++ b/VDSSample/ViewControllers/NotificationViewController.swift @@ -97,7 +97,7 @@ class NotificationViewController: BaseViewController { secondButtonTextField.textPublisher.sink { [weak self] newString in guard let self else { return } if !(self.firstButtonTextField.text?.isEmpty ?? true){ - self.setupButtons(secondButtonText: newString) + self.setupButtons(with: self.firstButtonTextField.text, secondButtonText: newString) } }.store(in: &subscribers) @@ -122,16 +122,20 @@ class NotificationViewController: BaseViewController { } func setupButtons(with firstButtonText: String? = nil, secondButtonText: String? = nil) { - if let firstButtonText { + if let firstButtonText, !firstButtonText.isEmpty { component.primaryButtonModel = .init(text: firstButtonText, onClick: { [weak self] button in self?.label.text = "\(button.text!) button click" }) + } else { + component.primaryButtonModel = nil } - if let secondButtonText { + if let secondButtonText, !secondButtonText.isEmpty { component.secondaryButtonModel = .init(text: secondButtonText, onClick: { [weak self] button in self?.label.text = "\(button.text!) button click" }) + } else { + component.secondaryButtonModel = nil } } }