|
@ -33,6 +33,7 @@ class SplashScreenViewController: UIViewController { |
|
|
|
|
|
|
|
|
@IBOutlet private weak var languageBackGroundView: UIView! |
|
|
@IBOutlet private weak var languageBackGroundView: UIView! |
|
|
@IBOutlet private weak var languageLabel: UILabel! |
|
|
@IBOutlet private weak var languageLabel: UILabel! |
|
|
|
|
|
@IBOutlet private weak var flagImageView: UIImageView! |
|
|
|
|
|
|
|
|
private var languageTapGuesture: UITapGestureRecognizer? |
|
|
private var languageTapGuesture: UITapGestureRecognizer? |
|
|
// MARK: Properties |
|
|
// MARK: Properties |
|
@ -58,6 +59,8 @@ class SplashScreenViewController: UIViewController { |
|
|
UserDefaults.standard.set(code, forKey: AppConstants.firstTimeLanguageIsSet) |
|
|
UserDefaults.standard.set(code, forKey: AppConstants.firstTimeLanguageIsSet) |
|
|
|
|
|
|
|
|
setText() |
|
|
setText() |
|
|
|
|
|
|
|
|
|
|
|
flagImageView.image = CountryInfo().getFlag(for: selectedLanguage?.code ?? "") |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -69,49 +72,49 @@ class SplashScreenViewController: UIViewController { |
|
|
override func viewDidLoad() { |
|
|
override func viewDidLoad() { |
|
|
super.viewDidLoad() |
|
|
super.viewDidLoad() |
|
|
checkJailBreak() |
|
|
checkJailBreak() |
|
|
self.setup() |
|
|
|
|
|
|
|
|
setup() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
override func viewWillAppear(_ animated: Bool) { |
|
|
override func viewWillAppear(_ animated: Bool) { |
|
|
super.viewWillAppear(animated) |
|
|
super.viewWillAppear(animated) |
|
|
self.navigationItem.title = "" |
|
|
self.navigationItem.title = "" |
|
|
self.hideNavBar() |
|
|
|
|
|
self.setupTimer() |
|
|
|
|
|
|
|
|
hideNavBar() |
|
|
|
|
|
setupTimer() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
override func viewWillDisappear(_ animated: Bool) { |
|
|
override func viewWillDisappear(_ animated: Bool) { |
|
|
super.viewWillDisappear(animated) |
|
|
super.viewWillDisappear(animated) |
|
|
self.navigationItem.title = "" |
|
|
|
|
|
self.timer?.invalidate() |
|
|
|
|
|
|
|
|
navigationItem.title = "" |
|
|
|
|
|
timer?.invalidate() |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// MARK: IBActions |
|
|
// MARK: IBActions |
|
|
private func checkJailBreak() { |
|
|
private func checkJailBreak() { |
|
|
if (DTTJailbreakDetection.isJailbroken()) { |
|
|
|
|
|
self.alert(message: "Your device is jail broken.", title: "Alert!") { |
|
|
|
|
|
|
|
|
if DTTJailbreakDetection.isJailbroken() { |
|
|
|
|
|
alert(message: "Your device is jail broken.", title: "Alert!") { |
|
|
exit(0) |
|
|
exit(0) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@IBAction private func login(_ sender: UIButton) { |
|
|
@IBAction private func login(_ sender: UIButton) { |
|
|
self.presenter?.login() |
|
|
|
|
|
|
|
|
presenter?.login() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@IBAction private func register(_ sender: UIButton) { |
|
|
@IBAction private func register(_ sender: UIButton) { |
|
|
self.presenter?.register() |
|
|
|
|
|
|
|
|
presenter?.register() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// MARK: Other Functions |
|
|
// MARK: Other Functions |
|
|
|
|
|
|
|
|
private func hideNavBar() { |
|
|
private func hideNavBar() { |
|
|
self.navigationController?.isNavigationBarHidden = true |
|
|
|
|
|
self.navigationController?.navigationBar.barTintColor = AppConstants.themeRedColor |
|
|
|
|
|
self.navigationController?.navigationBar.isTranslucent = false |
|
|
|
|
|
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) |
|
|
|
|
|
self.navigationController?.navigationBar.shadowImage = UIImage() |
|
|
|
|
|
|
|
|
navigationController?.isNavigationBarHidden = true |
|
|
|
|
|
navigationController?.navigationBar.barTintColor = AppConstants.themeRedColor |
|
|
|
|
|
navigationController?.navigationBar.isTranslucent = false |
|
|
|
|
|
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) |
|
|
|
|
|
navigationController?.navigationBar.shadowImage = UIImage() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func setup() { |
|
|
private func setup() { |
|
@ -119,7 +122,9 @@ class SplashScreenViewController: UIViewController { |
|
|
hideNavBar() |
|
|
hideNavBar() |
|
|
setUpButtons() |
|
|
setUpButtons() |
|
|
imageViewDotLeft.image = UIImage(named: "dotSelected") |
|
|
imageViewDotLeft.image = UIImage(named: "dotSelected") |
|
|
|
|
|
|
|
|
let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(_SplashScreenViewController.handleSwipes(_:))) |
|
|
let leftSwipe = UISwipeGestureRecognizer(target: self, action: #selector(_SplashScreenViewController.handleSwipes(_:))) |
|
|
|
|
|
|
|
|
let rightSwipe = UISwipeGestureRecognizer(target: self, action: #selector(_SplashScreenViewController.handleSwipes(_:))) |
|
|
let rightSwipe = UISwipeGestureRecognizer(target: self, action: #selector(_SplashScreenViewController.handleSwipes(_:))) |
|
|
|
|
|
|
|
|
leftSwipe.direction = .left |
|
|
leftSwipe.direction = .left |
|
@ -132,12 +137,12 @@ class SplashScreenViewController: UIViewController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func setLanguageBackgroundView() { |
|
|
private func setLanguageBackgroundView() { |
|
|
let languageSelectionGuesture = UITapGestureRecognizer(target: self, action: #selector(self.showCountryPickerview)) |
|
|
|
|
|
self.languageBackGroundView.addGestureRecognizer(languageSelectionGuesture) |
|
|
|
|
|
|
|
|
let languageSelectionGuesture = UITapGestureRecognizer(target: self, action: #selector(showCountryPickerview)) |
|
|
|
|
|
languageBackGroundView.addGestureRecognizer(languageSelectionGuesture) |
|
|
|
|
|
|
|
|
self.languageBackGroundView.layer.cornerRadius = 10 |
|
|
|
|
|
self.languageBackGroundView.clipsToBounds = true |
|
|
|
|
|
self.languageBackGroundView.layer.addShadow(offset: CGSize.init(width: 2, height: 2)) |
|
|
|
|
|
|
|
|
languageBackGroundView.layer.cornerRadius = 10 |
|
|
|
|
|
languageBackGroundView.clipsToBounds = true |
|
|
|
|
|
languageBackGroundView.layer.addShadow(offset: CGSize.init(width: 2, height: 2)) |
|
|
NotificationCenter.default.addObserver(self, selector: #selector(setText), name: NSNotification.Name(LCLLanguageChangeNotification), object: nil) |
|
|
NotificationCenter.default.addObserver(self, selector: #selector(setText), name: NSNotification.Name(LCLLanguageChangeNotification), object: nil) |
|
|
|
|
|
|
|
|
setupLanguages() |
|
|
setupLanguages() |
|
@ -145,7 +150,13 @@ class SplashScreenViewController: UIViewController { |
|
|
|
|
|
|
|
|
// if exist a selected language then don't animate, and put in the selected language into languageLabel |
|
|
// if exist a selected language then don't animate, and put in the selected language into languageLabel |
|
|
if let language = UserDefaults.standard.string(forKey: AppConstants.firstTimeLanguageIsSet){ |
|
|
if let language = UserDefaults.standard.string(forKey: AppConstants.firstTimeLanguageIsSet){ |
|
|
self.selectedLanguage = self.languages.filter{$0.code?.languageCode == language.languageCode}.first |
|
|
|
|
|
|
|
|
selectedLanguage = languages |
|
|
|
|
|
.filter{ |
|
|
|
|
|
$0.code?.languageCode == language.languageCode |
|
|
|
|
|
} |
|
|
|
|
|
.first |
|
|
|
|
|
|
|
|
|
|
|
flagImageView.image = CountryInfo().getFlag(for: selectedLanguage?.code ?? "") |
|
|
} else { |
|
|
} else { |
|
|
configureTimer() |
|
|
configureTimer() |
|
|
} |
|
|
} |
|
@ -153,41 +164,49 @@ class SplashScreenViewController: UIViewController { |
|
|
|
|
|
|
|
|
@objc private func setText() { |
|
|
@objc private func setText() { |
|
|
timer?.invalidate() |
|
|
timer?.invalidate() |
|
|
self.buttonLogin.setTitle("login_text".localized(), for: .normal) |
|
|
|
|
|
self.buttonSignUp.setTitle("new_user_text".localized(), for: .normal) |
|
|
|
|
|
self.languageLabel.text = self.selectedLanguage?.title |
|
|
|
|
|
|
|
|
buttonLogin.setTitle("login_text".localized(), for: .normal) |
|
|
|
|
|
buttonSignUp.setTitle("new_user_text".localized(), for: .normal) |
|
|
|
|
|
languageLabel.text = selectedLanguage?.title |
|
|
|
|
|
|
|
|
setImageandLabels() |
|
|
setImageandLabels() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func setupLanguages() { |
|
|
private func setupLanguages() { |
|
|
self.languages = Utility.getLanguages() |
|
|
|
|
|
|
|
|
languages = Utility.getLanguages() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func configureTimer() { |
|
|
private func configureTimer() { |
|
|
let timer = Timer.scheduledTimer(timeInterval: 2, target: self, selector: #selector(self.updateLanguage), userInfo: nil, repeats: true) |
|
|
|
|
|
self.timer = timer |
|
|
|
|
|
|
|
|
timer = Timer.scheduledTimer( |
|
|
|
|
|
timeInterval: 2, |
|
|
|
|
|
target: self, |
|
|
|
|
|
selector: #selector(updateLanguage), |
|
|
|
|
|
userInfo: nil, |
|
|
|
|
|
repeats: true |
|
|
|
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func configureLanguage() { |
|
|
private func configureLanguage() { |
|
|
self.buttonLogin.setTitle(StringConstants().loginText, for: .normal) |
|
|
|
|
|
self.buttonSignUp.setTitle(StringConstants().newUserText, for: .normal) |
|
|
|
|
|
|
|
|
buttonLogin.setTitle(StringConstants().loginText, for: .normal) |
|
|
|
|
|
buttonSignUp.setTitle(StringConstants().newUserText, for: .normal) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@objc private func handleSwipes(_ sender: UISwipeGestureRecognizer) { |
|
|
@objc private func handleSwipes(_ sender: UISwipeGestureRecognizer) { |
|
|
if (sender.direction == .right) { |
|
|
|
|
|
|
|
|
switch sender.direction { |
|
|
|
|
|
case .right: |
|
|
counter = counter - 1 |
|
|
counter = counter - 1 |
|
|
if counter < 0 { |
|
|
if counter < 0 { |
|
|
counter = 2 |
|
|
counter = 2 |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (sender.direction == .left) { |
|
|
|
|
|
|
|
|
case .left: |
|
|
counter = counter + 1 |
|
|
counter = counter + 1 |
|
|
if counter > 2 { |
|
|
if counter > 2 { |
|
|
counter = 0 |
|
|
counter = 0 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
break |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setImageandLabels() |
|
|
setImageandLabels() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -226,66 +245,74 @@ class SplashScreenViewController: UIViewController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func setUpButtons() { |
|
|
private func setUpButtons() { |
|
|
buttonSignUp.layer.cornerRadius = 25 |
|
|
|
|
|
buttonLogin.backgroundColor = .clear |
|
|
buttonLogin.backgroundColor = .clear |
|
|
buttonLogin.layer.cornerRadius = 25 |
|
|
buttonLogin.layer.cornerRadius = 25 |
|
|
buttonLogin.layer.borderWidth = 1 |
|
|
buttonLogin.layer.borderWidth = 1 |
|
|
buttonLogin.layer.borderColor = UIColor.white.cgColor |
|
|
buttonLogin.layer.borderColor = UIColor.white.cgColor |
|
|
// buttonSignUp.layer.borderWidth = 1 |
|
|
|
|
|
// buttonSignUp.layer.borderColor = UIColor.white.cgColor |
|
|
|
|
|
self.view.backgroundColor = AppConstants.themeRedColor |
|
|
|
|
|
// self.buttonSignUp.backgroundColor = AppConstants.themeDarkRedColor |
|
|
|
|
|
self.buttonLogin.backgroundColor = AppConstants.themeBlueColor |
|
|
|
|
|
// self.buttonSignUp.backgroundColor = AppConstants.themeBlueColor |
|
|
|
|
|
|
|
|
buttonLogin.backgroundColor = AppConstants.themeBlueColor |
|
|
|
|
|
|
|
|
|
|
|
view.backgroundColor = AppConstants.themeRedColor |
|
|
|
|
|
|
|
|
|
|
|
buttonSignUp.layer.cornerRadius = 25 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func setupTimer() { |
|
|
private func setupTimer() { |
|
|
self.timer?.fire() |
|
|
|
|
|
|
|
|
timer?.fire() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@objc private func updateLanguage() { |
|
|
@objc private func updateLanguage() { |
|
|
|
|
|
guard let element = languages.elementAt(index: languageIndex) |
|
|
|
|
|
else { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
self.changeText(text: self.languages.elementAt(index: self.languageIndex)?.name ?? "") |
|
|
|
|
|
if (self.languageIndex + 1) >= (self.languages.count) { |
|
|
|
|
|
self.languageIndex = 0 |
|
|
|
|
|
|
|
|
changeLanguageInfo( |
|
|
|
|
|
text: element.name ?? "", |
|
|
|
|
|
flag: CountryInfo().getFlag(for: element.code ?? "") |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
if (languageIndex + 1) >= languages.count { |
|
|
|
|
|
languageIndex = 0 |
|
|
}else { |
|
|
}else { |
|
|
self.languageIndex += 1 |
|
|
|
|
|
|
|
|
languageIndex += 1 |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func changeText(text: String) { |
|
|
|
|
|
let animation: CATransition = CATransition() |
|
|
|
|
|
animation.timingFunction = CAMediaTimingFunction(name: |
|
|
|
|
|
kCAMediaTimingFunctionEaseInEaseOut) |
|
|
|
|
|
|
|
|
private func changeLanguageInfo(text: String, flag: UIImage?) { |
|
|
|
|
|
let animation = CATransition() |
|
|
|
|
|
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) |
|
|
animation.type = kCATransitionPush |
|
|
animation.type = kCATransitionPush |
|
|
animation.subtype = kCATransitionFromTop |
|
|
animation.subtype = kCATransitionFromTop |
|
|
animation.duration = 0.8 |
|
|
animation.duration = 0.8 |
|
|
|
|
|
|
|
|
let animation1: CATransition = CATransition() |
|
|
|
|
|
animation1.timingFunction = CAMediaTimingFunction(name: |
|
|
|
|
|
kCAMediaTimingFunctionEaseInEaseOut) |
|
|
|
|
|
animation1.type = kCATransitionFade |
|
|
|
|
|
animation1.subtype = kCATransitionReveal |
|
|
|
|
|
animation1.duration = 0.8 |
|
|
|
|
|
languageLabel.layer.add(animation, forKey: kCATransitionPush) |
|
|
languageLabel.layer.add(animation, forKey: kCATransitionPush) |
|
|
|
|
|
languageLabel.text = text |
|
|
|
|
|
|
|
|
|
|
|
flagImageView.layer.add(animation, forKey: kCATransitionPush) |
|
|
|
|
|
flagImageView.image = flag |
|
|
|
|
|
|
|
|
self.languageLabel.text = text |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@objc private func showCountryPickerview() { |
|
|
@objc private func showCountryPickerview() { |
|
|
setupLanguages() |
|
|
setupLanguages() |
|
|
let viewcontroller = UIStoryboard.init(name: "CountryPicker", bundle: nil).instantiateViewController(withIdentifier: "CountryPickerViewController") as! CountryPickerViewController |
|
|
|
|
|
let data: [SendMoneyCountryViewModel] = self.languages |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let viewcontroller = UIStoryboard |
|
|
|
|
|
.init(name: "CountryPicker", bundle: nil) |
|
|
|
|
|
.instantiateViewController( |
|
|
|
|
|
withIdentifier: "CountryPickerViewController" |
|
|
|
|
|
) as! CountryPickerViewController |
|
|
|
|
|
|
|
|
viewcontroller.isLanguageSelection = true |
|
|
viewcontroller.isLanguageSelection = true |
|
|
viewcontroller.data = data |
|
|
|
|
|
viewcontroller.doneAction = self.countrySelected |
|
|
|
|
|
viewcontroller.type = PickerTitle.country |
|
|
|
|
|
self.present(viewcontroller, animated: true, completion: nil) |
|
|
|
|
|
|
|
|
viewcontroller.data = languages |
|
|
|
|
|
viewcontroller.doneAction = countrySelected |
|
|
|
|
|
viewcontroller.type = .country |
|
|
|
|
|
|
|
|
|
|
|
present(viewcontroller, animated: true, completion: nil) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func countrySelected(models: [SendMoneyCountryViewModel]) { |
|
|
private func countrySelected(models: [SendMoneyCountryViewModel]) { |
|
|
if models.count != 0 { |
|
|
if models.count != 0 { |
|
|
self.selectedLanguage = models.first |
|
|
|
|
|
|
|
|
selectedLanguage = models.first |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|