Files
Woka_Native_iOS/WOKA/Authentication/Controller/EmailVC.swift
BilalKhanWDI 95ae60c464 - Added the network library with proper versioning
- Made the network adapter
- Made the config file to hold the url auth
2024-05-07 11:14:02 +05:30

89 lines
2.8 KiB
Swift

//
// EmailVC.swift
// WOKA
//
// Created by Bilal on 26/04/2024.
//
import UIKit
class EmailVC: UIViewController {
@IBOutlet weak var nextBtn: LocalisedElementsButton!
@IBOutlet weak var enterEmailTF: UITextField!
@IBOutlet weak var wokaLogoTopConstriant: NSLayoutConstraint!
@IBOutlet weak var beSafeLabel: UILabel!
@IBOutlet weak var emailLabel: UILabel!
@IBOutlet weak var emailVerifyLabel: LocalisedElementsLabel!
var vm = EmailVM()
// MARK: - LifeCycle
override func viewDidLoad() {
super.viewDidLoad()
vm.vc = self
vm.initView()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.setNavigationBarHidden(true, animated: animated)
}
@IBAction func nextBtnTapped(_ sender: LocalisedElementsButton) {
Utilities.startProgressHUD()
DispatchQueue.main.async { [weak self] in
guard let self else{return}
//validate email fiirst
let emailValidate = EmailValidation(email: enterEmailTF.text!).validate()
if emailValidate != .isCorrect{
enterEmailTF.rightView?.isHidden = false
enterEmailTF.setError(emailValidate.rawValue, show: true)
Utilities.dismissProgressHUD()
return
}
vm.checkEmail()
// let sb = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil)
// let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.oTPVC) as! OTPVC
// self.navigationController?.pushViewController(vc, animated: true)
}
}
}
// MARK: - TextField Delegate
extension EmailVC : UITextFieldDelegate{
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool{
switch textField{
case enterEmailTF:
if let rightView = textField.rightView {
// Hide the right view
rightView.isHidden = true
// Check if the right view is hidden
if rightView.isHidden {
// If hidden, hide the associated error view
if let errorView = errorViews.object(forKey: enterEmailTF) {
errorView.isHidden = true
}
}
}
return ValidatorClass.sharedInstanec.limitCharacter(length: 255,textField, shouldChangeCharactersIn: range, replacementString: string)
default:
return true
}
}
}