|
@@ -21,9 +21,11 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ typealias BackClosure = () -> Void
|
|
|
+ var backClosure : BackClosure?
|
|
|
|
|
|
- typealias DelPicBlock = (_ idxRow:Int?) -> Void
|
|
|
- var delPicBlock : DelPicBlock?
|
|
|
+ typealias ShareClosure = () -> Void
|
|
|
+ var shareClosure : ShareClosure?
|
|
|
|
|
|
class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> CommunityVideoCoverCollectionCell {
|
|
|
let ID = "CommunityVideoCoverCollectionCell"
|
|
@@ -51,13 +53,20 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
}
|
|
|
|
|
|
- //MRAK: - 设置View
|
|
|
+ //MARK: - 设置View
|
|
|
private func setupViews() {
|
|
|
- self.backgroundColor = kf7f8faColor
|
|
|
|
|
|
addSubview(videoPlayView)
|
|
|
+ videoPlayView.addTapGesture(1, target: self, action: #selector(videoTapAction))
|
|
|
+
|
|
|
+ addSubview(navBackView)
|
|
|
+ navBackView.addSubview(navBackBtn)
|
|
|
+ navBackView.addSubview(shareBtnRight)
|
|
|
+ navBackView.addSubview(shareBtnLeft)
|
|
|
+
|
|
|
+ addSubview(playStatusImageView)
|
|
|
+
|
|
|
|
|
|
- addSubview(delButton)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -67,45 +76,112 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
|
|
|
make.edges.equalToSuperview()
|
|
|
}
|
|
|
|
|
|
- delButton.snp.makeConstraints { (make) in
|
|
|
- make.top.right.equalToSuperview()
|
|
|
- make.size.equalTo(18)
|
|
|
+ navBackView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(20)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(44)
|
|
|
+ }
|
|
|
+ navBackBtn.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(5)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.size.equalTo(40)
|
|
|
+ }
|
|
|
+ shareBtnRight.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalTo(-6)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.size.equalTo(39)
|
|
|
+ }
|
|
|
+ shareBtnLeft.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalTo(-52)
|
|
|
+ make.bottom.equalTo(-8)
|
|
|
+ make.width.equalTo(123)
|
|
|
+ make.height.equalTo(35)
|
|
|
+ }
|
|
|
+
|
|
|
+ playStatusImageView.snp.makeConstraints { (make) in
|
|
|
+ make.center.equalToSuperview()
|
|
|
+ make.width.equalTo(50)
|
|
|
+ make.height.equalTo(60)
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+ // 视频播放View
|
|
|
private lazy var videoPlayView: CommunityVideoPlayView = {
|
|
|
let videoPlayView = CommunityVideoPlayView()
|
|
|
videoPlayView.isUserInteractionEnabled = true
|
|
|
return videoPlayView
|
|
|
}()
|
|
|
|
|
|
- private lazy var picImageView: UIImageView = {
|
|
|
- let picImageView = UIImageView()
|
|
|
- picImageView.cornerRadius = 4
|
|
|
- picImageView.masksToBounds = true
|
|
|
- return picImageView
|
|
|
+ private lazy var navBackView: UIView = {
|
|
|
+ let navBackView = UIView()
|
|
|
+ navBackView.backgroundColor = UIColor.clear
|
|
|
+ return navBackView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var navBackBtn: UIButton = {
|
|
|
+ let navBackBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ navBackBtn.setImage(kImage(name: "navbar_back_white"), for: UIControl.State.normal)
|
|
|
+ navBackBtn.rx.tap.subscribe(onNext: {
|
|
|
+ [weak self] (data) in
|
|
|
+ if let backClosure = self?.backClosure {
|
|
|
+ backClosure()
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return navBackBtn
|
|
|
}()
|
|
|
|
|
|
- private lazy var delButton: UIButton = {
|
|
|
- let delButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
- delButton.setImage(kImage(name: "common_sku_cancel"), for: UIControl.State.normal)
|
|
|
- delButton.rx.tap.subscribe(onNext: {
|
|
|
+ private lazy var shareBtnRight: UIButton = {
|
|
|
+ let shareBtnRight = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ shareBtnRight.setImage(kImage(name: "btn_share_gray"), for: UIControl.State.normal)
|
|
|
+ shareBtnRight.rx.tap.subscribe(onNext: {
|
|
|
[weak self] (data) in
|
|
|
- let idxPath = self?.indexPath
|
|
|
- if let delPicBlock = self?.delPicBlock {
|
|
|
- delPicBlock(idxPath?.row)
|
|
|
+ if let shareClosure = self?.shareClosure {
|
|
|
+ shareClosure()
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
- return delButton
|
|
|
+ return shareBtnRight
|
|
|
}()
|
|
|
|
|
|
- // MARK: -
|
|
|
+ private lazy var shareBtnLeft: UIButton = {
|
|
|
+ let shareBtnLeft = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ shareBtnLeft.setImage(kImage(name: "nav_share_poster"), for: UIControl.State.normal)
|
|
|
+ shareBtnLeft.rx.tap.subscribe(onNext: {
|
|
|
+ [weak self] (data) in
|
|
|
+ if let shareClosure = self?.shareClosure {
|
|
|
+ shareClosure()
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return shareBtnLeft
|
|
|
+ }()
|
|
|
+
|
|
|
+
|
|
|
+ // 播放暂停icon
|
|
|
+ private lazy var playStatusImageView: UIImageView = {
|
|
|
+ let playStatusImageView = UIImageView()
|
|
|
+ playStatusImageView.image = kImage(name: "btn_pause")
|
|
|
+ return playStatusImageView
|
|
|
+ }()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // MARK: - 播放动作
|
|
|
func play() {
|
|
|
+ playStatusImageView.isHidden = true
|
|
|
videoPlayView.play()
|
|
|
}
|
|
|
|
|
|
func pause() {
|
|
|
+ playStatusImageView.isHidden = false
|
|
|
videoPlayView.pause()
|
|
|
}
|
|
|
|
|
|
+ @objc func videoTapAction(_ tap: UITapGestureRecognizer?) {
|
|
|
+ if videoPlayView.pauseFlag {
|
|
|
+ self.play()
|
|
|
+ } else {
|
|
|
+ self.pause()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|