Using now BankingPresenter instead of BankFinder directly (therefore bank list is now also sorted alphabetically)
This commit is contained in:
parent
1e09eac9e0
commit
73faa6e7e5
|
@ -6,8 +6,8 @@ struct SelectBankDialog: View {
|
||||||
|
|
||||||
@Environment(\.presentationMode) var presentation
|
@Environment(\.presentationMode) var presentation
|
||||||
|
|
||||||
|
@Inject private var presenter: BankingPresenterSwift
|
||||||
|
|
||||||
private let bankFinder = InMemoryBankFinder()
|
|
||||||
|
|
||||||
@Binding private var selectedBank: BankInfo?
|
@Binding private var selectedBank: BankInfo?
|
||||||
|
|
||||||
|
@ -22,9 +22,11 @@ struct SelectBankDialog: View {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@State private var supportedBanksSearchResults: [BankInfo]
|
@State private var supportedBanksSearchResults: [BankInfo] = []
|
||||||
|
|
||||||
@State private var unsupportedBanksSearchResults: [BankInfo]
|
@State private var unsupportedBanksSearchResults: [BankInfo] = []
|
||||||
|
|
||||||
|
@State private var isInitialized = false
|
||||||
|
|
||||||
|
|
||||||
@State private var errorMessage: Message? = nil
|
@State private var errorMessage: Message? = nil
|
||||||
|
@ -32,12 +34,6 @@ struct SelectBankDialog: View {
|
||||||
|
|
||||||
init(_ selectedBank: Binding<BankInfo?>) {
|
init(_ selectedBank: Binding<BankInfo?>) {
|
||||||
self._selectedBank = selectedBank
|
self._selectedBank = selectedBank
|
||||||
|
|
||||||
bankFinder.preloadBankList()
|
|
||||||
|
|
||||||
let allBanks = bankFinder.getBankList()
|
|
||||||
_supportedBanksSearchResults = State(initialValue:allBanks.filter { $0.supportsFinTs3_0 })
|
|
||||||
_unsupportedBanksSearchResults = State(initialValue:allBanks.filter { $0.supportsFinTs3_0 == false })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,12 +77,19 @@ struct SelectBankDialog: View {
|
||||||
}
|
}
|
||||||
.alert(message: $errorMessage)
|
.alert(message: $errorMessage)
|
||||||
.fixKeyboardCoversLowerPart()
|
.fixKeyboardCoversLowerPart()
|
||||||
|
.executeMutatingMethod {
|
||||||
|
if isInitialized == false {
|
||||||
|
isInitialized = true
|
||||||
|
|
||||||
|
findBanks("")
|
||||||
|
}
|
||||||
|
}
|
||||||
.showNavigationBarTitle("Select Bank Dialog Title")
|
.showNavigationBarTitle("Select Bank Dialog Title")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private func findBanks(_ query: String) {
|
private func findBanks(_ query: String) {
|
||||||
let searchResult = self.bankFinder.findBankByNameBankCodeOrCity(query: query)
|
let searchResult = presenter.searchBanksByNameBankCodeOrCity(query: query)
|
||||||
|
|
||||||
supportedBanksSearchResults = searchResult.filter { $0.supportsFinTs3_0 }
|
supportedBanksSearchResults = searchResult.filter { $0.supportsFinTs3_0 }
|
||||||
unsupportedBanksSearchResults = searchResult.filter { $0.supportsFinTs3_0 == false }
|
unsupportedBanksSearchResults = searchResult.filter { $0.supportsFinTs3_0 == false }
|
||||||
|
@ -99,7 +102,7 @@ struct SelectBankDialog: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func showBankIsNotSupportedMessage(_ bank: BankInfo) {
|
private func showBankIsNotSupportedMessage(_ bank: BankInfo) {
|
||||||
self.errorMessage = Message(title: Text("\(bank.name) does not support FinTS 3.0"), message: Text("Only banks supporting FinTS 3.0 can be used in this app."))
|
self.errorMessage = Message(title: Text("\(bank.name) does not support FinTS 3.0"), message: Text("\(bank.name) does not support FinTS 3.0."))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue