diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj index 9a51737..a059209 100644 --- a/WOKA.xcodeproj/project.pbxproj +++ b/WOKA.xcodeproj/project.pbxproj @@ -130,6 +130,8 @@ 9C0A853F2BEE35340093783D /* ForgotPassDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C0A853E2BEE35340093783D /* ForgotPassDM.swift */; }; 9C0A85412BEE35670093783D /* ResetPassUserNameVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C0A85402BEE35670093783D /* ResetPassUserNameVM.swift */; }; 9C0A85432BEE3EC90093783D /* NewPasswordVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C0A85422BEE3EC90093783D /* NewPasswordVM.swift */; }; + 9C1C69FA2C106B290035B2C7 /* RSKPlaceholderTextView in Frameworks */ = {isa = PBXBuildFile; productRef = 9C1C69F92C106B290035B2C7 /* RSKPlaceholderTextView */; }; + 9C1C69FC2C106C240035B2C7 /* ContactSupportVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C1C69FB2C106C240035B2C7 /* ContactSupportVM.swift */; }; 9C27E1602BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C27E15F2BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift */; }; 9C27E1632BDB6F1900EC1DA9 /* AuthFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C27E1622BDB6F1900EC1DA9 /* AuthFunc.swift */; }; 9C27E1652BDB6FBC00EC1DA9 /* StoryBoardID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C27E1642BDB6FBC00EC1DA9 /* StoryBoardID.swift */; }; @@ -155,6 +157,8 @@ 9C7939172C0F23E900F5D6E6 /* LinkTypeEnum.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C7939162C0F23E900F5D6E6 /* LinkTypeEnum.swift */; }; 9C7939192C0F345000F5D6E6 /* ContactSupportVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C7939182C0F345000F5D6E6 /* ContactSupportVC.swift */; }; 9C9BEEC72BEE1BBF004ECC2F /* CollectionViewCenteredFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C9BEEC62BEE1BBF004ECC2F /* CollectionViewCenteredFlowLayout.swift */; }; + 9CA7C6C02C1093E500D73742 /* ProfileVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CA7C6BF2C1093E500D73742 /* ProfileVC.swift */; }; + 9CA7C6C22C1095B600D73742 /* ProfileVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CA7C6C12C1095B600D73742 /* ProfileVM.swift */; }; 9CBCB29B2BE4D614007D7934 /* LoginVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CBCB29A2BE4D614007D7934 /* LoginVC.swift */; }; 9CBCB29D2BE4D6BB007D7934 /* LoginVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CBCB29C2BE4D6BB007D7934 /* LoginVM.swift */; }; 9CBCB29F2BE4E13A007D7934 /* ValidatorClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9CBCB29E2BE4E13A007D7934 /* ValidatorClass.swift */; }; @@ -318,6 +322,7 @@ 9C0A853E2BEE35340093783D /* ForgotPassDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForgotPassDM.swift; sourceTree = ""; }; 9C0A85402BEE35670093783D /* ResetPassUserNameVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResetPassUserNameVM.swift; sourceTree = ""; }; 9C0A85422BEE3EC90093783D /* NewPasswordVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewPasswordVM.swift; sourceTree = ""; }; + 9C1C69FB2C106C240035B2C7 /* ContactSupportVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactSupportVM.swift; sourceTree = ""; }; 9C27E15F2BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsStruct.swift; sourceTree = ""; }; 9C27E1622BDB6F1900EC1DA9 /* AuthFunc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthFunc.swift; sourceTree = ""; }; 9C27E1642BDB6FBC00EC1DA9 /* StoryBoardID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryBoardID.swift; sourceTree = ""; }; @@ -349,6 +354,8 @@ 9C7939162C0F23E900F5D6E6 /* LinkTypeEnum.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkTypeEnum.swift; sourceTree = ""; }; 9C7939182C0F345000F5D6E6 /* ContactSupportVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactSupportVC.swift; sourceTree = ""; }; 9C9BEEC62BEE1BBF004ECC2F /* CollectionViewCenteredFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewCenteredFlowLayout.swift; sourceTree = ""; }; + 9CA7C6BF2C1093E500D73742 /* ProfileVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileVC.swift; sourceTree = ""; }; + 9CA7C6C12C1095B600D73742 /* ProfileVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileVM.swift; sourceTree = ""; }; 9CBCB29A2BE4D614007D7934 /* LoginVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginVC.swift; sourceTree = ""; }; 9CBCB29C2BE4D6BB007D7934 /* LoginVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginVM.swift; sourceTree = ""; }; 9CBCB29E2BE4E13A007D7934 /* ValidatorClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidatorClass.swift; sourceTree = ""; }; @@ -379,6 +386,7 @@ buildActionMask = 2147483647; files = ( 522A93132C0DB5D50098FE49 /* JWPlayerKit in Frameworks */, + 9C1C69FA2C106B290035B2C7 /* RSKPlaceholderTextView in Frameworks */, 525954512BEB5EB700191286 /* SkeletonView in Frameworks */, 619A5A1BD8BD968ADC83C106 /* Pods_WOKA.framework in Frameworks */, ); @@ -464,6 +472,7 @@ 522A931B2C0DE9150098FE49 /* AboutUsVc.swift */, 52BC3BE12C0E02EE002FACA6 /* FaqVC.swift */, 9C7939182C0F345000F5D6E6 /* ContactSupportVC.swift */, + 9CA7C6BF2C1093E500D73742 /* ProfileVC.swift */, ); path = Controller; sourceTree = ""; @@ -995,6 +1004,8 @@ isa = PBXGroup; children = ( 9C7939122C0EFCAE00F5D6E6 /* FaqVM.swift */, + 9C1C69FB2C106C240035B2C7 /* ContactSupportVM.swift */, + 9CA7C6C12C1095B600D73742 /* ProfileVM.swift */, ); path = ViewModel; sourceTree = ""; @@ -1080,6 +1091,7 @@ packageProductDependencies = ( 525954502BEB5EB700191286 /* SkeletonView */, 522A93122C0DB5D50098FE49 /* JWPlayerKit */, + 9C1C69F92C106B290035B2C7 /* RSKPlaceholderTextView */, ); productName = WOKA; productReference = 523ED25A2BDA2BC700CFED02 /* WOKA.app */; @@ -1157,6 +1169,7 @@ packageReferences = ( 5259544F2BEB5EB700191286 /* XCRemoteSwiftPackageReference "SkeletonView" */, 522A93112C0DB5D50098FE49 /* XCRemoteSwiftPackageReference "JWPlayerKit-package" */, + 9C1C69F82C106B290035B2C7 /* XCRemoteSwiftPackageReference "RSKPlaceholderTextView" */, ); productRefGroup = 523ED25B2BDA2BC700CFED02 /* Products */; projectDirPath = ""; @@ -1346,6 +1359,7 @@ 525954172BE8CAD300191286 /* NetworkManager.swift in Sources */, 52B8D4DD2C04A25E00ED65F3 /* UIViewController+SideMenu.swift in Sources */, 525954292BEA079500191286 /* UserEmailVerifyDM.swift in Sources */, + 9C1C69FC2C106C240035B2C7 /* ContactSupportVM.swift in Sources */, 52A3F6AF2BECC0690000BB0B /* LinkedChildVM.swift in Sources */, 525954252BE8F01600191286 /* ValueWrapper.swift in Sources */, 52A3F6A82BECBF2A0000BB0B /* LinkedChildCell.swift in Sources */, @@ -1379,6 +1393,7 @@ 52C1A4E12C05B69F007BAA50 /* UIApplicationSwitchRoot.swift in Sources */, 52663FF72BDFACF60001D8CE /* ShadowView.swift in Sources */, 9C535DC22C00B36900DA6DCD /* ThemeTwoVC.swift in Sources */, + 9CA7C6C22C1095B600D73742 /* ProfileVM.swift in Sources */, 52D774F12BDFC53B001D87DE /* StringSubScript.swift in Sources */, 9CBE1B3F2C0F37B300CA6E61 /* DPDConstants.swift in Sources */, 52B8D4DA2C04A25E00ED65F3 /* Preferences.swift in Sources */, @@ -1396,6 +1411,7 @@ 525327D92BFCDDF700F64283 /* AuthFuncStartupSoundHandling.swift in Sources */, 52663FFB2BDFB1700001D8CE /* TextFieldShadow.swift in Sources */, 52C6E0212BE3ADE300E22D59 /* GenderEnum.swift in Sources */, + 9CA7C6C02C1093E500D73742 /* ProfileVC.swift in Sources */, 525953D12BE8B2B200191286 /* LLSpinner.swift in Sources */, 52C6E0272BE3B46A00E22D59 /* SelectAvatarCell.swift in Sources */, 9C535DB82C0089B400DA6DCD /* ViewButtonAnimation.swift in Sources */, @@ -1818,6 +1834,14 @@ version = 1.31.0; }; }; + 9C1C69F82C106B290035B2C7 /* XCRemoteSwiftPackageReference "RSKPlaceholderTextView" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/ruslanskorb/RSKPlaceholderTextView.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 8.0.0; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -1831,6 +1855,11 @@ package = 5259544F2BEB5EB700191286 /* XCRemoteSwiftPackageReference "SkeletonView" */; productName = SkeletonView; }; + 9C1C69F92C106B290035B2C7 /* RSKPlaceholderTextView */ = { + isa = XCSwiftPackageProductDependency; + package = 9C1C69F82C106B290035B2C7 /* XCRemoteSwiftPackageReference "RSKPlaceholderTextView" */; + productName = RSKPlaceholderTextView; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = 523ED2522BDA2BC700CFED02 /* Project object */; diff --git a/WOKA/Authentication/Controller/ResetPassUserNameVC.swift b/WOKA/Authentication/Controller/ResetPassUserNameVC.swift index 342864b..bfc08c3 100644 --- a/WOKA/Authentication/Controller/ResetPassUserNameVC.swift +++ b/WOKA/Authentication/Controller/ResetPassUserNameVC.swift @@ -56,7 +56,6 @@ extension ResetPassUserNameVC : UITextFieldDelegate{ textField.hideError() if !string.numberAndCharacterAndSpecialChar(){return false} return ValidatorClass.sharedInstanec.limitCharacter(length: 16,textField, shouldChangeCharactersIn: range, replacementString: string) - default: return true } diff --git a/WOKA/Constants K/ConstantString.swift b/WOKA/Constants K/ConstantString.swift index c0063b0..956890c 100644 --- a/WOKA/Constants K/ConstantString.swift +++ b/WOKA/Constants K/ConstantString.swift @@ -23,6 +23,7 @@ extension K{ static let genderSel = "Please select Gender." static let shortPass = "Password is too short." static let shortUsername = "Username is too short." + static let shortName = "Name is too short." static let userNameVerify = "Verifying Username" static let intrest = "Please select intrest" static let avatar = "Please select avatar" diff --git a/WOKA/Constants K/StoryBoardID.swift b/WOKA/Constants K/StoryBoardID.swift index 287acfc..2a62676 100644 --- a/WOKA/Constants K/StoryBoardID.swift +++ b/WOKA/Constants K/StoryBoardID.swift @@ -47,6 +47,7 @@ extension K{ static let aboutUsVc = "AboutUsVc" static let faqVC = "FaqVC" static let contactSupportVC = "ContactSupportVC" + static let profileVC = "ProfileVC" } } } diff --git a/WOKA/Helpers/UIElements Helper/TextFieldShadow.swift b/WOKA/Helpers/UIElements Helper/TextFieldShadow.swift index f663587..dc88c6b 100644 --- a/WOKA/Helpers/UIElements Helper/TextFieldShadow.swift +++ b/WOKA/Helpers/UIElements Helper/TextFieldShadow.swift @@ -40,3 +40,30 @@ class TextFieldShadow: UITextField { innerShadow.cornerRadius = self.frame.size.height/2 } } + +extension UIView { + func applyInnerShadow(radius : CGFloat) { + let innerShadow = CALayer() + layer.addSublayer(innerShadow) + + // Inner shadow setup + innerShadow.frame = bounds + + // Shadow path (1pt ring around bounds) + let radius = radius + let path = UIBezierPath(roundedRect: innerShadow.bounds.insetBy(dx: -1, dy: -1), cornerRadius: radius) + let cutout = UIBezierPath(roundedRect: innerShadow.bounds, cornerRadius: radius).reversing() + + path.append(cutout) + innerShadow.shadowPath = path.cgPath + innerShadow.masksToBounds = true + + // Shadow properties + innerShadow.shadowColor = UIColor.black.cgColor + innerShadow.shadowOffset = CGSize(width: 0, height: 1.2) + innerShadow.shadowOpacity = 0.8 + innerShadow.shadowRadius = 2 + innerShadow.cornerRadius = radius + } +} + diff --git a/WOKA/Home/Home.storyboard b/WOKA/Home/Home.storyboard index aa41dcd..1f7afd5 100644 --- a/WOKA/Home/Home.storyboard +++ b/WOKA/Home/Home.storyboard @@ -52,10 +52,10 @@ - + - + @@ -79,7 +79,7 @@ - + @@ -326,7 +326,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WOKA/SideBarNav/ViewModel/ContactSupportVM.swift b/WOKA/SideBarNav/ViewModel/ContactSupportVM.swift new file mode 100644 index 0000000..add06ce --- /dev/null +++ b/WOKA/SideBarNav/ViewModel/ContactSupportVM.swift @@ -0,0 +1,188 @@ +// +// ContactSupportVM.swift +// WOKA +// +// Created by Bilal on 05/06/2024. +// + +import UIKit +import Alamofire + +class ContactSupportVM{ + + weak var vc : ContactSupportVC! + let dropDownModule = DropDown() + var dataSource = [String]() + + func initView(){ + let color1 = #colorLiteral(red: 0.7294117647, green: 0.7529411765, blue: 0.3803921569, alpha: 1) + let color2 = #colorLiteral(red: 0.1843137255, green: 0.2156862745, blue: 0.0431372549, alpha: 1) + vc.view.applyGradient(colors: [color1, color2], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 0.8)) + vc.supportGirlImage.roundCorner() + + userTypeManipulations() + + + vc.emailTF.roundCorner() + vc.nameTF.roundCorner() + vc.nameTF.delegate = self.vc + vc.emailTF.delegate = self.vc + vc.messageTextView.delegate = self.vc + + + let color3 = #colorLiteral(red: 0.968627451, green: 0.7882352941, blue: 0.1294117647, alpha: 1) + let color4 = #colorLiteral(red: 0.968627451, green: 0.4196078431, blue: 0.1098039216, alpha: 1) + vc.submitBtn.applyGradient(colors: [color3, color4], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 0.8)) + vc.submitBtn.roundCorner() + + vc.subjectStack.roundCorner() + + vc.messageTextView.textContainerInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) + vc.messageTextView.applyInnerShadow(radius: 15) + vc.subjectStack.applyInnerShadow(radius: vc.subjectStack.frame.height / 2) + + vc.nameTF.addRightButton(title: "", tintColor: UIColor.red, btnImage: UIImage(systemName: "exclamationmark.circle.fill"), target: self, action: #selector(errorName)) + vc.nameTF.rightView?.isHidden = true + + vc.emailTF.addRightButton(title: "", tintColor: UIColor.red, btnImage: UIImage(systemName: "exclamationmark.circle.fill"), target: self, action: #selector(errorEmail)) + vc.emailTF.rightView?.isHidden = true + + dataSource = ["Query" , "Complaint", "Suggestion", "Other"] + initDropDown() + + vc.bottomArrow.addTapGesture { + self.dropDownModule.show() + } + + vc.subjectLabel.addTapGesture { + self.dropDownModule.show() + } + + } + + @objc func errorName(){ + let errorView = errorViews.object(forKey: vc.nameTF) + if let errorView = errorView { + errorView.isHidden.toggle() + } + } + + @objc func errorEmail(){ + let errorView = errorViews.object(forKey: vc.emailTF) + if let errorView = errorView { + errorView.isHidden.toggle() + } + } + + private func userTypeManipulations(){ + if let userType = AuthFunc.shareInstance.getUserType(){ // 1- kid , 2 - guardian , 3 - guest + switch userType{ + case 1: // if th user is child dont let him contact support + vc.subjectMainStack.isHidden = true + vc.nameStack.isHidden = true + vc.emailStack.isHidden = true + vc.messageStack.isHidden = true + vc.submitBtn.isHidden = true + vc.assistanceLabel.isHidden = false + return + case 2: + break + case 3: + vc.nameStack.isHidden = false + vc.emailStack.isHidden = false + default: + break + } + } + } + + func contactSupportApiCall(){ + let params: Parameters = [ + "user_id": AuthFunc.shareInstance.getUserID(), + "subject": vc.subjectLabel.text!, + "message": vc.messageTextView.text!, + ] + + let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi", + "access-token" : AuthFunc.shareInstance.getAccessToken()] + + Utilities.startProgressHUD() + NetworkManager.shareInstance.apiRequest(url: APIEndPoints.SideBarNav.user_queries_store, method: .post ,parameters: params,headers: headers) {(result : Result, NetworkManager.APIError>) in + switch result{ + case .success(let data): + switch data.success{ + case 0: // some error + Utilities.dismissProgressHUD() + self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) + case 1: // Success + Utilities.dismissProgressHUD() + self.vc.toast(msg: data.message ?? "Message Sent", time: 1.5) { + self.vc.navigationController?.popViewController(animated: true) + } + default: + Utilities.dismissProgressHUD() + self.vc.toast(msg: K.ConstantString.unRecognised , time: 1) + } + case .failure(let error): + Utilities.dismissProgressHUD() + self.vc.toast(msg: error.localizedDescription , time: 2) + } + } + } + + func guestContactSupportApiCall(){ + let params: Parameters = [ + "name": vc.nameTF.text!, + "email_id": vc.emailTF.text!, + "subject": vc.subjectLabel.text!, + "message": vc.messageTextView.text!, + ] + + let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi"] + + Utilities.startProgressHUD() + NetworkManager.shareInstance.apiRequest(url: APIEndPoints.SideBarNav.guest_queries_store, method: .post ,parameters: params,headers: headers) {(result : Result, NetworkManager.APIError>) in + switch result{ + case .success(let data): + switch data.success{ + case 0: // some error + Utilities.dismissProgressHUD() + self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) + case 1: // Success + Utilities.dismissProgressHUD() + self.vc.toast(msg: data.message ?? "Message Sent", time: 1.5) { + self.vc.navigationController?.popViewController(animated: true) + } + default: + Utilities.dismissProgressHUD() + self.vc.toast(msg: K.ConstantString.unRecognised , time: 1) + } + case .failure(let error): + Utilities.dismissProgressHUD() + self.vc.toast(msg: error.localizedDescription , time: 2) + } + } + } + + // this func will initialize the dropdown menu + func initDropDown(){ + dropDownModule.anchorView = vc.subjectStack + dropDownModule.dataSource = dataSource + dropDownModule.cornerRadius = 10 + dropDownModule.bottomOffset = CGPoint(x: 0, y:(dropDownModule.anchorView?.plainView.bounds.height)!) + dropDownModule.topOffset = CGPoint(x: 0, y:-(dropDownModule.anchorView?.plainView.bounds.height)!) + dropDownModule.direction = .bottom + dropDownModule.textFont = FontCustom.shareInstance.customFont(fontName: .Exo2_Medium, size: 16) + dropDownModule.shadowColor = UIColor.appColor(.TextDarkBlue)! + dropDownModule.backgroundColor = .white + dropDownModule.shadowOffset = CGSize(width: 0, height: 1) + dropDownModule.separatorColor = UIColor.lightGray + dropDownModule.width = vc.subjectStack.frame.width + dropDownModule.selectionBackgroundColor = UIColor.appColor(.TextDarkBlue)! + dropDownModule.selectedTextColor = UIColor.white + dropDownModule.selectionAction = { [weak self] (index: Int, item: String) in + self?.vc.subjectLabel.text = item + print(index , item) + } + } +} diff --git a/WOKA/SideBarNav/ViewModel/ProfileVM.swift b/WOKA/SideBarNav/ViewModel/ProfileVM.swift new file mode 100644 index 0000000..460f24b --- /dev/null +++ b/WOKA/SideBarNav/ViewModel/ProfileVM.swift @@ -0,0 +1,178 @@ +// +// ProfileVM.swift +// WOKA +// +// Created by Bilal on 05/06/2024. +// + +import UIKit +import Alamofire + +class ProfileVM{ + + weak var vc : ProfileVC! + var gender = Int() + + func initView(){ + vc.boyView.roundCorner(radius: 25) + vc.girlView.roundCorner(radius: 25) + vc.fullNameTF.roundCorner() + vc.emailTF.roundCorner() + vc.fullNameTF.delegate = self.vc + let color1 = #colorLiteral(red: 0.144693464, green: 0.1426281333, blue: 0.6686832905, alpha: 1) + let color2 = #colorLiteral(red: 0.6901960784, green: 0.2745098039, blue: 0.7568627451, alpha: 1) + vc.nextBtn.applyGradient(colors: [color1, color2], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0.8, y: 0)) + vc.nextBtn.roundCorner() + addTapGesture() + setUserData() + + /* + Depnding on user type limit the date + */ +// if AuthFunc.shareInstance.getUserType() == 2{ +// vc.dob.minimumDate = Calendar.current.date(byAdding: .year, value: -150, to: Date()) +// vc.dob.maximumDate = Calendar.current.date(byAdding: .year, value: -16, to: Date()) +// }else{ +// vc.dob.minimumDate = Calendar.current.date(byAdding: .year, value: -16, to: Date()) +// vc.dob.maximumDate = Calendar.current.date(byAdding: .year, value: -3, to: Date()) +// } + + enableDisableNextBtn(enable: false) + } + + func checkChanges(name : String?){ + guard let data = AuthFunc.shareInstance.userData else{return} + + if let name { + if name.trimmingCharacters(in: .whitespaces).lowercased() != data.fullname?.lowercased() { // || gender == data.gender + enableDisableNextBtn(enable: true) + } else{ + enableDisableNextBtn(enable: false) + } + } + + } + + private func enableDisableNextBtn(enable : Bool){ + if enable{ + vc.nextBtn.alpha = 1 + vc.nextBtn.isEnabled = true + }else{ + vc.nextBtn.alpha = 0.7 + vc.nextBtn.isEnabled = false + } + } + + func setUserData(){ + guard let data = AuthFunc.shareInstance.userData else{return} + gender = 2 // static for now + + vc.fullNameTF.text = data.fullname + vc.userNameLabel.text = data.username + vc.emailTF.text = data.email + + if let date = data.birthdate{ + let formattedDate = DateFormatterLib.dateMods(dateStr: date, dateCurrentFormat: .yyyy_MM_dd, dateReturnFormat: .yyyy_MM_dd, stringOrDate: .date).1 + vc.dob.date = formattedDate ?? Date() + } + //set the first name as the name + if let avatar = data.avtar{ + //https://wokaland.com/admin/storage/app/public/uploads/avtar/avatar2.png?d=1716889852 + vc.avatarImage.imageURL("https://wokaland.com/admin/storage/app/public/uploads/avtar/avatar2.png?d=1716889852",color: .white) + } + + setGender() + } + + private func addTapGesture(){ + vc.boyView.addTapGesture { + self.boyBtnTapped() + } + vc.girlView.addTapGesture { + self.girlBtnTapped() + } + } + + // MARK: - Update Profile API CALL + + func updateUserData(){ + let params: Parameters = [ + "fullname": vc.fullNameTF.text!, + "email": vc.emailTF.text!, + "gender": gender, //2->boy 1-> girl + ] + + let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi", + "access-token" : AuthFunc.shareInstance.getAccessToken()] + + Utilities.startProgressHUD(msg: "Updating") + NetworkManager.shareInstance.apiRequest(url: APIEndPoints.SideBarNav.update_profile, method: .post ,parameters: params,headers: headers) {(result : Result, NetworkManager.APIError>) in + switch result{ + case .success(let data): + switch data.success{ + case 0: // some error + Utilities.dismissProgressHUD() + 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.enableDisableNextBtn(enable: false) +// self.vc.navigationController?.popViewController(animated: true) + } + default: + Utilities.dismissProgressHUD() + self.vc.toast(msg: K.ConstantString.unRecognised , time: 1) + } + case .failure(let error): + Utilities.dismissProgressHUD() + self.vc.toast(msg: error.localizedDescription , time: 2) + } + } + } + + // MARK: - Gender Handler + + func boyBtnTapped() { + // Apply click effect animation + gender = 2 + UIView.animate(withDuration: 0.1, animations: { + self.vc.boyView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9) + }) { _ in + UIView.animate(withDuration: 0.1) { + self.vc.boyView.transform = .identity + self.setGender() + } + } + } + + func girlBtnTapped() { + gender = 1 + + // Apply click effect animation + UIView.animate(withDuration: 0.1, animations: { + self.vc.girlView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9) + }) { _ in + UIView.animate(withDuration: 0.1) { + self.vc.girlView.transform = .identity + self.setGender() + } + } + } + + func setGender(){ + let alphaComp = 0.6 + switch gender{ + case 2: + vc.boyView.backgroundColor = UIColor.white + vc.girlView.backgroundColor = UIColor.white.withAlphaComponent(alphaComp) + case 1: + vc.girlView.backgroundColor = UIColor.white + vc.boyView.backgroundColor = UIColor.white.withAlphaComponent(alphaComp) + default: + vc.girlView.backgroundColor = UIColor.white.withAlphaComponent(alphaComp) + vc.boyView.backgroundColor = UIColor.white.withAlphaComponent(alphaComp) + } + } +} diff --git a/WOKA/TabBar & SideMenu/Controller/SideMenuVC.swift b/WOKA/TabBar & SideMenu/Controller/SideMenuVC.swift index f8451e3..15f41c9 100644 --- a/WOKA/TabBar & SideMenu/Controller/SideMenuVC.swift +++ b/WOKA/TabBar & SideMenu/Controller/SideMenuVC.swift @@ -27,6 +27,7 @@ class SideMenuVC: UIViewController { @IBOutlet weak var faqBtn: UIButton! @IBOutlet weak var wokaSupportBtn: UIButton! @IBOutlet weak var profileBtn: UIButton! + @IBOutlet weak var myOrderBtn: UIButton! @IBOutlet weak var addChildBtn: UIButton! @IBOutlet weak var deactivateBtn: UIButton! @@ -60,6 +61,9 @@ class SideMenuVC: UIViewController { case wokaSupportBtn: self.sideMenuController?.hideMenu() NotificationCenter.default.post(name: .linkPush, object: nil, userInfo: ["type": LinkTypeEnum.support]) + case profileBtn: + self.sideMenuController?.hideMenu() + NotificationCenter.default.post(name: .linkPush, object: nil, userInfo: ["type": LinkTypeEnum.profile]) default: break diff --git a/WOKA/TabBar & SideMenu/Controller/TabBarVC.swift b/WOKA/TabBar & SideMenu/Controller/TabBarVC.swift index 8c9e837..984d94b 100644 --- a/WOKA/TabBar & SideMenu/Controller/TabBarVC.swift +++ b/WOKA/TabBar & SideMenu/Controller/TabBarVC.swift @@ -48,6 +48,10 @@ class TabBarVC: UITabBarController { let sb = UIStoryboard(name: K.StoryBoard.sideBarNav, bundle: nil) let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.SideBarNav.contactSupportVC) as! ContactSupportVC self.navigationController?.pushViewController(vcPush, animated: true) + case .profile: + let sb = UIStoryboard(name: K.StoryBoard.sideBarNav, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.SideBarNav.profileVC) as! ProfileVC + self.navigationController?.pushViewController(vcPush, animated: true) default: break } diff --git a/WOKA/TabBar & SideMenu/ViewModel/SideMenuVM.swift b/WOKA/TabBar & SideMenu/ViewModel/SideMenuVM.swift index 20ae7d9..105b938 100644 --- a/WOKA/TabBar & SideMenu/ViewModel/SideMenuVM.swift +++ b/WOKA/TabBar & SideMenu/ViewModel/SideMenuVM.swift @@ -88,6 +88,11 @@ class SideMenuVM{ vc.userName.text = (data.fullname == nil || data.fullname == "") ? "User" : data.fullname case "3": // Guest vc.userName.text = "" + vc.profileBtn.isHidden = true + vc.addChildBtn.isHidden = true + vc.deactivateBtn.isHidden = true + vc.myOrderBtn.isHidden = true + vc.logoutBtn.setTitle("Login/Register", for: .normal) break default: break diff --git a/WOKA/Theme/Base.lproj/Theme.storyboard b/WOKA/Theme/Base.lproj/Theme.storyboard index ca9a061..fc9b46c 100644 --- a/WOKA/Theme/Base.lproj/Theme.storyboard +++ b/WOKA/Theme/Base.lproj/Theme.storyboard @@ -621,7 +621,7 @@ - +