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.

92 lines
2.6 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. //
  2. // PaymentSelectionViewController.swift
  3. // GME Remit
  4. //
  5. // Created by gme_2 on 07/01/2019.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class PaymentSelectionViewController: UIViewController {
  10. struct StringConstants {
  11. // Todo ccr
  12. let closeText = "penny_test_close_text".localized()
  13. }
  14. // MARK: IBOutlets
  15. @IBOutlet weak var mainView: UIView!
  16. @IBOutlet weak var closeButton: UIButton!
  17. // MARK: Properties
  18. var accounts: [Account]?
  19. var onSelection: ((Account) -> ())?
  20. @IBOutlet weak var tableView: UITableView!
  21. var presenter: PaymentSelectionModuleInterface?
  22. // MARK: VC's Life cycle
  23. override func viewDidLoad() {
  24. super.viewDidLoad()
  25. self.setup()
  26. }
  27. override func viewWillAppear(_ animated: Bool) {
  28. super.viewWillAppear(animated)
  29. mainView.bottomToOrigin()
  30. }
  31. // MARK: IBActions
  32. @IBAction func close(_ sender: Any) {
  33. mainView.originToBottom(){
  34. self.dismiss(animated: true, completion: nil)
  35. }
  36. }
  37. // MARK: Other Functions
  38. private func setup() {
  39. // all setup should be done here
  40. self.mainView.layer.cornerRadius = 10
  41. self.mainView.clipsToBounds = true
  42. self.tableView.dataSource = self
  43. self.tableView.delegate = self
  44. self.tableView.reloadData()
  45. configureText()
  46. mainView.layer.cornerRadius = 10
  47. closeButton.layer.cornerRadius = 10
  48. }
  49. private func configureText() {
  50. self.closeButton.setTitle(StringConstants().closeText, for: UIControlState.normal)
  51. }
  52. }
  53. // MARK: PaymentSelectionViewInterface
  54. extension PaymentSelectionViewController: PaymentSelectionViewInterface {
  55. }
  56. extension PaymentSelectionViewController: UITableViewDelegate {
  57. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  58. if let accunt = self.accounts?.elementAt(index: indexPath.row) {
  59. mainView.originToBottom(){
  60. self.dismiss(animated: true, completion: nil)
  61. }
  62. }
  63. }
  64. }
  65. extension PaymentSelectionViewController: UITableViewDataSource {
  66. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  67. return self.accounts?.count ?? 0
  68. }
  69. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  70. let model = tableView.dequeueReusableCell(withIdentifier: "PaymentSelectionTableViewCell") as! PaymentSelectionTableViewCell
  71. model.acunt = accounts?.elementAt(index: indexPath.row)
  72. model.setup()
  73. return model
  74. }
  75. }