Selaa lähdekoodia

视频播放关注 && 评论键盘

Chris 5 vuotta sitten
vanhempi
commit
321f237f82

+ 17 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityAllCommentView.swift

@@ -10,6 +10,7 @@ import UIKit
 import FWPopupView
 import RxSwift
 import RxCocoa
+import IQKeyboardManagerSwift
 
 class CommunityAllCommentView: FWPopupView {
     
@@ -33,6 +34,8 @@ class CommunityAllCommentView: FWPopupView {
     
     override init(frame: CGRect) {
         super.init(frame: frame)
+        IQKeyboardManager.shared.enable = false
+        IQKeyboardManager.shared.enableAutoToolbar = false
         self.backgroundColor = kf7f8faColor
         
         addSubview(topView)
@@ -43,6 +46,7 @@ class CommunityAllCommentView: FWPopupView {
         noCommentsLabel.isHidden = true
         
         addSubview(tableView)
+        addSubview(commentInputView)
         
         setupLayouts()
     }
@@ -76,7 +80,7 @@ class CommunityAllCommentView: FWPopupView {
         tableView.snp.makeConstraints { (make) in
             make.top.equalTo(topView.snp_bottom)
             make.left.right.equalToSuperview()
-            make.bottom.equalTo(-48)
+            make.bottom.equalTo(-48-kSafeTabBarHeight)
         }
     }
     
@@ -89,6 +93,11 @@ class CommunityAllCommentView: FWPopupView {
             [weak self] (page) in
             
         }
+        
+        commentInputView.commentInputViewClosure = {
+            [weak self] text in
+//            self?.communityPostCommentApi(text: text)
+        }
     }
     
     private lazy var topView: UIView = {
@@ -123,6 +132,11 @@ class CommunityAllCommentView: FWPopupView {
         return noCommentsLabel
     }()
     
+    lazy var commentInputView: CommentInputView = {
+        let commentInputView = CommentInputView(isHidden: false, height: kSafeTabBarHeight + 500)
+        return commentInputView
+    }()
+    
     lazy var tableView: UITableView = {
         let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
         tableView.separatorStyle = .none
@@ -186,7 +200,8 @@ extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
 }
 
 extension CommunityAllCommentView {
-    /// 评论
+    
+    /// 评论列表
     ///
     /// - Parameters:
     ///   - postId: 内容id

+ 5 - 3
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -14,7 +14,6 @@ enum videoBtnClickType {
     case typeLike
     case typeCollect
     case typePerson
-    case typeFollow
 }
 
 class CommunityVideoCoverCollectionCell: UICollectionViewCell {
@@ -88,6 +87,9 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
     typealias ButtonClickClosure = (_ clickType: videoBtnClickType, _ uid: Int, _ postId: Int) -> Void
     var buttonClickClosure : ButtonClickClosure?
     
+    typealias FollowClosure = (_ videoItemMdl: CommunityVideoItemModel, _ button: UIButton) -> Void
+    var followClosure : FollowClosure?
+    
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> CommunityVideoCoverCollectionCell {
         let ID = "CommunityVideoCoverCollectionCell"
         collectionView.register(CommunityVideoCoverCollectionCell.self, forCellWithReuseIdentifier: ID)
@@ -589,8 +591,8 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
         followButton.layer.masksToBounds = true
         followButton.setTitleColor(kffffffColor, for: .normal)
         followButton.rx.tap.subscribe(onNext: {[weak self] (data) in
-            if let buttonClickClosure = self?.buttonClickClosure {
-                buttonClickClosure(videoBtnClickType.typeFollow, self?.videoItemMdl?.uid ?? 0, self?.videoItemMdl?.id ?? 0)
+            if let followClosure = self?.followClosure {
+                followClosure(self!.videoItemMdl!, followButton)
             }
         }).disposed(by: disposeBag)
         return followButton

+ 3 - 3
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/ViewController/CommunityVideoListController.swift

@@ -135,6 +135,9 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
             [weak self] in
             print("------点击了[分享]")
         }
+        cell.followClosure = { (videoItemMdl, followButton) in
+            CommunityFollowUserViewModel.shared.follow(communityVideoItemModel: videoItemMdl, button: followButton)
+        }
         cell.buttonClickClosure = {
             [weak self] (clickType, uid, postId) in
             switch clickType {
@@ -151,9 +154,6 @@ extension CommunityVideoListController: UICollectionViewDelegateFlowLayout,UICol
                 vc.uid = uid
                 self?.navigationController?.pushViewController(vc, animated: true)
                 
-            case videoBtnClickType.typeFollow:
-                print("关注动作")
-                
             default:
                 break
             }

+ 10 - 5
RainbowPlanet/RainbowPlanet/Tools/CommentInputView/CommentInputView.swift

@@ -40,14 +40,19 @@ class CommentInputView: UIView {
     }
 
     /// 初始化是否隐藏
-    init(isHidden:Bool) {
+    init(isHidden:Bool,height:CGFloat = 0) {
         self.init()
         inputViewIsHidden = isHidden
-        if isHidden {
-            self.frame = CGRect(x: 0, y: kScreenHeight, width: kScreenWidth, height: kSafeTabBarHeight+48)
-        } else {
-            self.frame = CGRect(x: 0, y: kScreenHeight-kSafeTabBarHeight-48, width: kScreenWidth, height: kSafeTabBarHeight+48)
+        if height == 0 {
+            if isHidden {
+                self.frame = CGRect(x: 0, y: kScreenHeight, width: kScreenWidth, height: kSafeTabBarHeight+48)
+            } else {
+                self.frame = CGRect(x: 0, y: kScreenHeight-kSafeTabBarHeight-48, width: kScreenWidth, height: kSafeTabBarHeight+48)
+            }
+        }else {
+            self.frame = CGRect(x: 0, y: height-kSafeTabBarHeight-48, width: kScreenWidth, height: kSafeTabBarHeight+48)
         }
+        
         setupViews()
         setupData()
     }

+ 23 - 0
RainbowPlanet/RainbowPlanet/ViewModel/Community/CommunityFollowUserViewModel.swift

@@ -202,3 +202,26 @@ extension CommunityFollowUserViewModel {
         }
     }
 }
+
+
+// MARK: - CommunityVideoItemModel
+extension CommunityFollowUserViewModel {
+    /// 关注/取消关注
+    ///
+    /// - Parameter communityVideoItemModel: 帖子模型
+    func follow(communityVideoItemModel: 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)
+                
+            })
+        }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)
+                
+            })
+        }
+    }
+}