diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj index 5c10d39..0193ece 100644 --- a/WOKA.xcodeproj/project.pbxproj +++ b/WOKA.xcodeproj/project.pbxproj @@ -64,6 +64,7 @@ 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 */; }; + 529B0DD42C06156B00CFC54B /* LoginNavVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 529B0DD32C06156B00CFC54B /* LoginNavVC.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 */; }; @@ -80,6 +81,9 @@ 52B8D4E02C04A25E00ED65F3 /* UIView+Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B8D4D62C04A25D00ED65F3 /* UIView+Container.swift */; }; 52B8D4E12C04A25E00ED65F3 /* BasicTransitionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B8D4D72C04A25E00ED65F3 /* BasicTransitionAnimator.swift */; }; 52B8D4E22C04A25E00ED65F3 /* Segue.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52B8D4D82C04A25E00ED65F3 /* Segue.swift */; }; + 52C1A4E12C05B69F007BAA50 /* UIApplicationSwitchRoot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C1A4E02C05B69F007BAA50 /* UIApplicationSwitchRoot.swift */; }; + 52C1A4E52C05BC86007BAA50 /* MainNavController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52C1A4E42C05BC86007BAA50 /* MainNavController.swift */; }; + 52C1A4E82C05C95D007BAA50 /* Theme.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 52C1A4E72C05C95D007BAA50 /* Theme.storyboard */; }; 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 */; }; @@ -132,7 +136,6 @@ 9C535DC22C00B36900DA6DCD /* ThemeTwoVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C535DC12C00B36900DA6DCD /* ThemeTwoVC.swift */; }; 9C535DC52C00BF2400DA6DCD /* HomeExploreCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9C535DC42C00BF2400DA6DCD /* HomeExploreCell.xib */; }; 9C535DC62C00BF2400DA6DCD /* HomeExploreCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C535DC32C00BF2400DA6DCD /* HomeExploreCell.swift */; }; - 9C535DCA2C00C34A00DA6DCD /* Theme.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9C535DC92C00C34A00DA6DCD /* Theme.storyboard */; }; 9C56E83B2BDBC6E600E4CA14 /* SelectAgeVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C56E83A2BDBC6E600E4CA14 /* SelectAgeVM.swift */; }; 9C56E8462BDBEE6400E4CA14 /* EmailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C56E8452BDBEE6400E4CA14 /* EmailVC.swift */; }; 9C56E8482BDBEFAB00E4CA14 /* AssetColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C56E8472BDBEFAB00E4CA14 /* AssetColor.swift */; }; @@ -224,6 +227,7 @@ 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 = ""; }; + 529B0DD32C06156B00CFC54B /* LoginNavVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginNavVC.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 = ""; }; @@ -241,6 +245,11 @@ 52B8D4D62C04A25D00ED65F3 /* UIView+Container.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Container.swift"; sourceTree = ""; }; 52B8D4D72C04A25E00ED65F3 /* BasicTransitionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicTransitionAnimator.swift; sourceTree = ""; }; 52B8D4D82C04A25E00ED65F3 /* Segue.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Segue.swift; sourceTree = ""; }; + 52C1A4E02C05B69F007BAA50 /* UIApplicationSwitchRoot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplicationSwitchRoot.swift; sourceTree = ""; }; + 52C1A4E42C05BC86007BAA50 /* MainNavController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainNavController.swift; sourceTree = ""; }; + 52C1A4E62C05C95D007BAA50 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Theme.storyboard; sourceTree = ""; }; + 52C1A4EF2C05DA49007BAA50 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Theme.strings; sourceTree = ""; }; + 52C1A4F12C05DA4C007BAA50 /* hi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hi; path = hi.lproj/Theme.strings; 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 = ""; }; @@ -295,7 +304,6 @@ 9C535DC12C00B36900DA6DCD /* ThemeTwoVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeTwoVC.swift; sourceTree = ""; }; 9C535DC32C00BF2400DA6DCD /* HomeExploreCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = HomeExploreCell.swift; path = WOKA/Theme/View/HomeExploreCell.swift; sourceTree = SOURCE_ROOT; }; 9C535DC42C00BF2400DA6DCD /* HomeExploreCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = HomeExploreCell.xib; path = WOKA/Theme/View/HomeExploreCell.xib; sourceTree = SOURCE_ROOT; }; - 9C535DC92C00C34A00DA6DCD /* Theme.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Theme.storyboard; sourceTree = ""; }; 9C56E82E2BDBC3EF00E4CA14 /* Exo2-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Exo2-Bold.ttf"; sourceTree = ""; }; 9C56E82F2BDBC3EF00E4CA14 /* Exo2-Medium.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Exo2-Medium.ttf"; sourceTree = ""; }; 9C56E8302BDBC3EF00E4CA14 /* Exo2-SemiBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Exo2-SemiBold.ttf"; sourceTree = ""; }; @@ -423,6 +431,7 @@ 523ED26B2BDA2BC900CFED02 /* Info.plist */, 9C9BEEC62BEE1BBF004ECC2F /* CollectionViewCenteredFlowLayout.swift */, 5259541E2BE8E93500191286 /* Config.xcconfig */, + 523ED2682BDA2BC900CFED02 /* LaunchScreen.storyboard */, 5259542C2BEA392A00191286 /* Alerts */, 523ED2932BDA3D0100CFED02 /* Assets */, 9C56E83E2BDBE4FB00E4CA14 /* Authentication */, @@ -430,7 +439,6 @@ 52C6E01F2BE3ADD800E22D59 /* Default Enum */, 52C8B0512BDA4B51003B51D0 /* Helpers */, 9CBCB2A62BE5104F007D7934 /* Home */, - 523ED2682BDA2BC900CFED02 /* LaunchScreen.storyboard */, 9C27E15E2BDB6E4F00EC1DA9 /* Localized Module */, 9C27E1612BDB6F0F00EC1DA9 /* Main */, 525954152BE8CAC900191286 /* Network Adapter */, @@ -503,6 +511,7 @@ 523ED2612BDA2BC700CFED02 /* SplashVC.swift */, 52C8B0732BDA7626003B51D0 /* OnBoardVC.swift */, 9CDC343B2BDBBC6B00093089 /* SelectAgeVC.swift */, + 52C1A4E42C05BC86007BAA50 /* MainNavController.swift */, ); path = Controller; sourceTree = ""; @@ -641,6 +650,17 @@ path = Alerts; sourceTree = ""; }; + 52C1A4DF2C05B670007BAA50 /* Delegate */ = { + isa = PBXGroup; + children = ( + 523ED25D2BDA2BC700CFED02 /* AppDelegate.swift */, + 523ED25F2BDA2BC700CFED02 /* SceneDelegate.swift */, + 9C535DB42C005A6C00DA6DCD /* KeyWindowFix.swift */, + 52C1A4E02C05B69F007BAA50 /* UIApplicationSwitchRoot.swift */, + ); + path = Delegate; + sourceTree = ""; + }; 52C6E01F2BE3ADD800E22D59 /* Default Enum */ = { isa = PBXGroup; children = ( @@ -758,10 +778,8 @@ 9C27E1612BDB6F0F00EC1DA9 /* Main */ = { isa = PBXGroup; children = ( + 52C1A4DF2C05B670007BAA50 /* Delegate */, 52FDBA792BFF26F9009D7AC7 /* AuthFunc */, - 523ED25D2BDA2BC700CFED02 /* AppDelegate.swift */, - 523ED25F2BDA2BC700CFED02 /* SceneDelegate.swift */, - 9C535DB42C005A6C00DA6DCD /* KeyWindowFix.swift */, ); path = Main; sourceTree = ""; @@ -788,7 +806,7 @@ 52F12C812C04569500AF8139 /* View */, 9C535DCC2C00CD1200DA6DCD /* ViewModel */, 9C535DCB2C00CD0800DA6DCD /* Controller */, - 9C535DC92C00C34A00DA6DCD /* Theme.storyboard */, + 52C1A4E72C05C95D007BAA50 /* Theme.storyboard */, ); path = Theme; sourceTree = ""; @@ -879,6 +897,7 @@ 9CBCB2A22BE50C95007D7934 /* ResetPassUserNameVC.swift */, 9CBCB2A42BE50D49007D7934 /* NewPasswordVC.swift */, 52A3F6AA2BECBF550000BB0B /* LinkedChildVC.swift */, + 529B0DD32C06156B00CFC54B /* LoginNavVC.swift */, ); path = Controller; sourceTree = ""; @@ -1027,7 +1046,7 @@ 523ED26A2BDA2BC900CFED02 /* Base in Resources */, 52C8B05B2BDA5924003B51D0 /* WokaSplashSound.m4a in Resources */, 525954352BEB4B3B00191286 /* Exo2-Thin.ttf in Resources */, - 9C535DCA2C00C34A00DA6DCD /* Theme.storyboard in Resources */, + 52C1A4E82C05C95D007BAA50 /* Theme.storyboard in Resources */, 525954362BEB4B3B00191286 /* Exo2-Medium.ttf in Resources */, 525954372BEB4B3B00191286 /* Exo2-Bold.ttf in Resources */, 525954382BEB4B3B00191286 /* Exo2-Regular.ttf in Resources */, @@ -1200,7 +1219,9 @@ 525954322BEA39D200191286 /* AddTapGesture.swift in Sources */, 522242682BFC74380085C632 /* TabBarVC.swift in Sources */, 9C27E1722BDB86B600EC1DA9 /* OnBoardCell.swift in Sources */, + 529B0DD42C06156B00CFC54B /* LoginNavVC.swift in Sources */, 52C8B05F2BDA5AFA003B51D0 /* SplashVM.swift in Sources */, + 52C1A4E12C05B69F007BAA50 /* UIApplicationSwitchRoot.swift in Sources */, 52663FF72BDFACF60001D8CE /* ShadowView.swift in Sources */, 9C535DC22C00B36900DA6DCD /* ThemeTwoVC.swift in Sources */, 52D774F12BDFC53B001D87DE /* StringSubScript.swift in Sources */, @@ -1208,6 +1229,7 @@ 52FB2D8F2BDF898F0009B0C7 /* TextFieldPadding.swift in Sources */, 5257B2652BDFB6F50086D79B /* CheckPhoneHomeBtnOrNotch.swift in Sources */, 52663FF92BDFAF110001D8CE /* EmailVM.swift in Sources */, + 52C1A4E52C05BC86007BAA50 /* MainNavController.swift in Sources */, 525954342BEA620800191286 /* IntrestTopicDM.swift in Sources */, 52663FF52BDFAB830001D8CE /* TextFieldErrorView.swift in Sources */, 9C27E16D2BDB852F00EC1DA9 /* GVar.swift in Sources */, @@ -1273,6 +1295,16 @@ name = LaunchScreen.storyboard; sourceTree = ""; }; + 52C1A4E72C05C95D007BAA50 /* Theme.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 52C1A4E62C05C95D007BAA50 /* Base */, + 52C1A4EF2C05DA49007BAA50 /* en */, + 52C1A4F12C05DA4C007BAA50 /* hi */, + ); + name = Theme.storyboard; + sourceTree = ""; + }; 52C8B0612BDA6993003B51D0 /* Localizable.strings */ = { isa = PBXVariantGroup; children = ( diff --git a/WOKA/Alerts/CustomAlerts.storyboard b/WOKA/Alerts/CustomAlerts.storyboard index e03652a..35b462c 100644 --- a/WOKA/Alerts/CustomAlerts.storyboard +++ b/WOKA/Alerts/CustomAlerts.storyboard @@ -3,7 +3,7 @@ - + @@ -134,22 +134,22 @@ - + - + - + - + - + - + @@ -75,14 +107,17 @@ + + + @@ -240,10 +275,10 @@ - + - + @@ -489,6 +524,9 @@ + + + diff --git a/WOKA/OnBoarding Module/Controller/MainNavController.swift b/WOKA/OnBoarding Module/Controller/MainNavController.swift new file mode 100644 index 0000000..c971684 --- /dev/null +++ b/WOKA/OnBoarding Module/Controller/MainNavController.swift @@ -0,0 +1,29 @@ +// +// MainNavController.swift +// WOKA +// +// Created by MacBook Pro on 28/05/24. +// + +import UIKit + +class MainNavController: UINavigationController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/WOKA/OnBoarding Module/Controller/SplashVC.swift b/WOKA/OnBoarding Module/Controller/SplashVC.swift index 732f9cd..e2b7a62 100644 --- a/WOKA/OnBoarding Module/Controller/SplashVC.swift +++ b/WOKA/OnBoarding Module/Controller/SplashVC.swift @@ -16,6 +16,9 @@ class SplashVC: UIViewController { @IBOutlet weak var languageBtnStack: UIStackView! @IBOutlet weak var wokaOriginY: NSLayoutConstraint! + @IBOutlet weak var retryBtn: UIButton! + @IBOutlet weak var activityIndicator: UIActivityIndicatorView! + var vm = SplashVM() // MARK: - View Life Cycle @@ -29,11 +32,7 @@ class SplashVC: UIViewController { } @IBAction func languageBtnTapped(_ sender: UIButton) { - let sb1 = UIStoryboard(name: "Home", bundle: nil) - let vc1 = sb1.instantiateViewController(withIdentifier: "SideMenu") as! SideMenuController - self.navigationController?.pushViewController(vc1, animated: true) - - return + switch sender{ case hindiBtn: AuthFunc.shareInstance.languageSelected = .hindi @@ -43,6 +42,15 @@ class SplashVC: UIViewController { AuthFunc.shareInstance.languageSelected = .english } +// let sb1 = UIStoryboard(name: "Home", bundle: nil) +// let vc1 = sb1.instantiateViewController(withIdentifier: "SideMenu") as! SideMenuController +// self.navigationController?.pushViewController(vc1, animated: true) + + +// UIApplication.setRootView(SideMenuController.instantiate(from: .Home)) +// +// return + let sb = UIStoryboard(name: K.StoryBoard.main, bundle: nil) let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.OnBoarding.onBoardVC) as! OnBoardVC @@ -63,6 +71,10 @@ class SplashVC: UIViewController { navigationController.pushViewController(vc, animated: false) } + @IBAction func retryBtnTapped(_ sender: UIButton) { + vm.getUserData() + } + func animateImageScale() { UIView.animate(withDuration: 3.0, delay: 0, options: [], animations: { self.wokaLogo.transform = CGAffineTransform(scaleX: 1.8, y: 1.8) @@ -70,21 +82,30 @@ class SplashVC: UIViewController { let newConstant = wokaOriginY.constant - 50 - Timer.scheduledTimer(withTimeInterval: 6, repeats: false) { _ in + Timer.scheduledTimer(withTimeInterval: 6, repeats: false) { [weak self] _ in + guard let self else{return} + /* + If user is loggined no need to shift the woka logo upside to new constant. + Directly Navigate user to home + */ + if AuthFunc.shareInstance.checkLogin(){ + vm.getUserData() + return + } UIView.animate(withDuration: 0.5, animations: { // Update the constant value of the top constraint self.wokaOriginY.constant = newConstant // Inform the layout system to update self.view.layoutIfNeeded() }) { _ in - UIView.animate(withDuration: 0.3, delay: 0,options : [.transitionCrossDissolve],animations: { - // Set the isHidden property of the view - self.languageBtnStack.isHidden = false - }) {_ in - - - // Inform the stack view to update its layout - self.languageBtnStack.layoutIfNeeded() + if !AuthFunc.shareInstance.checkLogin(){ + UIView.animate(withDuration: 0.3, delay: 0,options : [.transitionCrossDissolve],animations: { + // Set the isHidden property of the view + self.languageBtnStack.isHidden = false + }) {_ in + // Inform the stack view to update its layout + self.languageBtnStack.layoutIfNeeded() + } } } } diff --git a/WOKA/OnBoarding Module/ViewModel/SplashVM.swift b/WOKA/OnBoarding Module/ViewModel/SplashVM.swift index 7b06e19..3901465 100644 --- a/WOKA/OnBoarding Module/ViewModel/SplashVM.swift +++ b/WOKA/OnBoarding Module/ViewModel/SplashVM.swift @@ -7,6 +7,7 @@ import UIKit import AVFoundation +import Alamofire class SplashVM{ @@ -35,6 +36,7 @@ class SplashVM{ vc.hindiBtn.roundCorner() vc.englishBtn.roundCorner() selectTheme() + vc.activityIndicator.stopAnimating() } func selectTheme(){ @@ -45,4 +47,51 @@ class SplashVM{ AuthFunc.shareInstance.selectedTheme = .theme1 } } + + func getUserData(){ + + let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi", + "access-token": AuthFunc.shareInstance.getAccessToken()] + startStopIndicator(start: true) + NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.get_user_data, method: .get, headers: headers) { [weak self](result : Result, NetworkManager.APIError>) in + switch result{ + case .success(let data): + guard let self else{return} + switch data.success{ + case 0: + startStopIndicator(start: false) + self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2) + case 1: + startStopIndicator(start: false,hide: true) + guard let data = data.data?.result else{return} + AuthFunc.shareInstance.userData = data + UIApplication.setRootView(SideMenuController.instantiate(from: .Home)) + default: + break + } + case .failure(let error): + guard let self else{return} + startStopIndicator(start: false) + self.vc.toast(msg: error.localizedDescription , time: 2) + } + } + } + + func startStopIndicator(start : Bool , hide : Bool = false){ + if hide{ + vc.activityIndicator.stopAnimating() + vc.activityIndicator.isHidden = true + vc.retryBtn.isHidden = true + return + } + if start{ + vc.activityIndicator.isHidden = false + vc.activityIndicator.startAnimating() + vc.retryBtn.isHidden = true + }else{ + vc.activityIndicator.stopAnimating() + vc.activityIndicator.isHidden = true + vc.retryBtn.isHidden = false + } + } } diff --git a/WOKA/TabBar & SideMenu/Controller/SideMenuVC.swift b/WOKA/TabBar & SideMenu/Controller/SideMenuVC.swift index d80e319..a7adbbd 100644 --- a/WOKA/TabBar & SideMenu/Controller/SideMenuVC.swift +++ b/WOKA/TabBar & SideMenu/Controller/SideMenuVC.swift @@ -21,7 +21,9 @@ class SideMenuVC: UIViewController { @IBOutlet weak var themeOneCheckMark: UIImageView! @IBOutlet weak var themeTwoView: UIView! @IBOutlet weak var themetwoCheckMark: UIImageView! + @IBOutlet weak var userName: UILabel! + @IBOutlet weak var avatarImage: UIImageView! var vm = SideMenuVM() @@ -38,4 +40,40 @@ class SideMenuVC: UIViewController { @IBAction func closeBtnTapped(_ sender: UIButton) { self.sideMenuController?.hideMenu() } + + @IBAction func logoutBtnTapped(_ sender: LocalisedElementsButton) { + let sb = UIStoryboard(name: K.StoryBoard.customAlerts, bundle: nil) + let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.CustomAlerts.yesNoAlertVC) as! YesNoAlertVC + vcPush.mainTitleText = "WOKA" + vcPush.contentLabel = "Do you want to LOGOUT from the WOKA APP" + vcPush.onDoneBlock = { mode in + switch mode{ + case .yes: + //If user clicked to proceed on login. Call the api. + self.sideMenuController?.hideMenu() + AuthFunc.shareInstance.logout() +// UIApplication.setRootView(MainNavController.instantiate(from: .Main)) + UIApplication.setRootView(LoginNavVC.instantiate(from: .AuthenticationSB)) + case .no: + print("no") + } + } + vcPush.modalPresentationStyle = .overCurrentContext + vcPush.modalTransitionStyle = .crossDissolve + self.present(vcPush, animated: true) + } + + @IBAction func languageSwitchSlide(_ sender: CustomizableSegmentControl) { + Timer.scheduledTimer(withTimeInterval: 0.2, repeats: false) { _ in + switch sender.selectedSegmentIndex{ + case 0: // English + AuthFunc.shareInstance.languageSelected = .english + case 1: // Hindi + AuthFunc.shareInstance.languageSelected = .hindi + default: + break + } + self.sideMenuController?.hideMenu() + } + } } diff --git a/WOKA/TabBar & SideMenu/Controller/TabBarVC.swift b/WOKA/TabBar & SideMenu/Controller/TabBarVC.swift index 8ec110f..5028c37 100644 --- a/WOKA/TabBar & SideMenu/Controller/TabBarVC.swift +++ b/WOKA/TabBar & SideMenu/Controller/TabBarVC.swift @@ -20,7 +20,16 @@ class TabBarVC: UITabBarController { self.setupTabBarUI() self.addCustomTabBarView() - + NotificationCenter.default.addObserver(self, selector: #selector(languageDidChange), name: .languageDidChange, object: nil) + + } + + deinit{ + NotificationCenter.default.removeObserver(self, name: .languageDidChange, object: nil) + } + + @objc private func languageDidChange() { + updateText() } override func viewDidLayoutSubviews() { @@ -35,6 +44,13 @@ class TabBarVC: UITabBarController { } + func updateText(){ + guard let tabItems = self.tabBar.items else{return} + tabItems[0].title = tabItems[0].title?.localized(loc: AuthFunc.shareInstance.languageSelected.rawValue) + tabItems[1].title = tabItems[1].title?.localized(loc: AuthFunc.shareInstance.languageSelected.rawValue) + tabItems[2].title = tabItems[2].title?.localized(loc: AuthFunc.shareInstance.languageSelected.rawValue) + } + func customizeTabBarItemIconSize() { // Get a reference to the tab bar controller if let tabBarController = self.tabBarController { diff --git a/WOKA/TabBar & SideMenu/ViewModel/SideMenuVM.swift b/WOKA/TabBar & SideMenu/ViewModel/SideMenuVM.swift index 152493c..056d2e6 100644 --- a/WOKA/TabBar & SideMenu/ViewModel/SideMenuVM.swift +++ b/WOKA/TabBar & SideMenu/ViewModel/SideMenuVM.swift @@ -13,7 +13,7 @@ class SideMenuVM{ func initView(){ customizeSegmentControl() - + AuthFunc.shareInstance.languageSelected == .english ? (vc.languageControl.selectedSegmentIndex = 0) : (vc.languageControl.selectedSegmentIndex = 1) 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.logoutBtn.applyGradient(colors: [color1, color2], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0.8, y: 0)) @@ -51,6 +51,19 @@ class SideMenuVM{ self.themeSelect() } } + + setData() + } + + func setData(){ + guard let data = AuthFunc.shareInstance.userData else{return} + //set the first name as the name + vc.userName.text = (data.fullname == nil || data.fullname == "") ? "User" : data.fullname + 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) + } + } func themeSelect(){ diff --git a/WOKA/Theme/Theme.storyboard b/WOKA/Theme/Base.lproj/Theme.storyboard similarity index 93% rename from WOKA/Theme/Theme.storyboard rename to WOKA/Theme/Base.lproj/Theme.storyboard index 973adde..ca2194b 100644 --- a/WOKA/Theme/Theme.storyboard +++ b/WOKA/Theme/Base.lproj/Theme.storyboard @@ -73,18 +73,29 @@ - + - + - + + + + + + +