|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
import UIKit
|
|
|
import RxSwift
|
|
|
+import Lottie
|
|
|
|
|
|
class CardContentActionTableViewCell: UITableViewCell {
|
|
|
|
|
@@ -45,6 +46,8 @@ class CardContentActionTableViewCell: UITableViewCell {
|
|
|
addSubview(collectButton)
|
|
|
addSubview(praiseButton)
|
|
|
addSubview(lineLabel)
|
|
|
+ collectButton.addSubview(collectAnimationView)
|
|
|
+ praiseButton.imageView?.addSubview(praiseAnimationView)
|
|
|
}
|
|
|
|
|
|
private func setupLayouts() {
|
|
@@ -70,11 +73,17 @@ class CardContentActionTableViewCell: UITableViewCell {
|
|
|
make.right.equalTo(shareButton.snp_left).offset(-21)
|
|
|
make.size.equalTo(22)
|
|
|
}
|
|
|
+ collectAnimationView.snp.makeConstraints { (make) in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ }
|
|
|
praiseButton.snp.makeConstraints { (make) in
|
|
|
make.centerY.equalToSuperview()
|
|
|
make.right.equalTo(collectButton.snp_left).offset(-21)
|
|
|
}
|
|
|
praiseButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 7)
|
|
|
+ praiseAnimationView.snp.makeConstraints { (make) in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ }
|
|
|
lineLabel.snp.makeConstraints { (make) in
|
|
|
make.bottom.equalToSuperview()
|
|
|
make.left.equalTo(14)
|
|
@@ -129,6 +138,24 @@ class CardContentActionTableViewCell: UITableViewCell {
|
|
|
collectButton.setImage(kImage(name: "btn_collect_pre"), for: .selected)
|
|
|
collectButton.rx.tap.subscribe(onNext: {
|
|
|
[weak self] (data) in
|
|
|
+
|
|
|
+ if self?.communityRecommendDataModel != nil {
|
|
|
+ if self?.communityRecommendDataModel?.isCollect == 0 {
|
|
|
+ self?.collectAnimationView.isHidden = false
|
|
|
+ self?.collectAnimationView.play(completion: { (_) in
|
|
|
+ self?.collectAnimationView.isHidden = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if self?.communityFollowDataModel != nil {
|
|
|
+ if self?.communityFollowDataModel?.relateData?.isCollect == 0 {
|
|
|
+ self?.collectAnimationView.isHidden = false
|
|
|
+ self?.collectAnimationView.play(completion: { (_) in
|
|
|
+ self?.collectAnimationView.isHidden = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
if let collectClosureName = self?.collectClosureName {
|
|
|
collectClosureName(collectButton)
|
|
|
}
|
|
@@ -136,6 +163,26 @@ class CardContentActionTableViewCell: UITableViewCell {
|
|
|
return collectButton
|
|
|
}()
|
|
|
|
|
|
+ private lazy var collectAnimationView: AnimationView = {
|
|
|
+ let collectAnimationView = AnimationView()
|
|
|
+ let animation = Animation.named("collect")
|
|
|
+ collectAnimationView.animation = animation
|
|
|
+ collectAnimationView.contentMode = .scaleAspectFit
|
|
|
+ collectAnimationView.loopMode = .playOnce
|
|
|
+ collectAnimationView.isHidden = true
|
|
|
+ return collectAnimationView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var praiseAnimationView: AnimationView = {
|
|
|
+ let praiseAnimationView = AnimationView()
|
|
|
+ let animation = Animation.named("verywell")
|
|
|
+ praiseAnimationView.animation = animation
|
|
|
+ praiseAnimationView.contentMode = .scaleAspectFit
|
|
|
+ praiseAnimationView.loopMode = .playOnce
|
|
|
+ praiseAnimationView.isHidden = true
|
|
|
+ return praiseAnimationView
|
|
|
+ }()
|
|
|
+
|
|
|
typealias PraiseClosureName = (UIButton) -> Void
|
|
|
var praiseClosureName : PraiseClosureName?
|
|
|
private lazy var praiseButton: UIButton = {
|
|
@@ -147,6 +194,25 @@ class CardContentActionTableViewCell: UITableViewCell {
|
|
|
praiseButton.titleLabel?.font = kRegularFont12
|
|
|
praiseButton.rx.tap.subscribe(onNext: {
|
|
|
[weak self] (data) in
|
|
|
+
|
|
|
+ if self?.communityRecommendDataModel != nil {
|
|
|
+ if self?.communityRecommendDataModel?.isLike == 0 {
|
|
|
+ self?.praiseAnimationView.isHidden = false
|
|
|
+ self?.praiseAnimationView.play(completion: { (_) in
|
|
|
+ self?.praiseAnimationView.isHidden = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if self?.communityFollowDataModel != nil {
|
|
|
+ if self?.communityFollowDataModel?.relateData?.isLike == 0 {
|
|
|
+ self?.praiseAnimationView.isHidden = false
|
|
|
+ self?.praiseAnimationView.play(completion: { (_) in
|
|
|
+ self?.praiseAnimationView.isHidden = true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if let praiseClosureName = self?.praiseClosureName {
|
|
|
praiseClosureName(praiseButton)
|
|
|
}
|