diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj index c9f4732..6ce1302 100644 --- a/WOKA.xcodeproj/project.pbxproj +++ b/WOKA.xcodeproj/project.pbxproj @@ -55,6 +55,12 @@ 52663FFB2BDFB1700001D8CE /* TextFieldShadow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52663FFA2BDFB1700001D8CE /* TextFieldShadow.swift */; }; 5272FCE32BDFDB05000ECB1D /* UserDetailsRegisterVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5272FCE22BDFDB05000ECB1D /* UserDetailsRegisterVC.swift */; }; 5272FCE52BDFDC8C000ECB1D /* UserDetailsRegisterVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5272FCE42BDFDC8C000ECB1D /* UserDetailsRegisterVM.swift */; }; + 52A3F6A52BECBA8D0000BB0B /* LinkedChildDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A3F6A42BECBA8D0000BB0B /* LinkedChildDM.swift */; }; + 52A3F6A82BECBF2A0000BB0B /* LinkedChildCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A3F6A62BECBF2A0000BB0B /* LinkedChildCell.swift */; }; + 52A3F6A92BECBF2A0000BB0B /* LinkedChildCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 52A3F6A72BECBF2A0000BB0B /* LinkedChildCell.xib */; }; + 52A3F6AB2BECBF550000BB0B /* LinkedChildVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A3F6AA2BECBF550000BB0B /* LinkedChildVC.swift */; }; + 52A3F6AD2BECC0340000BB0B /* TypeAlias.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A3F6AC2BECC0340000BB0B /* TypeAlias.swift */; }; + 52A3F6AF2BECC0690000BB0B /* LinkedChildVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52A3F6AE2BECC0690000BB0B /* LinkedChildVM.swift */; }; 52C6E01B2BE383C000E22D59 /* YourIntrestCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C6E0192BE383C000E22D59 /* YourIntrestCell.swift */; }; 52C6E01C2BE383C000E22D59 /* YourIntrestCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 52C6E01A2BE383C000E22D59 /* YourIntrestCell.xib */; }; 52C6E01E2BE3847F00E22D59 /* BorderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C6E01D2BE3847F00E22D59 /* BorderView.swift */; }; @@ -175,6 +181,12 @@ 52663FFA2BDFB1700001D8CE /* TextFieldShadow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldShadow.swift; sourceTree = ""; }; 5272FCE22BDFDB05000ECB1D /* UserDetailsRegisterVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDetailsRegisterVC.swift; sourceTree = ""; }; 5272FCE42BDFDC8C000ECB1D /* UserDetailsRegisterVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDetailsRegisterVM.swift; sourceTree = ""; }; + 52A3F6A42BECBA8D0000BB0B /* LinkedChildDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedChildDM.swift; sourceTree = ""; }; + 52A3F6A62BECBF2A0000BB0B /* LinkedChildCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedChildCell.swift; sourceTree = ""; }; + 52A3F6A72BECBF2A0000BB0B /* LinkedChildCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LinkedChildCell.xib; sourceTree = ""; }; + 52A3F6AA2BECBF550000BB0B /* LinkedChildVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedChildVC.swift; sourceTree = ""; }; + 52A3F6AC2BECC0340000BB0B /* TypeAlias.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypeAlias.swift; sourceTree = ""; }; + 52A3F6AE2BECC0690000BB0B /* LinkedChildVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkedChildVM.swift; sourceTree = ""; }; 52C6E0192BE383C000E22D59 /* YourIntrestCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YourIntrestCell.swift; sourceTree = ""; }; 52C6E01A2BE383C000E22D59 /* YourIntrestCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = YourIntrestCell.xib; sourceTree = ""; }; 52C6E01D2BE3847F00E22D59 /* BorderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BorderView.swift; sourceTree = ""; }; @@ -495,6 +507,7 @@ 525954312BEA39D200191286 /* AddTapGesture.swift */, 525954592BEB67D200191286 /* DateFormatterLib.swift */, 5259545D2BEBBA1A00191286 /* LoadingIndicatorImageView.swift */, + 52A3F6AC2BECC0340000BB0B /* TypeAlias.swift */, ); path = Helpers; sourceTree = ""; @@ -585,6 +598,7 @@ 5259542A2BEA292800191286 /* UserRegPostModel.swift */, 525954332BEA620800191286 /* IntrestTopicDM.swift */, 5259545B2BEBB80400191286 /* AvatarDM.swift */, + 52A3F6A42BECBA8D0000BB0B /* LinkedChildDM.swift */, ); path = Model; sourceTree = ""; @@ -596,6 +610,8 @@ 52C6E01A2BE383C000E22D59 /* YourIntrestCell.xib */, 52C6E0242BE3B46A00E22D59 /* SelectAvatarCell.swift */, 52C6E0252BE3B46A00E22D59 /* SelectAvatarCell.xib */, + 52A3F6A62BECBF2A0000BB0B /* LinkedChildCell.swift */, + 52A3F6A72BECBF2A0000BB0B /* LinkedChildCell.xib */, ); path = View; sourceTree = ""; @@ -609,6 +625,7 @@ 52CA28FB2BE11A0400708B49 /* UserIntrestVM.swift */, 52C6E0282BE3B52500E22D59 /* SelectAvatarVM.swift */, 9CBCB29C2BE4D6BB007D7934 /* LoginVM.swift */, + 52A3F6AE2BECC0690000BB0B /* LinkedChildVM.swift */, ); path = ViewModel; sourceTree = ""; @@ -624,6 +641,7 @@ 9CBCB29A2BE4D614007D7934 /* LoginVC.swift */, 9CBCB2A22BE50C95007D7934 /* ResetPassUserNameVC.swift */, 9CBCB2A42BE50D49007D7934 /* NewPasswordVC.swift */, + 52A3F6AA2BECBF550000BB0B /* LinkedChildVC.swift */, ); path = Controller; sourceTree = ""; @@ -774,6 +792,7 @@ 525954382BEB4B3B00191286 /* Exo2-Regular.ttf in Resources */, 525954392BEB4B3B00191286 /* Exo2-ExtraBold.ttf in Resources */, 5259543A2BEB4B3B00191286 /* Exo2-SemiBold.ttf in Resources */, + 52A3F6A92BECBF2A0000BB0B /* LinkedChildCell.xib in Resources */, 523ED2652BDA2BC700CFED02 /* Base in Resources */, 52C6E01C2BE383C000E22D59 /* YourIntrestCell.xib in Resources */, 52C6E0262BE3B46A00E22D59 /* SelectAvatarCell.xib in Resources */, @@ -856,6 +875,7 @@ 5259545E2BEBBA1A00191286 /* LoadingIndicatorImageView.swift in Sources */, 52CA28FC2BE11A0400708B49 /* UserIntrestVM.swift in Sources */, 9C27E1602BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift in Sources */, + 52A3F6AD2BECC0340000BB0B /* TypeAlias.swift in Sources */, 5259541D2BE8D94400191286 /* QueueHelper.swift in Sources */, 525954232BE8F00400191286 /* BaseResponseModel.swift in Sources */, 9C27E1692BDB76F200EC1DA9 /* OnBoardVM.swift in Sources */, @@ -877,6 +897,8 @@ 523ED25E2BDA2BC700CFED02 /* AppDelegate.swift in Sources */, 52D774ED2BDFC13F001D87DE /* OTPVM.swift in Sources */, 9CBCB2A32BE50C95007D7934 /* ResetPassUserNameVC.swift in Sources */, + 52A3F6A52BECBA8D0000BB0B /* LinkedChildDM.swift in Sources */, + 52A3F6AB2BECBF550000BB0B /* LinkedChildVC.swift in Sources */, 9CBCB2A52BE50D49007D7934 /* NewPasswordVC.swift in Sources */, 9CBCB29F2BE4E13A007D7934 /* ValidatorClass.swift in Sources */, 9CBCB29B2BE4D614007D7934 /* LoginVC.swift in Sources */, @@ -895,7 +917,9 @@ 525954122BE8C84900191286 /* Toast.swift in Sources */, 525954172BE8CAD300191286 /* NetworkManager.swift in Sources */, 525954292BEA079500191286 /* UserEmailVerifyDM.swift in Sources */, + 52A3F6AF2BECC0690000BB0B /* LinkedChildVM.swift in Sources */, 525954252BE8F01600191286 /* ValueWrapper.swift in Sources */, + 52A3F6A82BECBF2A0000BB0B /* LinkedChildCell.swift in Sources */, 52C6E01E2BE3847F00E22D59 /* BorderView.swift in Sources */, 52C8B0742BDA7626003B51D0 /* OnBoardVC.swift in Sources */, 525953CF2BE8B28F00191286 /* Utilities.swift in Sources */, diff --git a/WOKA/Authentication/Base.lproj/AuthenticationSB.storyboard b/WOKA/Authentication/Base.lproj/AuthenticationSB.storyboard index 165e0f9..507735f 100644 --- a/WOKA/Authentication/Base.lproj/AuthenticationSB.storyboard +++ b/WOKA/Authentication/Base.lproj/AuthenticationSB.storyboard @@ -729,8 +729,10 @@ Sent to Your Parent’s Email + + @@ -1317,46 +1319,141 @@ Sent to Your Parent’s Email + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + diff --git a/WOKA/Authentication/Controller/EmailVC.swift b/WOKA/Authentication/Controller/EmailVC.swift index fe6e46d..c84f351 100644 --- a/WOKA/Authentication/Controller/EmailVC.swift +++ b/WOKA/Authentication/Controller/EmailVC.swift @@ -59,8 +59,10 @@ class EmailVC: UIViewController { */ switch AuthFunc.shareInstance.userType{ + //if parent verify the email case .adult: vm.checkEmail() + // if kid then directly send the otp by checking the format of email case .kid: vm.sendOTP() } diff --git a/WOKA/Authentication/Controller/LinkedChildVC.swift b/WOKA/Authentication/Controller/LinkedChildVC.swift new file mode 100644 index 0000000..d5132f8 --- /dev/null +++ b/WOKA/Authentication/Controller/LinkedChildVC.swift @@ -0,0 +1,62 @@ +// +// LinkedChildVC.swift +// WOKA +// +// Created by MacBook Pro on 09/05/24. +// + +import UIKit + +class LinkedChildVC: UIViewController { + + @IBOutlet weak var tableView: UITableView! + @IBOutlet weak var nextBtn: LocalisedElementsButton! + + var vm = LinkedChildVM() + + override func viewDidLoad() { + super.viewDidLoad() + vm.vc = self + vm.initView() + } + + 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) { + let sb = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil) + let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.userDetailsRegisterVC) as! UserDetailsRegisterVC + self.navigationController?.pushViewController(vc, animated: true) + } + +} + +// MARK: - TableView + +extension LinkedChildVC : TableViewSRC{ + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return vm.linkedChilds.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: K.CellIdentifier.Authentication.linkedChildCell, for: indexPath) as! LinkedChildCell + cell.setData(data: vm.linkedChilds[indexPath.row]) + return cell + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + print(indexPath.row) + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return 100 + } +} diff --git a/WOKA/Authentication/Controller/SelectAvatarVC.swift b/WOKA/Authentication/Controller/SelectAvatarVC.swift index aff458c..cd64ae4 100644 --- a/WOKA/Authentication/Controller/SelectAvatarVC.swift +++ b/WOKA/Authentication/Controller/SelectAvatarVC.swift @@ -31,6 +31,20 @@ class SelectAvatarVC: UIViewController { } @IBAction func nextBtnTapped(_ sender: LocalisedElementsButton) { + // Check for avatar. + if AuthFunc.shareInstance.regData.avtar == nil || AuthFunc.shareInstance.regData.avtar == ""{ + let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC + + vcPush.contentLabel = K.ConstantString.intrest + vcPush.mainTitleText = K.ConstantString.error + // vcPush.onDoneBlock = { isDone in } + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + self.present(vcPush, animated: true) + return + } + vm.registerUser() } } @@ -49,7 +63,8 @@ extension SelectAvatarVC : UICollectionViewDelegate , UICollectionViewDataSource } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - + AuthFunc.shareInstance.regData.avtar = vm.avatarData[indexPath.row].avatarName + collectionView.reloadData() } } diff --git a/WOKA/Authentication/Controller/UserIntrestVC.swift b/WOKA/Authentication/Controller/UserIntrestVC.swift index 55d2c9a..8b72314 100644 --- a/WOKA/Authentication/Controller/UserIntrestVC.swift +++ b/WOKA/Authentication/Controller/UserIntrestVC.swift @@ -22,6 +22,8 @@ class UserIntrestVC: UIViewController { @IBOutlet weak var fullName: UILabel! @IBOutlet weak var contentHeight: NSLayoutConstraint! + @IBOutlet weak var intrestStackView: UIStackView! + @IBOutlet weak var selectAsManyYouWant: UILabel! var vm = UserIntrestVM() var test = [Temp(text: "ADVENTURES", selected: false), @@ -63,7 +65,7 @@ class UserIntrestVC: UIViewController { /* Append the DOB to RegData */ - AuthFunc.shareInstance.regData.date_of_birth = dob + AuthFunc.shareInstance.regData.birthdate = dob // Check for Gender. if AuthFunc.shareInstance.regData.gender == nil{ @@ -80,21 +82,24 @@ class UserIntrestVC: UIViewController { } // Check for Intrest. - if AuthFunc.shareInstance.regData.interest_topic_id == nil || AuthFunc.shareInstance.regData.interest_topic_id?.count == 0{ - let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) - let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC - - vcPush.contentLabel = K.ConstantString.intrest - vcPush.mainTitleText = K.ConstantString.error - // vcPush.onDoneBlock = { isDone in } - vcPush.modalPresentationStyle = .overCurrentContext - vcPush.modalTransitionStyle = .crossDissolve - self.present(vcPush, animated: true) - return + if AuthFunc.shareInstance.userType == .kid{ + if AuthFunc.shareInstance.regData.interest_topic_id == nil || AuthFunc.shareInstance.regData.interest_topic_id?.count == 0{ + let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC + + vcPush.contentLabel = K.ConstantString.intrest + vcPush.mainTitleText = K.ConstantString.error + // vcPush.onDoneBlock = { isDone in } + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + self.present(vcPush, animated: true) + return + } } + // Check for DOB. - if AuthFunc.shareInstance.regData.date_of_birth == nil{ + if AuthFunc.shareInstance.regData.birthdate == nil{ let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC diff --git a/WOKA/Authentication/Model/LinkedChildDM.swift b/WOKA/Authentication/Model/LinkedChildDM.swift new file mode 100644 index 0000000..8611c3b --- /dev/null +++ b/WOKA/Authentication/Model/LinkedChildDM.swift @@ -0,0 +1,22 @@ +// +// LinkedChildDM.swift +// WOKA +// +// Created by MacBook Pro on 09/05/24. +// + +import Foundation + +// MARK: - LinkedChildDM + +struct LinkedChildDM: Codable { + let result: [ResultChild]? + + // MARK: - Result + struct ResultChild: Codable { + let id: Int? + let username, fullname: String? + let avtar: String? + } +} + diff --git a/WOKA/Authentication/Model/UserDataDM.swift b/WOKA/Authentication/Model/UserDataDM.swift index 0eace71..832ec99 100644 --- a/WOKA/Authentication/Model/UserDataDM.swift +++ b/WOKA/Authentication/Model/UserDataDM.swift @@ -9,10 +9,10 @@ import Foundation // MARK: - UserDataDM struct UserDataDM: Codable { - let result: Result? + let result: ResultData? // MARK: - Result - struct Result: Codable { + struct ResultData: Codable { let id: Int? let username, fullname: String? let gender: Gender? @@ -20,19 +20,15 @@ struct UserDataDM: Codable { let avtar: String? let userType: String? let languageMasterID: Int? - let isActive: String? - let deletedAt: String? let lastLogin, rememberToken: String? - let childDetail: String? + let childDetail: ChildDetail? let language: Language? let alreadyLoggedIn: Bool? - + enum CodingKeys: String, CodingKey { case id, username, fullname, gender, birthdate, email, avtar case userType = "user_type" case languageMasterID = "language_master_id" - case isActive = "is_active" - case deletedAt = "deleted_at" case lastLogin = "last_login" case rememberToken = "remember_token" case childDetail = "child_detail" @@ -40,7 +36,30 @@ struct UserDataDM: Codable { case alreadyLoggedIn = "already_logged_in" } } - + + // MARK: - ChildDetail + struct ChildDetail: Codable { + let id, userID: Int? + let interestTopic: [InterestTopic]? + + enum CodingKeys: String, CodingKey { + case id + case userID = "user_id" + case interestTopic = "interest_topic" + } + } + + // MARK: - InterestTopic + struct InterestTopic: Codable { + let id: Int? + let topicName: String? + + enum CodingKeys: String, CodingKey { + case id + case topicName = "topic_name" + } + } + // MARK: - Gender struct Gender: Codable { let id: Int? @@ -51,7 +70,7 @@ struct UserDataDM: Codable { case genderName = "gender_name" } } - + // MARK: - Language struct Language: Codable { let id: Int? @@ -63,5 +82,59 @@ struct UserDataDM: Codable { } } } - - +//// MARK: - UserDataDM +//struct UserDataDM: Codable { +// let result: Result? +// +// // MARK: - Result +// struct Result: Codable { +// let id: Int? +// let username, fullname: String? +// let gender: Gender? +// let birthdate, email: String? +// let avtar: String? +// let userType: String? +// let languageMasterID: Int? +// let isActive: String? +// let deletedAt: String? +// let lastLogin, rememberToken: String? +// let childDetail: String? +// let language: Language? +// let alreadyLoggedIn: Bool? +// +// enum CodingKeys: String, CodingKey { +// case id, username, fullname, gender, birthdate, email, avtar +// case userType = "user_type" +// case languageMasterID = "language_master_id" +// case isActive = "is_active" +// case deletedAt = "deleted_at" +// case lastLogin = "last_login" +// case rememberToken = "remember_token" +// case childDetail = "child_detail" +// case language +// case alreadyLoggedIn = "already_logged_in" +// } +// } +// +// // MARK: - Gender +// struct Gender: Codable { +// let id: Int? +// let genderName: String? +// +// enum CodingKeys: String, CodingKey { +// case id +// case genderName = "gender_name" +// } +// } +// +// // MARK: - Language +// struct Language: Codable { +// let id: Int? +// let languageName: String? +// +// enum CodingKeys: String, CodingKey { +// case id +// case languageName = "language_name" +// } +// } +//} diff --git a/WOKA/Authentication/Model/UserRegPostModel.swift b/WOKA/Authentication/Model/UserRegPostModel.swift index 78df19f..95023a1 100644 --- a/WOKA/Authentication/Model/UserRegPostModel.swift +++ b/WOKA/Authentication/Model/UserRegPostModel.swift @@ -12,7 +12,7 @@ struct UserRegPostModel: Encodable { var username : String? var password : String? var gender : Int? //mandatory (1 for girl/female, 2 for boy/male) - var date_of_birth: String? //2015-11-1 + var birthdate: String? //2015-11-1 var email: String? var guardian_email: String? var user_type: String? @@ -28,9 +28,9 @@ struct UserRegPostModel: Encodable { "username" : username ?? "", "password" : password ?? "", "gender" : gender ?? "", - "date_of_birth": date_of_birth ?? "", + "birthdate": birthdate ?? "", "email": email ?? "", - "guardian_email": guardian_email ?? "", + "guardian_email": guardian_email ?? nil, "user_type": user_type ?? "", "language_id": language_id ?? "", "interest_topic_id": interest_topic_id ?? [], diff --git a/WOKA/Authentication/View/LinkedChildCell.swift b/WOKA/Authentication/View/LinkedChildCell.swift new file mode 100644 index 0000000..5ef78b7 --- /dev/null +++ b/WOKA/Authentication/View/LinkedChildCell.swift @@ -0,0 +1,36 @@ +// +// LinkedChildCell.swift +// WOKA +// +// Created by MacBook Pro on 09/05/24. +// + +import UIKit + +class LinkedChildCell: UITableViewCell { + + @IBOutlet weak var outerView: UIView! + @IBOutlet weak var childAvatarImage: UIImageView! + @IBOutlet weak var childName: UILabel! + @IBOutlet weak var imageSupportView: UIView! + + override func awakeFromNib() { + super.awakeFromNib() + outerView.roundCorner(radius: 15) + imageSupportView.roundCorner() + outerView.backgroundColor = .white.withAlphaComponent(0.5) + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + + func setData(data : LinkedChildDM.ResultChild){ + if let imageAvatar = data.avtar{ + self.childAvatarImage.imageURL(imageAvatar) + } + self.childName.text = data.username + } +} diff --git a/WOKA/Authentication/View/LinkedChildCell.xib b/WOKA/Authentication/View/LinkedChildCell.xib new file mode 100644 index 0000000..e8a9a23 --- /dev/null +++ b/WOKA/Authentication/View/LinkedChildCell.xib @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + Exo2-Bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WOKA/Authentication/View/SelectAvatarCell.swift b/WOKA/Authentication/View/SelectAvatarCell.swift index c7c340e..3ffe40a 100644 --- a/WOKA/Authentication/View/SelectAvatarCell.swift +++ b/WOKA/Authentication/View/SelectAvatarCell.swift @@ -16,15 +16,37 @@ class SelectAvatarCell: UICollectionViewCell { super.awakeFromNib() self.outerView.backgroundColor = UIColor.white.withAlphaComponent(0.5) } - + override func layoutSubviews() { self.roundCorner() } func setData(data : AvatarDM.ResultRecords){ + /* + Reset the cells + */ + self.outerView.backgroundColor = UIColor.white.withAlphaComponent(0.5) + + if data.avatarName == AuthFunc.shareInstance.regData.avtar{ + // Provide haptic feedback + let selectionFeedback = UISelectionFeedbackGenerator() + selectionFeedback.selectionChanged() + UIView.animate(withDuration: 0.1, animations: { [weak self] in + guard let self else{return} + imageView.transform = CGAffineTransform(scaleX: 0.9, y: 0.9) + }) { _ in + UIView.animate(withDuration: 0.1) { [weak self] in + guard let self else{return} + imageView.transform = .identity + outerView.backgroundColor = .white + } + } + }else{ + self.outerView.backgroundColor = UIColor.white.withAlphaComponent(0.5) + } + if let url = data.avatarImageURL{ self.imageView.imageURL(url) } -// self.imageView.image = UIImage(named: "avatar") } } diff --git a/WOKA/Authentication/View/SelectAvatarCell.xib b/WOKA/Authentication/View/SelectAvatarCell.xib index 37e5463..b82a4fe 100644 --- a/WOKA/Authentication/View/SelectAvatarCell.xib +++ b/WOKA/Authentication/View/SelectAvatarCell.xib @@ -22,15 +22,15 @@ - + - - - - + + + + diff --git a/WOKA/Authentication/ViewModel/EmailVM.swift b/WOKA/Authentication/ViewModel/EmailVM.swift index 6e16cf0..156301e 100644 --- a/WOKA/Authentication/ViewModel/EmailVM.swift +++ b/WOKA/Authentication/ViewModel/EmailVM.swift @@ -69,8 +69,7 @@ class EmailVM{ Send OTP Start updating the user Reg data */ - - AuthFunc.shareInstance.regData.email = self.vc.enterEmailTF.text! + self.sendOTP() default: break @@ -83,6 +82,7 @@ class EmailVM{ } func sendOTP(){ + let params: Parameters = [ "email": vc.enterEmailTF.text!, "user_type": AuthFunc.shareInstance.userType == .adult ? "2" :"1" @@ -99,6 +99,14 @@ class EmailVM{ self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) case 1: // Success Utilities.dismissProgressHUD() + /* + Set both guardian and normal email + */ + AuthFunc.shareInstance.regData.email = self.vc.enterEmailTF.text! + if AuthFunc.shareInstance.userType == .kid{ + AuthFunc.shareInstance.regData.guardian_email = self.vc.enterEmailTF.text! + } + guard let uniqueString = data.data?.unique_string else{ self.vc.toast(msg: K.ConstantString.unRecognised , time: 1) return diff --git a/WOKA/Authentication/ViewModel/LinkedChildVM.swift b/WOKA/Authentication/ViewModel/LinkedChildVM.swift new file mode 100644 index 0000000..a740ce2 --- /dev/null +++ b/WOKA/Authentication/ViewModel/LinkedChildVM.swift @@ -0,0 +1,29 @@ +// +// LinkedChildVM.swift +// WOKA +// +// Created by MacBook Pro on 09/05/24. +// + +import UIKit + +class LinkedChildVM{ + + weak var vc : LinkedChildVC! + + var linkedChilds = [LinkedChildDM.ResultChild]() + + func initView(){ + setupCell() + 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() + } + + func setupCell(){ + vc.tableView.register(UINib(nibName: K.CellIdentifier.Authentication.linkedChildCell, bundle: nil), forCellReuseIdentifier: K.CellIdentifier.Authentication.linkedChildCell) + vc.tableView.delegate = vc.self + vc.tableView.dataSource = vc.self + } +} diff --git a/WOKA/Authentication/ViewModel/LoginVM.swift b/WOKA/Authentication/ViewModel/LoginVM.swift index 211fe77..51faf55 100644 --- a/WOKA/Authentication/ViewModel/LoginVM.swift +++ b/WOKA/Authentication/ViewModel/LoginVM.swift @@ -64,7 +64,7 @@ class LoginVM{ "username": vc.userNameTF.text!, "password": vc.passwordTF.text! ] - let header : HTTPHeaders = ["device-id" : "12345"] + let header : HTTPHeaders = ["device-id" : AuthFunc.shareInstance.getDeviceUUID()] Utilities.startProgressHUD() NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.login, method: .post ,parameters: params, headers: header) {(result : Result, NetworkManager.APIError>) in diff --git a/WOKA/Authentication/ViewModel/OTPVM.swift b/WOKA/Authentication/ViewModel/OTPVM.swift index 256b985..0aa84ef 100644 --- a/WOKA/Authentication/ViewModel/OTPVM.swift +++ b/WOKA/Authentication/ViewModel/OTPVM.swift @@ -129,6 +129,9 @@ class OTPVM{ self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) case 1: // Success Utilities.dismissProgressHUD() + if let string = data.data?.unique_string{ + self.validateString = string + } self.emptyTF(tf: [self.vc.tf1,self.vc.tf2,self.vc.tf3,self.vc.tf4]) self.startTimer() self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) @@ -143,7 +146,53 @@ class OTPVM{ } } + func getLinkedChild(){ + let params: Parameters = [ + "email": AuthFunc.shareInstance.regData.email!, + ] + + Utilities.startProgressHUD() + NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.get_linked_child, method: .post ,parameters: params) {(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) + let sb = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil) + let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.userDetailsRegisterVC) as! UserDetailsRegisterVC + self.vc.navigationController?.pushViewController(vc, animated: true) + case 1: // Success + Utilities.dismissProgressHUD() + guard let result = data.data?.result else{ + self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) + return + } + + let sb = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil) + let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.linkedChildVC) as! LinkedChildVC + vc.vm.linkedChilds = result + self.vc.navigationController?.pushViewController(vc, 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 navigate(){ + /* + if parent is doing registeration please check if he has any child linked + */ + if AuthFunc.shareInstance.userType == .adult{ + self.getLinkedChild() + return + } + switch self.vc.navigateCheck{ case .newPass: let sb = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil) diff --git a/WOKA/Authentication/ViewModel/SelectAvatarVM.swift b/WOKA/Authentication/ViewModel/SelectAvatarVM.swift index 117dad0..5ef7e00 100644 --- a/WOKA/Authentication/ViewModel/SelectAvatarVM.swift +++ b/WOKA/Authentication/ViewModel/SelectAvatarVM.swift @@ -6,11 +6,13 @@ // import UIKit +import Alamofire class SelectAvatarVM{ weak var vc : SelectAvatarVC! var avatarData = [AvatarDM.ResultRecords]() + func initView(){ 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) @@ -36,7 +38,19 @@ class SelectAvatarVM{ switch data.success{ case 0: Utilities.dismissProgressHUD() - self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) + + let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC + vcPush.contentLabel = data.message ?? "Unrecognised error" + vcPush.mainTitleText = "Error" + vcPush.yesBtnText = "Retry?" + vcPush.onDoneBlock = { isDone in + self.getAvatarListing() + } + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + self.vc.present(vcPush, animated: true) + return case 1: Utilities.dismissProgressHUD() if let avatarData = data.data?.result{ @@ -48,7 +62,88 @@ class SelectAvatarVM{ } case .failure(let error): Utilities.dismissProgressHUD() - self.vc.toast(msg: error.localizedDescription, time: 2) + let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC + vcPush.contentLabel = error.localizedDescription + vcPush.mainTitleText = "Error" + vcPush.yesBtnText = "Retry?" + vcPush.onDoneBlock = { isDone in + self.getAvatarListing() + } + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + self.vc.present(vcPush, animated: true) + } + } + } + + func registerUser(){ + /* + Set UserType + */ + if AuthFunc.shareInstance.userType == .adult{ + AuthFunc.shareInstance.regData.user_type = "2" + }else{ + AuthFunc.shareInstance.regData.user_type = "1" + } + + /* + In Reg Add child will be 0 + */ + AuthFunc.shareInstance.regData.add_child = "0" + + /* + Set Language id + */ + if AuthFunc.shareInstance.languageSelected == .hindi{ + AuthFunc.shareInstance.regData.language_id = "2" + }else{ + AuthFunc.shareInstance.regData.language_id = "1" + } + + Utilities.startProgressHUD() + + let headers : HTTPHeaders = ["device-id" : AuthFunc.shareInstance.getDeviceUUID()] + + NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.child_registration, method: .post,parameters: AuthFunc.shareInstance.regData.dictionaryRepresentation, headers: headers) {(result : Result, NetworkManager.APIError>) in + switch result{ + case .success(let data): + switch data.success{ + case 0: + Utilities.dismissProgressHUD() + + let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC + vcPush.contentLabel = data.message ?? "Unrecognised error" + vcPush.mainTitleText = "Error" + vcPush.yesBtnText = "Retry?" + vcPush.onDoneBlock = { isDone in + self.getAvatarListing() + } + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + self.vc.present(vcPush, animated: true) + return + case 1: + Utilities.dismissProgressHUD() + AuthFunc.shareInstance.regData = UserRegPostModel() + print(data.data?.result) + default: + break + } + case .failure(let error): + Utilities.dismissProgressHUD() + let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.alertCustomVC) as! AlertCustomVC + vcPush.contentLabel = error.localizedDescription + vcPush.mainTitleText = "Error" + vcPush.yesBtnText = "Retry?" + vcPush.onDoneBlock = { isDone in + self.getAvatarListing() + } + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + self.vc.present(vcPush, animated: true) } } } diff --git a/WOKA/Authentication/ViewModel/UserIntrestVM.swift b/WOKA/Authentication/ViewModel/UserIntrestVM.swift index 3854ee1..548eebc 100644 --- a/WOKA/Authentication/ViewModel/UserIntrestVM.swift +++ b/WOKA/Authentication/ViewModel/UserIntrestVM.swift @@ -11,12 +11,9 @@ import Alamofire class UserIntrestVM{ weak var vc : UserIntrestVC! -// var gender = GenderEnum.none var intrestTopics = [IntrestTopicDM.Result]() func initView(){ - setupCell() - /* Setting the minimum and maximum date as per user type */ @@ -54,8 +51,24 @@ class UserIntrestVM{ let tapGesture2 = UITapGestureRecognizer(target: self, action: #selector(girlBtnTapped)) vc.girlView.addGestureRecognizer(tapGesture2) + if AuthFunc.shareInstance.userType == .adult{ + /* + If user type is adult then no need to show intrest + */ + self.vc.intrestStackView.isHidden = true + self.vc.selectAsManyYouWant.isHidden = true + }else{ + /* + If user type is child get the intrest and show all + */ + setupCell() + getIntrests() + } + + /* + Setup Gender Stack for selection + */ setGender() - getIntrests() } func setGender(){ diff --git a/WOKA/Constants K/CellIdentifier.swift b/WOKA/Constants K/CellIdentifier.swift index b5f4b72..7e66519 100644 --- a/WOKA/Constants K/CellIdentifier.swift +++ b/WOKA/Constants K/CellIdentifier.swift @@ -20,6 +20,7 @@ extension K{ struct Authentication{ static let yourIntrestCell = "YourIntrestCell" static let selectAvatarCell = "SelectAvatarCell" + static let linkedChildCell = "LinkedChildCell" } } } diff --git a/WOKA/Constants K/ConstantString.swift b/WOKA/Constants K/ConstantString.swift index fd7219f..34dcf3a 100644 --- a/WOKA/Constants K/ConstantString.swift +++ b/WOKA/Constants K/ConstantString.swift @@ -26,6 +26,7 @@ extension K{ static let userNameVerify = "Verifying Username" static let intrest = "Please select intrest." static let dob = "Please select DOB." + static let registerUser = "Please wait registering user." static let error = "Error" } diff --git a/WOKA/Constants K/StoryBoardID.swift b/WOKA/Constants K/StoryBoardID.swift index 05bc612..2ddd8a6 100644 --- a/WOKA/Constants K/StoryBoardID.swift +++ b/WOKA/Constants K/StoryBoardID.swift @@ -26,6 +26,7 @@ extension K{ static let loginVC = "LoginVC" static let resetPassUserNameVC = "ResetPassUserNameVC" static let newPasswordVC = "NewPasswordVC" + static let linkedChildVC = "LinkedChildVC" } struct Home{ diff --git a/WOKA/Helpers/TypeAlias.swift b/WOKA/Helpers/TypeAlias.swift new file mode 100644 index 0000000..c3f8402 --- /dev/null +++ b/WOKA/Helpers/TypeAlias.swift @@ -0,0 +1,14 @@ +// +// TypeAlias.swift +// WOKA +// +// Created by MacBook Pro on 09/05/24. +// + +import UIKit + +typealias CollectionViewSRC = UICollectionViewDelegate & UICollectionViewDataSource + +typealias TableViewSRC = UITableViewDelegate & UITableViewDataSource + +typealias ImagePicker = UINavigationControllerDelegate & UIImagePickerControllerDelegate diff --git a/WOKA/Main/AuthFunc.swift b/WOKA/Main/AuthFunc.swift index b7526d6..aad3372 100644 --- a/WOKA/Main/AuthFunc.swift +++ b/WOKA/Main/AuthFunc.swift @@ -7,6 +7,7 @@ import Foundation import AVFoundation +import UIKit /* Language Enum @@ -36,6 +37,16 @@ class AuthFunc{ static let shareInstance = AuthFunc() + func getDeviceUUID() -> String{ + /* + UIDevice.current.name // e.g. "My iPhone" + UIDevice.current.model // e.g. @"iPhone", @"iPod touch" + UIDevice.current.localizedModel // localized version of model + UIDevice.current.systemName // e.g. @"iOS" + UIDevice.current.systemVersion // e.g. @"15.5" + */ + return UIDevice.current.identifierForVendor!.uuidString + } func setAuthIDPass(){ if let id = Bundle.main.infoDictionary?["API_KEY_ID"] as? String{ diff --git a/WOKA/Network Adapter/APIEndPoints.swift b/WOKA/Network Adapter/APIEndPoints.swift index f47f9d4..9421524 100644 --- a/WOKA/Network Adapter/APIEndPoints.swift +++ b/WOKA/Network Adapter/APIEndPoints.swift @@ -29,6 +29,8 @@ struct APIEndPoints { static let interest_topic_listing = makeURL(path: "interest_topic_listing") static let check_exist_username = makeURL(path: "check_exist_username") static let avatar_listing = makeURL(path: "avatar_listing") + static let child_registration = makeURL(path: "child_registration") + static let get_linked_child = makeURL(path: "get_linked_child") } // Other endpoint categories... diff --git a/WOKA/OnBoarding Module/Controller/SplashVC.swift b/WOKA/OnBoarding Module/Controller/SplashVC.swift index 3ad84ee..9b71ee2 100644 --- a/WOKA/OnBoarding Module/Controller/SplashVC.swift +++ b/WOKA/OnBoarding Module/Controller/SplashVC.swift @@ -29,11 +29,11 @@ class SplashVC: UIViewController { } @IBAction func languageBtnTapped(_ sender: UIButton) { - let sb1 = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil) - let vc1 = sb1.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.userIntrestVC) as! UserIntrestVC - self.navigationController?.pushViewController(vc1, animated: true) - - return +// let sb1 = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil) +// let vc1 = sb1.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.userIntrestVC) as! UserIntrestVC +// self.navigationController?.pushViewController(vc1, animated: true) +// +// return switch sender{ case hindiBtn: AuthFunc.shareInstance.languageSelected = .hindi