Made Message more generic
This commit is contained in:
parent
2c0e7bfc08
commit
af1e155106
|
@ -1,8 +1,29 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
|
||||||
struct Message: Identifiable {
|
struct Message: Identifiable {
|
||||||
let id = UUID()
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct AddAccountDialog: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.alert(item: $errorMessage) { message in
|
.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)
|
.navigationBarTitle(Text("Add account"), displayMode: NavigationBarItem.TitleDisplayMode.inline)
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ struct AddAccountDialog: View {
|
||||||
presentation.wrappedValue.dismiss()
|
presentation.wrappedValue.dismiss()
|
||||||
}
|
}
|
||||||
else {
|
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 ?? "")"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue