From 448ce54ae981ca2bb138abe38e8a6abfc65f4f0a Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 27 Jul 2020 13:30:56 +0200 Subject: [PATCH] Fixed that AccountTransactionsDialog got eagerly created and selected bank account(s) therefore set to bank account(s) of last created AccountTransactionsDialog --- .../BankingiOSApp/ui/views/AccountsTab.swift | 3 ++- .../ui/views/BankAccountListItem.swift | 4 ++-- .../BankingiOSApp/ui/views/BankListItem.swift | 4 ++-- .../BankingiOSApp/ui/views/LazyView.swift | 24 +++++++++++++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 ui/BankingiOSApp/BankingiOSApp/ui/views/LazyView.swift diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift index c8d880ef..1d21761f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift @@ -13,6 +13,8 @@ struct AccountsTab: View { VStack { if data.banks.isEmpty == false { Form { + AllBanksListItem(banks: data.banks) + ForEach(0 ..< data.banks.count) { bankIndex in BankListItem(bank: self.data.banks[bankIndex]) } @@ -24,7 +26,6 @@ struct AccountsTab: View { NavigationLink(destination: AddAccountDialog()) { Text("Add account") } - .padding() Spacer() } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift index 1508d36d..04ad101b 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankAccountListItem.swift @@ -4,7 +4,7 @@ import BankingUiSwift struct BankAccountListItem : View { - var account: BankAccount + let account: BankAccount var body: some View { @@ -14,7 +14,7 @@ struct BankAccountListItem : View { Spacer() }.frame(height: 35) - NavigationLink(destination: AccountTransactionsDialog(account: account)) { + NavigationLink(destination: LazyView(AccountTransactionsDialog(account: self.account))) { EmptyView() } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift index 9f871054..6a9cef6f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankListItem.swift @@ -4,7 +4,7 @@ import BankingUiSwift struct BankListItem : View { - var bank: Customer + let bank: Customer var body: some View { @@ -17,7 +17,7 @@ struct BankListItem : View { Spacer() }.frame(height: 35) - NavigationLink(destination: AccountTransactionsDialog(bank: bank)) { + NavigationLink(destination: LazyView(AccountTransactionsDialog(bank: self.bank))) { EmptyView() } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/LazyView.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/LazyView.swift new file mode 100644 index 00000000..8974ea9c --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/LazyView.swift @@ -0,0 +1,24 @@ +import SwiftUI + + +struct LazyView: View { + + private let build: () -> Content + + init(_ build: @autoclosure @escaping () -> Content) { + self.build = build + } + + var body: Content { + build() + } +} + + +struct LazyView_Previews: PreviewProvider { + + static var previews: some View { + LazyView(Text("Hello")) + } + +}