南鑫林 пре 5 година
родитељ
комит
e4390e6813

+ 0 - 8
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -2320,7 +2320,6 @@
 		A72A725422321B9400B21995 /* Manager */ = {
 			isa = PBXGroup;
 			children = (
-				A75B785A22E02635007B986A /* GifManager */,
 				A743229922B8C1440017C367 /* AppStoreManager */,
 				A73A56DC22DC9CB8004920FE /* UpdateVersionManager */,
 				A797FDE922C5AC570076DCB3 /* CacheManager */,
@@ -2743,13 +2742,6 @@
 			path = json;
 			sourceTree = "<group>";
 		};
-		A75B785A22E02635007B986A /* GifManager */ = {
-			isa = PBXGroup;
-			children = (
-			);
-			path = GifManager;
-			sourceTree = "<group>";
-		};
 		A75B787522E079BC007B986A /* AnimationJSON */ = {
 			isa = PBXGroup;
 			children = (

+ 1 - 2
RainbowPlanet/RainbowPlanet/AppDelegate/AppDelegate+Window.swift

@@ -60,8 +60,7 @@ extension AppDelegate {
     
     /// 设置Tabbar
     func setTabbarController() {
-        let tabbarViewController = BaseTabbarViewController.shared
-        self.window?.rootViewController = tabbarViewController
+        self.window?.rootViewController = BaseTabbarViewController.shared.tabBarViewController()
     }
 
     /// 设置Login

+ 1 - 1
RainbowPlanet/RainbowPlanet/AppDelegate/AppDelegate.swift

@@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
         //初始化窗口
         initWindow()
         //版本更新
-//        _ = UpdateVersionManager.shared
+        _ = UpdateVersionManager.shared
 
         //初始化百度地图
         BaiduMapManager.shared.initBaiduMap()

+ 46 - 13
RainbowPlanet/RainbowPlanet/Base/BaseTabbarViewController/BaseLottieAnimateContentView.swift

@@ -10,28 +10,61 @@ import UIKit
 import ESTabBarController_swift
 import Lottie
 
-class ExampleLottieAnimateBasicContentView: ESTabBarItemContentView {
+class BaseLottieAnimateContentView: ESTabBarItemContentView {
     
+    let animationView = AnimationView()
     override init(frame: CGRect) {
         super.init(frame: frame)
-        textColor = k333333Color
-        highlightTextColor = k666666Color
-        iconColor = k333333Color
-        highlightIconColor = k666666Color
+        self.imageView.isHidden = true
+        
+    }
+    
+    init(jsonStr:String) {
+        self.init()
+        
+        textColor = k666666Color
+        highlightTextColor = k333333Color
+
+        let animation = Animation.named(jsonStr)
+        animationView.animation = animation
+        animationView.contentMode = .scaleAspectFit
+        animationView.loopMode = .playOnce
+        animationView.animationSpeed = 1.5
+        addSubview(animationView)
+
     }
     
     public required init?(coder aDecoder: NSCoder) {
         fatalError("init(coder:) has not been implemented")
     }
+    override func updateLayout() {
+        super.updateLayout()
+        animationView.frame = self.imageView.frame
+        if selected {
+            animationView.isHidden = false
+            self.imageView.isHidden = true
+            animationView.play()
+        }else {
+            animationView.isHidden = true
+            self.imageView.isHidden = false
+            animationView.stop()
+        }
+    }
     
-}
-
-class BaseLottieAnimateContentView: ExampleLottieAnimateBasicContentView {
+    override func selectAnimation(animated: Bool, completion: (() -> ())?) {
+        super.selectAnimation(animated: animated, completion: nil)
+        animationView.isHidden = false
+        self.imageView.isHidden = true
+        animationView.play()
+    }
+    
+    override func deselectAnimation(animated: Bool, completion: (() -> ())?) {
+        super.deselectAnimation(animated: animated, completion: nil)
+        animationView.isHidden = true
+        self.imageView.isHidden = false
+        
+        animationView.stop()
+    }
     
-//    lazy var animationView: AnimationView = {
-//        let animationView = AnimationView()
-//        animationView.frame = CGRect(x: 0, y: 0, width: 24, height: 24)
-//        return animationView
-//    }()
 
 }

+ 118 - 106
RainbowPlanet/RainbowPlanet/Base/BaseTabbarViewController/BaseTabbarViewController.swift

@@ -7,6 +7,9 @@
 //
 
 import UIKit
+import Lottie
+import ESTabBarController_swift
+
 /*
 class BaseTabbarViewController: UITabBarController {
     
@@ -36,26 +39,20 @@ class BaseTabbarViewController: UITabBarController {
     }
     
     func setViewControllers() {
-        tabBarItemStyle(vc: v1, normalImg: "tabbar_home", selectorImg: "tabbar_home_pre", title: "社区")
-        
-        tabBarItemStyle(vc: v2, normalImg: "tabbar_shopping", selectorImg: "tabbar_shopping_pre", title: "商城")
-        
-        tabBarItemStyle(vc: v3, normalImg: "tabbar_publish", selectorImg: "tabbar_publish", title: "")
+        v1.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(jsonStr: "communityModuleTabbar"), title: "社区", image: UIImage(named: "tabbar_home")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: nil)
+        v2.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(jsonStr: "shoppingMallModuleTabbar"), title: "商城", image: UIImage(named: "tabbar_shopping"), selectedImage: nil)
+        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);
+        v4.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(jsonStr: "messageModuleTabbar"), title: "消息", image: UIImage(named: "tabbar_massage"), selectedImage: nil)
+        v5.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(jsonStr: "MineModuleTabbar"), title: "我的", image: UIImage(named: "tabbar_my"), selectedImage: nil)
         
-        tabBarItemStyle(vc: v4, normalImg: "tabbar_massage", selectorImg: "tabbar_massage_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)
         
-        tabBarItemStyle(vc: v5, normalImg: "tabbar_my", selectorImg: "tabbar_my_pre", title: "我的")
-    }
-    
-    func tabBarItemStyle(vc : BaseViewController, normalImg : String, selectorImg : String, title : String){
-        vc.tabBarItem.title = title
-        vc.tabBarItem.image = UIImage.init(named: normalImg)?.withRenderingMode(.alwaysOriginal)
-        vc.tabBarItem.selectedImage = UIImage.init(named: selectorImg)?.withRenderingMode(.alwaysOriginal)
-    
-        vc.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor:k333333Color], for: UIControl.State.selected)
-        vc.tabBarItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor:k666666Color], for: UIControl.State.normal)
-        self.addChild(BaseNavigationViewController.init(rootViewController: vc))
+        self.viewControllers = [n1, n2, n3, n4, n5]
     }
     
     func setTag() {
@@ -77,120 +74,135 @@ class BaseTabbarViewController: UITabBarController {
     }
 
 }
+ */
 
-extension BaseTabbarViewController : UITabBarControllerDelegate {
-    
-     func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
-        
-        if viewController.tabBarItem.tag == 2 {
-            return false
-        }else{
-            return true
-        }
-    }
-    
-    
-    override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
-        
-        if item.tag == 2 {
-            let pickVc = PublishViewController()
-            let nav = BaseNavigationViewController.init(rootViewController: pickVc)
-            self.present(nav, animated: true, completion: nil)
-        }else {
-            if item.tag == self.lastClickTag && item.tag == 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 communityModuleTopType == .communityModulePlanetTop {
-                    NotificationCenter.default.post(name: NSNotification.Name("CommunityModulePlanetTop"), object: nil)
-
-                }
-                
-            }
-            if item.tag == self.lastClickTag && item.tag == 1  {
-                NotificationCenter.default.post(name: NSNotification.Name("ShoppingMallModuleTop"), object: nil)
-//                NotificationCenter.default.post(name: NSNotification.Name("RedemptionAreaModuleTop"), object: nil)
-                
-            }
-            if item.tag == self.lastClickTag && item.tag == 3  {
-                NotificationCenter.default.post(name: NSNotification.Name("MessageModuleTop"), object: nil)
-
-            }
-            if item.tag == self.lastClickTag && item.tag == 4  {
-                NotificationCenter.default.post(name: NSNotification.Name("MineModuleTop"), object: nil)
-            }
-        }
-        
-        self.lastClickTag = item.tag
-        
-    }
-}
-
-*/
 
-import ESTabBarController_swift
+class BaseTabbarViewController: ESTabBarController {
 
-class BaseTabbarViewController : ESTabBarController {
-    
     static let shared : BaseTabbarViewController = BaseTabbarViewController()
     
-    var lastClickTag : Int?
-    
     /// 社区
     let v1 = CommunityViewController()
     /// 商城
     let v2 = ShoppingMallViewController()
-    /// 兑换专区
-    //    let v2 = RedemptionAreaViewController()
     /// 发布
-    let v3 = BaseViewController()
+    let v3 = UIViewController()
     /// 消息
     let v4 = MessageMainViewController()
     /// 我的
     let v5 = UserPersonalCenterViewController()
+    
+    /// 社区
+    let lottieAnimateContentView1 = BaseLottieAnimateContentView(jsonStr: "communityModuleTabbar")
+    
+    /// 商城
+    let lottieAnimateContentView2 = BaseLottieAnimateContentView(jsonStr: "shoppingMallModuleTabbar")
+    
+    /// 消息
+    let lottieAnimateContentView4 = BaseLottieAnimateContentView(jsonStr: "messageModuleTabbar")
+    
+    /// 我的
+    let lottieAnimateContentView5 = BaseLottieAnimateContentView(jsonStr: "MineModuleTabbar")
+    
+    var lastIndex : Int = 0
 
-    override func viewDidLoad() {
-        
-        self.tabBar.shadowImage = UIImage(named: "tab_top_line")
-        self.delegate = self as? UITabBarControllerDelegate
-        
-        self.shouldHijackHandler = {
-            tabbarController, viewController, index in
+    func tabBarViewController() -> ESTabBarController {
+        let tabBarViewController = ESTabBarController()
+
+        tabBarViewController.tabBar.shadowImage = UIImage(named: "tab_top_line")
+        tabBarViewController.shouldHijackHandler = {
+           [weak self] (tabbarController, viewController, index) in
             if index == 2 {
+                self?.lastIndex = index
                 return true
+            }else {
+                self?.reloadTabbar(index:index)
+                self?.lastIndex = index
+                return false
             }
-            return false
         }
-        self.didHijackHandler = {
-            [weak self] tabbarController, viewController, index in
+
+        tabBarViewController.didHijackHandler = {
+            tabbarController, viewController, index in
             let pickVc = PublishViewController()
             let nav = BaseNavigationViewController.init(rootViewController: pickVc)
-            self?.present(nav, animated: true, completion: nil)
+            tabbarController.present(nav, animated: true, completion: nil)
         }
-
-        v1.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(), title: "社区", image: UIImage(named: "tabbar_home"), selectedImage: UIImage(named: "tabbar_home_pre"))
-        v2.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(), title: "商城", image: UIImage(named: "tabbar_shopping"), selectedImage: UIImage(named: "tabbar_shopping_pre"))
-        v3.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(), title: nil, image: UIImage(named: "tabbar_publish"), selectedImage: UIImage(named: "tabbar_publish"))
+        
+        v1.tabBarItem = ESTabBarItem.init(lottieAnimateContentView1, title: "社区", image: UIImage(named: "tabbar_home")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal), selectedImage: nil)
+        v2.tabBarItem = ESTabBarItem.init(lottieAnimateContentView2, title: "商城", image: UIImage(named: "tabbar_shopping"), selectedImage: nil)
+        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);
+        v4.tabBarItem = ESTabBarItem.init(lottieAnimateContentView4, title: "消息", image: UIImage(named: "tabbar_massage"), selectedImage: nil)
+        v5.tabBarItem = ESTabBarItem.init(lottieAnimateContentView5, title: "我的", image: UIImage(named: "tabbar_my"), selectedImage: nil)
 
-        v4.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(), title: "消息", image: UIImage(named: "tabbar_massage"), selectedImage: UIImage(named: "tabbar_massage_pre"))
-        v5.tabBarItem = ESTabBarItem.init(BaseLottieAnimateContentView(), title: "我的", image: UIImage(named: "tabbar_my"), selectedImage: UIImage(named: "tabbar_my_pre"))
-        
-        addNavigationVC(vc: v1)
-        addNavigationVC(vc: v2)
-        addNavigationVC(vc: v3)
-        addNavigationVC(vc: v4)
-        addNavigationVC(vc: v5)
+        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)
+
+        tabBarViewController.viewControllers = [n1, n2, n3, n4, n5]
+        //将要进入前台的时候
+        setBadge()
+        NotificationCenter.default.addObserver(forName: UIApplication.willEnterForegroundNotification, object: nil, queue: OperationQueue.main, using: {
+            [weak self] (notification) in
+            self?.setBadge()
+        })
+        return tabBarViewController
     }
     
-    func addNavigationVC(vc:UIViewController) {
-        self.addChild(BaseNavigationViewController.init(rootViewController: vc))
+    // 设置Badge
+    func setBadge() {
+        if UpdateVersionModel.shared.object()?.upGradeModelType == .update ||  UpdateVersionModel.shared.object()?.upGradeModelType == .strongUpdate {
+
+            let tabBarItem = v5.tabBarItem as? ESTabBarItem
+            tabBarItem?.contentView?.badgeColor = kFE352BColor
+            tabBarItem?.contentView?.badgeValue = ""
+            tabBarItem?.contentView?.badgeOffset = UIOffset(horizontal: 0, vertical: -22)
+        }else {
+            let tabBarItem = v5.tabBarItem as? ESTabBarItem
+            tabBarItem?.contentView?.badgeValue = nil
+        }
     }
-}
+    
+    func reloadTabbar(index:Int) {
+        
+        if index == 0 && lastIndex == 0  {
+            self.lottieAnimateContentView1.animationView.stop()
+            self.lottieAnimateContentView1.animationView.play()
 
+            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 communityModuleTopType == .communityModulePlanetTop {
+                NotificationCenter.default.post(name: NSNotification.Name("CommunityModulePlanetTop"), object: nil)
+                
+            }
+            
+        }
+        if index == 1 && lastIndex == 1  {
+            self.lottieAnimateContentView2.animationView.stop()
+            self.lottieAnimateContentView2.animationView.play()
+            NotificationCenter.default.post(name: NSNotification.Name("ShoppingMallModuleTop"), object: nil)
+            //                NotificationCenter.default.post(name: NSNotification.Name("RedemptionAreaModuleTop"), object: nil)
+            
+        }
+        if index == 3 && lastIndex == 3  {
+            self.lottieAnimateContentView4.animationView.stop()
+            self.lottieAnimateContentView4.animationView.play()
+            NotificationCenter.default.post(name: NSNotification.Name("MessageModuleTop"), object: nil)
+            
+        }
+        if index == 4 && lastIndex == 4  {
+            self.lottieAnimateContentView5.animationView.stop()
+            self.lottieAnimateContentView5.animationView.play()
+            NotificationCenter.default.post(name: NSNotification.Name("MineModuleTop"), object: nil)
+        }
+    }
+}

+ 2 - 2
RainbowPlanet/RainbowPlanet/Manager/UMManager/UMManager.swift

@@ -160,8 +160,8 @@ extension UMManager:UNUserNotificationCenterDelegate {
         if (notification.request.trigger?.isKind(of: UNPushNotificationTrigger.self))! {
             UMessage.setAutoAlert(false)
             //应用处于前台时的远程推送接受
-            let json = JSON(userInfo)
-            RouterManager.shared.UMPush(pushModel: PushModel(JSONString: json.description) ?? PushModel())
+//            let json = JSON(userInfo)
+//            RouterManager.shared.UMPush(pushModel: PushModel(JSONString: json.description) ?? PushModel())
             //必须加这句代码
             UMessage.didReceiveRemoteNotification(userInfo)
             

+ 2 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/ViewController/Main/CommunityViewController.swift

@@ -286,6 +286,7 @@ class CommunityViewController: BaseViewController {
         self.segmentedView.defaultSelectedIndex = 1
         self.listContainerView.defaultSelectedIndex = 1
         self.segmentedDataSource.reloadData(selectedIndex: 1)
+        self.listContainerView.reloadData()
 
     }
     //选中星球
@@ -294,6 +295,7 @@ class CommunityViewController: BaseViewController {
         self.segmentedView.defaultSelectedIndex = 2
         self.listContainerView.defaultSelectedIndex = 2
         self.segmentedDataSource.reloadData(selectedIndex: 2)
+        self.listContainerView.reloadData()
         
     }
     /// navigationBar

+ 11 - 0
RainbowPlanet/RainbowPlanet/Modules/MessageModule/MessageMain/ViewController/MessageMainViewController.swift

@@ -7,9 +7,12 @@
 //
 
 import UIKit
+import Lottie
 
 class MessageMainViewController: BaseViewController {
     
+    let animationView = AnimationView()
+    
     deinit {
         if observe != nil {
             NotificationCenter.default.removeObserver(observe!)
@@ -23,6 +26,14 @@ class MessageMainViewController: BaseViewController {
         super.viewDidLoad()
         setupViews()
         setupData()
+        animationView.frame = CGRect(x: 100, y: 100, width: 24, height: 24)
+        
+        let animation = Animation.named("communityModuleTabbar")
+        animationView.animation = animation
+        animationView.contentMode = .scaleAspectFit
+        view.addSubview(animationView)
+        animationView.loopMode = .loop
+        animationView.play()
     }
     
     override func setupViews() {

+ 1 - 3
RainbowPlanet/RainbowPlanet/Modules/MineModule/PersonalCenter/UserPersonalCenter/ViewController/UserPersonalCenterViewController.swift

@@ -10,6 +10,7 @@ import UIKit
 import JXSegmentedView
 import RxSwift
 import SwiftyMediator
+import ESTabBarController_swift
 
 class UserPersonalCenterViewController: BaseViewController {
     
@@ -135,11 +136,8 @@ class UserPersonalCenterViewController: BaseViewController {
         if UpdateVersionModel.shared.object()?.upGradeModelType == .update ||  UpdateVersionModel.shared.object()?.upGradeModelType == .strongUpdate {
             self.setButton.pp.moveBadge(x: -8, y: 8)
             self.setButton.pp.addDot(color: kFE352BColor)
-            self.tabBarItem.pp.moveBadge(x: -1, y: 3)
-            self.tabBarItem.pp.addDot(color: kFE352BColor)
         }else {
             self.setButton.pp.hiddenBadge()
-            self.tabBarItem.pp.hiddenBadge()
         }
     }
     

+ 7 - 7
RainbowPlanet/RainbowPlanet/Router/RouterManager.swift

@@ -58,9 +58,9 @@ class RouterManager: NSObject {
             break
         case .recommend?: //推荐
             let vc = UIViewController.topMost
-            let tabBarController = vc?.tabBarController as? BaseTabbarViewController
-            tabBarController?.v1.reloadSegmentedView()
-            tabBarController?.selectedIndex = 0
+            let v1 = BaseTabbarViewController.shared.v1
+            v1.reloadSegmentedView()
+            v1.tabBarController?.selectedIndex = 0
             if vc?.presentingViewController != nil {
                 vc?.dismissToWindowRootViewController(animated: false, completion: {
                     
@@ -69,11 +69,11 @@ class RouterManager: NSObject {
                 vc?.navigationController?.popToRootViewController(animated: false)
             }
             break
-        case .star?:
+        case .star?: //星球
             let vc = UIViewController.topMost
-            let tabBarController = vc?.tabBarController as? BaseTabbarViewController
-            tabBarController?.v1.reloadSegmentedStarView()
-            tabBarController?.selectedIndex = 0
+            let v1 = BaseTabbarViewController.shared.v1
+            v1.reloadSegmentedStarView()
+            v1.tabBarController?.selectedIndex = 0
             if vc?.presentingViewController != nil {
                 vc?.dismissToWindowRootViewController(animated: false, completion: {
                     

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
RainbowPlanet/RainbowPlanet/Src/AnimationJSON/communityModuleTabbar.json


Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
RainbowPlanet/RainbowPlanet/Src/AnimationJSON/shoppingMallModuleTabbar.json


+ 2 - 2
RainbowPlanet/RainbowPlanet/Supporting Files/Info.plist

@@ -20,7 +20,7 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>1.0.0</string>
+	<string>0.2.4</string>
 	<key>CFBundleURLTypes</key>
 	<array>
 		<dict>
@@ -75,7 +75,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>1</string>
+	<string>0</string>
 	<key>LSApplicationQueriesSchemes</key>
 	<array>
 		<string>wechat</string>