Files
Woka_Native_iOS/WOKA/SideBarNav/Controller/ProfileVC.swift
Bilal 334dc39dda - Implemented UserQuery API with post and error handling with checks
- Implemented the logic for Guest Query.
- Added api for guest contact support
- Finalised the logic for the user guest and normal.
- Completed Profile UI
- Updated the profile from the getuserdata
- Added API for Profile update
2024-06-05 20:00:10 +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"
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
// }
//
}