Implemented hiding update all accounts' transaction when no account has been added; Implemented array extension property isNotEmpty
This commit is contained in:
parent
766209c1e6
commit
ae1b209db4
|
@ -113,10 +113,12 @@ 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"
|
||||
|
||||
if data.hasAtLeastOneAccountBeenAdded {
|
||||
self.leadingNavigationBarItem = AnyView(UpdateButton { _ in
|
||||
self.presenter.updateAccountsTransactionsAsync { _ in }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,15 @@ extension Array where Element == NSDecimalNumber {
|
|||
}
|
||||
|
||||
|
||||
extension Array {
|
||||
|
||||
var isNotEmpty: Bool {
|
||||
return !isEmpty
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
extension NSObject {
|
||||
|
||||
var className: String {
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue