You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.4 KiB

3 years ago
5 years ago
3 years ago
  1. //
  2. // LauncherScreenViewController.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 22/07/2019.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class LauncherScreenViewController: UIViewController {
  10. // MARK: Properties
  11. var presenter: LauncherScreenModuleInterface?
  12. private var isShow = false
  13. private var window: UIWindow? {
  14. if let app = UIApplication.shared.delegate as? AppDelegate {
  15. return app.window
  16. } else {
  17. return nil
  18. }
  19. }
  20. // MARK: Computed Properties
  21. // MARK: IBOutlets
  22. @IBOutlet private weak var logoImageView: UIImageView!
  23. // MARK: VC's Life cycle
  24. override func viewDidLoad() {
  25. super.viewDidLoad()
  26. setup()
  27. }
  28. override func viewDidAppear(_ animated: Bool) {
  29. super.viewDidAppear(animated)
  30. // #if DEBUG
  31. DebugManager.shared.selectServerAlert(target: self) {
  32. if !self.isShow {
  33. self.setEntryPoint()
  34. self.isShow = true
  35. }
  36. }
  37. // #else
  38. // if !isShow {
  39. // setEntryPoint()
  40. // isShow = true
  41. // }
  42. // #endif
  43. }
  44. }
  45. // MARK: LauncherScreenViewInterface
  46. extension LauncherScreenViewController: LauncherScreenViewInterface {
  47. func setError(with error: Error) {
  48. alertWithOk(
  49. type: .error,
  50. message: error.localizedDescription,
  51. okTitle: "retry_text".localized(),
  52. okAction: {
  53. self.presenter?.goSplashScreen()
  54. }
  55. )
  56. }
  57. }
  58. // MARK: Other Functions
  59. extension LauncherScreenViewController {
  60. private func setup() {
  61. setUUID()
  62. setupNavBar()
  63. view.backgroundColor = .themeRed
  64. }
  65. private func setUUID() {
  66. if GMEDB.shared.app.string(.uuid) == nil {
  67. let uuid = UUID().uuidString
  68. GMEDB.shared.app.set(uuid, .uuid)
  69. }
  70. }
  71. private func setupNavBar() {
  72. let appearance = UINavigationBar.appearance()
  73. appearance.backIndicatorImage = #imageLiteral(resourceName: "backIconBlack")
  74. appearance.backIndicatorTransitionMaskImage = #imageLiteral(resourceName: "backIconBlack")
  75. appearance.tintColor = UIColor.black
  76. }
  77. }
  78. // MARK: - Login Logic
  79. extension LauncherScreenViewController {
  80. private func setEntryPoint() {
  81. guard KeyChain.shared.get(key: .id) != nil,
  82. (KeyChain.shared.get(key: .login) ?? "1") == "1" ? true : false else {
  83. presenter?.goSplashScreen()
  84. return
  85. }
  86. presenter?.openAuthenticationScreen()
  87. }
  88. }