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.

103 lines
3.9 KiB

6 years ago
  1. //
  2. // ProfileAccountViewController.swift
  3. // GMERemittance
  4. //
  5. // Created by FMI-12 on 1/29/18.
  6. // Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class UserInfoViewController: UIViewController {
  10. private var activityIndicator: UIActivityIndicatorView = UIActivityIndicatorView()
  11. private var userinfoviewmodel = UserInfoViewModel()
  12. private var count = 0
  13. public static var profileEditConnectionTimeOutCheck = 0
  14. override func viewDidAppear(_ animated: Bool) {
  15. setUpAnotherLoginListener(genericviewmodel: userinfoviewmodel)
  16. showActivityIndicator(activityIndicator: activityIndicator)
  17. disableUserInteractions()
  18. userinfoviewmodel.userConnectionTimeOut.value = nil
  19. /**
  20. connection timeout
  21. */
  22. userinfoviewmodel.userConnectionTimeOut.bind { [unowned self] in
  23. guard $0 != nil else {
  24. return
  25. }
  26. self.enableUserInteractions()
  27. self.dismissActivityIndicator(activityIndicator: self.activityIndicator)
  28. if UserInfoViewController.profileEditConnectionTimeOutCheck == 0{
  29. UserInfoViewController.profileEditConnectionTimeOutCheck = UserInfoViewController.profileEditConnectionTimeOutCheck+1
  30. self.popUpMessage(value: 39)
  31. }
  32. }
  33. userinfoviewmodel.internetConnection.bind { [unowned self] in
  34. guard $0 != nil else {
  35. return
  36. }
  37. self.enableUserInteractions()
  38. self.dismissActivityIndicator(activityIndicator: self.activityIndicator)
  39. if self.count == 0{
  40. self.popUpMessage(value: 15)
  41. }
  42. self.count = self.count+1
  43. }
  44. userinfoviewmodel.userDataAvailable.bind { [weak self] in
  45. guard $0 != nil else {
  46. return
  47. }
  48. self?.dismissActivityIndicator(activityIndicator: (self?.activityIndicator)!)
  49. self?.enableUserInteractions()
  50. guard $0! else {
  51. if UserInfoViewController.profileEditConnectionTimeOutCheck == 0{
  52. UserInfoViewController.profileEditConnectionTimeOutCheck = UserInfoViewController.profileEditConnectionTimeOutCheck+1
  53. self?.popUpMessageError(value: 10, message: (self?.userinfoviewmodel.getErrorMessage())!)
  54. }
  55. return
  56. }
  57. if UserDefaults.standard.object(forKey: "com.gmeremit.address") as? String == nil {
  58. UserDefaults.standard.set(self?.userinfoviewmodel.getAddress(), forKey: "com.gmeremit.address")
  59. }
  60. }
  61. userinfoviewmodel.fetchUserInfo()
  62. }
  63. override func viewDidLoad() {
  64. super.viewDidLoad()
  65. setUpNavBar(id: 201, title: "Profile")
  66. }
  67. override func didReceiveMemoryWarning() {
  68. super.didReceiveMemoryWarning()
  69. }
  70. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  71. if (segue.identifier == "profileUserGeneral") {
  72. let nextViewController = segue.destination as! ProfileGeneralViewController
  73. if (self.userinfoviewmodel.getInfo().firstName) != nil{
  74. nextViewController.userinfoviewmodel = self.userinfoviewmodel
  75. }
  76. } else if (segue.identifier == "profileUserDocument") {
  77. let nextViewController = segue.destination as! ProfileDocumentViewController
  78. if (self.userinfoviewmodel.getInfo().firstName) != nil{
  79. nextViewController.userinfoviewmodel = self.userinfoviewmodel
  80. }
  81. } else if (segue.identifier == "profileUserBank") {
  82. let nextViewController = segue.destination as! ProfileBankViewController
  83. if (self.userinfoviewmodel.getInfo().firstName) != nil{
  84. nextViewController.userinfoviewmodel = self.userinfoviewmodel
  85. }
  86. }
  87. }
  88. }