Files
Woka_Native_iOS/WOKA/SideBarNav/Controller/ProfileVC.swift
Bilal 5fdd255130 - fixed home name label content hugging issue
- added edit btn to full name
- Linked the add child to the userregisteration details
- Added Hindi Lingual file to profile view
- Made the custom alert for deactivate account
- updated the username check logic
- Added logout api and handled the user logout
- Handled the logout when device change globally
2024-06-06 20:19:22 +05:30

91 lines
3.1 KiB
Swift

//
// ProfileVC.swift
// WOKA
//
// Created by Bilal on 05/06/2024.
//
import UIKit
class ProfileVC: UIViewController {
@IBOutlet weak var avatarImage: UIImageView!
@IBOutlet weak var userNameLabel: UILabel!
@IBOutlet weak var fullNameTF: TextFieldShadow!
@IBOutlet weak var emailTF: TextFieldShadow!
@IBOutlet weak var dob: UIDatePicker!
@IBOutlet weak var boyView: UIView!
@IBOutlet weak var girlView: UIView!
@IBOutlet weak var nextBtn: LocalisedElementsButton!
var vm = ProfileVM()
override func viewDidLoad() {
super.viewDidLoad()
vm.vc = self
vm.initView()
self.title = "Profile".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
}
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) {
if fullNameTF.text!.count < 3 {
let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC
vcPush.contentLabel = "Name is too short".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
vcPush.mainTitleText = "Error".localized(loc: AuthFunc.shareInstance.languageSelected.rawValue)
vcPush.modalPresentationStyle = .overCurrentContext
vcPush.modalTransitionStyle = .crossDissolve
self.present(vcPush, animated: true)
return
}
vm.updateUserData()
}
}
// MARK: - Textfield
extension ProfileVC : UITextFieldDelegate {
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool{
switch textField{
case fullNameTF:
// check if the latest name is same as the stored name
if let text = textField.text, let textRange = Range(range, in: text) {
let updatedText = text.replacingCharacters(in: textRange, with: string)
vm.checkChanges(name: updatedText)
}
if !string.nameCharacterOnly(){return false}
return ValidatorClass.sharedInstanec.limitCharacter(length: 50,textField, shouldChangeCharactersIn: range, replacementString: string)
default:
return true
}
}
// func textFieldShouldReturn(_ textField: UITextField) -> Bool {
// switch textField{
// case emailTF:
// nameTF.becomeFirstResponder()
// case nameTF:
// textField.resignFirstResponder()
// default:
// break
// }
// return true
// }
//
}