From 9dc45cb53fd629b77cee213d5714946a74bfa82c Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 7 Sep 2020 03:42:04 +0200 Subject: [PATCH] Added context menu item to navigate to settings dialog --- .../ui/views/BankAccountListItem.swift | 14 ++++++++++++++ .../BankingiOSApp/ui/views/BankListItem.swift | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift index eee85105..036c636f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift @@ -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)) + } + } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift index 7d540910..e81812de 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift @@ -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) }