Browse Source

add flag on language label

pull/1/head
james 5 years ago
parent
commit
3870001c77
  1. 98
      GMERemittance/Module/SplashScreen/User Interface/View/SplashScreen.storyboard
  2. 151
      GMERemittance/Module/SplashScreen/User Interface/View/SplashScreenViewController.swift

98
GMERemittance/Module/SplashScreen/User Interface/View/SplashScreen.storyboard

@ -10,6 +10,9 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<customFonts key="customFonts"> <customFonts key="customFonts">
<array key="SanFranciscoDisplay-Regular.otf">
<string>SanFranciscoDisplay-Regular</string>
</array>
<array key="SanFranciscoDisplay-Semibold.otf"> <array key="SanFranciscoDisplay-Semibold.otf">
<string>SanFranciscoDisplay-Semibold</string> <string>SanFranciscoDisplay-Semibold</string>
</array> </array>
@ -36,28 +39,60 @@
<rect key="frame" x="84.5" y="0.0" width="166" height="162.5"/> <rect key="frame" x="84.5" y="0.0" width="166" height="162.5"/>
</imageView> </imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ONN-vO-ntP"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ONN-vO-ntP">
<rect key="frame" x="40" y="162.5" width="255" height="50"/>
<rect key="frame" x="10" y="162.5" width="315" height="50"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZdU-Ub-FUa" customClass="LTMorphingLabel">
<rect key="frame" x="0.0" y="0.0" width="255" height="50"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="morphingProgress">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="morphingDuration">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="morphingCharacterDelay">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="morphingEnabled" value="YES"/>
</userDefinedRuntimeAttributes>
</label>
<stackView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="W5h-Sp-BqP">
<rect key="frame" x="0.0" y="0.0" width="315" height="50"/>
<subviews>
<view opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nqN-St-ZU7">
<rect key="frame" x="0.0" y="0.0" width="70" height="50"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="flag_south_korea" translatesAutoresizingMaskIntoConstraints="NO" id="GIr-wO-yaG">
<rect key="frame" x="5" y="5" width="60" height="40"/>
<constraints>
<constraint firstAttribute="width" secondItem="GIr-wO-yaG" secondAttribute="height" multiplier="6:4" id="Yig-vh-rv7"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="GIr-wO-yaG" secondAttribute="bottom" constant="5" id="0bc-ZR-Mb8"/>
<constraint firstAttribute="trailing" secondItem="GIr-wO-yaG" secondAttribute="trailing" constant="5" id="Alt-wZ-1DO"/>
<constraint firstItem="GIr-wO-yaG" firstAttribute="leading" secondItem="nqN-St-ZU7" secondAttribute="leading" constant="5" id="VgM-yC-vFj"/>
<constraint firstItem="GIr-wO-yaG" firstAttribute="top" secondItem="nqN-St-ZU7" secondAttribute="top" constant="5" id="tf9-sW-VQb"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="bahasa Indonesia" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZdU-Ub-FUa" customClass="LTMorphingLabel">
<rect key="frame" x="70" y="0.0" width="175" height="50"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="morphingProgress">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="morphingDuration">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="morphingCharacterDelay">
<real key="value" value="2"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="boolean" keyPath="morphingEnabled" value="YES"/>
</userDefinedRuntimeAttributes>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7r7-8E-nP4">
<rect key="frame" x="245" y="0.0" width="70" height="50"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="7r7-8E-nP4" firstAttribute="width" secondItem="nqN-St-ZU7" secondAttribute="width" id="sbn-kv-2j3"/>
</constraints>
</stackView>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_dropdown" translatesAutoresizingMaskIntoConstraints="NO" id="EwP-fb-0gd"> <imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_dropdown" translatesAutoresizingMaskIntoConstraints="NO" id="EwP-fb-0gd">
<rect key="frame" x="218" y="11.5" width="27" height="27"/>
<rect key="frame" x="289" y="17" width="16" height="16"/>
<constraints> <constraints>
<constraint firstAttribute="width" secondItem="EwP-fb-0gd" secondAttribute="height" multiplier="1:1" id="UEE-io-00t"/> <constraint firstAttribute="width" secondItem="EwP-fb-0gd" secondAttribute="height" multiplier="1:1" id="UEE-io-00t"/>
</constraints> </constraints>
@ -65,20 +100,20 @@
</subviews> </subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints> <constraints>
<constraint firstAttribute="bottom" secondItem="EwP-fb-0gd" secondAttribute="bottom" constant="11.5" id="Myw-33-NRw"/>
<constraint firstAttribute="bottom" secondItem="ZdU-Ub-FUa" secondAttribute="bottom" id="NZc-kH-9wI"/>
<constraint firstItem="ZdU-Ub-FUa" firstAttribute="top" secondItem="ONN-vO-ntP" secondAttribute="top" id="PFC-aN-M2J"/>
<constraint firstItem="ZdU-Ub-FUa" firstAttribute="leading" secondItem="ONN-vO-ntP" secondAttribute="leading" id="S2s-RH-Bt1"/>
<constraint firstItem="EwP-fb-0gd" firstAttribute="top" secondItem="ONN-vO-ntP" secondAttribute="top" constant="11.5" id="T7D-N1-s3X"/>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="45" id="c7k-OG-rTg"/>
<constraint firstAttribute="trailing" secondItem="EwP-fb-0gd" secondAttribute="trailing" constant="10" id="yWS-Ls-Tzc"/>
<constraint firstAttribute="trailing" secondItem="ZdU-Ub-FUa" secondAttribute="trailing" id="zle-qs-ea6"/>
<constraint firstAttribute="trailing" secondItem="EwP-fb-0gd" secondAttribute="trailing" constant="10" id="22J-WK-mdM"/>
<constraint firstItem="W5h-Sp-BqP" firstAttribute="leading" secondItem="ONN-vO-ntP" secondAttribute="leading" id="6tw-MX-H1P"/>
<constraint firstItem="W5h-Sp-BqP" firstAttribute="top" secondItem="ONN-vO-ntP" secondAttribute="top" id="Edz-8a-0Cj"/>
<constraint firstAttribute="trailing" secondItem="W5h-Sp-BqP" secondAttribute="trailing" id="I0l-2J-h3s"/>
<constraint firstAttribute="height" constant="50" id="c7k-OG-rTg"/>
<constraint firstItem="EwP-fb-0gd" firstAttribute="top" secondItem="ONN-vO-ntP" secondAttribute="top" constant="17" id="gey-fb-gVB"/>
<constraint firstAttribute="bottom" secondItem="W5h-Sp-BqP" secondAttribute="bottom" id="m7D-dK-1fR"/>
<constraint firstAttribute="bottom" secondItem="EwP-fb-0gd" secondAttribute="bottom" constant="17" id="sWh-R4-bqP"/>
</constraints> </constraints>
</view> </view>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstAttribute="trailing" secondItem="ONN-vO-ntP" secondAttribute="trailing" constant="40" id="FYf-qa-Af9"/>
<constraint firstItem="ONN-vO-ntP" firstAttribute="leading" secondItem="6kh-QB-9Ob" secondAttribute="leading" constant="40" id="s9E-yD-f2N"/>
<constraint firstAttribute="trailing" secondItem="ONN-vO-ntP" secondAttribute="trailing" constant="10" id="KMf-pr-W0D"/>
<constraint firstItem="ONN-vO-ntP" firstAttribute="leading" secondItem="6kh-QB-9Ob" secondAttribute="leading" constant="10" id="crp-Nx-alQ"/>
</constraints> </constraints>
</stackView> </stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="Vft-CU-APP"> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="Vft-CU-APP">
@ -199,6 +234,7 @@
<constraints> <constraints>
<constraint firstAttribute="bottom" secondItem="idQ-Xy-Bxh" secondAttribute="bottom" constant="30" id="1NR-I1-2GK"/> <constraint firstAttribute="bottom" secondItem="idQ-Xy-Bxh" secondAttribute="bottom" constant="30" id="1NR-I1-2GK"/>
<constraint firstAttribute="trailing" secondItem="idQ-Xy-Bxh" secondAttribute="trailing" constant="20" id="4cT-Ki-7mO"/> <constraint firstAttribute="trailing" secondItem="idQ-Xy-Bxh" secondAttribute="trailing" constant="20" id="4cT-Ki-7mO"/>
<constraint firstItem="ONN-vO-ntP" firstAttribute="centerX" secondItem="rya-vW-oho" secondAttribute="centerX" id="TGr-WQ-BHL"/>
<constraint firstItem="idQ-Xy-Bxh" firstAttribute="leading" secondItem="rya-vW-oho" secondAttribute="leading" constant="20" id="arT-Cq-T4L"/> <constraint firstItem="idQ-Xy-Bxh" firstAttribute="leading" secondItem="rya-vW-oho" secondAttribute="leading" constant="20" id="arT-Cq-T4L"/>
<constraint firstItem="idQ-Xy-Bxh" firstAttribute="top" secondItem="rya-vW-oho" secondAttribute="top" id="qzr-gl-OoE"/> <constraint firstItem="idQ-Xy-Bxh" firstAttribute="top" secondItem="rya-vW-oho" secondAttribute="top" id="qzr-gl-OoE"/>
</constraints> </constraints>
@ -218,6 +254,7 @@
<connections> <connections>
<outlet property="buttonLogin" destination="G73-dq-xvs" id="JbA-re-pVh"/> <outlet property="buttonLogin" destination="G73-dq-xvs" id="JbA-re-pVh"/>
<outlet property="buttonSignUp" destination="xXT-1Y-c8Y" id="699-2r-8l6"/> <outlet property="buttonSignUp" destination="xXT-1Y-c8Y" id="699-2r-8l6"/>
<outlet property="flagImageView" destination="GIr-wO-yaG" id="SAM-i0-jFW"/>
<outlet property="imageViewDotCenter" destination="YH4-j7-ASu" id="zcu-n5-9q8"/> <outlet property="imageViewDotCenter" destination="YH4-j7-ASu" id="zcu-n5-9q8"/>
<outlet property="imageViewDotLeft" destination="XaM-Bb-cbb" id="OZK-A6-a4p"/> <outlet property="imageViewDotLeft" destination="XaM-Bb-cbb" id="OZK-A6-a4p"/>
<outlet property="imageViewDotRight" destination="zwr-Vy-PYs" id="Snz-cG-hIV"/> <outlet property="imageViewDotRight" destination="zwr-Vy-PYs" id="Snz-cG-hIV"/>
@ -234,6 +271,7 @@
</scenes> </scenes>
<resources> <resources>
<image name="dotUnselected" width="7" height="7"/> <image name="dotUnselected" width="7" height="7"/>
<image name="flag_south_korea" width="512" height="512"/>
<image name="ic_dropdown" width="11" height="6"/> <image name="ic_dropdown" width="11" height="6"/>
<image name="ic_ovalBackground" width="150" height="150"/> <image name="ic_ovalBackground" width="150" height="150"/>
<image name="ic_splashFirstScreen" width="50" height="48"/> <image name="ic_splashFirstScreen" width="50" height="48"/>

151
GMERemittance/Module/SplashScreen/User Interface/View/SplashScreenViewController.swift

@ -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
} }
} }

Loading…
Cancel
Save