|
@@ -10,115 +10,224 @@ import UIKit
|
|
|
import RxSwift
|
|
|
import RxCocoa
|
|
|
|
|
|
+enum BtnActionType {
|
|
|
+ case back // 返回
|
|
|
+ case reverse // 翻转
|
|
|
+ case music // 音乐
|
|
|
+ case filter // 滤镜
|
|
|
+ case delete // 回删
|
|
|
+ case confirm // 确定
|
|
|
+}
|
|
|
+
|
|
|
class PublishVideoView: BaseView {
|
|
|
|
|
|
- typealias AllSelectBlock = (_ isAllSelected: Int) -> Void
|
|
|
- var allSelectBlock : AllSelectBlock?
|
|
|
-
|
|
|
- typealias OrderPayBlock = () -> Void
|
|
|
- var orderPayBlock : OrderPayBlock?
|
|
|
-
|
|
|
- var isAllSelected: Int? {
|
|
|
- didSet {
|
|
|
- // 选中状态
|
|
|
- let selStatus = isAllSelected == 1 ? true : false
|
|
|
- allSelectBtn.isSelected = selStatus
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ typealias BtnClickClosure = (_ btnType: BtnActionType) -> Void
|
|
|
+ var btnClickClosure : BtnClickClosure?
|
|
|
|
|
|
+ typealias VideoClosure = (_ isRecording: Int) -> Void
|
|
|
+ var videoClosure : VideoClosure?
|
|
|
|
|
|
override func setupViews() {
|
|
|
self.backgroundColor = kffffffColor
|
|
|
- addSubview(allSelectBtn)
|
|
|
- addSubview(accountBtn)
|
|
|
- addSubview(priceLabel)
|
|
|
- addSubview(prePriceLabel)
|
|
|
- addSubview(previewView)
|
|
|
|
|
|
+ addSubview(backButton)
|
|
|
+ addSubview(recordButton)
|
|
|
+
|
|
|
+ addSubview(controlBackView)
|
|
|
+ controlBackView.addSubview(reverseButton)
|
|
|
+ controlBackView.addSubview(musicButton)
|
|
|
+ controlBackView.addSubview(filterButton)
|
|
|
+
|
|
|
+ addSubview(selBackView)
|
|
|
+ selBackView.addSubview(confirmButton)
|
|
|
+ selBackView.addSubview(delButton)
|
|
|
+
|
|
|
+ addSubview(previewView)
|
|
|
insertSubview(previewView, at: 0)
|
|
|
}
|
|
|
|
|
|
override func setupLayouts() {
|
|
|
- allSelectBtn.snp.makeConstraints { (make) in
|
|
|
- make.left.equalToSuperview().offset(10)
|
|
|
- make.centerY.equalToSuperview()
|
|
|
- make.height.equalTo(30)
|
|
|
- make.width.equalTo(54)
|
|
|
+
|
|
|
+ backButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(55)
|
|
|
+ make.left.equalTo(5)
|
|
|
+ make.width.equalTo(40)
|
|
|
+ make.height.equalTo(40)
|
|
|
}
|
|
|
- allSelectBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 4)
|
|
|
|
|
|
- accountBtn.snp.makeConstraints { (make) in
|
|
|
- make.right.equalToSuperview().offset(-14)
|
|
|
- make.centerY.equalToSuperview()
|
|
|
+ recordButton.snp.makeConstraints { (make) in
|
|
|
+ make.bottom.equalTo(-56)
|
|
|
+ make.centerX.equalToSuperview()
|
|
|
make.width.equalTo(100)
|
|
|
- make.height.equalTo(37)
|
|
|
+ make.height.equalTo(100)
|
|
|
+ }
|
|
|
+
|
|
|
+ /***** 翻转、音乐、滤镜 *****/
|
|
|
+ controlBackView.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(64)
|
|
|
+ make.right.equalTo(-15)
|
|
|
+ make.width.equalTo(44)
|
|
|
+ }
|
|
|
+
|
|
|
+ reverseButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(46)
|
|
|
+ }
|
|
|
+ reverseButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.top, imageTitleSpace: 4)
|
|
|
+
|
|
|
+ musicButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(reverseButton.snp_bottom).offset(20)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(46)
|
|
|
+ }
|
|
|
+ musicButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.top, imageTitleSpace: 4)
|
|
|
+
|
|
|
+ filterButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(musicButton.snp_bottom).offset(20)
|
|
|
+ make.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(46)
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
+ }
|
|
|
+ filterButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.top, imageTitleSpace: 4)
|
|
|
+
|
|
|
+ /***** 回删、确定 *****/
|
|
|
+ selBackView.snp.makeConstraints { (make) in
|
|
|
+ make.bottom.equalTo(-83)
|
|
|
+ make.right.equalTo(-24*kScaleWidth)
|
|
|
+ make.height.equalTo(50)
|
|
|
}
|
|
|
|
|
|
- priceLabel.snp.makeConstraints { (make) in
|
|
|
- make.centerY.equalToSuperview()
|
|
|
- make.right.equalTo(accountBtn.snp_left).offset(-12)
|
|
|
- make.height.equalTo(25)
|
|
|
+ confirmButton.snp.makeConstraints { (make) in
|
|
|
+ make.top.bottom.right.equalToSuperview()
|
|
|
+ make.width.equalTo(30)
|
|
|
}
|
|
|
+ confirmButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.top, imageTitleSpace: 4)
|
|
|
|
|
|
- prePriceLabel.snp.makeConstraints { (make) in
|
|
|
- make.centerY.equalToSuperview()
|
|
|
- make.right.equalTo(priceLabel.snp_left).offset(-1)
|
|
|
+ delButton.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalTo(confirmButton.snp_left).offset(-30*kScaleWidth)
|
|
|
+ make.top.bottom.equalToSuperview()
|
|
|
+ make.width.equalTo(30)
|
|
|
+ make.left.equalToSuperview()
|
|
|
}
|
|
|
+ delButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.top, imageTitleSpace: 4)
|
|
|
|
|
|
+ /***** 预览视图 *****/
|
|
|
previewView.snp.makeConstraints { (make) in
|
|
|
make.edges.equalToSuperview()
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- private lazy var allSelectBtn: UIButton = {
|
|
|
- let allSelectBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
- allSelectBtn.setTitle("全选", for: UIControl.State.normal)
|
|
|
- allSelectBtn.setTitleColor(k333333Color, for: UIControl.State.normal)
|
|
|
- allSelectBtn.setTitleColor(k666666Color, for: UIControl.State.selected)
|
|
|
- allSelectBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
|
|
|
- allSelectBtn.setImage(kImage(name: "common_check_icon"), for: UIControl.State.selected)
|
|
|
- allSelectBtn.titleLabel?.font = kScaleRegularFont16
|
|
|
- allSelectBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
- allSelectBtn.isSelected = !allSelectBtn.isSelected
|
|
|
- if let allSelectBlock = self?.allSelectBlock {
|
|
|
- let isAllSel: Int = allSelectBtn.isSelected == true ? 1 : 0
|
|
|
- allSelectBlock(isAllSel)
|
|
|
+ lazy var backButton: UIButton = {
|
|
|
+ let backButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ backButton.setImage(kImage(name: "video_btn_close_white"), for: UIControl.State.normal)
|
|
|
+ backButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let btnClickClosure = self?.btnClickClosure {
|
|
|
+ btnClickClosure(BtnActionType.back)
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
- return allSelectBtn
|
|
|
+ return backButton
|
|
|
}()
|
|
|
|
|
|
- private lazy var accountBtn: UIButton = {
|
|
|
- let accountBtn = UIButton(type: UIButton.ButtonType.custom)
|
|
|
- accountBtn.setTitle("结算(0)", for: UIControl.State.normal)
|
|
|
- accountBtn.titleLabel?.font = kScaleRegularFont15
|
|
|
- accountBtn.cornerRadius = 18
|
|
|
- accountBtn.masksToBounds = true
|
|
|
- accountBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
- if let orderPayBlock = self?.orderPayBlock {
|
|
|
- orderPayBlock()
|
|
|
+ // 放置"翻转、音乐、滤镜"のView
|
|
|
+ lazy var controlBackView: UIView = {
|
|
|
+ let controlBackView = UIView()
|
|
|
+ return controlBackView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var reverseButton: UIButton = {
|
|
|
+ let reverseButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ reverseButton.setImage(kImage(name: "video_ico_overturn"), for: UIControl.State.normal)
|
|
|
+ reverseButton.setTitle("翻转", for: UIControl.State.normal)
|
|
|
+ reverseButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
+ reverseButton.titleLabel?.font = kRegularFont12
|
|
|
+ reverseButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let btnClickClosure = self?.btnClickClosure {
|
|
|
+ btnClickClosure(BtnActionType.reverse)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return reverseButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var musicButton: UIButton = {
|
|
|
+ let musicButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ musicButton.setImage(kImage(name: "video_ico_music"), for: UIControl.State.normal)
|
|
|
+ musicButton.setTitle("音乐", for: UIControl.State.normal)
|
|
|
+ musicButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
+ musicButton.titleLabel?.font = kRegularFont12
|
|
|
+ musicButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let btnClickClosure = self?.btnClickClosure {
|
|
|
+ btnClickClosure(BtnActionType.music)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return musicButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var filterButton: UIButton = {
|
|
|
+ let filterButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ filterButton.setImage(kImage(name: "video_ico_filter"), for: UIControl.State.normal)
|
|
|
+ filterButton.setTitle("滤镜", for: UIControl.State.normal)
|
|
|
+ filterButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
+ filterButton.titleLabel?.font = kRegularFont12
|
|
|
+ filterButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let btnClickClosure = self?.btnClickClosure {
|
|
|
+ btnClickClosure(BtnActionType.filter)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return filterButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ // 放置"回删、确定"のView
|
|
|
+ lazy var selBackView: UIView = {
|
|
|
+ let selBackView = UIView()
|
|
|
+ return selBackView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var delButton: UIButton = {
|
|
|
+ let delButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ delButton.setImage(kImage(name: "video_btn_delete"), for: UIControl.State.normal)
|
|
|
+ delButton.setTitle("回删", for: UIControl.State.normal)
|
|
|
+ delButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
+ delButton.titleLabel?.font = kRegularFont12
|
|
|
+ delButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let btnClickClosure = self?.btnClickClosure {
|
|
|
+ btnClickClosure(BtnActionType.delete)
|
|
|
}
|
|
|
}).disposed(by: disposeBag)
|
|
|
- return accountBtn
|
|
|
+ return delButton
|
|
|
}()
|
|
|
|
|
|
- private lazy var priceLabel: UILabel = {
|
|
|
- let priceLabel = UILabel()
|
|
|
- priceLabel.textColor = kFE352BColor
|
|
|
- priceLabel.font = kScaleBoldFont18
|
|
|
- return priceLabel
|
|
|
+ private lazy var confirmButton: UIButton = {
|
|
|
+ let confirmButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ confirmButton.setImage(kImage(name: "video_btn_submit"), for: UIControl.State.normal)
|
|
|
+ confirmButton.setTitle("确定", for: UIControl.State.normal)
|
|
|
+ confirmButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
+ confirmButton.titleLabel?.font = kRegularFont12
|
|
|
+ confirmButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ if let btnClickClosure = self?.btnClickClosure {
|
|
|
+ btnClickClosure(BtnActionType.confirm)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return confirmButton
|
|
|
}()
|
|
|
|
|
|
- private lazy var prePriceLabel: UILabel = {
|
|
|
- let prePriceLabel = UILabel()
|
|
|
- prePriceLabel.text = "合计"
|
|
|
- prePriceLabel.textColor = k333333Color
|
|
|
- prePriceLabel.font = kScaleRegularFont16
|
|
|
- return prePriceLabel
|
|
|
+ // 录制のButton
|
|
|
+ private lazy var recordButton: UIButton = {
|
|
|
+ let recordButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ recordButton.setImage(kImage(name: "video_btn_shoot"), for: UIControl.State.normal)
|
|
|
+ recordButton.setImage(kImage(name: "video_btn_pause"), for: UIControl.State.selected)
|
|
|
+ recordButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ recordButton.isSelected = !recordButton.isSelected
|
|
|
+ if let videoClosure = self?.videoClosure {
|
|
|
+ let isRecording: Int = recordButton.isSelected == true ? 1 : 0
|
|
|
+ videoClosure(isRecording)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+
|
|
|
+ return recordButton
|
|
|
}()
|
|
|
|
|
|
+
|
|
|
// 预览View
|
|
|
lazy var previewView: UIView = {
|
|
|
let previewView = UIView()
|