From d16dfaa281e00f003497f672acad645458725f3a Mon Sep 17 00:00:00 2001 From: yare Date: Wed, 29 Dec 2021 23:01:25 +0545 Subject: [PATCH] Back Button Added and Validation added in Send money --- .../View/NewRegisterViewController.swift | 15 +++++- .../CDDIViewControllerViewController.swift | 54 ++++++++++++++++--- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/GME Remit/Modules/RegisterModules/UserAuthentication/NewRegister/User Interface/View/NewRegisterViewController.swift b/GME Remit/Modules/RegisterModules/UserAuthentication/NewRegister/User Interface/View/NewRegisterViewController.swift index 77dd41ec..02cc8ea0 100644 --- a/GME Remit/Modules/RegisterModules/UserAuthentication/NewRegister/User Interface/View/NewRegisterViewController.swift +++ b/GME Remit/Modules/RegisterModules/UserAuthentication/NewRegister/User Interface/View/NewRegisterViewController.swift @@ -58,7 +58,7 @@ class NewRegisterViewController: UIViewController { title = "new_registration_title_text".localized() setupNormalNavigation() - navigationItem.setHidesBackButton(true, animated: true) + //navigationItem.setHidesBackButton(true, animated: true) if self.presentingViewController != nil { let closeButton = UIBarButtonItem( @@ -68,6 +68,15 @@ class NewRegisterViewController: UIViewController { action: #selector(close) ) + navigationItem.leftBarButtonItem = closeButton + } else { + let closeButton = UIBarButtonItem( + image: UIImage(named: "ic_back_button"), + style: .plain, + target: self, + action: #selector(back) + ) + navigationItem.leftBarButtonItem = closeButton } @@ -173,7 +182,9 @@ extension NewRegisterViewController { @objc private func close() { dismiss(animated: true, completion: nil) } - + @objc private func back() { + self.navigationController?.popToRootViewController(animated: true) + } func setMultilanguages() { step1TitleLabel.text = "step1_sub_title_text".localized() step2TitleLabel.text = "documents_text".localized() diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewControllerViewController.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewControllerViewController.swift index aba04cfe..813e0508 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewControllerViewController.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewControllerViewController.swift @@ -44,8 +44,17 @@ class CDDIViewControllerViewController: UIViewController { // MARK: IBActions @IBAction func continueButton(_ sender: UIButton) { view.endEditing(true) - let model = CDDIRequestData(sourceOfFund: fund, purposeOfRemittance: purpose) - actionDelegate?.continueToVerificationAction(model: model) + if self.sourceOfFund.text == "Others (please specify)" { + self.alert(message: "Please Enter Others Source of Fund") + } + if self.purposeOfRemit.text == "Other (please specify)" { + self.alert(message: "Please Enter Others Purpose of Remit") + } + else if self.sourceOfFund.text != "Others (please specify)" && self.purposeOfRemit.text != "Other (please specify)" { + let model = CDDIRequestData(sourceOfFund: fund, purposeOfRemittance: purpose) + actionDelegate?.continueToVerificationAction(model: model) + } + } // MARK: Other Functions @@ -76,11 +85,41 @@ class CDDIViewControllerViewController: UIViewController { let alert = UIAlertController(title: "specifySourceOfFund_text".localized(), message: "", preferredStyle: .alert) alert.addTextField(configurationHandler: nil) alert.addAction(UIAlertAction(title: "Submit", style: .default, handler: { [weak alert] (_) in - guard let textField = alert?.textFields?.first else { return } - let setSourceOfFund = KeyValue(id: textField.text ?? "", value: textField.text ?? "") - self.sourceOfFund.didSelect( - item: setSourceOfFund - ) + let textField = alert?.textFields?.first + //else { return } + if textField?.text == "" || textField?.text?.isEmpty ?? true { + self.alert(message: "Please Enter Others Source of Fund") + } else { + let setSourceOfFund = KeyValue(id: textField?.text ?? "", value: textField?.text ?? "") + self.sourceOfFund.didSelect( + item: setSourceOfFund + ) + } + + })) + self.present(alert, animated: true, completion: nil) + } + } + return $0 as? KeyValue + + }.asDriverOnErrorJustComplete(), + purpose: purposeOfRemit.selectedItem.map { + if $0?.cellTitle == "Other (please specify)" { + DispatchQueue.main.async { + let alert = UIAlertController(title: "specifySourceOfFund_text".localized(), message: "", preferredStyle: .alert) + alert.addTextField(configurationHandler: nil) + alert.addAction(UIAlertAction(title: "Submit", style: .default, handler: { [weak alert] (_) in + let textField = alert?.textFields?.first + //else { return } + if textField?.text == "" || textField?.text?.isEmpty ?? true { + self.alert(message: "Please Enter Others Source of Fund") + } else { + let setSourceOfFund = KeyValue(id: textField?.text ?? "", value: textField?.text ?? "") + self.sourceOfFund.didSelect( + item: setSourceOfFund + ) + } + })) self.present(alert, animated: true, completion: nil) } @@ -88,7 +127,6 @@ class CDDIViewControllerViewController: UIViewController { return $0 as? KeyValue }.asDriverOnErrorJustComplete(), - purpose: purposeOfRemit.selectedItem.map{$0 as? KeyValue}.asDriverOnErrorJustComplete(), submit: continueButton.rx.tap.asDriverOnErrorJustComplete() )