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.

81 lines
2.9 KiB

6 years ago
  1. //
  2. // MainWireframe.swift
  3. // Sipradi
  4. //
  5. // Created by bibek timalsina on 5/26/17.
  6. // Copyright © 2017 Ekbana. All rights reserved.
  7. //
  8. import Foundation
  9. import UIKit
  10. class MainWireframe {
  11. static var shared: MainWireframe? = MainWireframe()
  12. weak var view: UIViewController!
  13. }
  14. extension MainWireframe: MainWireframeInput {
  15. var storyboardName: String {return "Main"}
  16. func getMainView() -> UIViewController {
  17. let viewController = MainViewController()
  18. let viewControllers: [UIViewController] = self.getViewControllers()
  19. viewController.setup(viewControllers: viewControllers)
  20. viewController.setupTabItem()
  21. self.view = viewController
  22. self.show(index: 0) // temporary
  23. return viewController
  24. }
  25. private func getViewControllers() -> [UIViewController] {
  26. // home view controller
  27. let homeViewController = UIStoryboard.init(name: "Home", bundle: nil).instantiateViewController(withIdentifier: "Home") as! HomeViewController
  28. let navHomeViewController = UINavigationController(rootViewController: homeViewController)
  29. // user send money view controller
  30. let sendMoneyViewController = UIStoryboard.init(name: "RecipientListViewController", bundle: nil).instantiateViewController(withIdentifier: "RecipientListViewController") as! RecipientListViewController
  31. let navSendMoneyViewController = UINavigationController(rootViewController: sendMoneyViewController)
  32. // Constacts view controller
  33. let contactsViewController = GmeContactsWireframe().getMainView()
  34. let navContactsViewController = UINavigationController(rootViewController: contactsViewController)
  35. // profile view controller
  36. let profileViewController = UIStoryboard.init(name: "Profile", bundle: nil).instantiateViewController(withIdentifier: "ProfileViewController") as! ProfileViewController
  37. let navProfileViewController = UINavigationController(rootViewController: profileViewController)
  38. return [navHomeViewController, navSendMoneyViewController, navContactsViewController, navProfileViewController]
  39. }
  40. func show(index: Int) {
  41. if let view = self.view as? MainViewController {
  42. view.selectedIndex = index
  43. }
  44. }
  45. static func logout() {
  46. guard let window = MainWireframe.shared?.window else {return}
  47. let splaseWireframe = SplashScreenWireframe()
  48. let nav = UINavigationController.init(rootViewController: splaseWireframe.getMainView())
  49. window.rootViewController = nav
  50. window.makeKeyAndVisible()
  51. }
  52. // func showStoreListing () {
  53. // if !self.isUserWireframe {
  54. // self.show(index: 1)
  55. // self.storeListWireframe.changeOrderType(alphabetic: false)
  56. // }
  57. // }
  58. }