Browse Source

no message

南鑫林 5 years ago
parent
commit
6c341d2ccb

+ 3 - 7
RainbowPlanet/RainbowPlanet/AppDelegate/AppDelegate+HandleOpen.swift

@@ -46,18 +46,14 @@ extension AppDelegate {
     func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
         //关闭友盟自带的弹出框
         UMessage.setAutoAlert(true)
-        if #available(iOS 9.0, *)  {
-            if #available(iOS 10.0, *){
-            }else {
-                UMessage.didReceiveRemoteNotification(userInfo)
-                completionHandler(UIBackgroundFetchResult.newData);
-            }
-        }
+        UMessage.didReceiveRemoteNotification(userInfo)
+        completionHandler(UIBackgroundFetchResult.newData);
     }
 
     func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
         //关闭友盟自带的弹出框
         UMessage.setAutoAlert(true)
+        // 接受笑死通知
         UMessage.didReceiveRemoteNotification(userInfo)
     }
 

+ 1 - 1
RainbowPlanet/RainbowPlanet/Macro/Common.swift

@@ -291,7 +291,7 @@ func getImageWidth(imgStr:String) -> CGFloat {
 /// 获取图片的高
 ///
 /// - Parameter imgStr: 图片链接
-/// - Returns: 
+/// - Returns: gao
 func getImageHeight(imgStr:String) -> CGFloat {
     let imageStr = getImageWidthheightStr(imgStr: imgStr)
     let widthStr = imageStr.prefix(upTo:(imageStr.firstIndex(of: "_"))!)

+ 31 - 33
RainbowPlanet/RainbowPlanet/Manager/UMManager/UMManager.swift

@@ -84,40 +84,38 @@ public extension UMManager {
         //type是对推送的几个参数的选择,可以选择一个或者多个。默认是三个全部打开,即:声音,弹窗,角标
         _entity?.types = Int(UInt8(UMessageAuthorizationOptions.badge.rawValue)|UInt8(UMessageAuthorizationOptions.alert.rawValue)|UInt8(UMessageAuthorizationOptions.sound.rawValue))
 
-        if #available(iOS 8.0, *) {
-            if #available(iOS 10.0, *) {
+        if #available(iOS 10.0, *) {
+
+            let action1_ios10 = UNNotificationAction(identifier: "action1_identifier", title: "打开应用", options: UNNotificationActionOptions.foreground)
+            let action2_ios10 = UNNotificationAction(identifier: "action2_identifier", title: "忽略", options: UNNotificationActionOptions.foreground)
+
+            let category1_ios10 = UNNotificationCategory(identifier: "category1", actions: [action1_ios10,action2_ios10], intentIdentifiers: [], options: UNNotificationCategoryOptions.customDismissAction)
+            //UNNotificationCategoryOptionNone
+            //UNNotificationCategoryOptionCustomDismissAction  清除通知被触发会走通知的代理方法
+            //UNNotificationCategoryOptionAllowInCarPlay       适用于行车模式
+            let categories = NSSet(objects: category1_ios10)
+            _entity?.categories = (categories as! Set<AnyHashable>)
+            UNUserNotificationCenter.current().delegate = self
+
+        } else {
+            let action1 = UIMutableUserNotificationAction.init()
+            action1.identifier = "action1_identifier"
+            action1.title = "打开应用"
+            action1.activationMode = UIUserNotificationActivationMode.foreground;//当点击的时候启动程序
+
+            let action2 = UIMutableUserNotificationAction.init()
+            action2.identifier = "action2_identifier"
+            action2.title = "忽略"
+            action2.activationMode = UIUserNotificationActivationMode.background;//当点击的时候不启动程序,在后台处理
+            action2.isAuthenticationRequired = true;//需要解锁才能处理,如果action.activationMode = UIUserNotificationActivationModeForeground;则这个属性被忽略;
+            action2.isDestructive = true;
+
+            let actionCategory1 = UIMutableUserNotificationCategory.init()
+            actionCategory1.identifier = "category1"//这组动作的唯一标示
+            actionCategory1.setActions([action1,action2], for: UIUserNotificationActionContext.default)
+            let categories = NSSet(objects: actionCategory1)
+            _entity?.categories = (categories as! Set<AnyHashable>)
 
-                let action1_ios10 = UNNotificationAction(identifier: "action1_identifier", title: "打开应用", options: UNNotificationActionOptions.foreground)
-                let action2_ios10 = UNNotificationAction(identifier: "action2_identifier", title: "忽略", options: UNNotificationActionOptions.foreground)
-
-                let category1_ios10 = UNNotificationCategory(identifier: "category1", actions: [action1_ios10,action2_ios10], intentIdentifiers: [], options: UNNotificationCategoryOptions.customDismissAction)
-                //UNNotificationCategoryOptionNone
-                //UNNotificationCategoryOptionCustomDismissAction  清除通知被触发会走通知的代理方法
-                //UNNotificationCategoryOptionAllowInCarPlay       适用于行车模式
-                let categories = NSSet(objects: category1_ios10)
-                _entity?.categories = (categories as! Set<AnyHashable>)
-                UNUserNotificationCenter.current().delegate = self
-
-            } else {
-                let action1 = UIMutableUserNotificationAction.init()
-                action1.identifier = "action1_identifier"
-                action1.title = "打开应用"
-                action1.activationMode = UIUserNotificationActivationMode.foreground;//当点击的时候启动程序
-
-                let action2 = UIMutableUserNotificationAction.init()
-                action2.identifier = "action2_identifier"
-                action2.title = "忽略"
-                action2.activationMode = UIUserNotificationActivationMode.background;//当点击的时候不启动程序,在后台处理
-                action2.isAuthenticationRequired = true;//需要解锁才能处理,如果action.activationMode = UIUserNotificationActivationModeForeground;则这个属性被忽略;
-                action2.isDestructive = true;
-
-                let actionCategory1 = UIMutableUserNotificationCategory.init()
-                actionCategory1.identifier = "category1"//这组动作的唯一标示
-                actionCategory1.setActions([action1,action2], for: UIUserNotificationActionContext.default)
-                let categories = NSSet(objects: actionCategory1)
-                _entity?.categories = (categories as! Set<AnyHashable>)
-
-            }
         }
 
         //注册通知

+ 10 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/Controller/CommunityRecommendController.swift

@@ -135,7 +135,7 @@ class CommunityRecommendController: BaseViewController {
         return tableView
     }()
     lazy var communityPostDetailTableViewHeaderView: CommunityPostDetailTableViewHeaderView = {
-        let communityPostDetailTableViewHeaderView = CommunityPostDetailTableViewHeaderView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 211))
+        let communityPostDetailTableViewHeaderView = CommunityPostDetailTableViewHeaderView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 0))
         return communityPostDetailTableViewHeaderView
     }()
     
@@ -328,7 +328,6 @@ extension CommunityRecommendController {
                 self?.followButton.isHidden = false
             }
             CommunityFollowUserViewModel.shared.setFollowType(followButton: (self?.followButton)!, followType: FollowType(rawValue: self?.communityPostDetailModel?.isFollow ?? 0) ?? .futureFollow)
-            self?.communityPostDetailTableViewHeaderView.communityPostDetailModel = self?.communityPostDetailModel
             self?.commentView.communityPostDetailModel = self?.communityPostDetailModel
 
             if PostType(rawValue: self?.communityPostDetailModel?.type ?? "html") == .html {
@@ -342,15 +341,24 @@ extension CommunityRecommendController {
                     self?.followButton.isHidden = true
                 }
                 if !(self?.communityPostDetailModel?.imgs?.isEmpty ?? true) {
+                    let height = getImageHeight(imgStr: (self?.communityPostDetailModel?.imgs?[0])!)
+                    let width = getImageWidth(imgStr: (self?.communityPostDetailModel?.imgs?[0])!)
+                    self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth*height/width)
                     self?.communityPostDetailTableViewHeaderView.tableView = self?.tableView
                     self?.tableView.tableHeaderView = self?.communityPostDetailTableViewHeaderView
+
                     
                 }else {
                     if self?.communityPostDetailModel?.img != nil ||  self?.communityPostDetailModel?.img != "" {
+                        let height = getImageHeight(imgStr: (self?.communityPostDetailModel?.img)!)
+                        let width = getImageWidth(imgStr: (self?.communityPostDetailModel?.img)!)
+                        self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth*height/width)
                         self?.communityPostDetailTableViewHeaderView.tableView = self?.tableView
                         self?.tableView.tableHeaderView = self?.communityPostDetailTableViewHeaderView
                     }
                 }
+                self?.communityPostDetailTableViewHeaderView.communityPostDetailModel = self?.communityPostDetailModel
+
             }
             
             self?.tableView.reloadData()

+ 34 - 9
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/CommunityPostDetailTableViewHeaderView.swift

@@ -62,6 +62,9 @@ extension CommunityPostDetailTableViewHeaderView:FSPagerViewDataSource,FSPagerVi
     }
     func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
         let cell  = CommunityPostDetailFSPagerViewCell.cellWith(collectionView: pagerView, index: index)
+        let height = getImageHeight(imgStr: imgs[index])
+        let width = getImageWidth(imgStr: imgs[index])
+        cell.size = CGSize(width: kScreenWidth, height: kScreenWidth*height/width)
         cell.img = imgs[index]
         return cell
     }
@@ -71,22 +74,44 @@ extension CommunityPostDetailTableViewHeaderView:FSPagerViewDataSource,FSPagerVi
     }
     
     func pagerViewWillBeginDragging(_ pagerView: FSPagerView) {
-//        height1 += 20
+        let currentIndex = pagerView.currentIndex
+        let cell = pagerView.cellForItem(at: currentIndex) as! CommunityPostDetailFSPagerViewCell
+        UIView.animate(withDuration: 0.5) {
+            self.size = cell.size
+            self.tableView?.reloadData()
+        }
     }
-    
     func pagerViewWillEndDragging(_ pagerView: FSPagerView, targetIndex: Int) {
-        
+        let currentIndex = pagerView.currentIndex
+        let cell = pagerView.cellForItem(at: currentIndex) as! CommunityPostDetailFSPagerViewCell
+        UIView.animate(withDuration: 0.5) {
+            self.size = cell.size
+            self.tableView?.reloadData()
+        }
+    }
+    func pagerViewDidScroll(_ pagerView: FSPagerView) {
     }
     
-    func pagerViewDidEndScrollAnimation(_ pagerView: FSPagerView) {
-//        self.pageControl.currentPage = pagerView.currentIndex
+    func pagerView(_ pagerView: FSPagerView, willDisplay cell: FSPagerViewCell, forItemAt index: Int) {
+        //        UIView.animate(withDuration: 0.2) {
+        //            self.size = cell.size
+        //            self.tableView?.reloadData()
+        //        }
     }
-    func pagerViewDidScroll(_ pagerView: FSPagerView) {
-        
-//        self.frame = CGRect(x: 0.0, y: 0.0, width: CGFloat(kScreenWidth), height: CGFloat(221+height1))
-//        tableView?.reloadData()
+
+    func pagerView(_ pagerView: FSPagerView, didEndDisplaying cell: FSPagerViewCell, forItemAt index: Int) {
+        let currentIndex = pagerView.currentIndex
+        let cell = pagerView.cellForItem(at: currentIndex) as! CommunityPostDetailFSPagerViewCell
+        UIView.animate(withDuration: 0.5) {
+            self.size = cell.size
+            self.tableView?.reloadData()
+        }
     }
     
+    func pagerViewDidEndDecelerating(_ pagerView: FSPagerView) {
+        
+    }
+
 }