2024-05-03 20:26:58 +05:30
|
|
|
//
|
|
|
|
|
// NewPasswordVC.swift
|
|
|
|
|
// WOKA
|
|
|
|
|
//
|
|
|
|
|
// Created by Bilal on 03/05/2024.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
|
|
class NewPasswordVC: UIViewController {
|
|
|
|
|
|
2024-05-03 20:27:54 +05:30
|
|
|
@IBOutlet weak var enterNewPasswordTF: TextFieldShadow!
|
|
|
|
|
@IBOutlet weak var confirmPassTF: TextFieldShadow!
|
|
|
|
|
@IBOutlet weak var nextBtn: LocalisedElementsButton!
|
|
|
|
|
|
2024-05-10 20:43:57 +05:30
|
|
|
var vm = NewPasswordVM()
|
|
|
|
|
|
|
|
|
|
// MARK: - View LifeCycle
|
|
|
|
|
|
2024-05-03 20:26:58 +05:30
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
2024-05-10 20:43:57 +05:30
|
|
|
vm.vc = self
|
|
|
|
|
vm.initView()
|
2024-05-03 20:26:58 +05:30
|
|
|
}
|
|
|
|
|
|
2024-05-10 20:43:57 +05:30
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
|
|
|
super.viewWillAppear(animated)
|
|
|
|
|
navigationController?.setNavigationBarHidden(false, animated: animated)
|
2024-05-03 20:27:54 +05:30
|
|
|
}
|
|
|
|
|
|
2024-05-10 20:43:57 +05:30
|
|
|
override func viewWillDisappear(_ animated: Bool) {
|
|
|
|
|
super.viewWillDisappear(animated)
|
|
|
|
|
navigationController?.setNavigationBarHidden(true, animated: animated)
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-03 20:27:54 +05:30
|
|
|
@IBAction func nextBtnTapped(_ sender: LocalisedElementsButton) {
|
2024-05-10 20:43:57 +05:30
|
|
|
guard let pass = enterNewPasswordTF.text , let confirmPass = confirmPassTF.text else{return}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Check for password
|
|
|
|
|
*/
|
|
|
|
|
if pass.count < 6 || confirmPass.count < 6{
|
|
|
|
|
let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil)
|
|
|
|
|
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC
|
|
|
|
|
|
|
|
|
|
vcPush.contentLabel = "Password is too short."
|
|
|
|
|
vcPush.mainTitleText = "Error"
|
|
|
|
|
// vcPush.onDoneBlock = { isDone in }
|
|
|
|
|
vcPush.modalPresentationStyle = .overCurrentContext
|
|
|
|
|
vcPush.modalTransitionStyle = .crossDissolve
|
|
|
|
|
self.present(vcPush, animated: true)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Check if password are matching
|
|
|
|
|
*/
|
|
|
|
|
if pass != confirmPass{
|
|
|
|
|
let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil)
|
|
|
|
|
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC
|
|
|
|
|
|
|
|
|
|
vcPush.contentLabel = "Password doesn't match"
|
|
|
|
|
vcPush.mainTitleText = "Error"
|
|
|
|
|
// vcPush.onDoneBlock = { isDone in }
|
|
|
|
|
vcPush.modalPresentationStyle = .overCurrentContext
|
|
|
|
|
vcPush.modalTransitionStyle = .crossDissolve
|
|
|
|
|
self.present(vcPush, animated: true)
|
|
|
|
|
return
|
|
|
|
|
}
|
2024-05-03 20:27:54 +05:30
|
|
|
|
2024-05-10 20:43:57 +05:30
|
|
|
vm.updatePassword()
|
2024-05-03 20:27:54 +05:30
|
|
|
}
|
|
|
|
|
}
|
2024-05-03 20:26:58 +05:30
|
|
|
|
2024-05-03 20:27:54 +05:30
|
|
|
// MARK: - Textfield Delegate
|
2024-05-03 20:26:58 +05:30
|
|
|
|
2024-05-03 20:27:54 +05:30
|
|
|
extension NewPasswordVC : UITextFieldDelegate{
|
|
|
|
|
|
|
|
|
|
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
|
|
|
|
switch textField{
|
|
|
|
|
case enterNewPasswordTF,confirmPassTF:
|
|
|
|
|
let currentString = (textField.text ?? "") as NSString
|
|
|
|
|
let newString = currentString.replacingCharacters(in: range, with: string)
|
|
|
|
|
newString.count == 0 ? (textField.rightView?.isHidden = true) : (textField.rightView?.isHidden = false)
|
|
|
|
|
return ValidatorClass.sharedInstanec.limitCharacter(length: 16,textField, shouldChangeCharactersIn: range, replacementString: string)
|
|
|
|
|
default:
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
|
|
|
|
switch textField{
|
|
|
|
|
case enterNewPasswordTF:
|
|
|
|
|
self.confirmPassTF.becomeFirstResponder()
|
|
|
|
|
case confirmPassTF:
|
|
|
|
|
self.view.endEditing(true)
|
|
|
|
|
default:
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
return true
|
2024-05-03 20:26:58 +05:30
|
|
|
}
|
|
|
|
|
}
|