- Completed click count in sidebar

- Handled optional gender type
- Handled optional gender in profile
- Remaining MyListVC changes
This commit is contained in:
2024-08-13 20:02:41 +05:30
parent d17fe416ae
commit 5cf02c5aae
47 changed files with 1142 additions and 636 deletions

View File

@@ -51,10 +51,12 @@ class ContactSupportVM{
initDropDown()
vc.bottomArrow.addTapGesture {
PersistentStorage.shared.addOthersCount()
self.dropDownModule.show()
}
vc.subjectLabel.addTapGesture {
PersistentStorage.shared.addOthersCount()
self.dropDownModule.show()
}

View File

@@ -28,7 +28,8 @@ class ProfileVM{
addTapGesture()
setUserData()
hindiEnglishLanguage()
vc.dob.isEnabled = false
/*
Depnding on user type limit the date
*/
@@ -52,6 +53,7 @@ class ProfileVM{
}
@objc func editNameClicked(){
PersistentStorage.shared.addOthersCount()
vc.fullNameTF.becomeFirstResponder()
}
@@ -66,6 +68,15 @@ class ProfileVM{
}
}
if let genderData = data.genderData ,let id = genderData.id {
if gender == id{
enableDisableNextBtn(enable: false)
}else{
enableDisableNextBtn(enable: true)
}
}else{
enableDisableNextBtn(enable: true)
}
}
private func enableDisableNextBtn(enable : Bool){
@@ -80,8 +91,17 @@ class ProfileVM{
func setUserData(){
guard let data = AuthFunc.shareInstance.userData else{return}
gender = 2 // static for now
gender = 0 // default
if let genderData = data.genderData{
if genderData.id == 1{ // girl
gender = genderData.id ?? 1
}else if genderData.id == 2{ //boy
gender = genderData.id ?? 2
}
}else{
gender = 0
}
vc.fullNameTF.text = data.fullname
vc.userNameLabel.text = data.username
vc.emailTF.text = data.email
@@ -130,9 +150,13 @@ class ProfileVM{
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
case 1: // Success
Utilities.dismissProgressHUD()
self.vc.toast(msg: data.message ?? "Updated profile", time: 1.5) {
guard let data = data.data?.result else{return}
AuthFunc.shareInstance.userData = data
self.vc.toast(msg: data.message ?? "Updated profile", time: 1.5) { [weak self] in
guard let self, let data = data.data?.result else{return}
AuthFunc.shareInstance.userData?.fullname = vc.fullNameTF.text
AuthFunc.shareInstance.userData?.genderData?.id = gender
AuthFunc.shareInstance.userData?.genderData?.genderName = (gender == 1 ? "Boy" : "Girl")
// AuthFunc.shareInstance.userData = data
self.enableDisableNextBtn(enable: false)
// self.vc.navigationController?.popViewController(animated: true)
}
@@ -151,7 +175,22 @@ class ProfileVM{
func boyBtnTapped() {
// Apply click effect animation
PersistentStorage.shared.addOthersCount()
gender = 2
//check if userdata has same gender
if let data = AuthFunc.shareInstance.userData {
if let genderData = data.genderData, let id = genderData.id{
if id == 2{
enableDisableNextBtn(enable: false)
}else{
enableDisableNextBtn(enable: true)
}
}else{
enableDisableNextBtn(enable: true)
}
}
UIView.animate(withDuration: 0.1, animations: {
self.vc.boyView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)
}) { _ in
@@ -163,8 +202,22 @@ class ProfileVM{
}
func girlBtnTapped() {
PersistentStorage.shared.addOthersCount()
gender = 1
//check if userdata has same gender
if let data = AuthFunc.shareInstance.userData {
if let genderData = data.genderData, let id = genderData.id{
if id == 1{
enableDisableNextBtn(enable: false)
}else{
enableDisableNextBtn(enable: true)
}
}else{
enableDisableNextBtn(enable: true)
}
}
// Apply click effect animation
UIView.animate(withDuration: 0.1, animations: {
self.vc.girlView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9)