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.

553 lines
24 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. //
  2. // ExchangeRatesViewController.swift
  3. // GMERemittance
  4. //
  5. // Created by gme_2 on 24/08/2018.
  6. //Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. import Hex
  10. enum PaymentMode: String {
  11. case cashDelivery = "1"
  12. case bankDeposite = "2"
  13. case homeDelivery = "12"
  14. case mobileWallet = "13"
  15. }
  16. class ExchangeRatesViewController: UIViewController {
  17. struct Constants {
  18. static let transferFeeDetailText = StringConstants().transferFeeDetailText
  19. static let currentExchangeRateText = StringConstants().currentExchangeRateText
  20. static let paymentModeHeightConstant: CGFloat = 154
  21. static let title = StringConstants().title
  22. }
  23. struct StringConstants {
  24. let selectPaymentModeText = ""
  25. let youSendText = "you_send_text"
  26. let recepientGetsText = "receipient_gets_text"
  27. let calculate = "calculate_text"
  28. let title = "todays_rate_text"
  29. let currentExchangeRateText = "current_exchange_rate_text"
  30. let transferFeeDetailText = "transfer_fee_included_text"
  31. }
  32. struct ApiConstants {
  33. static let recieverCountryId = "pCountry"
  34. static let senderCurrency = "sCurrency"
  35. static let recieverCurrency = "pCurrency"
  36. static let senderAmount = "cAmount"
  37. static let recieverAmount = "pAmount"
  38. static let paymentMethod = "serviceType"
  39. static let calcBy = "calcBy"
  40. static let recieverCountryName = "pCountryName"
  41. static let senderCountryId = "sCountry"
  42. }
  43. // MARK: IBOutlets
  44. @IBOutlet weak var scrollView: UIScrollView!
  45. @IBOutlet weak var collectionView: UICollectionView!
  46. @IBOutlet weak var exchangeBackground1: UIView!
  47. @IBOutlet weak var exchangeBackground2: UIView!
  48. @IBOutlet weak var dropDownImageView: UIImageView!
  49. @IBOutlet weak var backgroundViewCountryLabel1: UIView!
  50. @IBOutlet weak var backgroundViewCountryLabel2: UIView!
  51. @IBOutlet weak var countryListStackView: UIStackView!
  52. @IBOutlet weak var countryCodeLabel: UILabel!
  53. @IBOutlet weak var countryFlagImage: UIImageView!
  54. @IBOutlet weak var paymentModeStackViewConstraint: NSLayoutConstraint!
  55. @IBOutlet weak var paymentModeStackView: UIStackView!
  56. @IBOutlet weak var senderTextField: UITextField!
  57. @IBOutlet weak var reciepientTextField: UITextField!
  58. @IBOutlet weak var transferFeeInfoLabel: UILabel!
  59. @IBOutlet weak var exchangeRateInfoLabel: UILabel!
  60. @IBOutlet weak var youSendTitleLabel: UILabel!
  61. @IBOutlet weak var recepientGetsTitleLabel: UILabel!
  62. @IBOutlet weak var selectPaymentModeTitleLabel: UILabel!
  63. @IBOutlet weak var calculateTItleLabel: UIButton!
  64. var presenter: ExchangeRatesModuleInterface?
  65. var countryListTapGuesture: UITapGestureRecognizer?
  66. var selectedPaymentIndex: IndexPath = IndexPath.init(row: 0, section: 0)
  67. var translated: Bool = false
  68. var nativeCountryCode: String? = "np"
  69. var calcBy = ""
  70. var exchangeRateModels: [ExchangeRateModel]? {
  71. didSet {
  72. if let _ = CountryInfo().defaultCountryCodes.filter({$0.lowercased() == (self.nativeCountryCode ?? "").lowercased()}).first {
  73. if let defaultExchangeRate = self.exchangeRateModels?.filter({
  74. ($0.countryCode ?? "").lowercased() == (self.nativeCountryCode ?? "").lowercased()
  75. }).first {
  76. // there is native country, defaultExchangeRate is the information for that country
  77. self.setCountryFlag(countryCode: defaultExchangeRate.countryCode ?? "")
  78. self.setCurrencyLabel(currency: defaultExchangeRate.currency ?? "")
  79. // set the default amount for this country. there are some default values in CountryInfo
  80. self.selectedExchageRateModel = defaultExchangeRate
  81. self.collectionView.reloadData()
  82. showPaymentModeView()
  83. self.populateDefaultAmounts()
  84. }
  85. } else {
  86. self.setDefaultValuesForCountriesNotHavingDefaultValue()
  87. showPaymentModeView()
  88. }
  89. }
  90. }
  91. var selectedExchageRateModel: ExchangeRateModel? {
  92. didSet {
  93. self.setCurrencyLabel(currency: self.selectedExchageRateModel?.currency ?? "")
  94. self.setCountryFlag(countryCode: self.selectedExchageRateModel?.countryCode ?? "")
  95. collectionView.reloadData()
  96. DispatchQueue.main.async {
  97. self.reciepientTextField.resignFirstResponder()
  98. self.senderTextField.resignFirstResponder()
  99. }
  100. }
  101. }
  102. // MARK: VC's Life cycle
  103. override func viewDidLoad() {
  104. super.viewDidLoad()
  105. setup()
  106. setupDelegates()
  107. setupTargets()
  108. setupNavigation()
  109. setupDefaultCountryFlagandCurrency()
  110. // todo: show default native country and falg
  111. // Do any additional setup after loading the view.
  112. // populateDefaultAmounts()
  113. fetchExchangeRateInformation()
  114. }
  115. func setupDefaultCountryFlagandCurrency() {
  116. if let defaultExchangeRate = self.exchangeRateModels?.filter({
  117. ($0.country ?? "").lowercased() == (self.nativeCountryCode ?? "").lowercased()
  118. }).first {
  119. // there is native country, defaultExchangeRate is the information for that country
  120. self.setCountryFlag(countryCode: defaultExchangeRate.countryCode ?? "")
  121. self.setCurrencyLabel(currency: defaultExchangeRate.currency ?? "")
  122. }
  123. }
  124. override func viewWillAppear(_ animated: Bool) {
  125. super.viewWillAppear(animated)
  126. self.title = Constants.title
  127. }
  128. // IBActions
  129. @IBAction func calculateExchangeRate(_ sender: Any?) {
  130. let senderAmount = self.senderTextField.text!
  131. let reciepientAmount = self.reciepientTextField.text!
  132. let recipientCurrency = self.selectedExchageRateModel?.currency
  133. let reciepientCountryId = self.selectedExchageRateModel?.countryId
  134. let paymentMethod = self.selectedExchageRateModel?.availableServices?.elementAt(index: selectedPaymentIndex.row)
  135. let reciepientCountryName = self.selectedExchageRateModel?.country
  136. self.calculate(senderAmt: senderAmount, recieverAmt: reciepientAmount, recieverCurrency: recipientCurrency, recieverCountryName: reciepientCountryName, recieverCountryId: reciepientCountryId, paymentMethod: paymentMethod?.id, calcBy: self.calcBy)
  137. // call calculate( ... ) function
  138. // todo send to api for calculation
  139. }
  140. func calculate(senderAmt: String?, senderCurrency: String? = "KRW", recieverAmt: String?, recieverCurrency: String?, recieverCountryName: String?, recieverCountryId: String?, paymentMethod: String?, calcBy: String?, senderCountryId: String? = "118", shouldShowLoading: Bool = true ) {
  141. let param: [String: String] =
  142. [
  143. ApiConstants.senderAmount : senderAmt ?? "",
  144. ApiConstants.senderCurrency : senderCurrency ?? "",
  145. ApiConstants.recieverAmount : recieverAmt ?? "",
  146. ApiConstants.recieverCurrency : recieverCurrency ?? "",
  147. ApiConstants.recieverCountryId : recieverCountryId ?? "",
  148. ApiConstants.paymentMethod: paymentMethod ?? "",
  149. ApiConstants.calcBy : calcBy ?? "",
  150. ApiConstants.senderCountryId : senderCountryId ?? "",
  151. ApiConstants.recieverCountryName: recieverCountryName ?? ""
  152. ]
  153. // print(param)
  154. // todo
  155. if shouldShowLoading { self.showProgressHud() }
  156. self.getExchangeRateInformation(params: param, success: { (exchageRateDetail) in
  157. self.reciepientTextField.text = Utility.getCommaSeperatedStringWithDecimal(numberString: exchageRateDetail?.recipientAmount ?? "")
  158. self.senderTextField.text = Utility.getCommaSeperatedStringWithDecimal(numberString: exchageRateDetail?.senderAmount ?? "")
  159. self.calcBy = "c"
  160. let transferFee = exchageRateDetail?.transferFee ?? ""
  161. let currency = exchageRateDetail?.senderCurrency ?? ""
  162. self.transferFeeInfoLabel.text = "\(transferFee) \(currency) (\(Constants.transferFeeDetailText))"
  163. let exchangeRate = exchageRateDetail?.exchangeRate ?? ""
  164. self.exchangeRateInfoLabel.text = "\(exchangeRate) (\(Constants.currentExchangeRateText))"
  165. self.hideProgressHud()
  166. }) { (error) in
  167. self.hideProgressHud()
  168. self.view.endEditing(true)
  169. self.alert(message: error.localizedDescription)
  170. }
  171. // call api with these params
  172. }
  173. @objc func showCountryList(_ sender: UITapGestureRecognizer) {
  174. DispatchQueue.main.async {
  175. self.reciepientTextField.resignFirstResponder()
  176. self.senderTextField.resignFirstResponder()
  177. }
  178. let viewcontroller = UIStoryboard.init(name: "TableViewPicker", bundle: nil).instantiateViewController(withIdentifier: "TablePickerViewController") as! TablePickerViewController
  179. viewcontroller.data = self.exchangeRateModels ?? []
  180. viewcontroller.type = TablePickerViewTitle.currency
  181. viewcontroller.doneAction = self.countrySelected
  182. // viewcontroller.defaultSelectedData = [self.selectedExchageRateModel]
  183. self.present(viewcontroller, animated: true, completion: nil)
  184. }
  185. // other function
  186. func showPaymentModeView() {
  187. UIView.animate(withDuration: 0.33) {
  188. self.paymentModeStackViewConstraint.constant = Constants.paymentModeHeightConstant
  189. self.paymentModeStackView.alpha = 1
  190. self.view.layoutIfNeeded()
  191. }
  192. }
  193. func countrySelected(model: [ExchangeRateModel]) {
  194. self.selectedExchageRateModel = model.first
  195. guard let exchangeModel = self.selectedExchageRateModel else {return}
  196. guard let recievingCountryId = exchangeModel.countryId else {return}
  197. guard let paymentMethod = exchangeModel.availableServices?.elementAt(index: selectedPaymentIndex.row) else {return}
  198. if let recievingAmount = CountryInfo().getDefaultSendingAmount(for: selectedExchageRateModel?.countryCode ?? "") {
  199. if CountryInfo().doesCountryCodeHasDefined(country: exchangeModel.countryCode ?? "", currency: exchangeModel.currency ?? "") {
  200. if let recievingCurrency = CountryInfo().getDefaultSendingCurrency(for: exchangeModel.countryCode ?? "")
  201. {
  202. // do something if you have to do
  203. self.calcBy = "p"
  204. self.reciepientTextField.text = Utility.getCommaSeperatedStringWithDecimal(numberString: recievingAmount)
  205. let reciepientCountryName = exchangeModel.country
  206. self.calculate(senderAmt: nil, senderCurrency: "KRW", recieverAmt: recievingAmount, recieverCurrency: recievingCurrency, recieverCountryName: reciepientCountryName, recieverCountryId: recievingCountryId, paymentMethod: paymentMethod.id, calcBy: calcBy, shouldShowLoading: false)
  207. return
  208. }
  209. }
  210. }
  211. // for countries having two currency like vn "VND" and "USD", mongolia, mn nad srilanka, lk
  212. if let recievingAmount = CountryInfo().getSecondarySendingAmount(for: exchangeModel.countryCode ?? "") {
  213. let recievingCurrency = exchangeModel.currency ?? ""
  214. if CountryInfo().doesSecondaryOptiopsHasDefined(country: exchangeModel.countryCode ?? "" , currency: recievingCurrency)
  215. {
  216. // do something if you have to do
  217. self.calcBy = "p"
  218. self.reciepientTextField.text = Utility.getCommaSeperatedStringWithDecimal(numberString: recievingAmount)
  219. let reciepientCountryName = exchangeModel.country
  220. self.calculate(senderAmt: nil, senderCurrency: "KRW", recieverAmt: recievingAmount, recieverCurrency: recievingCurrency, recieverCountryName: reciepientCountryName, recieverCountryId: recievingCountryId, paymentMethod: paymentMethod.id, calcBy: calcBy, shouldShowLoading: false)
  221. return
  222. }
  223. }
  224. self.calculateExchangeRate(nil)
  225. // show country with flag.
  226. }
  227. @objc private func textChanged(sender: UITextField) {
  228. switch sender {
  229. case senderTextField:
  230. self.reciepientTextField.text = ""
  231. self.calcBy = "c"
  232. senderTextField.text = Utility.getCommaSeperatedString(numberString: senderTextField.text!)
  233. case reciepientTextField:
  234. self.senderTextField.text = ""
  235. self.calcBy = "p"
  236. reciepientTextField.text = Utility.getCommaSeperatedString(numberString: reciepientTextField.text!)
  237. default:
  238. break
  239. }
  240. }
  241. private func setCountryFlag(countryCode: String) {
  242. let flag = CountryInfo().getFlag(for: countryCode)
  243. self.countryFlagImage.image = flag
  244. }
  245. private func setCurrencyLabel(currency: String) {
  246. self.countryCodeLabel.text = currency.uppercased()
  247. }
  248. private func populateDefaultAmounts() {
  249. guard let nativeCountry = self.nativeCountryCode else {return}
  250. // todo: native country cha bhane tesko CountryInfo class ma defaullt value cha ki chaina herne
  251. // CountryInfo class ma defaullt value cha bhane tyo value rakhera second api hit garna paryo ani aako data dekhaune
  252. // natra bhane tesko 1000000 kwr ko native ma kati huncha teti populate garaune
  253. guard let exchangeModel = self.exchangeRateModels?.filter({
  254. $0.countryCode?.lowercased() == nativeCountry.lowercased() // countryCode
  255. }).first else {return}
  256. // self.selectedExchageRateModel = exchangeModel
  257. // if there is no default amount, then we have to calculate from korean won. so guard ma rakhna thik nahola, yo case hereko chaina
  258. if let recievingAmount = CountryInfo().getDefaultSendingAmount(for: exchangeModel.countryCode ?? "") {
  259. self.setDefaultValuesForCountriesHavingDefaultValue(recievingAmount: recievingAmount, exchangeModel: exchangeModel)
  260. }
  261. }
  262. private func setDefaultValuesForCountriesNotHavingDefaultValue() {
  263. self.selectedExchageRateModel = self.exchangeRateModels?.first
  264. let senderAmount = CountryInfo().getDefaultSendingMoneyInKoreanWon()
  265. self.senderTextField.text = Utility.getCommaSeperatedStringWithDecimal(numberString: senderAmount ?? "")
  266. let senderCurrency = "KWR"
  267. let recieverCurrency = self.selectedExchageRateModel?.currency
  268. let recieverCountryId = self.selectedExchageRateModel?.countryId
  269. let paymentMethod = self.selectedExchageRateModel?.availableServices?.elementAt(index: selectedPaymentIndex.row)
  270. let reciepientCountryName = self.selectedExchageRateModel?.country ?? ""
  271. let calcBy = "c"
  272. let senderCountryName = "KOREA"
  273. self.calculate(senderAmt: senderAmount, senderCurrency: senderCurrency, recieverAmt: nil, recieverCurrency: recieverCurrency, recieverCountryName: reciepientCountryName, recieverCountryId: recieverCountryId, paymentMethod: paymentMethod?.id, calcBy: calcBy, shouldShowLoading: false)
  274. }
  275. private func setDefaultValuesForCountriesHavingDefaultValue(recievingAmount: String, exchangeModel: ExchangeRateModel) {
  276. guard let recievingCurrency = CountryInfo().getDefaultSendingCurrency(for: exchangeModel.countryCode ?? ""),
  277. let recievingCountryId = exchangeModel.countryId,
  278. let paymentMethod = exchangeModel.availableServices?.elementAt(index: selectedPaymentIndex.row)
  279. else {
  280. // do something if you have to do
  281. return
  282. }
  283. self.calcBy = "p"
  284. self.reciepientTextField.text = Utility.getCommaSeperatedStringWithDecimal(numberString: recievingAmount)
  285. let reciepientCountryName = exchangeModel.country
  286. self.calculate(senderAmt: nil, senderCurrency: "KRW", recieverAmt: recievingAmount, recieverCurrency: recievingCurrency, recieverCountryName: reciepientCountryName, recieverCountryId: recievingCountryId, paymentMethod: paymentMethod.id, calcBy: calcBy, shouldShowLoading: false)
  287. }
  288. private func fetchExchangeRateInformation() {
  289. self.showProgressHud()
  290. self.fetchCountryCurrencyInfo(success: { (models) in
  291. self.exchangeRateModels = models
  292. }) { (error) in
  293. self.hideProgressHud()
  294. self.view.endEditing(true)
  295. self.alert(message: error.localizedDescription)
  296. }
  297. }
  298. private func setupTargets() {
  299. let tapGuesture = UITapGestureRecognizer(target: self, action: #selector(self.showCountryList(_:)))
  300. self.countryListTapGuesture = tapGuesture
  301. self.countryListStackView.addGestureRecognizer(self.countryListTapGuesture!)
  302. self.reciepientTextField.addTarget(self, action: #selector(self.textChanged(sender:)), for: UIControlEvents.editingChanged)
  303. self.senderTextField.addTarget(self, action: #selector(self.textChanged(sender:)), for: UIControlEvents.editingChanged)
  304. self.reciepientTextField.addTarget(self, action: #selector(self.textFieldSelected(sender:)), for: UIControlEvents.editingDidBegin)
  305. self.senderTextField.addTarget(self, action: #selector(self.textFieldSelected(sender:)), for: UIControlEvents.editingDidBegin)
  306. }
  307. @objc private func textFieldSelected(sender: UITextField) {
  308. switch sender {
  309. case senderTextField:
  310. if Utility.getDeviceModel() == .iphone678 {
  311. let x = self.scrollView.contentOffset.x
  312. let y = self.scrollView.contentOffset.y
  313. let newOffset = CGPoint.init(x: x, y: y + 100)
  314. scrollView.setContentOffset(newOffset, animated: true)
  315. }
  316. if Utility.getDeviceModel() == .iphone5 {
  317. let x = self.scrollView.contentOffset.x
  318. let y = self.scrollView.contentOffset.y
  319. let newOffset = CGPoint.init(x: x, y: y + 150)
  320. scrollView.setContentOffset(newOffset, animated: true)
  321. }
  322. case reciepientTextField:
  323. break
  324. default:
  325. break
  326. }
  327. }
  328. private func setupDelegates() {
  329. self.collectionView.delegate = self
  330. self.collectionView.dataSource = self
  331. }
  332. private func setup() {
  333. let dropDownImage = #imageLiteral(resourceName: "dropdown_white").withRenderingMode(UIImageRenderingMode.alwaysTemplate)
  334. let image = dropDownImage
  335. self.dropDownImageView.image = image
  336. self.dropDownImageView.tintColor = UIColor.white
  337. self.paymentModeStackViewConstraint.constant = 0
  338. self.paymentModeStackView.alpha = 0
  339. self.senderTextField.delegate = self
  340. self.reciepientTextField.delegate = self
  341. // corner Radius
  342. [backgroundViewCountryLabel1, backgroundViewCountryLabel2].forEach({
  343. $0?.layer.cornerRadius = 5
  344. })
  345. [exchangeBackground1, exchangeBackground2].forEach({
  346. $0?.layer.borderWidth = 1
  347. $0?.layer.borderColor = UIColor.init(hex: "#E0E0E0").cgColor
  348. $0?.layer.cornerRadius = 5
  349. })
  350. setupLanguage()
  351. }
  352. private func setupLanguage() {
  353. let constant = StringConstants()
  354. self.youSendTitleLabel.text = constant.youSendText
  355. self.recepientGetsTitleLabel.text = constant.recepientGetsText
  356. self.calculateTItleLabel.setTitle(constant.calculate, for: UIControlState.normal)
  357. }
  358. func show(error: String) {
  359. self.view.endEditing(true)
  360. self.alert(message: error)
  361. }
  362. func showLoading() {
  363. self.showProgressHud()
  364. }
  365. func hideLoading() {
  366. self.hideProgressHud()
  367. }
  368. private func setupNavigation() {
  369. self.setupNormalNavigation()
  370. }
  371. }
  372. extension ExchangeRatesViewController: UICollectionViewDelegate {
  373. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  374. let cell = collectionView.cellForItem(at: indexPath) as! ExchangeRateCollectionViewCell
  375. self.selectedPaymentIndex = indexPath
  376. self.collectionView.reloadData()
  377. self.calculateExchangeRate(nil)
  378. }
  379. }
  380. extension ExchangeRatesViewController: UICollectionViewDataSource {
  381. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  382. return self.selectedExchageRateModel?.availableServices?.count ?? 0
  383. }
  384. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  385. let service = self.selectedExchageRateModel?.availableServices?.elementAt(index: indexPath.row)
  386. guard let index = PaymentMode.init(rawValue: service?.id ?? "") else {
  387. return UICollectionViewCell()
  388. }
  389. switch index {
  390. case .bankDeposite:
  391. return configureBankDepositeCell(collectionView: collectionView, indexPath: indexPath)
  392. case .cashDelivery:
  393. return configureCashDeliveryCell(collectionView: collectionView, indexPath: indexPath)
  394. case .homeDelivery:
  395. return configureHomeDeliveryCell(collectionView: collectionView, indexPath: indexPath)
  396. case .mobileWallet:
  397. return configureWalletDeliveryCell(collectionView: collectionView, indexPath: indexPath)
  398. }
  399. }
  400. func configureBankDepositeCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
  401. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell
  402. cell.cellSelected = self.selectedPaymentIndex == indexPath
  403. cell.paymentServiceMethod = self.selectedExchageRateModel?.availableServices?.elementAt(index: indexPath.row)
  404. cell.image = #imageLiteral(resourceName: "ic_bank")
  405. cell.setup()
  406. return cell
  407. }
  408. func configureWalletDeliveryCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
  409. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell
  410. cell.cellSelected = self.selectedPaymentIndex == indexPath
  411. cell.paymentServiceMethod = self.selectedExchageRateModel?.availableServices?.elementAt(index: indexPath.row)
  412. cell.image = #imageLiteral(resourceName: "wallet-transfer")
  413. cell.setup()
  414. return cell
  415. }
  416. func configureCashDeliveryCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
  417. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell
  418. cell.cellSelected = self.selectedPaymentIndex == indexPath
  419. cell.paymentServiceMethod = self.selectedExchageRateModel?.availableServices?.elementAt(index: indexPath.row)
  420. cell.image = #imageLiteral(resourceName: "ic_cash")
  421. cell.setup()
  422. return cell
  423. }
  424. func configureHomeDeliveryCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
  425. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell
  426. cell.cellSelected = self.selectedPaymentIndex == indexPath
  427. cell.paymentServiceMethod = self.selectedExchageRateModel?.availableServices?.elementAt(index: indexPath.row)
  428. cell.image = #imageLiteral(resourceName: "ic_homeDelivery")
  429. cell.setup()
  430. return cell
  431. }
  432. }
  433. extension ExchangeRatesViewController: FetchCountryCurrencyInformation, getExchangeRateInformation {}
  434. extension ExchangeRatesViewController: UITextFieldDelegate {
  435. func textFieldDidEndEditing(_ textField: UITextField) {
  436. self.calculateExchangeRate(nil)
  437. }
  438. }
  439. // MARK: ExchangeRatesViewInterface
  440. extension ExchangeRatesViewController: ExchangeRatesViewInterface {
  441. }