You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
190 lines
5.6 KiB
190 lines
5.6 KiB
//
|
|
// DomesticRemitWireframe.swift
|
|
// GME Remit
|
|
//
|
|
// Created by InKwon James Kim on 17/09/2019.
|
|
//Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class DomesticRemitWireframe {
|
|
weak var view: UIViewController!
|
|
weak var output: DomesticRemitWireframeOutput?
|
|
|
|
private var model: DomesticRemitRequestModel?
|
|
}
|
|
|
|
extension DomesticRemitWireframe: DomesticRemitWireframeInput {
|
|
|
|
var storyboardName: String {return "DomesticRemit"}
|
|
|
|
func getMainView() -> UIViewController {
|
|
let service = DomesticRemitService()
|
|
let interactor = DomesticRemitInteractor(service: service)
|
|
let presenter = DomesticRemitPresenter()
|
|
let viewModel = DomesticRemitViewModel()
|
|
let viewController = viewControllerFromStoryboard(of: DomesticRemitViewController.self)
|
|
|
|
output = presenter
|
|
|
|
viewController.viewModel = viewModel
|
|
interactor.output = presenter
|
|
presenter.interactor = interactor
|
|
presenter.wireframe = self
|
|
presenter.viewModel = viewModel
|
|
|
|
viewModel.presenter = presenter
|
|
|
|
view = viewController
|
|
return viewController
|
|
}
|
|
|
|
func open(on source: UIViewController) {
|
|
let vc = getMainView()
|
|
|
|
source.navigationController?.pushViewController(vc, animated: true)
|
|
}
|
|
|
|
func showTablePresenter(with model: [TablePresenterProtocol]?, type: DomesticRemitPresenter.ShowType) {
|
|
TablePresenterWireframe().openWith(
|
|
tag: type.rawValue,
|
|
delegate: self,
|
|
model: model,
|
|
source: view
|
|
)
|
|
}
|
|
|
|
func showPaymentMode(with model: [Account]?) {
|
|
let wireframe = SelectPaymentWireframe()
|
|
wireframe.delegate = self
|
|
wireframe.openSelectPaymentUsingPanModal(with: model, in: view)
|
|
}
|
|
|
|
func showRecentHistories() {
|
|
RecentHistoriesWireframe().open(delegate: self, on: view)
|
|
}
|
|
|
|
func showBiometricAuth(with model: DomesticRemitRequestModel?) {
|
|
self.model = model
|
|
BiometricAuthenticationWireframe().openWithDelegate(on: view, delegate: self)
|
|
}
|
|
|
|
func showOTP(with model: DomesticRemitRequestModel?) {
|
|
self.model = model
|
|
|
|
SendMoneyCodeWireframe().open(
|
|
requestmodel: model,
|
|
completion: { self.output?.setPassword($0) },
|
|
source: view
|
|
)
|
|
}
|
|
|
|
func showSecureKeypad(with model: DomesticRemitRequestModel?) {
|
|
self.model = model
|
|
let secureKeypad = SecureKeypad(target: view)
|
|
secureKeypad.delegate = self
|
|
secureKeypad.present(animated: true)
|
|
}
|
|
|
|
func goReceipt(with model: DomesticRemitResponseModel) {
|
|
if let navigation = self.view.navigationController {
|
|
SendMoneyReceiptWireframe().openReciept(
|
|
type: .domestic,
|
|
transactionId: model.transactionID ?? "",
|
|
source: navigation
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
extension DomesticRemitWireframe: TablePresenterDelegate {
|
|
func tablePresenterView(_ viewController: TablePresenterViewController) -> TablePresenterConfiguration {
|
|
return TablePresenterConfiguration(
|
|
presenterTitle: "select_bank_text".localized(),
|
|
closeButtonTitle: "penny_test_close_text".localized(),
|
|
notFoundTitle: "no_bank_found_text".localized(),
|
|
searchBarPlaceHolder: "search_bank_text".localized(),
|
|
isUseSearchBar: false
|
|
)
|
|
}
|
|
|
|
func tablePresenterView(
|
|
_ viewController: TablePresenterViewController,
|
|
didSelectModel model: TablePresenterProtocol?
|
|
) {
|
|
guard let type = DomesticRemitPresenter.ShowType(rawValue: viewController.view.tag) else { return }
|
|
|
|
output?.selectedData(with: model, type: type)
|
|
}
|
|
}
|
|
|
|
extension DomesticRemitWireframe: RecentHistoriesDelegate {
|
|
func recentHistories(
|
|
_ viewController: RecentHistoriesViewController,
|
|
didSelectHistory: RecentRecipientModel
|
|
) {
|
|
output?.selectedData(with: didSelectHistory, type: .histories)
|
|
}
|
|
}
|
|
|
|
extension DomesticRemitWireframe: BiometricAuthenticationViewControllerDelegate {
|
|
func viewController(
|
|
_ viewController: BiometricAuthenticationViewController,
|
|
informationTitleLabel titleLabel: UILabel,
|
|
authenticationButton button: UIButton) {
|
|
titleLabel.text = "bio_sendmoney_intro_text".localized()
|
|
button.setTitle("send_money_text".localized(), for: .normal)
|
|
}
|
|
|
|
func didComplete(_ viewController: BiometricAuthenticationViewController) {
|
|
viewController.dismiss(animated: true) {
|
|
guard let encryptedPW = KeyChain.shared.get(key: .password) else {
|
|
MainWireframe.logoutWarningAlert(message: "To use biometrics authentication you have to login again.")
|
|
return
|
|
}
|
|
self.output?.setPassword(encryptedPW)
|
|
}
|
|
}
|
|
|
|
func viewController(
|
|
_ viewController: BiometricAuthenticationViewController,
|
|
didFailWithError error: BiometricAuthenticationError,
|
|
errorMessage: String?
|
|
) {
|
|
viewController.dismiss(animated: true) {
|
|
switch error {
|
|
case .userFallback:
|
|
if self.model?.type == "autodebit" {
|
|
self.showOTP(with: self.model)
|
|
} else {
|
|
self.showSecureKeypad(with: self.model)
|
|
}
|
|
case .biometryNotEnrolled, .notBeConfigured, .biometryNotAvailable:
|
|
self.view.alert(type: .error, message: error.message)
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extension DomesticRemitWireframe: SelectPaymentDelegate {
|
|
func selectPayment(_ viewController: SelectPaymentViewController, selectedAccount: Account) {
|
|
viewController.dismiss(animated: true) {
|
|
self.output?.selectedData(with: selectedAccount, type: .autodebit)
|
|
}
|
|
}
|
|
|
|
func selectPayment(_ viewController: SelectPaymentViewController, error: Error) {
|
|
}
|
|
}
|
|
|
|
extension DomesticRemitWireframe: SecureKeypadDelegate {
|
|
func didComplete(_ encryptedString: String, garbagePassword: String, length: Int) {
|
|
if length > 0 {
|
|
self.output?.setPassword(encryptedString)
|
|
}
|
|
}
|
|
}
|