Added context menu item to navigate to settings dialog

This commit is contained in:
dankito 2020-09-07 03:42:04 +02:00
parent 874d78d6ad
commit 9dc45cb53f
2 changed files with 28 additions and 2 deletions

View File

@ -19,11 +19,25 @@ struct BankAccountListItem : View {
AmountLabel(amount: account.balance) AmountLabel(amount: account.balance)
}.frame(height: 35) }.frame(height: 35)
} }
.contextMenu {
Button(action: { self.navigateToBankAccountSettingsDialog() }) {
HStack {
Text("Settings")
Image(systemName: "gear")
}
}
}
.onTapGesture { .onTapGesture {
self.navigateToAccountTransactionsDialog = true self.navigateToAccountTransactionsDialog = true
} }
} }
private func navigateToBankAccountSettingsDialog() {
SceneDelegate.navigateToView(BankAccountSettingsDialog(account))
}
} }

View File

@ -24,6 +24,14 @@ struct BankListItem : View {
} }
.frame(height: 35) .frame(height: 35)
.contextMenu { .contextMenu {
Button(action: { self.navigateToBankSettingsDialog() }) {
HStack {
Text("Settings")
Image(systemName: "gear")
}
}
Button(action: askUserToDeleteAccount) { Button(action: askUserToDeleteAccount) {
HStack { HStack {
Text("Delete account") Text("Delete account")
@ -46,7 +54,11 @@ struct BankListItem : View {
} }
func askUserToDeleteAccount() { private func navigateToBankSettingsDialog() {
SceneDelegate.navigateToView(BankSettingsDialog(bank))
}
private func askUserToDeleteAccount() {
// couldn't believe it, .alert() didn't work as SwiftUI resetted @State variable to dislpay it instantly, therefore Alert never got displayed // couldn't believe it, .alert() didn't work as SwiftUI resetted @State variable to dislpay it instantly, therefore Alert never got displayed
// TODO: use values from Message.createAskUserToDeleteAccountMessage(self.bank, self.deleteAccount) // TODO: use values from Message.createAskUserToDeleteAccountMessage(self.bank, self.deleteAccount)
UIAlert( UIAlert(
@ -57,7 +69,7 @@ struct BankListItem : View {
).show() ).show()
} }
func deleteAccount(_ bank: Customer) { private func deleteAccount(_ bank: Customer) {
presenter.deleteAccount(customer: bank) presenter.deleteAccount(customer: bank)
} }