From ca214457ca0ae0630cc5361345391e3ce776f138 Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 28 Jul 2020 11:03:39 +0200 Subject: [PATCH] Implemented showing balance in AllBanksListItem, BankAccountListItem and BankListItem; extracted AmountLabel for that --- .../BankingiOSApp/ContentView.swift | 15 +++++++----- .../BankingiOSApp/ui/AmountLabel.swift | 23 +++++++++++++++++++ .../ui/views/AccountTransactionListItem.swift | 3 +-- .../ui/views/AccountTransactionsDialog.swift | 3 +-- .../ui/views/AllBanksListItem.swift | 2 ++ .../ui/views/BankAccountListItem.swift | 3 +++ .../BankingiOSApp/ui/views/BankListItem.swift | 2 ++ 7 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/AmountLabel.swift diff --git a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift index 27516cd7..1d64e4b6 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift @@ -38,13 +38,13 @@ struct ContentView: View { TanMedium(displayName: "Handy mit Nummer 0170 / 12345678", status: .available) ] - self.enterTanState = EnterTanState(customer, TanChallenge(messageToShowToUser: "Gib die TAN ein du faules Stueck!", tanProcedure: selectedTanProcedure)) { result in } + self.enterTanState = EnterTanState(customer, TanChallenge(messageToShowToUser: "Gib die TAN ein du faules Stueck!\nAber jetzt manchen wir mal eine richtig, richtig lange Nachricht daraus.\nMal schauen, ob mir so viel Quatsch ueberhaupt einfaellt (aber anscheinend scheine ich sehr kreativ zu sein).", tanProcedure: selectedTanProcedure)) { result in } } var body: some View { // NavigationView { - VStack { +// VStack { TabView(selection: $selection) { AccountsTab(data: data) .onAppear { @@ -121,13 +121,15 @@ struct ContentView: View { } .tag(1) - NavigationView { EnterTanDialog(self.enterTanState) } + EnterTanDialog(self.enterTanState) .tabItem { VStack { Text("EnterTanDialog") } } - .tag(2) + .tag(3) + .navigationBarHidden(false) + .navigationBarTitle("Enter TAN") } .navigationBarHidden(false) @@ -135,8 +137,9 @@ struct ContentView: View { .navigationBarItems(leading: leadingNavigationBarItem) - } - .hideNavigationBar() +// } + //.hideNavigationBar() + //.navigationViewStyle(StackNavigationViewStyle()) // see https://stackoverflow.com/questions/59338711/swiftui-bug-navigationview-and-list-not-showing-on-ipad-simulator-only // } } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/AmountLabel.swift b/ui/BankingiOSApp/BankingiOSApp/ui/AmountLabel.swift new file mode 100644 index 00000000..cf859669 --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/AmountLabel.swift @@ -0,0 +1,23 @@ +import SwiftUI +import BankingUiSwift + + +struct AmountLabel: View { + + let amount: CommonBigDecimal + + @Inject private var presenter: BankingPresenterSwift + + + var body: some View { + Text(presenter.formatAmount(amount: amount)) + .styleAmount(amount: amount) + } +} + + +struct AmountLabel_Previews: PreviewProvider { + static var previews: some View { + AmountLabel(amount: CommonBigDecimal(double: 84.12)) + } +} diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionListItem.swift index c129eccd..4432b6e8 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionListItem.swift @@ -40,8 +40,7 @@ struct AccountTransactionListItem: View { Spacer() VStack(alignment: .trailing) { - Text(presenter.formatAmount(amount: transaction.amount)) - .styleAmount(amount: transaction.amount) + AmountLabel(amount: transaction.amount) Spacer() diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift index 1c1982cc..c1acab86 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountTransactionsDialog.swift @@ -69,8 +69,7 @@ struct AccountTransactionsDialog: View { Spacer() - Text(presenter.formatAmount(amount: balanceOfFilteredTransactions)) - .styleAmount(amount: balanceOfFilteredTransactions) + AmountLabel(amount: balanceOfFilteredTransactions) } .padding(.horizontal) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift index bbec0d01..13c87f55 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AllBanksListItem.swift @@ -15,6 +15,8 @@ struct AllBanksListItem: View { .font(.headline) Spacer() + + AmountLabel(amount: banks.sumBalances()) }.frame(height: 35) NavigationLink(destination: LazyView(AccountTransactionsDialog(allBanks: self.banks))) { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift index 04ad101b..ebc753c7 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift @@ -11,7 +11,10 @@ struct BankAccountListItem : View { ZStack { HStack { Text(account.displayName) + Spacer() + + AmountLabel(amount: account.balance) }.frame(height: 35) NavigationLink(destination: LazyView(AccountTransactionsDialog(account: self.account))) { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift index 6a9cef6f..5438f765 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift @@ -15,6 +15,8 @@ struct BankListItem : View { .font(.headline) Spacer() + + AmountLabel(amount: bank.balance) }.frame(height: 35) NavigationLink(destination: LazyView(AccountTransactionsDialog(bank: self.bank))) {