Browse Source

拍照流程pass

Chris 5 years ago
parent
commit
0eb765c789

+ 4 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -488,6 +488,7 @@
 		BDAA40FB228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40FA228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift */; };
 		BDAA40FD228E9CD600CF841D /* OrderApplyRefundPhoneCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40FC228E9CD600CF841D /* OrderApplyRefundPhoneCell.swift */; };
 		BDAA40FF228EA37900CF841D /* OrderApplyRefundPhotoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40FE228EA37900CF841D /* OrderApplyRefundPhotoCell.swift */; };
+		BDACE21122BB5AA300109AAD /* PublishConfirmPhotoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDACE21022BB5AA300109AAD /* PublishConfirmPhotoController.swift */; };
 		BDAF83A222B330540004BCC3 /* RecommendSimilarCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAF83A122B330540004BCC3 /* RecommendSimilarCell.swift */; };
 		BDAF83A622B334D90004BCC3 /* SearchContentListCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAF83A522B334D90004BCC3 /* SearchContentListCollectionCell.swift */; };
 		BDAF83A822B343C50004BCC3 /* RecommendBottomCommentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAF83A722B343C50004BCC3 /* RecommendBottomCommentView.swift */; };
@@ -1048,6 +1049,7 @@
 		BDAA40FA228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundNoteInfoCell.swift; sourceTree = "<group>"; };
 		BDAA40FC228E9CD600CF841D /* OrderApplyRefundPhoneCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundPhoneCell.swift; sourceTree = "<group>"; };
 		BDAA40FE228EA37900CF841D /* OrderApplyRefundPhotoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundPhotoCell.swift; sourceTree = "<group>"; };
+		BDACE21022BB5AA300109AAD /* PublishConfirmPhotoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishConfirmPhotoController.swift; sourceTree = "<group>"; };
 		BDAF83A122B330540004BCC3 /* RecommendSimilarCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSimilarCell.swift; sourceTree = "<group>"; };
 		BDAF83A522B334D90004BCC3 /* SearchContentListCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchContentListCollectionCell.swift; sourceTree = "<group>"; };
 		BDAF83A722B343C50004BCC3 /* RecommendBottomCommentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendBottomCommentView.swift; sourceTree = "<group>"; };
@@ -4274,6 +4276,7 @@
 			isa = PBXGroup;
 			children = (
 				BD929CD522B906D10098C139 /* PublishTakePhotoController.swift */,
+				BDACE21022BB5AA300109AAD /* PublishConfirmPhotoController.swift */,
 			);
 			path = PublishTakePhoto;
 			sourceTree = "<group>";
@@ -4575,6 +4578,7 @@
 				A7931E0D22AF874600297D0A /* GenderSelectionViewController.swift in Sources */,
 				A7C0FDF522B65FE000BC1E86 /* FeaturedTopicsCollectionViewCell.swift in Sources */,
 				A7F2D6D022B1119A0093000B /* CommunityEnum.swift in Sources */,
+				BDACE21122BB5AA300109AAD /* PublishConfirmPhotoController.swift in Sources */,
 				A7BB6857226965C100AB07A2 /* SelfRecommendationHeaderCollectionReusableView.swift in Sources */,
 				BDE3045F228554CA001D050F /* ProductCartAmountModel.swift in Sources */,
 				A7BB68672269B1DD00AB07A2 /* AddressPOIViewController.swift in Sources */,

+ 90 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishTakePhoto/PublishConfirmPhotoController.swift

@@ -0,0 +1,90 @@
+//
+//  PublishConfirmPhotoController.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/20.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import RxSwift
+import Photos
+
+class PublishConfirmPhotoController: BaseViewController {
+    
+    var photoImg: UIImage? {
+        didSet {
+            photoImageView.image = self.photoImg
+        }
+    }
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        setupViews()
+        setupLayouts()
+    }
+    
+    override func setupViews() {
+        navigationBar.isHidden = true
+        
+        view.addSubview(photoImageView)
+        view.addSubview(retakeBtn)
+        view.addSubview(usePhotoBtn)
+    }
+    
+    override func setupLayouts() {        
+        photoImageView.snp.makeConstraints { (make) in
+            make.top.left.right.equalToSuperview()
+            make.bottom.equalTo(-kSafeTabBarHeight)
+        }
+        retakeBtn.snp.makeConstraints { (make) in
+            make.left.equalTo(photoImageView.snp_left)
+            make.bottom.equalTo(photoImageView.snp_bottom)
+            make.width.equalTo(125)
+            make.height.equalTo(48)
+        }
+        usePhotoBtn.snp.makeConstraints { (make) in
+            make.right.equalTo(photoImageView.snp_right)
+            make.bottom.equalTo(photoImageView.snp_bottom)
+            make.width.equalTo(125)
+            make.height.equalTo(48)
+        }
+    }
+    
+    private lazy var photoImageView: UIImageView = {
+        let photoImageView = UIImageView()
+        return photoImageView
+    }()
+    
+    private lazy var retakeBtn: UIButton = {
+        let retakeBtn = UIButton(type: UIButton.ButtonType.custom)
+        retakeBtn.setTitle("重拍", for: .normal)
+        retakeBtn.setTitleColor(kffffffColor, for: .normal)
+        retakeBtn.titleLabel?.font = kMediumFont15
+        retakeBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            self?.dismiss(animated: true, completion: nil)
+        }).disposed(by: disposeBag)
+        return retakeBtn
+    }()
+    
+    private lazy var usePhotoBtn: UIButton = {
+        let usePhotoBtn = UIButton(type: UIButton.ButtonType.custom)
+        usePhotoBtn.setTitle("使用照片", for: .normal)
+        usePhotoBtn.setTitleColor(kffffffColor, for: .normal)
+        usePhotoBtn.titleLabel?.font = kMediumFont15
+        usePhotoBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            PHPhotoLibrary.shared().performChanges({
+                
+                _ = PHAssetChangeRequest.creationRequestForAsset(from: self!.photoImg!)}, completionHandler: { (success, error) in
+                    if success != true{
+                        SwiftProgressHUD.shared().showText("保存失败")
+                        return
+                    }
+                    print("保存成功")
+            })
+            
+        }).disposed(by: disposeBag)
+        return usePhotoBtn
+    }()
+    
+}

+ 7 - 8
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishTakePhoto/PublishTakePhotoController.swift

@@ -30,16 +30,14 @@ class PublishTakePhotoController: BaseViewController {
         setupLayouts()
     }
     
-    override func viewWillAppear(_ animated: Bool) {
-        navigationBar.isHidden = true
-    }
-    
-    override func viewWillDisappear(_ animated: Bool) {
-        navigationBar.isHidden = false
+    deinit {
+        // 控制器销毁时,销毁recorder
         recorder.destroy()
     }
     
     override func setupViews() {
+        navigationBar.isHidden = true
+        
         view.addSubview(backButton)
         view.addSubview(reverseButton)
         view.addSubview(flashButton)
@@ -146,8 +144,9 @@ class PublishTakePhotoController: BaseViewController {
         photoButton.setImage(kImage(name: "video_btn_shoot"), for: UIControl.State.normal)
         photoButton.rx.tap.subscribe(onNext: { [weak self] (data) in
             self?.recorder.takePhoto({ (image, rawImage) in
-                print("----\n")
-                print(image as Any)
+                let confirmVc = PublishConfirmPhotoController()
+                confirmVc.photoImg = image
+                self?.present(confirmVc, animated: true, completion: nil)
             })
         }).disposed(by: disposeBag)
         return photoButton