Files
Woka_Native_iOS/WOKA/Authentication/Controller/LoginVC.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

74 lines
2.4 KiB
Swift

//
// LoginVC.swift
// WOKA
//
// Created by Bilal on 03/05/2024.
//
import UIKit
class LoginVC: UIViewController {
@IBOutlet weak var loginBtn: LocalisedElementsButton!
@IBOutlet weak var createAccountBtn: LocalisedElementsButton!
@IBOutlet weak var userNameTF: TextFieldShadow!
@IBOutlet weak var passwordTF: TextFieldShadow!
@IBOutlet weak var passwordStack: UIStackView!
@IBOutlet weak var passwordEyeBtn: UIButton!
var vm = LoginVM()
override func viewDidLoad() {
super.viewDidLoad()
vm.vc = self
vm.initView()
}
@IBAction func loginBtnTapped(_ sender: LocalisedElementsButton) {
vm.loginUser()
}
@IBAction func createAccountBtnTapped(_ sender: LocalisedElementsButton) {
let sb = UIStoryboard(name: K.StoryBoard.main, bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.OnBoarding.selectAgeVC) as! SelectAgeVC
self.navigationController?.pushViewController(vc, animated: true)
}
@IBAction func continueGuestBtnTapped(_ sender: UIButton) {
}
@IBAction func forgotPasswordBtnTapped(_ sender: UIButton) {
let sb = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.resetPassUserNameVC) as! ResetPassUserNameVC
self.navigationController?.pushViewController(vc, animated: true)
}
}
// MARK: - Textfield Delegate
extension LoginVC : UITextFieldDelegate{
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
switch textField{
case passwordTF:
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 passwordTF:
self.view.endEditing(true)
default:
break
}
return true
}
}