Added primaryButton and secondaryButton to Message

This commit is contained in:
dankito 2020-07-17 20:35:24 +02:00
parent 6100810c16
commit 3879d65833
2 changed files with 13 additions and 3 deletions

View File

@ -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
}
}

View File

@ -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)
}