// // WithdrawFromWalletViewController.swift // GME Remit // // Created by Amrit Giri on 7/6/20. //Copyright © 2020 Gobal Money Express Co. Ltd. All rights reserved. // import UIKit class WithdrawFromWalletViewController: UIViewController { struct StringConstants { let titleText = "bank_deposit_text".localized() let proceedText = "proceed_text".localized() let withdrawSubtitle = "withdraw_description".localized() let amountPlaceholder = "enter_amount_text".localized() let amountError = "enter_amount_text".localized() } // MARK: Properties var presenter: WithdrawFromWalletModuleInterface? // MARK: IBOutlets @IBOutlet weak var subtitileLabel: UILabel! @IBOutlet weak var amount: ValidationTextField! @IBOutlet weak var proceedBtn: UIButton! private var isValid = false { didSet { // proceedBtn.isEnabled = isValid // proceedBtn.backgroundColor = isValid ? .themeRed : .themeText proceedBtn.isEnabled = true proceedBtn.backgroundColor = isValid ? .themeRed : .themeRed } } // MARK: VC's Life cycle override func viewDidLoad() { super.viewDidLoad() self.setup() } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.title = StringConstants().titleText self.setupNormalNavigation() } // MARK: IBActions @IBAction func proceed(_ sender: Any) { self.presenter?.makeApiRequest(amount: self.amount.text ?? "") } // MARK: Other Functions private func setup() { // all setup should be done here self.isValid = false self.configureLanguage() } private func configureLanguage() { subtitileLabel.text = StringConstants().withdrawSubtitle amount.titleText = StringConstants().amountPlaceholder amount.placeholder = StringConstants().amountPlaceholder amount.errorMessage = StringConstants().amountError amount.addTarget(self, action: #selector(editingChanged(_:)), for: .editingChanged) proceedBtn.setTitle(StringConstants().proceedText, for: .normal) } @objc private func editingChanged(_ textField: UITextField) { guard let tf = textField as? ValidationTextField else {return} isValid = tf.text != "" } } // MARK: WithdrawFromWalletViewInterface extension WithdrawFromWalletViewController: WithdrawFromWalletViewInterface { func showLoading() { self.showProgressHud() } func hideLoading() { self.hideProgressHud() } func show(error: String) { self.alert(type: .error, message: error) } func show(message: String) { self.alertWithOk( type: .success, message: message, title: "success_text".localized(), okTitle: "Ok" ) { } } }