浏览代码

video/photo 底框架

Chris 5 年之前
父节点
当前提交
708d3ca304

+ 13 - 1
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -445,6 +445,7 @@
 		BD1DC6C9228D005000B89C57 /* OrderCreateParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */; };
 		BD1DC6CB228D157000B89C57 /* OrderCreateBackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6CA228D157000B89C57 /* OrderCreateBackModel.swift */; };
 		BD1DC6CD228D160D00B89C57 /* OrderPurchaseModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6CC228D160D00B89C57 /* OrderPurchaseModel.swift */; };
+		BD1EF11722BA637D0052D87A /* PublishVideoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1EF11622BA637D0052D87A /* PublishVideoView.swift */; };
 		BD1FC17F22B08D3C00D55081 /* CommunityMyFollowTopicController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1FC17E22B08D3C00D55081 /* CommunityMyFollowTopicController.swift */; };
 		BD1FC18122B08D7A00D55081 /* CommunityMyFollowTopicCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1FC18022B08D7A00D55081 /* CommunityMyFollowTopicCell.swift */; };
 		BD1FC18622B09F9800D55081 /* CommunitySubCommentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1FC18522B09F9800D55081 /* CommunitySubCommentController.swift */; };
@@ -997,6 +998,7 @@
 		BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCreateParameterModel.swift; sourceTree = "<group>"; };
 		BD1DC6CA228D157000B89C57 /* OrderCreateBackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCreateBackModel.swift; sourceTree = "<group>"; };
 		BD1DC6CC228D160D00B89C57 /* OrderPurchaseModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderPurchaseModel.swift; sourceTree = "<group>"; };
+		BD1EF11622BA637D0052D87A /* PublishVideoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishVideoView.swift; sourceTree = "<group>"; };
 		BD1FC17E22B08D3C00D55081 /* CommunityMyFollowTopicController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityMyFollowTopicController.swift; sourceTree = "<group>"; };
 		BD1FC18022B08D7A00D55081 /* CommunityMyFollowTopicCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityMyFollowTopicCell.swift; sourceTree = "<group>"; };
 		BD1FC18522B09F9800D55081 /* CommunitySubCommentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunitySubCommentController.swift; sourceTree = "<group>"; };
@@ -3780,7 +3782,8 @@
 			children = (
 				BD929CCD22B904A30098C139 /* PublishViewController.swift */,
 				BD929CD322B906C10098C139 /* PublishVideoRecorderController.swift */,
-				BD929CD522B906D10098C139 /* PublishTakePhotoController.swift */,
+				BD1EF11622BA637D0052D87A /* PublishVideoView.swift */,
+				BDFE396C22BB224E0074F203 /* PublishTakePhoto */,
 				BD12B67222B4E99800AEB10B /* PublishMediaPicker */,
 				BD13B69F22B9CE8D008BB323 /* PublishEditController */,
 				BD13B6CF22BA03BB008BB323 /* PublishAddTopic */,
@@ -4267,6 +4270,14 @@
 			path = View;
 			sourceTree = "<group>";
 		};
+		BDFE396C22BB224E0074F203 /* PublishTakePhoto */ = {
+			isa = PBXGroup;
+			children = (
+				BD929CD522B906D10098C139 /* PublishTakePhotoController.swift */,
+			);
+			path = PublishTakePhoto;
+			sourceTree = "<group>";
+		};
 		FA8AAFBADE8BD144A5C36FDB /* Frameworks */ = {
 			isa = PBXGroup;
 			children = (
@@ -4668,6 +4679,7 @@
 				A754150F224CACF9002480B5 /* SwiftSign.swift in Sources */,
 				A71AF0BA226F00F8001730FE /* SearchResultView.swift in Sources */,
 				A77F2CB52232010F001BD3F6 /* ShoppingMallViewController.swift in Sources */,
+				BD1EF11722BA637D0052D87A /* PublishVideoView.swift in Sources */,
 				A7D07CD622B78BC300186014 /* PersonViewUserAndOtherListCollectionViewCell.swift in Sources */,
 				A71AA513227215B5008FF1A5 /* ExpressAddressListView.swift in Sources */,
 				A7B4E723228154750012914A /* ProductFloorBannerView.swift in Sources */,

+ 20 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishTakePhotoController.swift

@@ -9,6 +9,7 @@
 import UIKit
 import RxSwift
 import JXSegmentedView
+import AliyunVideoSDKPro
 
 class PublishTakePhotoController: BaseViewController {
     
@@ -23,19 +24,37 @@ class PublishTakePhotoController: BaseViewController {
     
     override func viewWillDisappear(_ animated: Bool) {
         navigationBar.isHidden = false
+        recorder.destroy()
         
     }
-    
     override func setupViews() {
         
         
     }
     
+    private lazy var recorder: AliyunIRecorder = {
+        
+        
+        let recorder = AliyunIRecorder.init(delegate: self as? AliyunIRecorderDelegate, videoSize: CGSize(width: 720, height: 1280))
+        
+        // 预览视图,必须设置
+        recorder?.preview = self.view;
+        
+        
+        return recorder!
+    }()
+    
 }
 
 extension PublishTakePhotoController : JXSegmentedListContainerViewListDelegate {
     func listView() -> UIView {
         return view
     }
+    func listDidAppear() {
+        recorder.startPreview()
+    }
+    func listDidDisappear() {
+        recorder.stopPreview()
+    }
 }
 

+ 46 - 3
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishVideoRecorderController.swift

@@ -15,8 +15,10 @@ class PublishVideoRecorderController: BaseViewController {
     override func viewDidLoad() {
         super.viewDidLoad()
         
+        setupViews()
+        setupLayouts()
+        
         
-        recorder.startPreview()
         
 //        recorder.takePhoto(<#T##handler: ((UIImage?, UIImage?) -> Void)!##((UIImage?, UIImage?) -> Void)!##(UIImage?, UIImage?) -> Void#>)
 //        recorder.startRecording()
@@ -31,11 +33,40 @@ class PublishVideoRecorderController: BaseViewController {
     
     override func viewWillDisappear(_ animated: Bool) {
         navigationBar.isHidden = false
-        
-        recorder.stopPreview()
         recorder.destroy()
     }
     
+    override func setupViews() {
+        view.addSubview(prePriceLabel)
+        view.addSubview(tstView)
+        
+    }
+    
+    override func setupLayouts() {
+        
+        prePriceLabel.snp.makeConstraints { (make) in
+            make.bottom.equalTo(-40)
+            make.centerX.equalToSuperview()
+            make.size.equalTo(80)
+        }
+        tstView.snp.makeConstraints { (make) in
+            make.bottom.equalTo(-80)
+            make.centerX.equalToSuperview()
+            make.width.equalTo(320)
+            make.height.equalTo(100)
+        }
+        
+    }
+    
+    private lazy var prePriceLabel: UILabel = {
+        let prePriceLabel = UILabel()
+        prePriceLabel.text = "合计"
+        prePriceLabel.textColor = k333333Color
+        prePriceLabel.font = kScaleRegularFont16
+        prePriceLabel.backgroundColor = UIColor.yellow
+        return prePriceLabel
+    }()
+    
     
     private lazy var recorder: AliyunIRecorder = {
         //清除之前生成的录制路径
@@ -88,6 +119,12 @@ class PublishVideoRecorderController: BaseViewController {
         return recorder!
     }()
     
+    lazy var tstView: PublishVideoView = {
+        let tstView = PublishVideoView()
+        tstView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight-40)
+        return tstView
+    }()
+    
     //    func recordButtonTouchesBegin {
     //    // 点击录制button开始录制
     //    [self.recorder startRecording];
@@ -114,4 +151,10 @@ extension PublishVideoRecorderController : JXSegmentedListContainerViewListDeleg
     func listView() -> UIView {
         return view
     }
+    func listDidAppear() {
+        recorder.startPreview()
+    }
+    func listDidDisappear() {
+        recorder.stopPreview()        
+    }
 }

+ 134 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishVideoView.swift

@@ -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
+    }()
+    
+}