|
@ -21,21 +21,33 @@ class SendMoneyCodeViewController: UIViewController { |
|
|
@IBOutlet weak var submitButton: UIButton! |
|
|
@IBOutlet weak var submitButton: UIButton! |
|
|
@IBOutlet weak var notNowButton: UIButton! |
|
|
@IBOutlet weak var notNowButton: UIButton! |
|
|
@IBOutlet weak var counterLabel: UILabel! |
|
|
@IBOutlet weak var counterLabel: UILabel! |
|
|
|
|
|
@IBOutlet weak var counterTitleLabel: UILabel! |
|
|
|
|
|
@IBOutlet weak var counterStackView: UIStackView! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@IBOutlet weak var backGourndBorderView: UIView! |
|
|
@IBOutlet weak var backGourndBorderView: UIView! |
|
|
var timer: Timer? |
|
|
var timer: Timer? |
|
|
var count: Int = 0 { |
|
|
|
|
|
|
|
|
let expiryTime = 120 // second |
|
|
|
|
|
var count: Int = 120 { |
|
|
didSet { |
|
|
didSet { |
|
|
let remainingTime = 120 - count |
|
|
|
|
|
if ( remainingTime <= 0) { |
|
|
|
|
|
count = 0 // two minutes passed |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( count <= 0) { |
|
|
|
|
|
count = expiryTime // two minutes passed |
|
|
self.timer?.invalidate() |
|
|
self.timer?.invalidate() |
|
|
self.resendButton.isHidden = false |
|
|
|
|
|
|
|
|
self.resendButton.isUserInteractionEnabled = true |
|
|
|
|
|
self.counterStackView.isHidden = true |
|
|
} else { |
|
|
} else { |
|
|
let result = count.quotientAndRemainder(dividingBy: 60) |
|
|
|
|
|
|
|
|
|
|
|
self.counterLabel.text = "\(2 - result.quotient): \(60 - result.remainder)" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let result = count.quotientAndRemainder(dividingBy: 60) |
|
|
|
|
|
self.counterLabel.text = "\(result.quotient): \(result.remainder)" |
|
|
|
|
|
// if (result.quotient == 1 || result.remainder == 60 ) { |
|
|
|
|
|
// self.counterLabel.text = "\(1): \(59)" |
|
|
|
|
|
// }else { |
|
|
|
|
|
// self.counterLabel.text = "\(2 - result.quotient): \(60 - result.remainder)" |
|
|
|
|
|
// } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -148,6 +160,8 @@ class SendMoneyCodeViewController: UIViewController { |
|
|
self.resendButton.setTitle("resend_text".localized(), for: UIControlState.normal) |
|
|
self.resendButton.setTitle("resend_text".localized(), for: UIControlState.normal) |
|
|
self.submitButton.setTitle("submit_text".localized(), for: UIControlState.normal) |
|
|
self.submitButton.setTitle("submit_text".localized(), for: UIControlState.normal) |
|
|
self.notNowButton.setTitle("not_now_text".localized(), for: UIControlState.normal) |
|
|
self.notNowButton.setTitle("not_now_text".localized(), for: UIControlState.normal) |
|
|
|
|
|
self.counterTitleLabel.text = "resend_code_text".localized() |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@IBAction func viewSample(_ sender: Any) { |
|
|
@IBAction func viewSample(_ sender: Any) { |
|
@ -189,7 +203,6 @@ class SendMoneyCodeViewController: UIViewController { |
|
|
self.requestOtp(customerId: customerId, success: { (message) in |
|
|
self.requestOtp(customerId: customerId, success: { (message) in |
|
|
self.hideProgressHud() |
|
|
self.hideProgressHud() |
|
|
self.startTimer() |
|
|
self.startTimer() |
|
|
self.resendButton.isHidden = true |
|
|
|
|
|
}) { (error) in |
|
|
}) { (error) in |
|
|
self.hideProgressHud() |
|
|
self.hideProgressHud() |
|
|
self.alert(message: error.localizedDescription) |
|
|
self.alert(message: error.localizedDescription) |
|
@ -199,10 +212,12 @@ class SendMoneyCodeViewController: UIViewController { |
|
|
private func startTimer() { |
|
|
private func startTimer() { |
|
|
self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.updateCounter), userInfo: nil, repeats: true) |
|
|
self.timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(self.updateCounter), userInfo: nil, repeats: true) |
|
|
self.timer?.fire() |
|
|
self.timer?.fire() |
|
|
|
|
|
self.resendButton.isUserInteractionEnabled = false |
|
|
|
|
|
self.counterStackView.isHidden = false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@objc func updateCounter() { |
|
|
@objc func updateCounter() { |
|
|
self.count += 1 |
|
|
|
|
|
|
|
|
self.count -= 1 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func requestOtpCodeRetryCount() { |
|
|
private func requestOtpCodeRetryCount() { |
|
|