|
@@ -33,9 +33,20 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
avatarButton.kf.setImage(with: kURLImage(name: self.videoItemMdl?.avatar ?? ""), for: .normal, placeholder: kImage(name: "default_avatar"))
|
|
|
personLabel.text = self.videoItemMdl?.username
|
|
|
|
|
|
- commentBtn.titleLabel?.text = "\(self.videoItemMdl?.commentCount ?? 0)"
|
|
|
- collectBtn.titleLabel?.text = "\(self.videoItemMdl?.collectCount ?? 0)"
|
|
|
- likeBtn.titleLabel?.text = "\(self.videoItemMdl?.praiseCount ?? 0)"
|
|
|
+ // 点赞
|
|
|
+ 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
|
|
@@ -74,7 +85,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
typealias ShareClosure = () -> Void
|
|
|
var shareClosure : ShareClosure?
|
|
|
|
|
|
- typealias ButtonClickClosure = (_ clickType: videoBtnClickType, _ uid: Int) -> Void
|
|
|
+ typealias ButtonClickClosure = (_ clickType: videoBtnClickType, _ uid: Int, _ postId: Int) -> Void
|
|
|
var buttonClickClosure : ButtonClickClosure?
|
|
|
|
|
|
class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> CommunityVideoCoverCollectionCell {
|
|
@@ -428,7 +439,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
commentBtn.titleLabel?.font = kRegularFont14
|
|
|
commentBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
if let buttonClickClosure = self?.buttonClickClosure {
|
|
|
- buttonClickClosure(videoBtnClickType.typeComment, self?.videoItemMdl?.uid ?? 0)
|
|
|
+ buttonClickClosure(videoBtnClickType.typeComment, self?.videoItemMdl?.uid ?? 0, self?.videoItemMdl?.id ?? 0)
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
return commentBtn
|
|
@@ -436,15 +447,24 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
|
|
|
private lazy var collectBtn: UIButton = {
|
|
|
let collectBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
- collectBtn.setTitle("0", for: UIControl.State.normal)
|
|
|
collectBtn.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
collectBtn.setImage(kImage(name: "video_btn_collect_white"), for: UIControl.State.normal)
|
|
|
collectBtn.setImage(kImage(name: "btn_collect_pre"), for: UIControl.State.selected)
|
|
|
collectBtn.titleLabel?.font = kRegularFont14
|
|
|
collectBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
collectBtn.isSelected = !collectBtn.isSelected
|
|
|
+ // 本地修改收藏数据
|
|
|
+ var collectCount = self?.videoItemMdl?.collectCount ?? 0
|
|
|
+ if self?.videoItemMdl?.isCollect == 0 {
|
|
|
+ collectBtn.setTitle("\(collectCount)", for: .normal)
|
|
|
+ collectBtn.setTitle("\(collectCount+1)", for: .selected)
|
|
|
+ } else {
|
|
|
+ collectBtn.setTitle("\(collectCount)", for: .selected)
|
|
|
+ collectBtn.setTitle("\(collectCount-1)", for: .normal)
|
|
|
+ }
|
|
|
+ // 点击回调
|
|
|
if let buttonClickClosure = self?.buttonClickClosure {
|
|
|
- buttonClickClosure(videoBtnClickType.typeCollect, self?.videoItemMdl?.uid ?? 0)
|
|
|
+ buttonClickClosure(videoBtnClickType.typeCollect, self?.videoItemMdl?.uid ?? 0, self?.videoItemMdl?.id ?? 0)
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
return collectBtn
|
|
@@ -452,15 +472,24 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
|
|
|
private lazy var likeBtn: UIButton = {
|
|
|
let likeBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
- likeBtn.setTitle("0", for: UIControl.State.normal)
|
|
|
likeBtn.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
likeBtn.setImage(kImage(name: "video_btn_praise_white"), for: UIControl.State.normal)
|
|
|
likeBtn.setImage(kImage(name: "btn_praise_pre_36px"), for: UIControl.State.selected)
|
|
|
likeBtn.titleLabel?.font = kRegularFont14
|
|
|
likeBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
likeBtn.isSelected = !likeBtn.isSelected
|
|
|
+ // 本地修改点赞数据
|
|
|
+ var praiseCount = self?.videoItemMdl?.praiseCount ?? 0
|
|
|
+ if self?.videoItemMdl?.isLike == 0 {
|
|
|
+ likeBtn.setTitle("\(praiseCount)", for: .normal)
|
|
|
+ likeBtn.setTitle("\(praiseCount+1)", for: .selected)
|
|
|
+ } else {
|
|
|
+ likeBtn.setTitle("\(praiseCount)", for: .selected)
|
|
|
+ likeBtn.setTitle("\(praiseCount-1)", for: .normal)
|
|
|
+ }
|
|
|
+ // 点击回调
|
|
|
if let buttonClickClosure = self?.buttonClickClosure {
|
|
|
- buttonClickClosure(videoBtnClickType.typeLike, self?.videoItemMdl?.uid ?? 0)
|
|
|
+ buttonClickClosure(videoBtnClickType.typeLike, self?.videoItemMdl?.uid ?? 0, self?.videoItemMdl?.id ?? 0)
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
return likeBtn
|
|
@@ -486,7 +515,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
let textBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
textBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
if let buttonClickClosure = self?.buttonClickClosure {
|
|
|
- buttonClickClosure(videoBtnClickType.typeComment, self?.videoItemMdl?.uid ?? 0)
|
|
|
+ buttonClickClosure(videoBtnClickType.typeComment, self?.videoItemMdl?.uid ?? 0, self?.videoItemMdl?.id ?? 0)
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
return textBtn
|
|
@@ -540,7 +569,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
avatarButton.rx.tap.subscribe(onNext: {
|
|
|
[weak self] (data) in
|
|
|
if let buttonClickClosure = self?.buttonClickClosure {
|
|
|
- buttonClickClosure(videoBtnClickType.typePerson, self?.videoItemMdl?.uid ?? 0)
|
|
|
+ buttonClickClosure(videoBtnClickType.typePerson, self?.videoItemMdl?.uid ?? 0, self?.videoItemMdl?.id ?? 0)
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
return avatarButton
|
|
@@ -561,7 +590,7 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
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)
|
|
|
+ buttonClickClosure(videoBtnClickType.typeFollow, self?.videoItemMdl?.uid ?? 0, self?.videoItemMdl?.id ?? 0)
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
return followButton
|