From 842485fb4906be4749b37c9a272d4b4d98eed0ef Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 11 Apr 2024 14:50:55 -0500 Subject: [PATCH] ui bug for notification Signed-off-by: Matt Bruce --- .../ViewControllers/NotificationViewController.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 } } }