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

//
// PaymentSelectionViewController.swift
// GME Remit
//
// Created by gme_2 on 07/01/2019.
//Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
import UIKit
class PaymentSelectionViewController: UIViewController {
struct StringConstants {
// Todo ccr
let closeText = "penny_test_close_text".localized()
}
// MARK: IBOutlets
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var closeButton: UIButton!
// MARK: Properties
var accounts: [Account]?
var onSelection: ((Account) -> ())?
@IBOutlet weak var tableView: UITableView!
var presenter: PaymentSelectionModuleInterface?
// MARK: VC's Life cycle
override func viewDidLoad() {
super.viewDidLoad()
self.setup()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
mainView.bottomToOrigin()
}
// MARK: IBActions
@IBAction func close(_ sender: Any) {
mainView.originToBottom(){
self.dismiss(animated: true, completion: nil)
}
}
// MARK: Other Functions
private func setup() {
// all setup should be done here
self.mainView.layer.cornerRadius = 10
self.mainView.clipsToBounds = true
self.tableView.dataSource = self
self.tableView.delegate = self
self.tableView.reloadData()
configureText()
mainView.layer.cornerRadius = 10
closeButton.layer.cornerRadius = 10
}
private func configureText() {
self.closeButton.setTitle(StringConstants().closeText, for: UIControlState.normal)
}
}
// MARK: PaymentSelectionViewInterface
extension PaymentSelectionViewController: PaymentSelectionViewInterface {
}
extension PaymentSelectionViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let accunt = self.accounts?.elementAt(index: indexPath.row) {
mainView.originToBottom(){
self.dismiss(animated: true, completion: nil)
}
}
}
}
extension PaymentSelectionViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.accounts?.count ?? 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let model = tableView.dequeueReusableCell(withIdentifier: "PaymentSelectionTableViewCell") as! PaymentSelectionTableViewCell
model.acunt = accounts?.elementAt(index: indexPath.row)
model.setup()
return model
}
}