fixed leaks

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-02-26 15:10:32 -06:00
parent 09f4fa7545
commit 6dda644f3b

View File

@ -73,31 +73,34 @@ class NotificationViewController: BaseViewController<VDS.Notification> {
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<VDS.Notification> {
}.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