123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- //
- // SplashScreenViewController.swift
- // LMS
- //
- // Created by Suraj Kumar Mandal on 17/08/22.
- //
- import UIKit
- import Toast_Swift
- class SplashScreenViewController: UIViewController {
-
- @IBOutlet var presentedByLabel: UILabel!
- @IBOutlet var hindujaLogoView: UIView!
- @IBOutlet var hindujaLogoImageView: UIImageView!
- @IBOutlet var andLabel: UILabel!
- @IBOutlet var hindujaCollegeView: UIView!
- @IBOutlet var hindujaCollegeImageView: UIImageView!
- @IBOutlet var poweredByLabel: UILabel!
- @IBOutlet var finlabsLogoView: UIView!
- @IBOutlet var finlabsLogoImageView: UIImageView!
-
- let viewModel = SplashScreenViewModel()
- var timer = Timer()
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- // Do any additional setup after loading the view.
- viewModel.delegate = self
- setupUI()
- perform(#selector(navigation), with: nil, afterDelay: 4)
- }
-
- override var preferredStatusBarStyle : UIStatusBarStyle {
- return .lightContent
- }
-
- func setupUI() {
- hindujaLogoView.layer.borderWidth = 1
- hindujaLogoView.layer.borderColor = #colorLiteral(red: 0.1058823529, green: 0.3764705882, blue: 0.5960784314, alpha: 1)
- hindujaLogoView.layer.cornerRadius = 30
-
- hindujaCollegeView.layer.borderWidth = 1
- hindujaCollegeView.layer.borderColor = #colorLiteral(red: 0.1058823529, green: 0.3764705882, blue: 0.5960784314, alpha: 1)
- hindujaCollegeView.layer.cornerRadius = 30
-
- finlabsLogoView.layer.borderWidth = 1
- finlabsLogoView.layer.borderColor = #colorLiteral(red: 0.1058823529, green: 0.3764705882, blue: 0.5960784314, alpha: 1)
- finlabsLogoView.layer.cornerRadius = 30
-
- andLabel.layer.masksToBounds = true
- andLabel.layer.cornerRadius = andLabel.frame.height / 2
- }
-
- @objc func navigation() {
- if UIApplication.isFirstLaunch() {
- UserDefaults.standard.set(false, forKey: "isLogin")
- UserDefaults.standard.synchronize()
- let vc = self.storyboard?.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
- self.navigationController?.pushViewController(vc, animated: false)
- } else {
- if UserDefaults.standard.bool(forKey: "isLogin") {
- if Reachability.isConnectedToNetwork() {
- viewModel.getAccessToken()
- } else {
- Alert.showInternetFailureAlert(on: self)
- }
- } else {
- let vc = self.storyboard?.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
- self.navigationController?.pushViewController(vc, animated: false)
- }
- }
- }
-
- func scheduledTimerWithTimeInterval() {
- let time = UserDefaults.standard.value(forKey: "tokenExpire") as! Int
- timer = Timer.scheduledTimer(timeInterval: TimeInterval(time), target: self, selector: #selector(self.refresh), userInfo: nil, repeats: true)
- }
-
- @objc func refresh() {
- Dispatch.background {
- self.viewModel.refreshToken()
- }
- }
-
-
- /*
- // 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.
- }
- */
-
- }
- extension SplashScreenViewController: SplashScreenViewProtocol {
- func navigateToHome() {
- self.scheduledTimerWithTimeInterval()
- // let vc = self.storyboard?.instantiateViewController(withIdentifier: "DashboardViewController") as! DashboardViewController
- // self.navigationController?.pushViewController(vc, animated: false)
-
- // Navigate to calendar page as home
- let vc = self.storyboard?.instantiateViewController(withIdentifier: "StudyMaterialsViewController") as! StudyMaterialsViewController
- self.navigationController?.pushViewController(vc, animated: false)
- }
- }
|