Added Alert.Button.ok()

This commit is contained in:
dankito 2020-07-17 20:14:40 +02:00
parent 89d6ea1002
commit 6100810c16
2 changed files with 12 additions and 3 deletions

View File

@ -9,4 +9,13 @@ extension View {
.navigationBarTitle("Title") .navigationBarTitle("Title")
} }
} }
extension Alert.Button {
public static func ok(_ action: (() -> Void)? = {}) -> Alert.Button {
return .default(Text("OK"), action: action)
}
}

View File

@ -45,7 +45,7 @@ struct AddAccountDialog: View {
} }
} }
.alert(item: $errorMessage) { message in .alert(item: $errorMessage) { message in
Alert(title: message.title, message: message.message, dismissButton: Alert.Button.cancel())) Alert(title: message.title, message: message.message, dismissButton: .ok())
} }
.navigationBarTitle(Text("Add account"), displayMode: NavigationBarItem.TitleDisplayMode.inline) .navigationBarTitle(Text("Add account"), displayMode: NavigationBarItem.TitleDisplayMode.inline)
} }
@ -84,4 +84,4 @@ struct AddAccountDialog_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
AddAccountDialog() AddAccountDialog()
} }
} }