Fixed that if initially no TAN procedure was selected and user selected first entry, that selectedTanProcedureChanged() callback didn't get called
This commit is contained in:
parent
05e8b1f4a4
commit
959e527d12
|
@ -11,15 +11,17 @@ struct TanProcedurePicker: View {
|
||||||
|
|
||||||
private var customersTanProcedures: [TanProcedure] = []
|
private var customersTanProcedures: [TanProcedure] = []
|
||||||
|
|
||||||
|
private let initiallySelectedTanProcedure: TanProcedure?
|
||||||
|
|
||||||
@State private var selectedTanProcedureIndex: Int
|
@State private var selectedTanProcedureIndex: Int
|
||||||
|
|
||||||
private var selectedTanProcedureIndexBinding: Binding<Int> {
|
private var selectedTanProcedureIndexBinding: Binding<Int> {
|
||||||
Binding<Int>(
|
Binding<Int>(
|
||||||
get: { self.selectedTanProcedureIndex },
|
get: { self.selectedTanProcedureIndex },
|
||||||
set: {
|
set: { newValue in
|
||||||
if (self.selectedTanProcedureIndex != $0) { // only if TAN procedure has really changed
|
if (self.selectedTanProcedureIndex != newValue || self.initiallySelectedTanProcedure == nil) { // only if TAN procedure has really changed
|
||||||
self.selectedTanProcedureIndex = $0
|
self.selectedTanProcedureIndex = newValue
|
||||||
self.dispatchSelectedTanProcedureChanged(self.customersTanProcedures[$0])
|
self.dispatchSelectedTanProcedureChanged(self.customersTanProcedures[newValue])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -33,9 +35,10 @@ struct TanProcedurePicker: View {
|
||||||
|
|
||||||
self.customersTanProcedures = bank.supportedTanProcedures.filter( {$0.type != .chiptanusb } ) // USB tan generators are not supported on iOS
|
self.customersTanProcedures = bank.supportedTanProcedures.filter( {$0.type != .chiptanusb } ) // USB tan generators are not supported on iOS
|
||||||
|
|
||||||
let selectedTanProcedureType = initiallySelectedTanProcedure?.type ?? bank.selectedTanProcedure?.type
|
self.initiallySelectedTanProcedure = initiallySelectedTanProcedure ?? bank.selectedTanProcedure
|
||||||
|
let initiallySelectedTanProcedureType = self.initiallySelectedTanProcedure?.type
|
||||||
|
|
||||||
_selectedTanProcedureIndex = State(initialValue: customersTanProcedures.firstIndex(where: { $0.type == selectedTanProcedureType } )
|
_selectedTanProcedureIndex = State(initialValue: customersTanProcedures.firstIndex(where: { $0.type == initiallySelectedTanProcedureType } )
|
||||||
?? bank.supportedTanProcedures.firstIndex(where: { $0.type != .chiptanmanuell && $0.type != .chiptanusb } )
|
?? bank.supportedTanProcedures.firstIndex(where: { $0.type != .chiptanmanuell && $0.type != .chiptanusb } )
|
||||||
?? 0)
|
?? 0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue