diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/Message.swift b/ui/BankingiOSApp/BankingiOSApp/ui/Message.swift index 46f2d332..c0a34926 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/Message.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/Message.swift @@ -1,8 +1,29 @@ import Foundation +import SwiftUI struct Message: Identifiable { let id = UUID() - let text: String + let title: Text + + let message: Text? + + + init(title: Text = Text(""), message: Text? = nil) { + self.title = title + self.message = message + } + + init(title: String = "", message: String? = nil) { + self.title = Text(title) + + if let text = message { + self.message = Text(text) + } + else { + self.message = nil + } + } + } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift index 9dffbe76..71253f50 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift @@ -48,7 +48,7 @@ struct AddAccountDialog: View { } } .alert(item: $errorMessage) { message in - Alert(title: Text("Could not add account"), message: Text("Error message from your bank \(message.text)"), dismissButton: Alert.Button.cancel()) + Alert(title: message.title, message: message.message, dismissButton: Alert.Button.cancel())) } .navigationBarTitle(Text("Add account"), displayMode: NavigationBarItem.TitleDisplayMode.inline) } @@ -77,7 +77,7 @@ struct AddAccountDialog: View { presentation.wrappedValue.dismiss() } else { - self.errorMessage = Message(text: (response.errorToShowToUser ?? "")) + self.errorMessage = Message(title: Text("Could not add account"), message: Text("Error message from your bank \(response.errorToShowToUser ?? "")")) } } }