|
@@ -0,0 +1,134 @@
|
|
|
+//
|
|
|
+// PublishVideoView.swift
|
|
|
+// RainbowPlanet
|
|
|
+//
|
|
|
+// Created by Christopher on 2019/6/19.
|
|
|
+// Copyright © 2019 RainbowPlanet. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+import UIKit
|
|
|
+import RxSwift
|
|
|
+import RxCocoa
|
|
|
+
|
|
|
+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
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var tPrice: Int? {
|
|
|
+ didSet {
|
|
|
+ priceLabel.text = priceConversion(price: tPrice ?? 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var tNumber: Int? {
|
|
|
+ didSet {
|
|
|
+ accountBtn.setTitle("结算(\(tNumber ?? 0))", for: UIControl.State.normal)
|
|
|
+ if tNumber == 0 {
|
|
|
+ accountBtn.backgroundColor = ke6e6e6Color
|
|
|
+ accountBtn.setTitleColor(k333333Color, for: UIControl.State.normal)
|
|
|
+ accountBtn.isEnabled = false
|
|
|
+ } else {
|
|
|
+ accountBtn.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
+ accountBtn.backgroundColor = kFFA42FColor
|
|
|
+ accountBtn.isEnabled = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupViews() {
|
|
|
+ self.backgroundColor = kffffffColor
|
|
|
+ addSubview(allSelectBtn)
|
|
|
+ addSubview(accountBtn)
|
|
|
+ addSubview(priceLabel)
|
|
|
+ addSubview(prePriceLabel)
|
|
|
+ }
|
|
|
+
|
|
|
+ override func setupLayouts() {
|
|
|
+ allSelectBtn.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalToSuperview().offset(10)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.height.equalTo(30)
|
|
|
+ make.width.equalTo(54)
|
|
|
+ }
|
|
|
+ allSelectBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 4)
|
|
|
+
|
|
|
+ accountBtn.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalToSuperview().offset(-14)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.width.equalTo(100)
|
|
|
+ make.height.equalTo(37)
|
|
|
+ }
|
|
|
+
|
|
|
+ priceLabel.snp.makeConstraints { (make) in
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.right.equalTo(accountBtn.snp_left).offset(-12)
|
|
|
+ make.height.equalTo(25)
|
|
|
+ }
|
|
|
+
|
|
|
+ prePriceLabel.snp.makeConstraints { (make) in
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.right.equalTo(priceLabel.snp_left).offset(-1)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return allSelectBtn
|
|
|
+ }()
|
|
|
+
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
+ return accountBtn
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var priceLabel: UILabel = {
|
|
|
+ let priceLabel = UILabel()
|
|
|
+ priceLabel.textColor = kFE352BColor
|
|
|
+ priceLabel.font = kScaleBoldFont18
|
|
|
+ return priceLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var prePriceLabel: UILabel = {
|
|
|
+ let prePriceLabel = UILabel()
|
|
|
+ prePriceLabel.text = "合计"
|
|
|
+ prePriceLabel.textColor = k333333Color
|
|
|
+ prePriceLabel.font = kScaleRegularFont16
|
|
|
+ return prePriceLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+}
|