Fixed placing "Add account" below List; extracted AddAccountButtonView
This commit is contained in:
parent
f168575e16
commit
bb347c8335
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue