南鑫林 5 years ago
parent
commit
062b35acb1

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/CardContent/PicVideo/CardContentPicVideoCollectionViewCell.swift

@@ -72,7 +72,7 @@ class CardContentPicVideoCollectionViewCell: UICollectionViewCell {
     
     var communityRecommendDataModel: CommunityRecommendDataModel? {
         didSet {
-            if PostType(rawValue: communityRecommendDataModel?.type ?? "image") == .video {
+            if PostType(rawValue: communityRecommendDataModel?.type ?? "") == .video {
                 pauseImageView.isHidden = false
             }else {
                 pauseImageView.isHidden = true
@@ -83,7 +83,7 @@ class CardContentPicVideoCollectionViewCell: UICollectionViewCell {
     
     var communityFollowDataModel: CommunityFollowDataModel? {
         didSet {
-            if PostType(rawValue: communityFollowDataModel?.relateData?.type ?? "image") == .video {
+            if PostType(rawValue: communityFollowDataModel?.relateData?.type ?? "") == .video {
                 pauseImageView.isHidden = false
             }else {
                 pauseImageView.isHidden = true

+ 1 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/CardContent/PicVideo/CardContentPicVideoTableViewCell.swift

@@ -199,6 +199,7 @@ extension CardContentPicVideoTableViewCell: UICollectionViewDelegateFlowLayout,U
             }else {
                 cell.imgStr = communityFollowDataModel?.relateData?.imgs?[indexPath.row]
             }
+            cell.communityFollowDataModel = communityFollowDataModel
         }
         return cell
     }

+ 49 - 59
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -20,64 +20,6 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
     
     let disposeBag = DisposeBag()
     
-    var videoItemMdl: CommunityVideoItemModel? {
-        didSet {
-            if !(self.videoItemMdl?.video == nil || self.videoItemMdl?.video == "")  {
-                videoPlayView.assetURLString = self.videoItemMdl?.video
-            }
-            
-            beanLabel.text = "\(self.videoItemMdl?.willCollectBean ?? 0)彩虹豆待收获"
-            
-            
-            avatarButton.kf.setImage(with: kURLImage(name: self.videoItemMdl?.avatar ?? ""), for: .normal, placeholder: kImage(name: "default_avatar"))
-            personLabel.text = self.videoItemMdl?.username
-            
-            // 点赞
-            if self.videoItemMdl?.isLike == 0 {
-                likeBtn.setTitle("\(self.videoItemMdl?.praiseCount ?? 0)", for: .normal)
-            } else {
-                likeBtn.setTitle("\(self.videoItemMdl?.praiseCount ?? 0)", for: .selected)
-            }
-            // 收藏
-            if self.videoItemMdl?.isCollect == 0 {
-                collectBtn.setTitle("\(self.videoItemMdl?.collectCount ?? 0)", for: .normal)
-            } else {
-                collectBtn.setTitle("\(self.videoItemMdl?.collectCount ?? 0)", for: .selected)
-            }
-            // 评论
-            commentBtn.setTitle("\(self.videoItemMdl?.commentCount ?? 0)", for: .normal)
-            
-            collectBtn.isSelected = self.videoItemMdl?.isCollect == 0 ? false : true
-            likeBtn.isSelected = self.videoItemMdl?.isLike == 0 ? false : true
-            
-            if self.videoItemMdl?.isFollow == 0 {
-                // 未关注
-                followButton.setTitle("+关注", for: UIControl.State.normal)
-                followButton.backgroundColor = k62CC74Color
-            } else {
-                // 已关注
-                followButton.setTitle("已关注", for: UIControl.State.normal)
-                followButton.backgroundColor = .clear
-                followButton.layer.borderWidth = 1
-                followButton.layer.borderColor = kffffffColor.cgColor
-            }
-            
-            if !(self.videoItemMdl?.title == "" || self.videoItemMdl?.title == nil) {
-                // 有标题
-                videoTitleLabel.text = self.videoItemMdl?.title
-                
-            } else {
-                // 无标题
-                
-            }
-            
-            topicView.topicArray = self.videoItemMdl?.topic
-            topicView.reloadData()
-            
-            contentLabel.text = self.videoItemMdl?.content
-        }
-    }
-    
     typealias BackClosure = () -> Void
     var backClosure : BackClosure?
     
@@ -177,7 +119,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         
         // 顶部
         navBackView.snp.makeConstraints { (make) in
-            make.top.equalTo(20)
+            make.top.equalTo(kSafeStatusBarHeight)
             make.left.right.equalToSuperview()
             make.height.equalTo(44)
         }
@@ -648,4 +590,52 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         }
     }
     
+    var videoItemMdl: CommunityVideoItemModel? {
+        didSet {
+            if !(self.videoItemMdl?.video == nil || self.videoItemMdl?.video == "")  {
+                videoPlayView.assetURLString = self.videoItemMdl?.video
+            }
+            
+            beanLabel.text = "\(self.videoItemMdl?.willCollectBean ?? 0)彩虹豆待收获"
+            
+            
+            avatarButton.kf.setImage(with: kURLImage(name: self.videoItemMdl?.avatar ?? ""), for: .normal, placeholder: kImage(name: "default_avatar"))
+            personLabel.text = self.videoItemMdl?.username
+            
+            // 点赞
+            if self.videoItemMdl?.isLike == 0 {
+                likeBtn.setTitle("\(self.videoItemMdl?.praiseCount ?? 0)", for: .normal)
+            } else {
+                likeBtn.setTitle("\(self.videoItemMdl?.praiseCount ?? 0)", for: .selected)
+            }
+            // 收藏
+            if self.videoItemMdl?.isCollect == 0 {
+                collectBtn.setTitle("\(self.videoItemMdl?.collectCount ?? 0)", for: .normal)
+            } else {
+                collectBtn.setTitle("\(self.videoItemMdl?.collectCount ?? 0)", for: .selected)
+            }
+            // 评论
+            commentBtn.setTitle("\(self.videoItemMdl?.commentCount ?? 0)", for: .normal)
+            
+            collectBtn.isSelected = self.videoItemMdl?.isCollect == 0 ? false : true
+            likeBtn.isSelected = self.videoItemMdl?.isLike == 0 ? false : true
+            
+            CommunityFollowUserViewModel.shared.setFollowType(followButton: followButton, followType: FollowType(rawValue: self.videoItemMdl?.isFollow ?? 0)!)
+            
+            if !(self.videoItemMdl?.title == "" || self.videoItemMdl?.title == nil) {
+                // 有标题
+                videoTitleLabel.text = self.videoItemMdl?.title
+                
+            } else {
+                // 无标题
+                
+            }
+            
+            topicView.topicArray = self.videoItemMdl?.topic
+            topicView.reloadData()
+            
+            contentLabel.text = self.videoItemMdl?.content
+        }
+    }
+    
 }

+ 16 - 5
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/ViewController/CommunityVideoListController.swift

@@ -39,6 +39,7 @@ class CommunityVideoListController: BaseViewController {
         super.viewDidLoad()
         setupViews()
         setUpAppStatusNotification()
+        statusBarStyle = .lightContent
     }
     
     override func viewDidAppear(_ animated: Bool) {
@@ -139,6 +140,18 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
         return videoItemList?.count ?? 0
     }
     
+    func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
+        
+        let cell = collectionView.cellForItem(at: indexPath) as? CommunityVideoCoverCollectionCell
+        if cell != nil {
+            collectionView.reloadItems(at: [indexPath])
+        }
+
+    }
+    
+    
+    
+    
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = CommunityVideoCoverCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
         cell.videoItemMdl = videoItemList?[indexPath.row]
@@ -150,8 +163,9 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
             [weak self] (videoItemMdl) in
             self?.share(videoItemMdl)
         }
-        cell.followClosure = { (videoItemMdl, followButton) in
-            CommunityFollowUserViewModel.shared.follow(communityVideoItemModel: videoItemMdl, button: followButton)
+        cell.followClosure = {
+            [weak self] (videoItemMdl, followButton) in
+            CommunityFollowUserViewModel.shared.follow(communityVideoItemModel: videoItemMdl,videoItemList:(self?.videoItemList)!, button: followButton)
         }
         cell.buttonClickClosure = {
             [weak self] (clickType, uid, postId) in
@@ -168,9 +182,6 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
                 let vc = OtherPersonalCenterViewController()
                 vc.uid = uid
                 self?.navigationController?.pushViewController(vc, animated: true)
-                
-            default:
-                break
             }
         }
         return cell

+ 11 - 2
RainbowPlanet/RainbowPlanet/ViewModel/Community/CommunityFollowUserViewModel.swift

@@ -209,18 +209,27 @@ extension CommunityFollowUserViewModel {
     /// 关注/取消关注
     ///
     /// - Parameter communityVideoItemModel: 帖子模型
-    func follow(communityVideoItemModel: CommunityVideoItemModel,button:UIButton) {
+    func follow(communityVideoItemModel: CommunityVideoItemModel,videoItemList:Array<CommunityVideoItemModel>,button:UIButton) {
         if communityVideoItemModel.isFollow == 0 {//加关注
             self.userFollow(followUid:  communityVideoItemModel.uid ?? 0, completion: { (isFollow) -> Void in
                 communityVideoItemModel.isFollow = isFollow
                 CommunityFollowUserViewModel.shared.setFollowType(followButton: button, followType: FollowType(rawValue: communityVideoItemModel.isFollow ?? 0) ?? .futureFollow)
+                for (_,model) in videoItemList.enumerated() {
+                    if model.uid == communityVideoItemModel.uid {
+                        model.isFollow = isFollow
+                    }
+                }
                 
             })
         }else {//取消关注
             self.userCancelFollow(followUid:  communityVideoItemModel.uid ?? 0, completion: { (isFollow) -> Void in
                 communityVideoItemModel.isFollow = isFollow
                 CommunityFollowUserViewModel.shared.setFollowType(followButton: button, followType: FollowType(rawValue: communityVideoItemModel.isFollow ?? 0) ?? .futureFollow)
-                
+                for (_,model) in videoItemList.enumerated() {
+                    if model.uid == communityVideoItemModel.uid {
+                        model.isFollow = isFollow
+                    }
+                }
             })
         }
     }