// // SendMoneyVerificationViewController.swift // GMERemittance // // Created by gme_2 on 28/08/2018. //Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved. // import UIKit class SendMoneyVerificationViewController: UITableViewController { // MARK: IBOutlets // Recievers Details @IBOutlet weak var fullNameLabel: UILabel! @IBOutlet weak var addressLabel: UILabel! @IBOutlet weak var countryLabel: UILabel! @IBOutlet weak var mobileLabel: UILabel! // Transation Details @IBOutlet weak var payoutCountryLabel: UILabel! @IBOutlet weak var payoutModeLabel: UILabel! @IBOutlet weak var payingAmountLabel: UILabel! @IBOutlet weak var exchangeRateLabel: UILabel! @IBOutlet weak var serviceChargeLabel: UILabel! @IBOutlet weak var payoutAgentBankLabel: UILabel! var url: String? // MARK: Properties var presenter: SendMoneyVerificationModuleInterface? var reciepient: Recipient? var requestModel: SendMoneyRequestModel? var hudDelegate: HUDStatusDelegate? var password: String? { didSet { if let model = self.requestModel, let reciepient = self.reciepient { model.transactionPassword = password ?? "" self.presenter?.submit(model: model, reciepient: reciepient) } } } // MARK: VC's Life cycle override func viewDidLoad() { super.viewDidLoad() self.setup() } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) populateRecieversInformations() populateTransactionDetails() } // MARK: IBActions // @IBOutlet weak var usewUserAgreement: UIButton! @IBAction func showUserAgreement(_ sender: UIButton) { let webController = UIStoryboard.init(name: "Storyboard", bundle: nil).instantiateViewController(withIdentifier: "WebLinksViewController") as! WebLinksViewController webController.titleString = "User Agreement" webController.url = self.url ?? "https://online.gmeremit.com/Terms" let nav = UINavigationController.init(rootViewController: webController) self.present(nav, animated: true, completion: nil) // self.navigationController?.pushViewController(webController, animated: true) } @IBAction func submit(_ sender: UIButton) { self.askPassword() // submit the request model } // MARK: Other Functions private func setup() { } private func populateRecieversInformations() { self.fullNameLabel.text = self.reciepient?.getFullName() self.addressLabel.text = self.reciepient?.address self.countryLabel.text = self.reciepient?.country self.mobileLabel.text = self.reciepient?.mobileNumber } private func populateTransactionDetails() { self.payoutCountryLabel.text = self.reciepient?.country self.payoutModeLabel.text = self.requestModel?.paymemtMode?.mode self.payingAmountLabel.text = (self.requestModel?.exchangeRateDetail?.recipientAmount ?? "") + " \(self.requestModel?.exchangeRateDetail?.reciepientCurrency ?? "")" self.exchangeRateLabel.text = self.requestModel?.exchangeRateDetail?.exchangeRate self.serviceChargeLabel.text = self.requestModel?.exchangeRateDetail?.transferFee self.payoutAgentBankLabel.text = self.requestModel?.bank?.name } func askPassword() { let alertController = UIAlertController(title: "Enter your login password", message: "", preferredStyle: .alert) alertController.addTextField { (textField : UITextField!) -> Void in textField.placeholder = "Enter password" textField.isSecureTextEntry = true textField.tag = 51 // textField.delegate = self } let confirmAction = UIAlertAction(title: "Confirm", style: .default, handler: { alert -> Void in let passwordTextField = alertController.textFields![0] as UITextField if passwordTextField.text! != "" { self.password = passwordTextField.text! } else { self.alert(message: "Password was missing") } }) let cancelAction = UIAlertAction(title: "Cancel", style: .destructive, handler: { (action : UIAlertAction!) -> Void in }) cancelAction.setValue(UIColor.black, forKey: "titleTextColor") confirmAction.setValue(UIColor(hex:0xEC1C24), forKey: "titleTextColor") alertController.addAction(cancelAction) alertController.addAction(confirmAction) self.present(alertController, animated: true, completion: nil) } } // MARK: SendMoneyVerificationViewInterface extension SendMoneyVerificationViewController: SendMoneyVerificationViewInterface { func show(model: SendMoneySubmitModelContainer?) { self.alertWithOk(message: model?.message , title: "Success", okTitle: "OK", style: UIAlertControllerStyle.alert, OkStyle: .default) { if let id = model?.id { self.presenter?.openReciept(transactionId: id) }else { self.alert(message: "No Transaction recievied.") } } } func show(error: String) { // self.presenter?.openReciept(transactionId: "1235") self.alert(message: error) } func showLoading() { self.hudDelegate?.showLoading() } func hideLoading() { self.hudDelegate?.hideLoading() } } extension SendMoneyVerificationViewController { override func didMove(toParentViewController parent: UIViewController?) { self.viewWillAppear(true) } }