Fixed that in BankInfoListItem only taps on text have fired, not e.g. on white space to the right

This commit is contained in:
dankito 2020-08-12 23:05:59 +02:00
parent 9d2df6fba7
commit 4d247bc43b
3 changed files with 40 additions and 23 deletions

View File

@ -25,7 +25,7 @@ struct AddAccountDialog: View {
NavigationLink(destination: SelectBankDialog($bank)) {
if bank != nil {
bank.map { bank in
BankInfoListItem(bank: bank)
BankInfoListItem(bank)
}
}
else {

View File

@ -4,10 +4,24 @@ 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 {
ZStack {
VStack {
HStack {
Text(bank.name)
@ -29,6 +43,10 @@ struct BankInfoListItem: View {
.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))
}
}

View File

@ -57,8 +57,7 @@ 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 {
BankInfoListItem(bank) {
self.handleSelectedBank(bank)
}
}