diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift index b866f501..2b37a766 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/AddAccountDialog.swift @@ -25,7 +25,7 @@ struct AddAccountDialog: View { NavigationLink(destination: SelectBankDialog($bank)) { if bank != nil { bank.map { bank in - BankInfoListItem(bank: bank) + BankInfoListItem(bank) } } else { diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankInfoListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankInfoListItem.swift index 3b9d3274..15330f69 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/BankInfoListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/BankInfoListItem.swift @@ -4,30 +4,48 @@ import BankingUiSwift struct BankInfoListItem: View { - let bank: BankInfo + private let bank: BankInfo + + private let onBankSelected: (() -> Void)? + + + init(_ bank: BankInfo, _ onBankSelected: @escaping () -> Void) { + self.bank = bank + self.onBankSelected = onBankSelected + } + + init(_ bank: BankInfo) { + self.bank = bank + self.onBankSelected = nil + } var body: some View { - VStack { - HStack { - Text(bank.name) - .font(.headline) + ZStack { + VStack { + HStack { + Text(bank.name) + .font(.headline) - Spacer() + Spacer() + } + + HStack { + Text(bank.bankCode) + + Text(bank.postalCode) + .padding(.leading, 4) + + Text(bank.city) + + Spacer() + } + .styleAsDetail() + .padding(.top, 6.0) } - HStack { - Text(bank.bankCode) - - Text(bank.postalCode) - .padding(.leading, 4) - - Text(bank.city) - - Spacer() - } - .styleAsDetail() - .padding(.top, 6.0) + // SwiftUI doesn't stretch item to whole width so tap on places without text are not detected -> add a button and pass to caller when tapped on item + Button("") { self.onBankSelected?() } } .opacity(bank.supportsFinTs3_0 ? 1.0 : 0.25) .accentColor(bank.supportsFinTs3_0 ? .label : .secondaryLabel) @@ -38,7 +56,7 @@ struct BankInfoListItem: View { struct BankInfoListItem_Previews: PreviewProvider { static var previews: some View { - BankInfoListItem(bank: BankInfo(name: "Abzockbank Berlin", bankCode: "12345678", bic: "ABZODEBBXXX", postalCode: "12345", city: "Berlin", checksumMethod: "", pinTanAddress: nil, pinTanVersion: "FinTS 3.0", oldBankCode: nil)) + BankInfoListItem(BankInfo(name: "Abzockbank Berlin", bankCode: "12345678", bic: "ABZODEBBXXX", postalCode: "12345", city: "Berlin", checksumMethod: "", pinTanAddress: nil, pinTanVersion: "FinTS 3.0", oldBankCode: nil)) } } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/SelectBankDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/SelectBankDialog.swift index 5d018ed7..45155de2 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/SelectBankDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/SelectBankDialog.swift @@ -57,9 +57,8 @@ struct SelectBankDialog: View { Section { // TODO: showing only the first 100 items is a workaround as SwiftUI tries to compare the two lists (to be able to animate them!) which takes extremely long for the full data set List(searchResult.prefix(100), id: \.self) { bank in - BankInfoListItem(bank: bank) - .onTapGesture { - self.handleSelectedBank(bank) + BankInfoListItem(bank) { + self.handleSelectedBank(bank) } } }