Implemented convenience method to show an Alert from a Message
This commit is contained in:
parent
7dc43aa369
commit
6b922fc2c6
|
@ -105,6 +105,19 @@ extension View {
|
||||||
method()
|
method()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func alert(message: Binding<Message?>) -> some View {
|
||||||
|
return self.alert(item: message) { message in
|
||||||
|
if let seconaryButton = message.secondaryButton {
|
||||||
|
return Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: seconaryButton)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,6 +136,8 @@ extension Color {
|
||||||
|
|
||||||
static let systemGroupedBackground = Color(UIColor.systemGroupedBackground)
|
static let systemGroupedBackground = Color(UIColor.systemGroupedBackground)
|
||||||
|
|
||||||
|
// There are more..
|
||||||
|
|
||||||
static var destructive: Color {
|
static var destructive: Color {
|
||||||
if UIColor.responds(to: Selector(("_systemDestructiveTintColor"))) {
|
if UIColor.responds(to: Selector(("_systemDestructiveTintColor"))) {
|
||||||
if let red = UIColor.perform(Selector(("_systemDestructiveTintColor")))?.takeUnretainedValue() as? UIColor {
|
if let red = UIColor.perform(Selector(("_systemDestructiveTintColor")))?.takeUnretainedValue() as? UIColor {
|
||||||
|
@ -132,22 +147,20 @@ extension Color {
|
||||||
|
|
||||||
return Color.red
|
return Color.red
|
||||||
}
|
}
|
||||||
|
|
||||||
// There are more..
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extension Alert.Button {
|
extension Alert.Button {
|
||||||
|
|
||||||
public static func `default`(_ label: String, _ action: (() -> Void)? = {}) -> Alert.Button {
|
static func `default`(_ label: String, _ action: (() -> Void)? = {}) -> Alert.Button {
|
||||||
return .default(Text(label), action: action)
|
return .default(Text(label), action: action)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ok(_ action: (() -> Void)? = {}) -> Alert.Button {
|
static func ok(_ action: (() -> Void)? = {}) -> Alert.Button {
|
||||||
return .default("OK", action)
|
return .default("OK", action)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func discard(_ action: (() -> Void)? = {}) -> Alert.Button {
|
static func discard(_ action: (() -> Void)? = {}) -> Alert.Button {
|
||||||
return .destructive(Text("Discard"), action: action)
|
return .destructive(Text("Discard"), action: action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,9 +155,7 @@ struct AccountTransactionsDialog: View {
|
||||||
.executeMutatingMethod {
|
.executeMutatingMethod {
|
||||||
self.showFetchAllTransactionsOverlay = self.shouldShowFetchAllTransactionsOverlay
|
self.showFetchAllTransactionsOverlay = self.shouldShowFetchAllTransactionsOverlay
|
||||||
}
|
}
|
||||||
.alert(item: $errorMessage) { message in
|
.alert(message: $errorMessage)
|
||||||
Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
|
||||||
}
|
|
||||||
.showNavigationBarTitle(LocalizedStringKey(title))
|
.showNavigationBarTitle(LocalizedStringKey(title))
|
||||||
.navigationBarItems(trailing: UpdateButton { _, executingDone in self.updateTransactions(executingDone) })
|
.navigationBarItems(trailing: UpdateButton { _, executingDone in self.updateTransactions(executingDone) })
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,7 @@ struct AddAccountDialog: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
.alert(item: $errorMessage) { message in
|
.alert(message: $errorMessage)
|
||||||
Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
|
||||||
}
|
|
||||||
.fixKeyboardCoversLowerPart()
|
.fixKeyboardCoversLowerPart()
|
||||||
.showNavigationBarTitle("Add account")
|
.showNavigationBarTitle("Add account")
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,7 @@ struct BankAccountSettingsDialog: View {
|
||||||
CheckmarkListItem("Supports Instant payment transfer", account.supportsInstantPaymentMoneyTransfer)
|
CheckmarkListItem("Supports Instant payment transfer", account.supportsInstantPaymentMoneyTransfer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.alert(item: $unsavedChangesMessage) { message in
|
.alert(message: $unsavedChangesMessage)
|
||||||
Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!)
|
|
||||||
}
|
|
||||||
.fixKeyboardCoversLowerPart()
|
.fixKeyboardCoversLowerPart()
|
||||||
.showNavigationBarTitle(LocalizedStringKey(account.displayName))
|
.showNavigationBarTitle(LocalizedStringKey(account.displayName))
|
||||||
.setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed)
|
.setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed)
|
||||||
|
|
|
@ -92,9 +92,7 @@ struct BankSettingsDialog: View {
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.alert(item: $askUserToDeleteAccountOrSaveChangesMessage) { message in
|
.alert(message: $askUserToDeleteAccountOrSaveChangesMessage)
|
||||||
Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!)
|
|
||||||
}
|
|
||||||
.fixKeyboardCoversLowerPart()
|
.fixKeyboardCoversLowerPart()
|
||||||
.showNavigationBarTitle(LocalizedStringKey(bank.displayName))
|
.showNavigationBarTitle(LocalizedStringKey(bank.displayName))
|
||||||
.setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed)
|
.setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed)
|
||||||
|
|
|
@ -130,9 +130,7 @@ struct EnterTanDialog: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.alert(item: $errorMessage) { message in
|
.alert(message: $errorMessage)
|
||||||
Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
|
||||||
}
|
|
||||||
.fixKeyboardCoversLowerPart()
|
.fixKeyboardCoversLowerPart()
|
||||||
.showNavigationBarTitle("Enter TAN Dialog Title")
|
.showNavigationBarTitle("Enter TAN Dialog Title")
|
||||||
.customNavigationBarBackButton {
|
.customNavigationBarBackButton {
|
||||||
|
|
|
@ -85,9 +85,7 @@ struct SelectBankDialog: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.alert(item: $errorMessage) { message in
|
.alert(message: $errorMessage)
|
||||||
Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
|
||||||
}
|
|
||||||
.fixKeyboardCoversLowerPart()
|
.fixKeyboardCoversLowerPart()
|
||||||
.showNavigationBarTitle("Select Bank Dialog Title")
|
.showNavigationBarTitle("Select Bank Dialog Title")
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,7 @@ struct SettingsTab: View {
|
||||||
self.navigateToProtectAppSettingsDialog()
|
self.navigateToProtectAppSettingsDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.alert(item: $askToDeleteAccountMessage) { message in
|
.alert(message: $askToDeleteAccountMessage)
|
||||||
Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!)
|
|
||||||
}
|
|
||||||
.showNavigationBarTitle("Settings")
|
.showNavigationBarTitle("Settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,14 +207,7 @@ struct TransferMoneyDialog: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.alert(item: $transferMoneyResponseMessage) { message in
|
.alert(message: $transferMoneyResponseMessage)
|
||||||
if let secondaryButton = message.secondaryButton {
|
|
||||||
return Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: secondaryButton)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.fixKeyboardCoversLowerPart()
|
.fixKeyboardCoversLowerPart()
|
||||||
.showNavigationBarTitle("Transfer Money Dialog Title")
|
.showNavigationBarTitle("Transfer Money Dialog Title")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue