diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift index 91c162ce..e5315e57 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AccountsTab.swift @@ -11,26 +11,30 @@ struct AccountsTab: View { var body: some View { VStack { - if data.banks.isNotEmpty { + if data.banks.isEmpty { + Spacer() + + AddAccountButtonView() + + Spacer() + } + else { Form { AllBanksListItem(banks: data.banks) ForEach(data.banks) { bank in BankListItem(bank: bank) } + + Section { + AddAccountButtonView() + } + .background(Color(UIColor.systemGroupedBackground)) + .listRowInsets(EdgeInsets()) + } } - - Spacer() - - NavigationLink(destination: LazyView(AddAccountDialog())) { - Text("Add account") - } - .frame(height: 35) - - Spacer() } - .frame(width: UIScreen.main.bounds.width) .background(Color(UIColor.systemGroupedBackground)) } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountButtonView.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountButtonView.swift new file mode 100644 index 00000000..0f2b950d --- /dev/null +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountButtonView.swift @@ -0,0 +1,39 @@ +import SwiftUI + + +struct AddAccountButtonView: View { + + @State private var showAddAccountDialog = false + + + var body: some View { + VStack { + HStack { + Spacer() + + Button("Add account") { self.showAddAccountDialog = true } + + Spacer() + } + .padding(.top, 10) // to fix that hidden NavigationLink below pulls HStack up + .frame(maxWidth: .infinity, minHeight: 40) + + + NavigationLink(destination: LazyView(AddAccountDialog()), isActive: $showAddAccountDialog) { + EmptyView() + } + .hidden() + .frame(height: 0) + } + } + +} + + +struct AddAccountButtonView_Previews: PreviewProvider { + + static var previews: some View { + AddAccountButtonView() + } + +}