| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // OOTabBarController.swift
- // O2Platform
- //
- // Created by 刘振兴 on 2018/4/12.
- // Copyright © 2018年 zoneland. All rights reserved.
- //
- import UIKit
- import CYLTabBarController
- import CocoaLumberjack
- class OOTabBarController: CYLTabBarController,UITabBarControllerDelegate {
-
- static var tabBarVC:OOTabBarController!
-
- private var currentIndex:Int = 0
-
- private let viewModel:OOLoginViewModel = {
- return OOLoginViewModel()
- }()
-
- override func viewDidLoad() {
- super.viewDidLoad()
- self.delegate = self
- selectedIndex = 2
- currentIndex = 2
- _init()
- }
-
- private func _init() {
- viewModel.registerIM().then { (result) in
- self.viewModel.loginIM().then({ (result) in
- Log.debug(message: "IM登陆完成")
- })
- }.catch { (imError) in
- let error = imError as! OOLoginError
- switch error {
- case .imRegisterFail(let myErr):
- Log.debug(message: myErr.errorDescription!)
- self.viewModel.loginIM().then({ (result) in
- Log.debug(message: "IM登陆完成")
- }).catch({ (loginError) in
- Log.error(message: "im Login Error \(loginError)")
- })
- break
- default:
- break
- }
- }
- }
-
- static func genernateVC(viewControllers:[UIViewController],tabBarItemsAttributes:[[String : String]]) -> OOTabBarController {
- guard let myVC = tabBarVC else {
- tabBarVC = OOTabBarController(viewControllers: viewControllers, tabBarItemsAttributes: tabBarItemsAttributes)
- return tabBarVC
- }
- return myVC
- }
-
- static func genernateVC() -> OOTabBarController {
- guard let myVC = tabBarVC else {
- tabBarVC = OOTabBarController(viewControllers: OOTabBarHelper.viewControllers(), tabBarItemsAttributes: OOTabBarHelper.tabBarItemsAttributesForController())
- return tabBarVC
- }
-
- return myVC
- }
-
- func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
- self.cyl_tabBarController.updateSelectionStatusIfNeeded(for: tabBarController, shouldSelect: viewController)
- return true
- }
-
-
-
- override func tabBarController(_ tabBarController: UITabBarController!, didSelect control: UIControl!) {
-
- if control is CYLPlusButton {
- if currentIndex == 2 && tabBarController.selectedIndex == 2 {
- if tabBarController.selectedViewController is ZLNavigationController {
- (tabBarController.selectedViewController as! ZLNavigationController).viewControllers.forEach { (vc) in
- if vc is MailViewController {
- DDLogDebug("点击了首页 portal")
- (vc as! MailViewController).loadDetailSubject()
- }
- if vc is MainTaskSecondViewController {
- DDLogDebug("点击了首页index")
- }
- }
- }
- }
- }
- self.currentIndex = tabBarController.selectedIndex
- }
- }
|