|
@@ -0,0 +1,146 @@
|
|
|
+//
|
|
|
+// RecommendBottomCommentView.swift
|
|
|
+// RainbowPlanet
|
|
|
+//
|
|
|
+// Created by Christopher on 2019/6/14.
|
|
|
+// Copyright © 2019 RainbowPlanet. All rights reserved.
|
|
|
+// 推荐图文内容--底部评论View
|
|
|
+
|
|
|
+import UIKit
|
|
|
+import RxSwift
|
|
|
+
|
|
|
+enum BottomClickType {
|
|
|
+ case typeComment
|
|
|
+ case typeLike
|
|
|
+ case typeCollect
|
|
|
+}
|
|
|
+
|
|
|
+class RecommendBottomCommentView: BaseView {
|
|
|
+
|
|
|
+ typealias BottomClickClosure = (_ clickType: BottomClickType) -> Void
|
|
|
+ var bottomClickClosure : BottomClickClosure?
|
|
|
+
|
|
|
+ override func setupViews() {
|
|
|
+ self.backgroundColor = kffffffColor
|
|
|
+
|
|
|
+ addSubview(commentView)
|
|
|
+ commentView.addSubview(commentLabel)
|
|
|
+ commentView.addSubview(textBtn)
|
|
|
+ addSubview(likeBtn)
|
|
|
+ addSubview(collectBtn)
|
|
|
+ addSubview(commentBtn)
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupLayouts() {
|
|
|
+ commentBtn.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalToSuperview().offset(-14)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.height.equalTo(24)
|
|
|
+ }
|
|
|
+ commentBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
|
|
|
+
|
|
|
+ collectBtn.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalTo(commentBtn.snp_left).offset(-15)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.height.equalTo(37)
|
|
|
+ }
|
|
|
+ collectBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
|
|
|
+
|
|
|
+ likeBtn.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalTo(collectBtn.snp_left).offset(-15)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.height.equalTo(37)
|
|
|
+ }
|
|
|
+ likeBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
|
|
|
+
|
|
|
+ commentView.snp.makeConstraints { (make) in
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.left.equalToSuperview().offset(14)
|
|
|
+ make.right.equalTo(likeBtn.snp_left).offset(-10)
|
|
|
+ make.height.equalTo(28)
|
|
|
+ }
|
|
|
+ commentLabel.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(15)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.width.equalTo(70)
|
|
|
+ make.height.equalTo(28)
|
|
|
+ }
|
|
|
+ textBtn.snp.makeConstraints { (make) in
|
|
|
+ make.edges.equalToSuperview()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private lazy var commentView: UIView = {
|
|
|
+ let commentView = UIView()
|
|
|
+ commentView.backgroundColor = kfafafaColor
|
|
|
+ commentView.cornerRadius = 15
|
|
|
+ commentView.masksToBounds = true
|
|
|
+ return commentView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var commentLabel: UILabel = {
|
|
|
+ let commentLabel = UILabel()
|
|
|
+ commentLabel.text = "添加评论..."
|
|
|
+ commentLabel.textColor = k999999Color
|
|
|
+ commentLabel.font = kRegularFont14
|
|
|
+ return commentLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var textBtn: UIButton = {
|
|
|
+ let textBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ textBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let bottomClickClosure = self?.bottomClickClosure {
|
|
|
+ bottomClickClosure(BottomClickType.typeComment)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return textBtn
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var likeBtn: UIButton = {
|
|
|
+ let likeBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ likeBtn.setTitle("8844", for: UIControl.State.normal)
|
|
|
+ likeBtn.setTitleColor(k313334Color, for: UIControl.State.normal)
|
|
|
+ likeBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
|
|
|
+ likeBtn.setImage(kImage(name: "common_check_icon"), for: UIControl.State.selected)
|
|
|
+ likeBtn.titleLabel?.font = kRegularFont14
|
|
|
+ likeBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ likeBtn.isSelected = !likeBtn.isSelected
|
|
|
+ if let bottomClickClosure = self?.bottomClickClosure {
|
|
|
+ bottomClickClosure(BottomClickType.typeLike)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return likeBtn
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var collectBtn: UIButton = {
|
|
|
+ let collectBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ collectBtn.setTitle("6124", for: UIControl.State.normal)
|
|
|
+ collectBtn.setTitleColor(k313334Color, for: UIControl.State.normal)
|
|
|
+ collectBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
|
|
|
+ collectBtn.setImage(kImage(name: "common_check_icon"), for: UIControl.State.selected)
|
|
|
+ collectBtn.titleLabel?.font = kRegularFont14
|
|
|
+ collectBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ collectBtn.isSelected = !collectBtn.isSelected
|
|
|
+ if let bottomClickClosure = self?.bottomClickClosure {
|
|
|
+ bottomClickClosure(BottomClickType.typeCollect)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return collectBtn
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var commentBtn: UIButton = {
|
|
|
+ let commentBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ commentBtn.setTitle("5178", for: UIControl.State.normal)
|
|
|
+ commentBtn.setTitleColor(k313334Color, for: UIControl.State.normal)
|
|
|
+ commentBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
|
|
|
+ commentBtn.titleLabel?.font = kRegularFont14
|
|
|
+ commentBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let bottomClickClosure = self?.bottomClickClosure {
|
|
|
+ bottomClickClosure(BottomClickType.typeComment)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return commentBtn
|
|
|
+ }()
|
|
|
+
|
|
|
+}
|