|
@@ -66,6 +66,7 @@ class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
addSubview(avatarButton)
|
|
|
addSubview(nameButton)
|
|
|
addSubview(likeBtn)
|
|
|
+ addSubview(likeLabel)
|
|
|
contentImageView.addSubview(pauseImageView)
|
|
|
likeBtn.imageView?.addSubview(praiseAnimationView)
|
|
|
|
|
@@ -85,20 +86,29 @@ class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
make.left.equalToSuperview().offset(10)
|
|
|
make.size.equalTo(18)
|
|
|
}
|
|
|
+
|
|
|
+ nameButton.snp.makeConstraints { (make) in
|
|
|
+ make.centerY.equalTo(avatarButton)
|
|
|
+ make.left.equalTo(avatarButton.snp_right).offset(5)
|
|
|
+ make.height.equalTo(18)
|
|
|
+ make.right.equalTo(likeBtn.snp_left).offset(-5)
|
|
|
+ }
|
|
|
|
|
|
- likeBtn.snp.remakeConstraints { (make) in
|
|
|
+
|
|
|
+ likeLabel.snp.makeConstraints { (make) in
|
|
|
make.centerY.equalTo(avatarButton)
|
|
|
make.right.equalTo(-13)
|
|
|
- make.height.equalTo(18)
|
|
|
+ make.left.equalTo(likeBtn.snp.right)
|
|
|
}
|
|
|
- likeBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
|
|
|
|
|
|
- nameButton.snp.remakeConstraints { (make) in
|
|
|
+ likeBtn.snp.makeConstraints { (make) in
|
|
|
make.centerY.equalTo(avatarButton)
|
|
|
- make.left.equalTo(avatarButton.snp_right).offset(5)
|
|
|
- make.height.equalTo(18)
|
|
|
- make.right.equalTo(likeBtn.snp_left).offset(-5)
|
|
|
+ make.right.equalTo(likeLabel.snp.left).offset(-3)
|
|
|
+ make.size.equalTo(18)
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
praiseAnimationView.snp.makeConstraints { (make) in
|
|
|
make.edges.equalToSuperview()
|
|
|
}
|
|
@@ -111,27 +121,10 @@ class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
func setupdata() {
|
|
|
avatarButton.rx.tap.subscribe(onNext: {
|
|
|
[weak self] (data) in
|
|
|
- if UserModel.isTokenNil() {
|
|
|
- kAppDelegate.setLogin()
|
|
|
- }else {
|
|
|
- if let userClosure = self?.userClosure {
|
|
|
- userClosure()
|
|
|
- }
|
|
|
- }
|
|
|
+ self?.nameButtonAction()
|
|
|
|
|
|
}).disposed(by: disposeBag)
|
|
|
|
|
|
- nameButton.rx.tap.subscribe(onNext: {
|
|
|
- [weak self] (data) in
|
|
|
- if UserModel.isTokenNil() {
|
|
|
- kAppDelegate.setLogin()
|
|
|
- }else {
|
|
|
- if let userClosure = self?.userClosure {
|
|
|
- userClosure()
|
|
|
- }
|
|
|
- }
|
|
|
- }).disposed(by: disposeBag)
|
|
|
-
|
|
|
likeBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
if UserModel.isTokenNil() {
|
|
|
kAppDelegate.setLogin()
|
|
@@ -177,27 +170,41 @@ class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
}()
|
|
|
|
|
|
|
|
|
- private lazy var nameButton: UIButton = {
|
|
|
- let nameButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
- nameButton.setTitle("昵称", for: UIControl.State.normal)
|
|
|
- nameButton.setTitleColor(k262626Color, for: UIControl.State.normal)
|
|
|
- nameButton.titleLabel?.font = kRegularFont12
|
|
|
- nameButton.contentHorizontalAlignment = .left
|
|
|
- nameButton.titleLabel?.lineBreakMode = .byTruncatingTail
|
|
|
-
|
|
|
+ private lazy var nameButton: UILabel = {
|
|
|
+ let nameButton = UILabel()
|
|
|
+ nameButton.text = "昵称"
|
|
|
+ nameButton.textColor = k262626Color
|
|
|
+ nameButton.font = kRegularFont12
|
|
|
+ nameButton.textAlignment = .left
|
|
|
+ nameButton.addTapGesture(1, target: self, action: #selector(nameButtonAction))
|
|
|
return nameButton
|
|
|
}()
|
|
|
|
|
|
+ @objc func nameButtonAction() {
|
|
|
+ if UserModel.isTokenNil() {
|
|
|
+ kAppDelegate.setLogin()
|
|
|
+ }else {
|
|
|
+ if let userClosure = self.userClosure {
|
|
|
+ userClosure()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
lazy var likeBtn: UIButton = {
|
|
|
let likeBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
- likeBtn.setTitleColor(k999999Color, for: UIControl.State.normal)
|
|
|
likeBtn.setImage(kImage(name: "btn_praise"), for: UIControl.State.normal)
|
|
|
likeBtn.setImage(kImage(name: "btn_praise_pre_36px"), for: UIControl.State.selected)
|
|
|
- likeBtn.titleLabel?.font = kRegularFont12
|
|
|
|
|
|
return likeBtn
|
|
|
}()
|
|
|
|
|
|
+ lazy var likeLabel: UILabel = {
|
|
|
+ let likeLabel = UILabel()
|
|
|
+ likeLabel.textColor = k999999Color
|
|
|
+ likeLabel.font = kRegularFont12
|
|
|
+ return likeLabel
|
|
|
+ }()
|
|
|
+
|
|
|
private lazy var praiseAnimationView: AnimationView = {
|
|
|
let praiseAnimationView = AnimationView()
|
|
|
let animation = Animation.named("verywell")
|
|
@@ -216,8 +223,7 @@ class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
|
|
|
var communityPostDataModel : CommunityPostDataModel? {
|
|
|
didSet {
|
|
|
- contentImageView.kf.setImage(with: kURLImage(name: communityPostDataModel?.img ?? ""), placeholder: kImage(name: "default_pic")
|
|
|
-)
|
|
|
+ contentImageView.kf.setImage(with: kURLImage(name: communityPostDataModel?.img ?? ""), placeholder: kImage(name: "default_pic"))
|
|
|
titleLabel.text = communityPostDataModel?.title
|
|
|
if communityPostDataModel?.title == "" || communityPostDataModel?.title == nil {
|
|
|
titleLabel.text = communityPostDataModel?.content?.replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: "\r", with: "")
|
|
@@ -225,32 +231,38 @@ class SearchContentListCollectionCell: UICollectionViewCell {
|
|
|
titleLabel.text = communityPostDataModel?.title?.replacingOccurrences(of: "\n", with: "").replacingOccurrences(of: "\r", with: "")
|
|
|
}
|
|
|
avatarButton.kf.setImage(with: kURLThumbnailsImage(name: communityPostDataModel?.avatar ?? "", size: kSize18x18Image), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
|
|
|
+ KingfisherManager.shared.cache.clearMemoryCache()
|
|
|
+ nameButton.text = communityPostDataModel?.username
|
|
|
|
|
|
- likeBtn.setTitle("\(communityPostDataModel?.praiseCount ?? 0)", for: UIControl.State.normal)
|
|
|
+ likeLabel.text = "\(communityPostDataModel?.praiseCount ?? 0)"
|
|
|
if communityPostDataModel?.isLike == 0 {
|
|
|
likeBtn.isSelected = false
|
|
|
}else {
|
|
|
likeBtn.isSelected = true
|
|
|
}
|
|
|
-
|
|
|
+ if PostType(rawValue: communityPostDataModel?.type ?? "video") == .video {
|
|
|
+ pauseImageView.isHidden = false
|
|
|
+ }else {
|
|
|
+ pauseImageView.isHidden = true
|
|
|
+ }
|
|
|
|
|
|
- nameButton.setTitle(communityPostDataModel?.username, for: UIControl.State.normal)
|
|
|
nameButton.snp.remakeConstraints { (make) in
|
|
|
make.centerY.equalTo(avatarButton)
|
|
|
make.left.equalTo(avatarButton.snp_right).offset(5)
|
|
|
make.height.equalTo(18)
|
|
|
- make.right.lessThanOrEqualTo(likeBtn.snp_left).offset(-5)
|
|
|
+ make.right.equalTo(likeBtn.snp_left).offset(-5)
|
|
|
}
|
|
|
- likeBtn.snp.remakeConstraints { (make) in
|
|
|
+
|
|
|
+ likeLabel.snp.remakeConstraints { (make) in
|
|
|
make.centerY.equalTo(avatarButton)
|
|
|
make.right.equalTo(-13)
|
|
|
- make.height.equalTo(18)
|
|
|
+ make.left.equalTo(likeBtn.snp.right)
|
|
|
}
|
|
|
- likeBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
|
|
|
- if PostType(rawValue: communityPostDataModel?.type ?? "video") == .video {
|
|
|
- pauseImageView.isHidden = false
|
|
|
- }else {
|
|
|
- pauseImageView.isHidden = true
|
|
|
+
|
|
|
+ likeBtn.snp.remakeConstraints { (make) in
|
|
|
+ make.centerY.equalTo(avatarButton)
|
|
|
+ make.right.equalTo(likeLabel.snp.left).offset(-3)
|
|
|
+ make.size.equalTo(18)
|
|
|
}
|
|
|
|
|
|
|