- Created an extension to handle the rootview.

- Added localisation to theme 1, also updated the English localisation for reversing the language
- Added localisation to the sidebar. Also handled the live language change with the help of observers
- Integrated GetUserData API at splash.
- Added the login NAv. Now if user will logout he will be redirected to the login Screen.
- Added Activity Indicator on the splash to handle the getuserdata.
- Added Guest Login To home.
This commit is contained in:
2024-05-28 19:47:51 +05:30
parent 0e921c3113
commit 86bd90db31
33 changed files with 1040 additions and 236 deletions

View File

@@ -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<BaseResponseModel<UserDataDM>, 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
}
}
}