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.

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