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|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- static let shared : BaseTabbarViewController = BaseTabbarViewController()
|
|
|
-
|
|
|
- var esTabBarController : ESTabBarController!
|
|
|
+
|
|
|
+class BaseTabbarViewController: UITabBarController {
|
|
|
|
|
|
+ static let shared : BaseTabbarViewController = BaseTabbarViewController()
|
|
|
|
|
|
var v1 : CommunityViewController!
|
|
|
-
|
|
|
-
|
|
|
|
|
|
var v2 : BackyardViewController!
|
|
|
|
|
|
var v3 : BaseViewController!
|
|
|
|
|
|
var v4 : MessageMainViewController!
|
|
|
-
|
|
|
|
|
|
var v5 : UserPersonalCenterViewController!
|
|
|
|
|
|
-
|
|
|
- var lottieAnimateContentView1 : BaseLottieAnimateContentView!
|
|
|
-
|
|
|
-
|
|
|
- var lottieAnimateContentView2 : BaseLottieAnimateContentView!
|
|
|
-
|
|
|
-
|
|
|
- var lottieAnimateContentView4 : BaseLottieAnimateContentView!
|
|
|
-
|
|
|
-
|
|
|
- var lottieAnimateContentView5 : BaseLottieAnimateContentView!
|
|
|
-
|
|
|
+
|
|
|
+ var customSelectedIndex : Int = 0
|
|
|
var lastIndex : Int = 0
|
|
|
-
|
|
|
- func tabBarViewController() -> ESTabBarController {
|
|
|
- esTabBarController = ESTabBarController()
|
|
|
-
|
|
|
+
|
|
|
+ override func viewDidLoad() {
|
|
|
+ delegate = self
|
|
|
if #available(iOS 13.0, *) {
|
|
|
- esTabBarController.tabBar.standardAppearance.configureWithOpaqueBackground()
|
|
|
- esTabBarController.tabBar.standardAppearance.backgroundImage = UIImage.imageWithColor(color: UIColor.white)
|
|
|
- esTabBarController.tabBar.standardAppearance.shadowImage = UIImage(named: "navbar_shadow_pic_down")
|
|
|
+ tabBar.standardAppearance.configureWithOpaqueBackground()
|
|
|
+ tabBar.standardAppearance.backgroundImage = UIImage.imageWithColor(color: UIColor.white)
|
|
|
+ tabBar.standardAppearance.shadowImage = UIImage(named: "navbar_shadow_pic_down")
|
|
|
} else {
|
|
|
- esTabBarController.tabBar.shadowImage = UIImage(named: "navbar_shadow_pic_down")
|
|
|
- }
|
|
|
-
|
|
|
- esTabBarController.shouldHijackHandler = {
|
|
|
- [weak self] (tabbarController, viewController, index) in
|
|
|
- AudioServicesPlaySystemSound(1519)
|
|
|
-
|
|
|
- if UserModel.isTokenNil() {
|
|
|
- if index == 2 || index == 3 || index == 4 {
|
|
|
- return true
|
|
|
- }else {
|
|
|
- self?.reloadTabbar(index:index)
|
|
|
- self?.lastIndex = index
|
|
|
- return false
|
|
|
- }
|
|
|
- }else {
|
|
|
- if index == 2 {
|
|
|
- return true
|
|
|
- }else {
|
|
|
- self?.reloadTabbar(index:index)
|
|
|
- self?.lastIndex = index
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- esTabBarController.didHijackHandler = {
|
|
|
- [weak self] tabbarController, viewController, index in
|
|
|
- if UserModel.isTokenNil() {
|
|
|
- kAppDelegate.setLogin()
|
|
|
- }else {
|
|
|
- self?.pushPublishVC()
|
|
|
- }
|
|
|
+ tabBar.shadowImage = UIImage(named: "navbar_shadow_pic_down")
|
|
|
}
|
|
|
|
|
|
|
|
|
v1 = CommunityViewController()
|
|
|
-
|
|
|
-
|
|
|
|
|
|
v2 = BackyardViewController()
|
|
|
|
|
@@ -105,41 +355,16 @@ class BaseTabbarViewController: NSObject {
|
|
|
|
|
|
v5 = UserPersonalCenterViewController()
|
|
|
|
|
|
-
|
|
|
- lottieAnimateContentView1 = BaseLottieAnimateContentView(jsonStr: "communityModuleTabbar")
|
|
|
-
|
|
|
-
|
|
|
- lottieAnimateContentView2 = BaseLottieAnimateContentView(jsonStr: "shoppingMallModuleTabbar")
|
|
|
-
|
|
|
-
|
|
|
- lottieAnimateContentView4 = BaseLottieAnimateContentView(jsonStr: "messageModuleTabbar")
|
|
|
+ setupChildController(controller: v1, title: "社区", image: "tabbar_home", selectedImage: "tabbar_home_pre")
|
|
|
+ setupChildController(controller: v2, title: "后院", image: "tabbar_shopping", selectedImage: "tabbar_shopping_pre")
|
|
|
+ setupChildController(controller: v3, title: "", image: "tabbar_publish", selectedImage: "tabbar_publish")
|
|
|
+ setupChildController(controller: v4, title: "消息", image: "tabbar_massage", selectedImage: "tabbar_massage_pre")
|
|
|
+ setupChildController(controller: v5, title: "我的", image: "tabbar_my", selectedImage: "tabbar_my_pre")
|
|
|
|
|
|
-
|
|
|
- lottieAnimateContentView5 = BaseLottieAnimateContentView(jsonStr: "MineModuleTabbar")
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- tabBarItemStyle(navc: v1, normalImg: "tabbar_home", selectorImg: "tabbar_home_pre", title: "社区")
|
|
|
- tabBarItemStyle(navc: v2, normalImg: "tabbar_shopping", selectorImg: "tabbar_shopping_pre", title: "后院")
|
|
|
v3.tabBarItem = UITabBarItem(title: nil, image: UIImage(named: "tabbar_publish")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: UIImage(named: "tabbar_publish")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal))
|
|
|
v3.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0);
|
|
|
- tabBarItemStyle(navc: v4, normalImg: "tabbar_massage", selectorImg: "tabbar_massage_pre", title: "消息")
|
|
|
- tabBarItemStyle(navc: v5, normalImg: "tabbar_my", selectorImg: "tabbar_my_pre", title: "我的")
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
- let n1 = BaseNavigationViewController.init(rootViewController: v1)
|
|
|
- let n2 = BaseNavigationViewController.init(rootViewController: v2)
|
|
|
- let n3 = BaseNavigationViewController.init(rootViewController: v3)
|
|
|
- let n4 = BaseNavigationViewController.init(rootViewController: v4)
|
|
|
- let n5 = BaseNavigationViewController.init(rootViewController: v5)
|
|
|
-
|
|
|
- esTabBarController.viewControllers = [n1, n2, n3, n4, n5]
|
|
|
+ UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: k333333Color], for: .selected)
|
|
|
|
|
|
setBadge()
|
|
|
NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main, using: {
|
|
@@ -156,36 +381,12 @@ class BaseTabbarViewController: NSObject {
|
|
|
[weak self] notification in
|
|
|
self?.setBadge()
|
|
|
}
|
|
|
- return esTabBarController
|
|
|
}
|
|
|
-
|
|
|
- func setLoginTabBarItem() {
|
|
|
-
|
|
|
-
|
|
|
- tabBarItemStyle(navc: v1, normalImg: "tabbar_home", selectorImg: "tabbar_home_pre", title: "社区")
|
|
|
- tabBarItemStyle(navc: v2, normalImg: "tabbar_shopping", selectorImg: "tabbar_shopping_pre", title: "后院")
|
|
|
- v3.tabBarItem = UITabBarItem(title: nil, image: UIImage(named: "tabbar_publish")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: UIImage(named: "tabbar_publish")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal))
|
|
|
- v3.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0);
|
|
|
- tabBarItemStyle(navc: v4, normalImg: "tabbar_massage", selectorImg: "tabbar_massage_pre", title: "消息")
|
|
|
- tabBarItemStyle(navc: v5, normalImg: "tabbar_my", selectorImg: "tabbar_my_pre", title: "我的")
|
|
|
- }
|
|
|
-
|
|
|
- func setLoginOutTabBarItem() {
|
|
|
-
|
|
|
-
|
|
|
- tabBarItemStyle(navc: v1, normalImg: "tabbar_home", selectorImg: "tabbar_home_pre", title: "社区")
|
|
|
- tabBarItemStyle(navc: v2, normalImg: "tabbar_shopping", selectorImg: "tabbar_shopping_pre", title: "后院")
|
|
|
- v3.tabBarItem = UITabBarItem(title: nil, image: UIImage(named: "tabbar_publish")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: UIImage(named: "tabbar_publish")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal))
|
|
|
- v3.tabBarItem.imageInsets = UIEdgeInsets(top: 4, left: 0, bottom: -4, right: 0);
|
|
|
- tabBarItemStyle(navc: v4, normalImg: "tabbar_massage", selectorImg: "tabbar_massage_pre", title: "消息")
|
|
|
- tabBarItemStyle(navc: v5, normalImg: "tabbar_my", selectorImg: "tabbar_my_pre", title: "我的")
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
func pushPublishVC() {
|
|
|
|
|
|
if !AliyunVodUpToyoPublishManager.shared.isUploading {
|
|
|
- PublishNewPopView.show(imageStrs: ["publish_btn_picture","publish_btn_video","publish_btn_photo","publish_btn_article"], titles: ["相册","视频","拍照","文章"], columnCount: 4) { (index) in
|
|
|
+ PublishNewPopView.show(imageStrs: ["publish_btn_picture","publish_btn_video","publish_btn_photo","publish_btn_article"], titles: ["相册","视频","拍照","文章"], columnCount: 4) { [weak self] (index) in
|
|
|
if index != 3 {
|
|
|
let pickVc = PublishViewController()
|
|
|
pickVc.index = index
|
|
@@ -193,7 +394,7 @@ class BaseTabbarViewController: NSObject {
|
|
|
|
|
|
let nav = BaseNavigationViewController.init(rootViewController: pickVc)
|
|
|
nav.modalPresentationStyle = .fullScreen
|
|
|
- BaseTabbarViewController.shared.esTabBarController.present(nav, animated: true, completion: nil)
|
|
|
+ self?.present(nav, animated: true, completion: nil)
|
|
|
}else {
|
|
|
Mediator.push(H5RouterModuleType.pushPostArticle)
|
|
|
}
|
|
@@ -214,29 +415,15 @@ class BaseTabbarViewController: NSObject {
|
|
|
if messageIndexModel?.activity?.isYes == 1 || messageIndexModel?.follow?.isYes == 1 || messageIndexModel?.notification?.isYes == 1 || messageIndexModel?.praise?.isYes == 1 || messageIndexModel?.comment?.isYes == 1 || (RCIMClient.shared()?.getTotalUnreadCount())! > Int32(0) {
|
|
|
v4.tabBarItem.pp.addDot(color:kFE352BColor)
|
|
|
v4.tabBarItem.pp.moveBadge(x: -3,y: 3)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}else {
|
|
|
-
|
|
|
-
|
|
|
v4.tabBarItem.pp.hiddenBadge()
|
|
|
}
|
|
|
|
|
|
|
|
|
if UpdateVersionModel.shared.object()?.upGradeModelType == .update || UpdateVersionModel.shared.object()?.upGradeModelType == .strongUpdate {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
v5.tabBarItem.pp.addDot(color:kFE352BColor)
|
|
|
v5.tabBarItem.pp.moveBadge(x: -3,y: 3)
|
|
|
}else {
|
|
|
-
|
|
|
-
|
|
|
v5.tabBarItem.pp.hiddenBadge()
|
|
|
}
|
|
|
}
|
|
@@ -245,48 +432,75 @@ class BaseTabbarViewController: NSObject {
|
|
|
func reloadTabbar(index:Int) {
|
|
|
|
|
|
if index == 0 && lastIndex == 0 {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if communityModuleTopType == .communityModuleFollowTop {
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("CommunityModuleFollowTop"), object: nil)
|
|
|
-
|
|
|
}
|
|
|
if communityModuleTopType == .communityModuleRecommendTop {
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("CommunityModuleRecommendTop"), object: nil)
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
if index == 1 && lastIndex == 1 {
|
|
|
-
|
|
|
-
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("BackyardViewModuleTop"), object: nil)
|
|
|
|
|
|
}
|
|
|
if index == 3 && lastIndex == 3 {
|
|
|
-
|
|
|
-
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("MessageModuleTop"), object: nil)
|
|
|
|
|
|
}
|
|
|
if index == 4 && lastIndex == 4 {
|
|
|
-
|
|
|
-
|
|
|
NotificationCenter.default.post(name: NSNotification.Name("MineModuleTop"), object: nil)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func setupChildController(controller: UIViewController, title: String, image: String, selectedImage: String) {
|
|
|
+
|
|
|
+ controller.tabBarItem.title = title
|
|
|
+ controller.tabBarItem.image = UIImage.init(named: image)?.withRenderingMode(.alwaysOriginal)
|
|
|
+ controller.tabBarItem.selectedImage = UIImage.init(named: selectedImage)?.withRenderingMode(.alwaysOriginal)
|
|
|
+ addChild(BaseNavigationViewController.init(rootViewController: controller))
|
|
|
|
|
|
- private func tabBarItemStyle(navc : BaseViewController, normalImg : String, selectorImg : String, title : String){
|
|
|
- navc.tabBarItem = UITabBarItem.init(title: title, image: UIImage(named:normalImg), selectedImage: UIImage(named:selectorImg))
|
|
|
- navc.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor:k333333Color], for: UIControl.State.normal)
|
|
|
- navc.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor:k333333Color], for: UIControl.State.selected)
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
+extension BaseTabbarViewController : UITabBarControllerDelegate{
|
|
|
+ func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
|
|
|
+ AudioServicesPlaySystemSound(1519)
|
|
|
+ if UserModel.isTokenNil() {
|
|
|
+ if customSelectedIndex == 2 || customSelectedIndex == 3 || customSelectedIndex == 4 {
|
|
|
+ kAppDelegate.setLogin()
|
|
|
+ return false
|
|
|
+ }else {
|
|
|
+ self.reloadTabbar(index:customSelectedIndex)
|
|
|
+ self.lastIndex = customSelectedIndex
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if customSelectedIndex == 2 {
|
|
|
+ self.pushPublishVC()
|
|
|
+ return false
|
|
|
+ }else {
|
|
|
+ self.reloadTabbar(index:customSelectedIndex)
|
|
|
+ self.lastIndex = customSelectedIndex
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
-extension ESTabBar {
|
|
|
+
|
|
|
+extension BaseTabbarViewController {
|
|
|
+
|
|
|
+ override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
|
|
|
+ guard let index = tabBar.items?.firstIndex(of: item) else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ customSelectedIndex = index
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+extension UITabBar {
|
|
|
open override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
|
|
|
|
|
let view = super.hitTest(point, with: event)
|
|
@@ -314,3 +528,4 @@ extension ESTabBar {
|
|
|
return view
|
|
|
}
|
|
|
}
|
|
|
+
|