Bläddra i källkod

Merge branch 'feature/publishNew' into develop

南鑫林 5 år sedan
förälder
incheckning
ab05bcf06a

+ 1 - 1
RainbowPlanet/Podfile

@@ -1,6 +1,6 @@
 #source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
 # Uncomment the next line to define a global platform for your project
- platform :ios, '9.0'
+ platform :ios, '10.0'
 
 target 'RainbowPlanet' do
   # Comment the next line if you're not using Swift and don't want to use dynamic frameworks

+ 21 - 5
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -148,6 +148,8 @@
 		A73A56DB22DC9AB5004920FE /* UpdateVersionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A73A56DA22DC9AB5004920FE /* UpdateVersionModel.swift */; };
 		A73A56DE22DC9CCE004920FE /* UpdateVersionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A73A56DD22DC9CCE004920FE /* UpdateVersionManager.swift */; };
 		A73D7C682268A032002A4CE3 /* SwiftyStarRatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A73D7C672268A032002A4CE3 /* SwiftyStarRatingView.swift */; };
+		A742C08C2325E8E40043184E /* PublishNewAuthorizationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A742C08B2325E8E40043184E /* PublishNewAuthorizationView.swift */; };
+		A742C0922325F7820043184E /* PublishNewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A742C0912325F7820043184E /* PublishNewViewModel.swift */; };
 		A743229422B88ED30017C367 /* EnumMacro.swift in Sources */ = {isa = PBXBuildFile; fileRef = A743229322B88ED30017C367 /* EnumMacro.swift */; };
 		A743229B22B8C1510017C367 /* AppStoreManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A743229A22B8C1510017C367 /* AppStoreManager.swift */; };
 		A74322A022B8D1F30017C367 /* MyFollowAndFanViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A743229F22B8D1F30017C367 /* MyFollowAndFanViewController.swift */; };
@@ -777,6 +779,8 @@
 		A73A56DA22DC9AB5004920FE /* UpdateVersionModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpdateVersionModel.swift; sourceTree = "<group>"; };
 		A73A56DD22DC9CCE004920FE /* UpdateVersionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateVersionManager.swift; sourceTree = "<group>"; };
 		A73D7C672268A032002A4CE3 /* SwiftyStarRatingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftyStarRatingView.swift; sourceTree = "<group>"; };
+		A742C08B2325E8E40043184E /* PublishNewAuthorizationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishNewAuthorizationView.swift; sourceTree = "<group>"; };
+		A742C0912325F7820043184E /* PublishNewViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishNewViewModel.swift; sourceTree = "<group>"; };
 		A743229322B88ED30017C367 /* EnumMacro.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnumMacro.swift; sourceTree = "<group>"; };
 		A743229A22B8C1510017C367 /* AppStoreManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppStoreManager.swift; sourceTree = "<group>"; };
 		A743229F22B8D1F30017C367 /* MyFollowAndFanViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyFollowAndFanViewController.swift; sourceTree = "<group>"; };
@@ -2186,6 +2190,14 @@
 			path = SwiftyStarRatingView;
 			sourceTree = "<group>";
 		};
+		A742C0902325F76A0043184E /* ViewModel */ = {
+			isa = PBXGroup;
+			children = (
+				A742C0912325F7820043184E /* PublishNewViewModel.swift */,
+			);
+			path = ViewModel;
+			sourceTree = "<group>";
+		};
 		A743229922B8C1440017C367 /* AppStoreManager */ = {
 			isa = PBXGroup;
 			children = (
@@ -2942,18 +2954,20 @@
 		A7811CCD2323D25A00C2D8DE /* PublishNew */ = {
 			isa = PBXGroup;
 			children = (
-				A7811CCE2323D25A00C2D8DE /* PublishNewVideoPhotoView */,
+				A742C0902325F76A0043184E /* ViewModel */,
+				A7811CCE2323D25A00C2D8DE /* View */,
 				A7811CD02323D25A00C2D8DE /* ViewController */,
 			);
 			path = PublishNew;
 			sourceTree = "<group>";
 		};
-		A7811CCE2323D25A00C2D8DE /* PublishNewVideoPhotoView */ = {
+		A7811CCE2323D25A00C2D8DE /* View */ = {
 			isa = PBXGroup;
 			children = (
 				A7811CCF2323D25A00C2D8DE /* PublishNewVideoPhotoView.swift */,
+				A742C08B2325E8E40043184E /* PublishNewAuthorizationView.swift */,
 			);
-			path = PublishNewVideoPhotoView;
+			path = View;
 			sourceTree = "<group>";
 		};
 		A7811CD02323D25A00C2D8DE /* ViewController */ = {
@@ -5434,6 +5448,7 @@
 				A7C0FDF322B65E5400BC1E86 /* FeaturedTopicsTableViewCell.swift in Sources */,
 				A770E61322D6625700CBD0A4 /* ShareCommunityViewCollectionViewCell.swift in Sources */,
 				A7F577D722FED3A100E2D757 /* PathManager.swift in Sources */,
+				A742C0922325F7820043184E /* PublishNewViewModel.swift in Sources */,
 				A7D77DEE22DDDDDB0048D5F6 /* RedemptionAreaViewModel.swift in Sources */,
 				A7824B042271F10300ABA381 /* EditSelfMentionContactsView.swift in Sources */,
 				A7811CCB2323A6D400C2D8DE /* YPDouYinLikeAnimation.m in Sources */,
@@ -5578,6 +5593,7 @@
 				A7BB68662269B1DD00AB07A2 /* AddressPOIView.swift in Sources */,
 				A7AA9F5D22C5FD710086498B /* VirueRecordAddParameterModel.swift in Sources */,
 				BD13B6C722BA034D008BB323 /* PublishEditAddTopicCell.swift in Sources */,
+				A742C08C2325E8E40043184E /* PublishNewAuthorizationView.swift in Sources */,
 				BD13B6DE22BA03BC008BB323 /* PublishTopicTypeItemCollectionCell.swift in Sources */,
 				A72A72C322321DE000B21995 /* Extension+Date.swift in Sources */,
 				BD0FAA4F22C474D400DDFB37 /* AliyunCoverPickViewController.m in Sources */,
@@ -5986,7 +6002,7 @@
 					"\"$(SRCROOT)/RainbowPlanet/Lib/AlipaySDK\"",
 				);
 				INFOPLIST_FILE = "$(SRCROOT)/RainbowPlanet/Supporting Files/Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",
 					"@executable_path/Frameworks",
@@ -6239,7 +6255,7 @@
 					"\"$(SRCROOT)/RainbowPlanet/Lib/AlipaySDK\"",
 				);
 				INFOPLIST_FILE = "$(SRCROOT)/RainbowPlanet/Supporting Files/Info.plist";
-				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",
 					"@executable_path/Frameworks",

+ 2 - 1
RainbowPlanet/RainbowPlanet/Base/BaseTabbarViewController/BaseTabbarViewController.swift

@@ -159,7 +159,8 @@ class BaseTabbarViewController: NSObject {
     /// 跳转到VC
     func pushPublishVC() {
         if BaseTabbarViewController.shared.v1.navigationBarbgView.isHidden {
-            let pickVc = PublishViewController()
+//            let pickVc = PublishViewController()
+            let  pickVc = PublishNewViewController()
             let nav = BaseNavigationViewController.init(rootViewController: pickVc)
             BaseTabbarViewController.shared.esTabBarController.present(nav, animated: true, completion: nil)
         } else {

+ 139 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/View/PublishNewAuthorizationView.swift

@@ -0,0 +1,139 @@
+//
+//  PublishNewAuthorizationView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/9/9.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class PublishNewAuthorizationView: BaseView {
+    
+    deinit {
+        NXLLog("deinit")
+    }
+    
+    override func setupViews() {
+        self.backgroundColor = UIColor.black
+        addSubview(backButton)
+        addSubview(titleLabel)
+        addSubview(cameraButton)
+        addSubview(microphoneButton)
+        addSubview(albumButton)
+    }
+    
+    override func setupLayouts() {
+        backButton.snp.makeConstraints { (make) in
+            make.top.equalTo(kSafeStatusBarHeight)
+            make.height.equalTo(44)
+            make.left.equalTo(14)
+        }
+        titleLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(backButton.snp.bottom).offset(164)
+            make.centerX.equalToSuperview()
+            
+        }
+        cameraButton.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel.snp.bottom).offset(40)
+            make.width.equalTo(200)
+            make.centerX.equalToSuperview()
+            make.height.equalTo(40)
+        }
+        microphoneButton.snp.makeConstraints { (make) in
+            make.top.equalTo(cameraButton.snp.bottom).offset(20)
+            make.width.equalTo(200)
+            make.centerX.equalToSuperview()
+            make.height.equalTo(40)
+        }
+        albumButton.snp.makeConstraints { (make) in
+            make.top.equalTo(microphoneButton.snp.bottom).offset(20)
+            make.width.equalTo(200)
+            make.centerX.equalToSuperview()
+            make.height.equalTo(40)
+        }
+    }
+    
+    override func setupData() {
+        
+        let vc = UIViewController.topMost
+        vc?.statusBarStyle = .lightContent
+        //返回
+        backButton.rx.tap.subscribe(onNext: { [weak vc] _ in
+             vc?.dismiss(animated: true, completion: nil)
+        }).disposed(by: disposeBag)
+        //跳转到相机权限
+        cameraButton.rx.tap.subscribe(onNext: { [weak vc] _ in
+            LBXPermissions.jumpToSystemPrivacySetting()
+            vc?.dismiss(animated: true, completion: nil)
+        }).disposed(by: disposeBag)
+        // 跳转到麦克风权限
+        microphoneButton.rx.tap.subscribe(onNext: { [weak vc] _ in
+            LBXPermissions.jumpToSystemPrivacySetting()
+            vc?.dismiss(animated: true, completion: nil)
+        }).disposed(by: disposeBag)
+        // 跳转到相册权限
+        albumButton.rx.tap.subscribe(onNext: { [weak vc] _ in
+            LBXPermissions.jumpToSystemPrivacySetting()
+            vc?.dismiss(animated: true, completion: nil)
+        }).disposed(by: disposeBag)
+    }
+    
+    
+    /// 返回
+    lazy var backButton: UIButton = {
+        let backButton = UIButton(type: UIButton.ButtonType.custom)
+        backButton.setImage(kImage(name: "navbar_back_white"), for: UIControl.State.normal)
+        return backButton
+    }()
+    
+    
+    /// 标题
+    lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.text = "允许启用权限即可进入视频发布"
+        titleLabel.textColor = UIColor.white
+        titleLabel.font = kMediumFont20
+        return titleLabel
+    }()
+    
+    /// 相机权限
+    lazy var cameraButton: UIButton = {
+        let cameraButton = UIButton(type: .custom)
+        cameraButton.setTitle("启用相机访问权限", for: UIControl.State.normal)
+        cameraButton.setTitleColor(kThemeColor, for: UIControl.State.normal)
+        cameraButton.titleLabel?.font = kRegularFont15
+        cameraButton.layer.borderColor = kThemeColor.cgColor
+        cameraButton.layer.borderWidth = 0.5
+        cameraButton.cornerRadius = 20
+        cameraButton.masksToBounds = true
+        return cameraButton
+    }()
+    
+    /// 麦克风权限
+    lazy var microphoneButton: UIButton = {
+        let microphoneButton = UIButton(type: .custom)
+        microphoneButton.setTitle("启用麦克风访问权限", for: UIControl.State.normal)
+        microphoneButton.setTitleColor(kThemeColor, for: UIControl.State.normal)
+        microphoneButton.titleLabel?.font = kRegularFont15
+        microphoneButton.layer.borderColor = kThemeColor.cgColor
+        microphoneButton.layer.borderWidth = 0.5
+        microphoneButton.cornerRadius = 20
+        microphoneButton.masksToBounds = true
+        return microphoneButton
+    }()
+    
+    /// 相册权限权限
+    lazy var albumButton: UIButton = {
+        let albumButton = UIButton(type: .custom)
+        albumButton.setTitle("启用相册访问权限", for: UIControl.State.normal)
+        albumButton.setTitleColor(kThemeColor, for: UIControl.State.normal)
+        albumButton.titleLabel?.font = kRegularFont15
+        albumButton.layer.borderColor = kThemeColor.cgColor
+        albumButton.layer.borderWidth = 0.5
+        albumButton.cornerRadius = 20
+        albumButton.masksToBounds = true
+        return albumButton
+    }()
+
+}

+ 20 - 8
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/PublishNewVideoPhotoView/PublishNewVideoPhotoView.swift

@@ -10,26 +10,28 @@ import UIKit
 
 class PublishNewVideoPhotoView: BaseView {
     
+    deinit {
+        NXLLog("deinit")
+    }
     
     override func setupViews() {
-        
+        // 预览视图,必须设置
     }
     
     override func setupData() {
         /// 开始预览
-        recorder.startPreview()
+        recorder?.startPreview()
         /// 开始预览前置/后置摄像头
-        recorder.startPreview(withPositon: AliyunIRecorderCameraPosition.back)
+//        recorder.startPreview(withPositon: AliyunIRecorderCameraPosition.back)
+        /// 停止预览
+        recorder?.stopPreview()
     }
     
     // SDK录制类
-    private lazy var recorder: AliyunIRecorder = {
-        
+    lazy var recorder: AliyunIRecorder? = {
         let recorder = AliyunIRecorder.init(delegate: self, videoSize: CGSize(width: 720, height: 1280))
-        
-        // 预览视图,必须设置
         recorder?.preview = self
-        
+
         /*
          视频的输出路径
          注意:若上一次录制的 outputPath 路径的视频存在沙盒里没有删除,并且与本次录制的视频路径且相同重名的话,录制将会失败
@@ -64,6 +66,12 @@ class PublishNewVideoPhotoView: BaseView {
         return recorder!
     }()
     
+    /// 显示授权View
+    func showAuthorizationView() {
+        PublishNewViewModel.shared.scrollView?.isHidden = true
+        PublishNewViewModel.shared.publishNewAuthorizationView?.isHidden = false
+    }
+    
 
 }
 
@@ -75,12 +83,16 @@ extension PublishNewVideoPhotoView : AliyunIRecorderDelegate {
             break
         // 音频授权被拒绝
         case .audioDenied:
+            showAuthorizationView()
             break
         // 视频授权被拒绝
         case .videoDenied:
+            showAuthorizationView()
             break
         default:
             break
         }
     }
+    
+    
 }

+ 42 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/ViewController/PublishNewViewController.swift

@@ -20,18 +20,32 @@ class PublishNewViewController: BaseViewController {
     
     deinit {
         NXLLog("deinit")
+        if publishNewVideoPhotoView.recorder != nil {
+            publishNewVideoPhotoView.recorder?.stopPreview()
+            publishNewVideoPhotoView.recorder?.destroy()
+            publishNewVideoPhotoView.recorder = nil
+        }
     }
+    
+    
+    /// viewModel
+    var publishNewViewModel: PublishNewViewModel?
+
 
     override func viewDidLoad() {
         super.viewDidLoad()
+        setupData()
         setupViews()
         setupLayouts()
     }
     
     override func setupViews() {
+        navigationBar.isHidden = true
         view.addSubview(scrollView)
         scrollView.addSubview(publishNewVideoPhotoView)
         view.addSubview(segmentedView)
+        view.addSubview(publishNewAuthorizationView)
+
     }
     override func setupLayouts() {
         segmentedView.snp.makeConstraints { (make) in
@@ -40,8 +54,27 @@ class PublishNewViewController: BaseViewController {
             make.right.equalTo(0)
             make.bottom.equalTo(-kSafeTabBarHeight)
         }
+        
+        publishNewAuthorizationView.snp.makeConstraints { (make) in
+            make.edges.equalToSuperview()
+        }
     }
     
+    override func setupData() {
+        
+        /// viewModel
+        publishNewViewModel = PublishNewViewModel.shared
+        publishNewViewModel?.scrollView = scrollView
+        publishNewViewModel?.publishNewAuthorizationView = publishNewAuthorizationView
+        
+    }
+    /// 授权View
+    private lazy var publishNewAuthorizationView: PublishNewAuthorizationView = {
+        let publishNewAuthorizationView = PublishNewAuthorizationView()
+        publishNewAuthorizationView.isHidden = true
+        return publishNewAuthorizationView
+    }()
+    
     //滚动的View
     private lazy var scrollView: UIScrollView = {
         let scrollView = UIScrollView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight))
@@ -51,6 +84,7 @@ class PublishNewViewController: BaseViewController {
         scrollView.showsVerticalScrollIndicator = false
         scrollView.scrollsToTop = false
         scrollView.isScrollEnabled = false
+        scrollView.isHidden = false
         return scrollView
     }()
     
@@ -58,6 +92,7 @@ class PublishNewViewController: BaseViewController {
     private lazy var publishNewVideoPhotoView: PublishNewVideoPhotoView = {
         let publishNewVideoPhotoView = PublishNewVideoPhotoView(frame: CGRect(x: kScreenWidth, y: 0, width: kScreenWidth, height: kScreenHeight))
         publishNewVideoPhotoView.backgroundColor = UIColor.black
+
         return publishNewVideoPhotoView
     }()
     
@@ -87,7 +122,6 @@ class PublishNewViewController: BaseViewController {
         segmentedDataSource.isTitleStrokeWidthEnabled = true
         //reloadData(selectedIndex:)方法一定要调用,方法内部会刷新数据源数组
         segmentedDataSource.reloadData(selectedIndex: 0)
-        
         return segmentedDataSource
     }()
     
@@ -129,17 +163,24 @@ extension PublishNewViewController : JXSegmentedViewDelegate {
             segmentedDataSourceAlbum.reloadData(selectedIndex: 0)
             segmentedView.dataSource = segmentedDataSourceAlbum
             statusBarStyle = .default
+            //停止预览摄像头
+            publishNewVideoPhotoView.recorder?.stopPreview()
         case 1:
             scrollView.setContentOffset(CGPoint(x: kScreenWidth, y:0), animated: true)
             segmentedDataSourceVideoPhoto.reloadData(selectedIndex: 1)
             segmentedView.dataSource = segmentedDataSourceVideoPhoto
             statusBarStyle = .lightContent
+            //开始预览摄像头
+            publishNewVideoPhotoView.recorder?.startPreview()
 
         case 2:
             scrollView.setContentOffset(CGPoint(x: kScreenWidth, y:0), animated: true)
             segmentedDataSourceVideoPhoto.reloadData(selectedIndex: 2)
             segmentedView.dataSource = segmentedDataSourceVideoPhoto
             statusBarStyle = .lightContent
+            //开始预览摄像头
+            publishNewVideoPhotoView.recorder?.startPreview()
+
         default:
             break
         }

+ 28 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/ViewModel/PublishNewViewModel.swift

@@ -0,0 +1,28 @@
+//
+//  PublishNewViewModel.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/9/9.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class PublishNewViewModel: NSObject {
+    
+    deinit {
+        NXLLog("deinit")
+    }
+    
+    
+    /// 单利类
+    static let shared : PublishNewViewModel = PublishNewViewModel()
+    
+    /// 底层View
+    weak var scrollView : UIScrollView?
+    
+    /// 授权View
+    weak var publishNewAuthorizationView : PublishNewAuthorizationView?
+    
+    
+}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/CommunityModule.xcassets/activity.imageset/activity@2x.png


+ 2 - 2
RainbowPlanet/RainbowPlanet/Supporting Files/Info.plist

@@ -210,7 +210,7 @@
 	<key>NSCalendarsUsageDescription</key>
 	<string>App需要您的同意,才能访问日历</string>
 	<key>NSCameraUsageDescription</key>
-	<string>App需要您的同意,才能访问相</string>
+	<string>App需要您的同意,才能访问相</string>
 	<key>NSContactsUsageDescription</key>
 	<string>App需要您的同意,才能访问通信录</string>
 	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
@@ -226,7 +226,7 @@
 	<key>NSPhotoLibraryAddUsageDescription</key>
 	<string>App需要您的同意,才能保存图像和视频到您的相册</string>
 	<key>NSPhotoLibraryUsageDescription</key>
-	<string>App需要您的同意,才能访问相</string>
+	<string>App需要您的同意,才能访问相</string>
 	<key>UIBackgroundModes</key>
 	<array>
 		<string>fetch</string>