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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // SetupRecipientWireframe.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 09/08/2019.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class SetupRecipientWireframe {
  10. weak var view: UIViewController!
  11. weak var output: SetupRecipientWireframeOutput?
  12. private var recipient: Recipient?
  13. private weak var delegate: SetupRecipientDelegate?
  14. }
  15. extension SetupRecipientWireframe: SetupRecipientWireframeInput {
  16. var storyboardName: String {return "SetupRecipient"}
  17. func getMainView() -> UIViewController {
  18. let service = SetupRecipientService()
  19. let interactor = SetupRecipientInteractor(service: service, recipient)
  20. let presenter = SetupRecipientPresenter()
  21. let viewModel = SetupRecipientViewModel()
  22. let viewController = viewControllerFromStoryboard(of: SetupRecipientViewController.self)
  23. output = presenter
  24. viewController.viewModel = viewModel
  25. viewController.delegate = delegate
  26. interactor.output = presenter
  27. presenter.interactor = interactor
  28. presenter.wireframe = self
  29. presenter.viewModel = viewModel
  30. viewModel.presenter = presenter
  31. view = viewController
  32. return viewController
  33. }
  34. func openEdit(
  35. using model: Recipient,
  36. with delegate: SetupRecipientDelegate,
  37. on base: UIViewController,
  38. completion: (() -> Void)? = nil
  39. ) {
  40. recipient = model
  41. self.delegate = delegate
  42. let viewcontroller = getMainView()
  43. let navigationController = UINavigationController(
  44. rootViewController: viewcontroller
  45. )
  46. navigationController.hero.isEnabled = true
  47. navigationController.modalPresentationStyle = .overFullScreen
  48. base.present(navigationController, animated: true, completion: completion)
  49. }
  50. func openNew(
  51. with delegate: SetupRecipientDelegate,
  52. on base: UIViewController,
  53. completion: (() -> Void)? = nil
  54. ) {
  55. self.delegate = delegate
  56. let viewcontroller = getMainView()
  57. let navigationController = UINavigationController(
  58. rootViewController: viewcontroller
  59. )
  60. navigationController.hero.isEnabled = true
  61. navigationController.modalPresentationStyle = .overFullScreen
  62. base.present(navigationController, animated: true, completion: completion)
  63. }
  64. func openSelectMode(with model: [TablePresenterProtocol], type: SetupOpenType) {
  65. TablePresenterWireframe().openWith(
  66. tag: type.rawValue,
  67. delegate: self,
  68. model: model,
  69. source: view
  70. )
  71. }
  72. func openBranches(countryCode: String, bankID: String) {
  73. TablePresenterWireframe().openWith(
  74. tag: SetupOpenType.branch.rawValue,
  75. type: .branches(countryCode: countryCode, bankID: bankID),
  76. delegate: self,
  77. model: nil,
  78. source: view
  79. )
  80. }
  81. }
  82. extension SetupRecipientWireframe: TablePresenterDelegate {
  83. func tablePresenterView(_ viewController: TablePresenterViewController) -> TablePresenterConfiguration {
  84. var configure = TablePresenterConfiguration(
  85. presenterTitle: "search_payout_country_text".localized(),
  86. closeButtonTitle: "penny_test_close_text".localized(),
  87. notFoundTitle: "no_payout_country_found_text".localized(),
  88. searchBarPlaceHolder: "search_text".localized()
  89. )
  90. guard let type = SetupOpenType(rawValue: viewController.view.tag) else {
  91. return configure
  92. }
  93. switch type {
  94. case .country:
  95. return configure
  96. case .paymentMode:
  97. configure.presenterTitle = "search_payment_method_text".localized()
  98. configure.notFoundTitle = "no_payment_method_found_text".localized()
  99. case .bank:
  100. configure.presenterTitle = "search_bank_text".localized()
  101. configure.notFoundTitle = "no_bank_found_text".localized()
  102. case .branch:
  103. configure.presenterTitle = "search_branch_text".localized()
  104. configure.notFoundTitle = "no_branch_found_text".localized()
  105. case .idType:
  106. configure.presenterTitle = "search_id_type_text".localized()
  107. configure.notFoundTitle = "no_id_type_found_text".localized()
  108. case .stateProvince:
  109. configure.presenterTitle = "search_province_text".localized()
  110. configure.notFoundTitle = "no_province_found_text".localized()
  111. case .district:
  112. configure.presenterTitle = "search_district_text".localized()
  113. configure.notFoundTitle = "no_district_found_text".localized()
  114. case .relation:
  115. configure.presenterTitle = "search_relation_text".localized()
  116. configure.notFoundTitle = "no_relation_found_text".localized()
  117. case .reason:
  118. configure.presenterTitle = "search_reason_text".localized()
  119. configure.notFoundTitle = "no_reason_found_text".localized()
  120. case .nativeCountry:
  121. configure.presenterTitle = "search_native_country_text".localized()
  122. configure.notFoundTitle = "no_native_country_found_text".localized()
  123. }
  124. return configure
  125. }
  126. func tablePresenterView(
  127. _ viewController: TablePresenterViewController,
  128. didSelectModel model: TablePresenterProtocol?
  129. ) {
  130. guard let type = SetupOpenType(rawValue: viewController.view.tag) else {
  131. return
  132. }
  133. output?.setSelectedData(with: model, type: type)
  134. }
  135. }