Initial Commit
This commit is contained in:
95
WOKA/OnBoarding Module/Controller/SplashVC.swift
Normal file
95
WOKA/OnBoarding Module/Controller/SplashVC.swift
Normal file
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// SplashVC.swift
|
||||
// WOKA
|
||||
//
|
||||
// Created by MacBook Pro on 25/04/24.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Lottie
|
||||
|
||||
class SplashVC: UIViewController {
|
||||
|
||||
@IBOutlet weak var wokaLogo: UIImageView!
|
||||
@IBOutlet weak var hindiBtn: UIButton!
|
||||
@IBOutlet weak var englishBtn: UIButton!
|
||||
@IBOutlet weak var languageBtnStack: UIStackView!
|
||||
@IBOutlet weak var wokaOriginY: NSLayoutConstraint!
|
||||
|
||||
var vm = SplashVM()
|
||||
|
||||
// MARK: - View Life Cycle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
vm.vc = self
|
||||
vm.playSplashSound()
|
||||
animateImageScale()
|
||||
self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"", style:.plain, target:nil, action:nil)
|
||||
}
|
||||
|
||||
@IBAction func languageBtnTapped(_ sender: UIButton) {
|
||||
switch sender{
|
||||
case hindiBtn:
|
||||
K.GVar.localized = K.LocalizedEnum.hindi
|
||||
case englishBtn:
|
||||
K.GVar.localized = K.LocalizedEnum.english
|
||||
default:
|
||||
K.GVar.localized = K.LocalizedEnum.english
|
||||
}
|
||||
|
||||
let sb = UIStoryboard(name: K.StoryBoard.main, bundle: nil)
|
||||
let vc = sb.instantiateViewController(withIdentifier: K.StoryBoardID.OnBoarding.onBoardVC) as! OnBoardVC
|
||||
|
||||
// Create a CATransition instance
|
||||
let transition = CATransition()
|
||||
transition.duration = 0.3 // Set the duration of the animation
|
||||
transition.type = CATransitionType.fade // Set the type of animation to fade
|
||||
|
||||
// Optionally, set other properties such as timing function, subtype, etc.
|
||||
// transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
|
||||
// transition.subtype = CATransitionSubtype.fromTop
|
||||
|
||||
// Get the navigation controller
|
||||
guard let navigationController = navigationController else { return }
|
||||
|
||||
// Perform the push animation with the custom transition
|
||||
navigationController.view.layer.add(transition, forKey: nil)
|
||||
navigationController.pushViewController(vc, animated: false)
|
||||
}
|
||||
|
||||
func animateImageScale() {
|
||||
UIView.animate(withDuration: 3.0, delay: 0, options: [], animations: {
|
||||
self.wokaLogo.transform = CGAffineTransform(scaleX: 1.8, y: 1.8)
|
||||
}, completion: nil)
|
||||
|
||||
let newConstant = wokaOriginY.constant - 50
|
||||
|
||||
Timer.scheduledTimer(withTimeInterval: 6, repeats: false) { _ in
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
vm.initView()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user