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)
}.frame(height: 35)
}
.contextMenu {
Button(action: { self.navigateToBankAccountSettingsDialog() }) {
HStack {
Text("Settings")
Image(systemName: "gear")
}
}
}
.onTapGesture {
self.navigateToAccountTransactionsDialog = true
}
}
private func navigateToBankAccountSettingsDialog() {
SceneDelegate.navigateToView(BankAccountSettingsDialog(account))
}
}

View File

@ -24,6 +24,14 @@ struct BankListItem : View {
}
.frame(height: 35)
.contextMenu {
Button(action: { self.navigateToBankSettingsDialog() }) {
HStack {
Text("Settings")
Image(systemName: "gear")
}
}
Button(action: askUserToDeleteAccount) {
HStack {
Text("Delete account")
@ -45,8 +53,12 @@ struct BankListItem : View {
}
}
private func navigateToBankSettingsDialog() {
SceneDelegate.navigateToView(BankSettingsDialog(bank))
}
func askUserToDeleteAccount() {
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
// TODO: use values from Message.createAskUserToDeleteAccountMessage(self.bank, self.deleteAccount)
UIAlert(
@ -57,7 +69,7 @@ struct BankListItem : View {
).show()
}
func deleteAccount(_ bank: Customer) {
private func deleteAccount(_ bank: Customer) {
presenter.deleteAccount(customer: bank)
}