Browse Source

简化media picker

Chris 5 years ago
parent
commit
efc1950b27
19 changed files with 30 additions and 114 deletions
  1. 3 7
      RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj
  2. 13 8
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/Controller/KSMediaPickerController.swift
  3. 1 23
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSExtension.swift
  4. 0 22
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSMediaPicker.strings
  5. 2 2
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerNavigationView.swift
  6. 0 5
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerPreviewView.swift
  7. 1 1
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerViewImageCell.swift
  8. 0 0
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSVideoPlayerView/KSVideoLayer.h
  9. 0 0
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSVideoPlayerView/KSVideoLayer.m
  10. 0 0
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSVideoPlayerView/KSVideoPlayerBaseView.h
  11. 0 0
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSVideoPlayerView/KSVideoPlayerBaseView.m
  12. 6 2
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishVideoRecorderController.swift
  13. 4 0
      RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishViewController.swift
  14. 0 22
      RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close.imageset/Contents.json
  15. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close.imageset/icon_mediaPicker_camera_close@2x.png
  16. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close.imageset/icon_mediaPicker_camera_close@3x.png
  17. 0 22
      RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close_b.imageset/Contents.json
  18. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close_b.imageset/icon_mediaPicker_camera_close_b@2x.png
  19. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close_b.imageset/icon_mediaPicker_camera_close_b@3x.png

+ 3 - 7
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -456,7 +456,6 @@
 		BD20F1D32283D0ED00677D8E /* OrderFinishPaySuccessCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD20F1D22283D0ED00677D8E /* OrderFinishPaySuccessCell.swift */; };
 		BD20F1D52283D15500677D8E /* OrderFinishPayFailureCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD20F1D42283D15500677D8E /* OrderFinishPayFailureCell.swift */; };
 		BD24FABB22B509CF00C7AA3B /* PublishModule.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BD24FABA22B509CF00C7AA3B /* PublishModule.xcassets */; };
-		BD24FABF22B50C4B00C7AA3B /* KSMediaPicker.strings in Resources */ = {isa = PBXBuildFile; fileRef = BD24FABE22B50C4B00C7AA3B /* KSMediaPicker.strings */; };
 		BD29A92E228F99780018CFC3 /* OrderCommentParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD29A92D228F99780018CFC3 /* OrderCommentParameterModel.swift */; };
 		BD2FCBE222B21CF70006D974 /* CommunityRecommendController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD2FCBE122B21CF70006D974 /* CommunityRecommendController.swift */; };
 		BD2FCBE422B244250006D974 /* RecommendDetailContentCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD2FCBE322B244250006D974 /* RecommendDetailContentCell.swift */; };
@@ -1009,7 +1008,6 @@
 		BD20F1D22283D0ED00677D8E /* OrderFinishPaySuccessCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderFinishPaySuccessCell.swift; sourceTree = "<group>"; };
 		BD20F1D42283D15500677D8E /* OrderFinishPayFailureCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderFinishPayFailureCell.swift; sourceTree = "<group>"; };
 		BD24FABA22B509CF00C7AA3B /* PublishModule.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = PublishModule.xcassets; sourceTree = "<group>"; };
-		BD24FABE22B50C4B00C7AA3B /* KSMediaPicker.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = KSMediaPicker.strings; sourceTree = "<group>"; };
 		BD29A92D228F99780018CFC3 /* OrderCommentParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCommentParameterModel.swift; sourceTree = "<group>"; };
 		BD2FCBE122B21CF70006D974 /* CommunityRecommendController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityRecommendController.swift; sourceTree = "<group>"; };
 		BD2FCBE322B244250006D974 /* RecommendDetailContentCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendDetailContentCell.swift; sourceTree = "<group>"; };
@@ -3691,9 +3689,7 @@
 		BD12B67222B4E99800AEB10B /* PublishMediaPicker */ = {
 			isa = PBXGroup;
 			children = (
-				BD12B6A422B502C200AEB10B /* KSVideoPlayerView */,
 				BD12B68722B4F28F00AEB10B /* KSExtension.swift */,
-				BD24FABE22B50C4B00C7AA3B /* KSMediaPicker.strings */,
 				BD12B67522B4ECE200AEB10B /* Controller */,
 				BD12B67622B4ED8800AEB10B /* Model */,
 				BD12B67922B4EE1A00AEB10B /* View */,
@@ -3722,12 +3718,13 @@
 		BD12B67922B4EE1A00AEB10B /* View */ = {
 			isa = PBXGroup;
 			children = (
+				BD12B6A422B502C200AEB10B /* KSVideoPlayerView */,
+				BD12B68222B4EFF000AEB10B /* KSMediaPickerView.swift */,
+				BD12B69D22B4FAF000AEB10B /* KSMediaPickerNavigationView.swift */,
 				BD12B69222B4F68400AEB10B /* KSMediaPickerCollectionView.h */,
 				BD12B69322B4F68400AEB10B /* KSMediaPickerCollectionView.m */,
-				BD12B69D22B4FAF000AEB10B /* KSMediaPickerNavigationView.swift */,
 				BD12B69522B4F72900AEB10B /* KSMediaPickerPreviewView.swift */,
 				BD12B69922B4FA8400AEB10B /* KSMediaPickerSelectIndicator.swift */,
-				BD12B68222B4EFF000AEB10B /* KSMediaPickerView.swift */,
 				BD12B67E22B4EF2600AEB10B /* KSMediaPickerViewImageCell.swift */,
 				BD12B67F22B4EF2600AEB10B /* KSMediaPickerViewVideoCell.swift */,
 			);
@@ -4308,7 +4305,6 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				BD24FABF22B50C4B00C7AA3B /* KSMediaPicker.strings in Resources */,
 				A7CC74DE22703B4A003C4F38 /* MineModule.xcassets in Resources */,
 				A7BF202422B392D600396DB3 /* CommunityModule.xcassets in Resources */,
 				A71AF0BE226F1792001730FE /* ShoppingMallModule.xcassets in Resources */,

+ 13 - 8
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/Controller/KSMediaPickerController.swift

@@ -25,6 +25,9 @@ import JXSegmentedView
 
 open class KSMediaPickerController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
     
+    typealias DismissClosure = () -> Void
+    var dismissClosure: DismissClosure?
+    
     @objc public enum mediaType : Int {
         case all        = 0
         case picture    = 1
@@ -150,7 +153,9 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
     }
     
     @objc private func _didClick(closeButton: UIButton?) {
-        self.dismiss(animated: true, completion: nil)
+        if let dismissClosure = self.dismissClosure {
+            dismissClosure()
+        }        
     }
     
     @objc private func _didClick(nextButton: UIButton) {
@@ -428,7 +433,7 @@ extension KSMediaPickerController {
                     completionHandler(type)
                     break
                 case .denied:
-                    authorityAlert(controller: controller, name: "IMAGE_PICKER_PHOTOS".ks_mediaPickerKeyToLocalized, cancelHandler: cancelHandler)
+                    authorityAlert(controller: controller, name: "照片", cancelHandler: cancelHandler)
                     break
                 default:
                     break
@@ -446,7 +451,7 @@ extension KSMediaPickerController {
                 if granted {
                     completionHandler(type)
                 } else {
-                    authorityAlert(controller: controller, name: "IMAGE_PICKER_CAMERA".ks_mediaPickerKeyToLocalized, cancelHandler: cancelHandler)
+                    authorityAlert(controller: controller, name: "照相机", cancelHandler: cancelHandler)
                 }
             }
             let mediaType = AVMediaType.video
@@ -465,10 +470,10 @@ extension KSMediaPickerController {
     open class func authorityAlert(controller: UIViewController, name: String, cancelHandler: ((UIAlertAction) -> Void)?) {
         let bundle = Bundle.main
         let appName = NSLocalizedString("CFBundleDisplayName", tableName: "InfoPlist", bundle: bundle, comment: "")
-        let title = String(format: "IMAGE_PICKER_NONAUTHORITY_TITLE_FORMAT".ks_mediaPickerKeyToLocalized(in: bundle), name)
-        let message = String(format: "IMAGE_PICKER_NONAUTHORITY_TIP_FORMAT".ks_mediaPickerKeyToLocalized(in: bundle), appName, name)
+        let title = "没有打开“\(appName)”访问权限"        
+        let message = "请进入“设置”-“\(appName)”打开\(appName)开关"
         let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
-        let go = UIAlertAction(title: "IMAGE_PICKER_NONAUTHORITY_GO_SETTING".ks_mediaPickerKeyToLocalized(in: bundle), style: .default) { (action) in
+        let go = UIAlertAction(title: "去设置", style: .default) { (action) in
             let application = UIApplication.shared
             let url = URL(string: UIApplication.openSettingsURLString)!
             if application.canOpenURL(url) {
@@ -483,7 +488,7 @@ extension KSMediaPickerController {
             }
         }
         alert.addAction(go)
-        let cancel = UIAlertAction(title: "CANCEL".ks_mediaPickerKeyToLocalized(in: bundle), style: .cancel, handler: cancelHandler)
+        let cancel = UIAlertAction(title: "取消", style: .cancel, handler: cancelHandler)
         alert.addAction(cancel)
         controller.present(alert, animated: true, completion: nil)
     }
@@ -493,7 +498,7 @@ extension KSMediaPickerController {
             if granted {
                 completionHandler()
             } else {
-                authorityAlert(controller: controller, name: "IMAGE_PICKER_MICROPHONE".ks_mediaPickerKeyToLocalized, cancelHandler: cancelHandler)
+                authorityAlert(controller: controller, name: "麦克风", cancelHandler: cancelHandler)
             }
         }
         let mediaType = AVMediaType.audio

+ 1 - 23
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSExtension.swift

@@ -8,26 +8,6 @@
 
 import UIKit
 
-extension String {
-
-    public var ks_KeyToLocalized: String {
-        return ks_KeyToLocalized(in: Bundle.main)
-    }
-    
-    public var ks_mediaPickerKeyToLocalized: String {
-        return ks_mediaPickerKeyToLocalized(in: Bundle.main)
-    }
-    
-    public func ks_mediaPickerKeyToLocalized(in bundle: Bundle, table: String? = "KSMediaPicker") -> String {
-        return ks_KeyToLocalized(in: bundle, table: table)
-    }
-    
-    public func ks_KeyToLocalized(in bundle: Bundle, table: String? = nil) -> String {
-        return bundle.localizedString(forKey: self, value: nil, table: table)
-    }
-    
-}
-
 extension UIEdgeInsets {
     
     static public let safeAreaInsets = {() -> UIEdgeInsets in
@@ -174,9 +154,7 @@ extension UIColor {
     public static let ks_wordMain = UIColor(red: 44/255.0, green: 41/255.0, blue: 84/255.0, alpha: 1)
     public static let ks_wordMain_2 = UIColor(red: 44/255.0, green: 41/255.0, blue: 84/255.0, alpha: 0.5)
     public static let ks_background = UIColor(red: 248/255.0, green: 248/255.0, blue: 248/255.0, alpha: 1)
-    public static let ks_main = UIColor(red: 255/255.0, green: 84/255.0, blue: 65/255.0, alpha: 1)
-    public static let ks_lightMain = UIColor(red: 240/255.0, green: 128/255.0, blue: 128/255.0, alpha: 1)
-    public static let ks_lightGray = UIColor(red: 234/255.0, green: 234/255.0, blue: 234/255.0, alpha: 1)
+    public static let ks_main = UIColor(red: 98/255.0, green: 204/255.0, blue: 116/255.0, alpha: 1)
     public static let ks_white = UIColor.white
     public static let ks_black = UIColor.black
 }

+ 0 - 22
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSMediaPicker.strings

@@ -1,22 +0,0 @@
-/* 
-  KSMediaPicker.strings
-  KSMediaPickerDemo
-
-  Created by kinsun on 2019/4/29.
-  Copyright © 2019年 kinsun. All rights reserved.
-*/
-
-NEXT = "下一步";
-
-IMAGE_PICKER_PHOTOS = "照片";
-IMAGE_PICKER_CAMERA = "照相机";
-IMAGE_PICKER_MICROPHONE = "麦克风";
-IMAGE_PICKER_NONAUTHORITY_TITLE_FORMAT = "没有打开“%@”访问权限";
-IMAGE_PICKER_NONAUTHORITY_TIP_FORMAT = "请进入“设置”-“%@”打开%@开关";
-IMAGE_PICKER_NONAUTHORITY_GO_SETTING = "去设置";
-
-MEDIA_PICKER_SCALE_ASPECT_FIT = "留白";
-MEDIA_PICKER_SCALE_ASPECT_FILL = "充满";
-MEDIA_PICKER_ALBUM_TAB_TITLE = "相册";
-MEDIA_PICKER_CAMERA_TAB_TITLE = "拍照";
-MEDIA_PICKER_VIDEOCORDER_TAB_TITLE = "拍视频";

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerNavigationView.swift

@@ -18,7 +18,7 @@ extension KSMediaPickerView {
         public let nextButton = {() -> UIButton in
             let nextButton = UIButton(type: .custom)
             nextButton.titleLabel?.font = .systemFont(ofSize: 14.0)
-            nextButton.setTitle("NEXT".ks_mediaPickerKeyToLocalized, for: .normal)
+            nextButton.setTitle("完成", for: .normal)
             nextButton.setTitleColor(.ks_wordMain, for: .normal)
             nextButton.setTitleColor(.ks_wordMain_2, for: .disabled)
             return nextButton
@@ -26,7 +26,7 @@ extension KSMediaPickerView {
         
         public let closeButton = {() -> UIButton in
             let closeButton = UIButton(type: .custom)
-            closeButton.setImage(UIImage(named: "icon_mediaPicker_camera_close_b"), for: .normal)
+            closeButton.setImage(UIImage(named: "navbar_back_black"), for: .normal)
             return closeButton
         }()
         

+ 0 - 5
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerPreviewView.swift

@@ -224,11 +224,6 @@ open class KSMediaPickerPreviewView: UIView {
         let zoomButton = UIButton(type: .custom)
         zoomButton.setImage(UIImage(named: "icon_mediaPicker_preview_aspect_fit"), for: .normal)
         zoomButton.setImage(UIImage(named: "icon_mediaPicker_preview_aspect_fill"), for: .selected)
-        let bundle = Bundle.main
-        zoomButton.setTitle("MEDIA_PICKER_SCALE_ASPECT_FIT".ks_mediaPickerKeyToLocalized(in: bundle), for: .normal)
-        zoomButton.setTitle("MEDIA_PICKER_SCALE_ASPECT_FILL".ks_mediaPickerKeyToLocalized(in: bundle), for: .selected)
-        zoomButton.titleLabel?.font = UIFont.systemFont(ofSize: 12.0)
-        zoomButton.setTitleColor(.ks_white, for: .normal)
         zoomButton.backgroundColor = UIColor.ks_black.withAlphaComponent(0.3)
         return zoomButton
     }()

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerViewImageCell.swift

@@ -29,7 +29,7 @@ open class KSMediaPickerViewImageCell: UICollectionViewCell {
         let highlightView = UIView()
         highlightView.isHidden = true
         highlightView.isUserInteractionEnabled = false
-        highlightView.backgroundColor = UIColor.ks_main.withAlphaComponent(0.5)
+        highlightView.backgroundColor = UIColor.ks_main.withAlphaComponent(0.2)
         highlightView.layer.borderWidth = 2.0
         highlightView.layer.borderColor = UIColor.ks_main.cgColor
         return highlightView

RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSVideoPlayerView/KSVideoLayer.h → RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSVideoPlayerView/KSVideoLayer.h


RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSVideoPlayerView/KSVideoLayer.m → RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSVideoPlayerView/KSVideoLayer.m


RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSVideoPlayerView/KSVideoPlayerBaseView.h → RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSVideoPlayerView/KSVideoPlayerBaseView.h


RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSVideoPlayerView/KSVideoPlayerBaseView.m → RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSVideoPlayerView/KSVideoPlayerBaseView.m


+ 6 - 2
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishVideoRecorderController.swift

@@ -16,14 +16,18 @@ class PublishVideoRecorderController: BaseViewController {
         super.viewDidLoad()
         
         
-        
-        
         recorder.startPreview()
         // 开始预览,cameraPosition 摄像头位置(前置、后置)
         //        recorder.startPreview(withPositon: AliyunIRecorderCameraPosition.back)
     }
     
+    override func viewWillAppear(_ animated: Bool) {
+        navigationBar.isHidden = true
+    }
+    
     override func viewWillDisappear(_ animated: Bool) {
+        navigationBar.isHidden = false
+        
         recorder.stopPreview()
         recorder.destroy()
     }

+ 4 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishViewController.swift

@@ -163,6 +163,10 @@ extension PublishViewController :JXSegmentedListContainerViewDataSource {
         switch index {
         case 0:
             let mediaVc = KSMediaPickerController(maxVideoItemCount: 1, maxPictureItemCount: 9)
+            mediaVc.dismissClosure = {
+                [weak self] in
+                self?.dismiss(animated: true, completion: nil)
+            }
             return mediaVc
         case 1:
             let videoVc = PublishVideoRecorderController()

+ 0 - 22
RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close.imageset/Contents.json

@@ -1,22 +0,0 @@
-{
-  "images" : [
-    {
-      "idiom" : "universal",
-      "scale" : "1x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "icon_mediaPicker_camera_close@2x.png",
-      "scale" : "2x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "icon_mediaPicker_camera_close@3x.png",
-      "scale" : "3x"
-    }
-  ],
-  "info" : {
-    "version" : 1,
-    "author" : "xcode"
-  }
-}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close.imageset/icon_mediaPicker_camera_close@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close.imageset/icon_mediaPicker_camera_close@3x.png


+ 0 - 22
RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close_b.imageset/Contents.json

@@ -1,22 +0,0 @@
-{
-  "images" : [
-    {
-      "idiom" : "universal",
-      "scale" : "1x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "icon_mediaPicker_camera_close_b@2x.png",
-      "scale" : "2x"
-    },
-    {
-      "idiom" : "universal",
-      "filename" : "icon_mediaPicker_camera_close_b@3x.png",
-      "scale" : "3x"
-    }
-  ],
-  "info" : {
-    "version" : 1,
-    "author" : "xcode"
-  }
-}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close_b.imageset/icon_mediaPicker_camera_close_b@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/PublishModule.xcassets/icon_mediaPicker_camera_close_b.imageset/icon_mediaPicker_camera_close_b@3x.png