From 3879d65833ab10d98a1e27ba56f1c0dde7fa7f54 Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 17 Jul 2020 20:35:24 +0200 Subject: [PATCH] Added primaryButton and secondaryButton to Message --- ui/BankingiOSApp/BankingiOSApp/ui/Message.swift | 14 ++++++++++++-- .../BankingiOSApp/ui/views/AddAccountDialog.swift | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/Message.swift b/ui/BankingiOSApp/BankingiOSApp/ui/Message.swift index c0a34926..cc831db1 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/Message.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/Message.swift @@ -9,13 +9,20 @@ struct Message: Identifiable { let message: Text? + let primaryButton: Alert.Button - init(title: Text = Text(""), message: Text? = nil) { + let secondaryButton: Alert.Button? + + + init(title: Text = Text(""), message: Text? = nil, primaryButton: Alert.Button = .ok(), secondaryButton: Alert.Button? = nil) { self.title = title self.message = message + + self.primaryButton = primaryButton + self.secondaryButton = secondaryButton } - init(title: String = "", message: String? = nil) { + init(title: String = "", message: String? = nil, primaryButton: Alert.Button = .ok(), secondaryButton: Alert.Button? = nil) { self.title = Text(title) if let text = message { @@ -24,6 +31,9 @@ struct Message: Identifiable { else { self.message = nil } + + self.primaryButton = primaryButton + self.secondaryButton = secondaryButton } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift index 1b8b1710..f9d080d3 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift @@ -45,7 +45,7 @@ struct AddAccountDialog: View { } } .alert(item: $errorMessage) { message in - Alert(title: message.title, message: message.message, dismissButton: .ok()) + Alert(title: message.title, message: message.message, dismissButton: message.primaryButton) } .navigationBarTitle(Text("Add account"), displayMode: NavigationBarItem.TitleDisplayMode.inline) }