Added primaryButton and secondaryButton to Message
This commit is contained in:
parent
6100810c16
commit
3879d65833
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue