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.
155 lines
5.1 KiB
155 lines
5.1 KiB
//
|
|
// SetupRecipientWireframe.swift
|
|
// GME Remit
|
|
//
|
|
// Created by InKwon James Kim on 09/08/2019.
|
|
//Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SetupRecipientWireframe {
|
|
weak var view: UIViewController!
|
|
weak var output: SetupRecipientWireframeOutput?
|
|
private var recipient: Recipient?
|
|
private weak var delegate: SetupRecipientDelegate?
|
|
}
|
|
|
|
extension SetupRecipientWireframe: SetupRecipientWireframeInput {
|
|
var storyboardName: String {return "SetupRecipient"}
|
|
|
|
func getMainView() -> UIViewController {
|
|
let service = SetupRecipientService()
|
|
let interactor = SetupRecipientInteractor(service: service, recipient)
|
|
let presenter = SetupRecipientPresenter()
|
|
let viewModel = SetupRecipientViewModel()
|
|
let viewController = viewControllerFromStoryboard(of: SetupRecipientViewController.self)
|
|
|
|
output = presenter
|
|
|
|
viewController.viewModel = viewModel
|
|
viewController.delegate = delegate
|
|
interactor.output = presenter
|
|
presenter.interactor = interactor
|
|
presenter.wireframe = self
|
|
presenter.viewModel = viewModel
|
|
|
|
viewModel.presenter = presenter
|
|
|
|
view = viewController
|
|
return viewController
|
|
}
|
|
|
|
func openEdit(
|
|
using model: Recipient,
|
|
with delegate: SetupRecipientDelegate,
|
|
on base: UIViewController,
|
|
completion: (() -> Void)? = nil
|
|
) {
|
|
recipient = model
|
|
self.delegate = delegate
|
|
|
|
let viewcontroller = getMainView()
|
|
let navigationController = UINavigationController(
|
|
rootViewController: viewcontroller
|
|
)
|
|
navigationController.hero.isEnabled = true
|
|
navigationController.modalPresentationStyle = .overFullScreen
|
|
base.present(navigationController, animated: true, completion: completion)
|
|
}
|
|
|
|
func openNew(
|
|
with delegate: SetupRecipientDelegate,
|
|
on base: UIViewController,
|
|
completion: (() -> Void)? = nil
|
|
) {
|
|
self.delegate = delegate
|
|
|
|
let viewcontroller = getMainView()
|
|
let navigationController = UINavigationController(
|
|
rootViewController: viewcontroller
|
|
)
|
|
navigationController.hero.isEnabled = true
|
|
navigationController.modalPresentationStyle = .overFullScreen
|
|
base.present(navigationController, animated: true, completion: completion)
|
|
}
|
|
|
|
func openSelectMode(with model: [TablePresenterProtocol], type: SetupOpenType) {
|
|
TablePresenterWireframe().openWith(
|
|
tag: type.rawValue,
|
|
delegate: self,
|
|
model: model,
|
|
source: view
|
|
)
|
|
}
|
|
|
|
func openBranches(countryCode: String, bankID: String) {
|
|
TablePresenterWireframe().openWith(
|
|
tag: SetupOpenType.branch.rawValue,
|
|
type: .branches(countryCode: countryCode, bankID: bankID),
|
|
delegate: self,
|
|
model: nil,
|
|
source: view
|
|
)
|
|
}
|
|
}
|
|
|
|
extension SetupRecipientWireframe: TablePresenterDelegate {
|
|
func tablePresenterView(_ viewController: TablePresenterViewController) -> TablePresenterConfiguration {
|
|
var configure = TablePresenterConfiguration(
|
|
presenterTitle: "search_payout_country_text".localized(),
|
|
closeButtonTitle: "penny_test_close_text".localized(),
|
|
notFoundTitle: "no_payout_country_found_text".localized(),
|
|
searchBarPlaceHolder: "search_text".localized()
|
|
)
|
|
|
|
guard let type = SetupOpenType(rawValue: viewController.view.tag) else {
|
|
return configure
|
|
}
|
|
|
|
switch type {
|
|
case .country:
|
|
return configure
|
|
case .paymentMode:
|
|
configure.presenterTitle = "search_payment_method_text".localized()
|
|
configure.notFoundTitle = "no_payment_method_found_text".localized()
|
|
case .bank:
|
|
configure.presenterTitle = "search_bank_text".localized()
|
|
configure.notFoundTitle = "no_bank_found_text".localized()
|
|
case .branch:
|
|
configure.presenterTitle = "search_branch_text".localized()
|
|
configure.notFoundTitle = "no_branch_found_text".localized()
|
|
case .idType:
|
|
configure.presenterTitle = "search_id_type_text".localized()
|
|
configure.notFoundTitle = "no_id_type_found_text".localized()
|
|
case .stateProvince:
|
|
configure.presenterTitle = "search_province_text".localized()
|
|
configure.notFoundTitle = "no_province_found_text".localized()
|
|
case .district:
|
|
configure.presenterTitle = "search_district_text".localized()
|
|
configure.notFoundTitle = "no_district_found_text".localized()
|
|
case .relation:
|
|
configure.presenterTitle = "search_relation_text".localized()
|
|
configure.notFoundTitle = "no_relation_found_text".localized()
|
|
case .reason:
|
|
configure.presenterTitle = "search_reason_text".localized()
|
|
configure.notFoundTitle = "no_reason_found_text".localized()
|
|
case .nativeCountry:
|
|
configure.presenterTitle = "search_native_country_text".localized()
|
|
configure.notFoundTitle = "no_native_country_found_text".localized()
|
|
}
|
|
|
|
return configure
|
|
}
|
|
|
|
func tablePresenterView(
|
|
_ viewController: TablePresenterViewController,
|
|
didSelectModel model: TablePresenterProtocol?
|
|
) {
|
|
guard let type = SetupOpenType(rawValue: viewController.view.tag) else {
|
|
return
|
|
}
|
|
|
|
output?.setSelectedData(with: model, type: type)
|
|
}
|
|
}
|