diff --git a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift index 1690cca8..f4cc7e52 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ContentView.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ContentView.swift @@ -113,9 +113,11 @@ struct ContentView: View { // due to a SwiftUI bug this cannot be set in AccountsTab directly, so i have to do it here self.navigationBarTitle = "Accounts" - self.leadingNavigationBarItem = AnyView(UpdateButton { _ in - self.presenter.updateAccountsTransactionsAsync { _ in } - }) + if data.hasAtLeastOneAccountBeenAdded { + self.leadingNavigationBarItem = AnyView(UpdateButton { _ in + self.presenter.updateAccountsTransactionsAsync { _ in } + }) + } } } diff --git a/ui/BankingiOSApp/BankingiOSApp/persistence/AppData.swift b/ui/BankingiOSApp/BankingiOSApp/persistence/AppData.swift index dcf0160f..8bc57669 100644 --- a/ui/BankingiOSApp/BankingiOSApp/persistence/AppData.swift +++ b/ui/BankingiOSApp/BankingiOSApp/persistence/AppData.swift @@ -8,12 +8,16 @@ class AppData : ObservableObject { @Published var banks: [Customer] = [] + @Published var hasAtLeastOneAccountBeenAdded: Bool = false + init() { banks = presenter.customers + hasAtLeastOneAccountBeenAdded = banks.isNotEmpty presenter.addAccountsChangedListener { banks in self.banks = banks + self.hasAtLeastOneAccountBeenAdded = banks.isNotEmpty } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/SwiftExtensions.swift b/ui/BankingiOSApp/BankingiOSApp/ui/SwiftExtensions.swift index 203bf4f5..3fa81ad0 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/SwiftExtensions.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/SwiftExtensions.swift @@ -90,6 +90,15 @@ extension Array where Element == NSDecimalNumber { } +extension Array { + + var isNotEmpty: Bool { + return !isEmpty + } + +} + + extension NSObject { var className: String { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift index 36dcc3a6..016231f7 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift @@ -11,7 +11,7 @@ struct AccountsTab: View { var body: some View { VStack { - if data.banks.isEmpty == false { + if data.banks.isNotEmpty { Form { AllBanksListItem(banks: data.banks)