Browse Source

no message

Chris 5 years ago
parent
commit
48b3d72a04

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

@@ -404,15 +404,11 @@
 		BD12B68022B4EF2600AEB10B /* KSMediaPickerViewImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B67E22B4EF2600AEB10B /* KSMediaPickerViewImageCell.swift */; };
 		BD12B68122B4EF2600AEB10B /* KSMediaPickerViewVideoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B67F22B4EF2600AEB10B /* KSMediaPickerViewVideoCell.swift */; };
 		BD12B68322B4EFF000AEB10B /* KSMediaPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B68222B4EFF000AEB10B /* KSMediaPickerView.swift */; };
-		BD12B68522B4F15300AEB10B /* KSMediaPickerCameraView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B68422B4F15300AEB10B /* KSMediaPickerCameraView.swift */; };
 		BD12B68822B4F28F00AEB10B /* KSExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B68722B4F28F00AEB10B /* KSExtension.swift */; };
-		BD12B68C22B4F4FF00AEB10B /* KSSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = BD12B68B22B4F4FF00AEB10B /* KSSegmentedControl.m */; };
-		BD12B68E22B4F5DD00AEB10B /* KSMediaPickerCameraToolBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B68D22B4F5DD00AEB10B /* KSMediaPickerCameraToolBar.swift */; };
 		BD12B69122B4F60300AEB10B /* KSMediaPickerScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD12B69022B4F60200AEB10B /* KSMediaPickerScrollView.m */; };
 		BD12B69422B4F68400AEB10B /* KSMediaPickerCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = BD12B69322B4F68400AEB10B /* KSMediaPickerCollectionView.m */; };
 		BD12B69622B4F72900AEB10B /* KSMediaPickerPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B69522B4F72900AEB10B /* KSMediaPickerPreviewView.swift */; };
 		BD12B69A22B4FA8400AEB10B /* KSMediaPickerSelectIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B69922B4FA8400AEB10B /* KSMediaPickerSelectIndicator.swift */; };
-		BD12B69C22B4FAC800AEB10B /* KSMediaPickerRECButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B69B22B4FAC800AEB10B /* KSMediaPickerRECButton.swift */; };
 		BD12B69E22B4FAF000AEB10B /* KSMediaPickerNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B69D22B4FAF000AEB10B /* KSMediaPickerNavigationView.swift */; };
 		BD12B6A222B4FC9B00AEB10B /* KSBorderButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B6A022B4FC9B00AEB10B /* KSBorderButton.swift */; };
 		BD12B6A322B4FC9B00AEB10B /* KSButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B6A122B4FC9B00AEB10B /* KSButton.swift */; };
@@ -940,18 +936,13 @@
 		BD12B67E22B4EF2600AEB10B /* KSMediaPickerViewImageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerViewImageCell.swift; sourceTree = "<group>"; };
 		BD12B67F22B4EF2600AEB10B /* KSMediaPickerViewVideoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerViewVideoCell.swift; sourceTree = "<group>"; };
 		BD12B68222B4EFF000AEB10B /* KSMediaPickerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerView.swift; sourceTree = "<group>"; };
-		BD12B68422B4F15300AEB10B /* KSMediaPickerCameraView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerCameraView.swift; sourceTree = "<group>"; };
 		BD12B68722B4F28F00AEB10B /* KSExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSExtension.swift; sourceTree = "<group>"; };
-		BD12B68A22B4F4FF00AEB10B /* KSSegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KSSegmentedControl.h; sourceTree = "<group>"; };
-		BD12B68B22B4F4FF00AEB10B /* KSSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSSegmentedControl.m; sourceTree = "<group>"; };
-		BD12B68D22B4F5DD00AEB10B /* KSMediaPickerCameraToolBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerCameraToolBar.swift; sourceTree = "<group>"; };
 		BD12B68F22B4F60200AEB10B /* KSMediaPickerScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KSMediaPickerScrollView.h; sourceTree = "<group>"; };
 		BD12B69022B4F60200AEB10B /* KSMediaPickerScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSMediaPickerScrollView.m; sourceTree = "<group>"; };
 		BD12B69222B4F68400AEB10B /* KSMediaPickerCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KSMediaPickerCollectionView.h; sourceTree = "<group>"; };
 		BD12B69322B4F68400AEB10B /* KSMediaPickerCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSMediaPickerCollectionView.m; sourceTree = "<group>"; };
 		BD12B69522B4F72900AEB10B /* KSMediaPickerPreviewView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerPreviewView.swift; sourceTree = "<group>"; };
 		BD12B69922B4FA8400AEB10B /* KSMediaPickerSelectIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerSelectIndicator.swift; sourceTree = "<group>"; };
-		BD12B69B22B4FAC800AEB10B /* KSMediaPickerRECButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerRECButton.swift; sourceTree = "<group>"; };
 		BD12B69D22B4FAF000AEB10B /* KSMediaPickerNavigationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerNavigationView.swift; sourceTree = "<group>"; };
 		BD12B6A022B4FC9B00AEB10B /* KSBorderButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSBorderButton.swift; sourceTree = "<group>"; };
 		BD12B6A122B4FC9B00AEB10B /* KSButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSButton.swift; sourceTree = "<group>"; };
@@ -3644,7 +3635,6 @@
 				BD12B68722B4F28F00AEB10B /* KSExtension.swift */,
 				BD24FABE22B50C4B00C7AA3B /* KSMediaPicker.strings */,
 				BD12B69F22B4FC9B00AEB10B /* KSButton */,
-				BD12B68922B4F4FF00AEB10B /* KSSegmentedControl */,
 				BD12B67522B4ECE200AEB10B /* Controller */,
 				BD12B67622B4ED8800AEB10B /* Model */,
 				BD12B67922B4EE1A00AEB10B /* View */,
@@ -3673,13 +3663,10 @@
 		BD12B67922B4EE1A00AEB10B /* View */ = {
 			isa = PBXGroup;
 			children = (
-				BD12B68D22B4F5DD00AEB10B /* KSMediaPickerCameraToolBar.swift */,
-				BD12B68422B4F15300AEB10B /* KSMediaPickerCameraView.swift */,
 				BD12B69222B4F68400AEB10B /* KSMediaPickerCollectionView.h */,
 				BD12B69322B4F68400AEB10B /* KSMediaPickerCollectionView.m */,
 				BD12B69D22B4FAF000AEB10B /* KSMediaPickerNavigationView.swift */,
 				BD12B69522B4F72900AEB10B /* KSMediaPickerPreviewView.swift */,
-				BD12B69B22B4FAC800AEB10B /* KSMediaPickerRECButton.swift */,
 				BD12B68F22B4F60200AEB10B /* KSMediaPickerScrollView.h */,
 				BD12B69022B4F60200AEB10B /* KSMediaPickerScrollView.m */,
 				BD12B69922B4FA8400AEB10B /* KSMediaPickerSelectIndicator.swift */,
@@ -3690,15 +3677,6 @@
 			path = View;
 			sourceTree = "<group>";
 		};
-		BD12B68922B4F4FF00AEB10B /* KSSegmentedControl */ = {
-			isa = PBXGroup;
-			children = (
-				BD12B68A22B4F4FF00AEB10B /* KSSegmentedControl.h */,
-				BD12B68B22B4F4FF00AEB10B /* KSSegmentedControl.m */,
-			);
-			path = KSSegmentedControl;
-			sourceTree = "<group>";
-		};
 		BD12B69F22B4FC9B00AEB10B /* KSButton */ = {
 			isa = PBXGroup;
 			children = (
@@ -4358,7 +4336,6 @@
 				A7274C5E228EE636000E3A07 /* LBXPermissions.swift in Sources */,
 				A7D46092227619CD00A5A54E /* BaiduToCityFactory.swift in Sources */,
 				A71AA51C227219EF008FF1A5 /* EditExpressAddressView.swift in Sources */,
-				BD12B68522B4F15300AEB10B /* KSMediaPickerCameraView.swift in Sources */,
 				BD1FC1A822B1075F00D55081 /* LXTextView.m in Sources */,
 				BDAA40FB228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift in Sources */,
 				A7DF50D622A4E8B400998908 /* OrderDetailProductTableViewCell.swift in Sources */,
@@ -4568,7 +4545,6 @@
 				A7CC75432271E038003C4F38 /* SelfMentionContactsListViewController.swift in Sources */,
 				BDF47D872282C92200941AB9 /* ShoppingCartListTableViewHeader.swift in Sources */,
 				A70B2C46228840B100B2449F /* ProductDetailHotSellTableViewCell.swift in Sources */,
-				BD12B69C22B4FAC800AEB10B /* KSMediaPickerRECButton.swift in Sources */,
 				A7778CDF22461BAD00C7C47A /* PhoneCountryAreaSectionHeaderView.swift in Sources */,
 				A7A98E2D22801642005306E9 /* SwiftMoyaServiceCMSApi.swift in Sources */,
 				A70B2C402288312900B2449F /* ProductDetailSectionHeader.swift in Sources */,
@@ -4613,7 +4589,6 @@
 				A7C0FE0222B682DB00BC1E86 /* CommunityFeaturedTopicsHeaderView.swift in Sources */,
 				A7274C5F228EE636000E3A07 /* LBXScanWrapper.swift in Sources */,
 				A7CC752F2271A1F2003C4F38 /* SetPasswordView.swift in Sources */,
-				BD12B68E22B4F5DD00AEB10B /* KSMediaPickerCameraToolBar.swift in Sources */,
 				A7A98E09227EB8DD005306E9 /* CategoryView.swift in Sources */,
 				A7D07CC122B73F0200186014 /* OtherPersonalCenterViewController.swift in Sources */,
 				A7CC75362271AC14003C4F38 /* AddressManagerView.swift in Sources */,
@@ -4700,7 +4675,6 @@
 				A743229422B88ED30017C367 /* EnumMacro.swift in Sources */,
 				BD1DC6C9228D005000B89C57 /* OrderCreateParameterModel.swift in Sources */,
 				A7BF203422B47E8600396DB3 /* CardContentActionTableViewCell.swift in Sources */,
-				BD12B68C22B4F4FF00AEB10B /* KSSegmentedControl.m in Sources */,
 				A71AA52622732068008FF1A5 /* SwiftMoyaServiceConfigApi.swift in Sources */,
 				A77F2C982231FD25001BD3F6 /* BaseNavigationViewController.swift in Sources */,
 				A7274C5D228EE636000E3A07 /* LBXScanViewStyle.swift in Sources */,

+ 0 - 1
RainbowPlanet/RainbowPlanet/Macro/RainbowPlanet-Bridging-Header.h

@@ -57,7 +57,6 @@
 
 //  KSMediaPicker所依靠的OC文件
 //#import "KSMediaViewerCell.h"
-#import "KSSegmentedControl.h"
 #import "KSMediaPickerScrollView.h"
 #import "KSMediaPickerCollectionView.h"
 #import "KSVideoPlayerLiteView.h"

+ 7 - 38
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/Controller/KSMediaPickerController.swift

@@ -16,6 +16,7 @@ open class KSNavigationController: UINavigationController {
 }
 
 import Photos
+import JXSegmentedView
 
 @objc public protocol KSMediaPickerControllerDelegate: NSObjectProtocol {
     
@@ -89,18 +90,6 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
         collectionView.delegate = self
         collectionView.dataSource = self
         
-        let cameraView = view.cameraView
-        cameraView.didTakePhotoCallback = {[weak self] (cameraView, image) in
-            self?._didTakePhotoFinish(cameraView: cameraView, image: image)
-        }
-        cameraView.didTakeVideoCallback = {[weak self] (cameraView, fileURL) in
-            self?._didTakeVideoFinish(cameraView: cameraView, fileURL: fileURL)
-        }
-        let toolBar = cameraView.toolBar
-        toolBar.closeButton.addTarget(self, action: #selector(_didClick(closeButton:)), for: .touchUpInside)
-        toolBar.didChangedStyleCallback = { (style) in
-            UIApplication.shared.setStatusBarStyle(style == .lightContent ? .lightContent : .default, animated: true)
-        }
         self.view = view
     }
     
@@ -185,31 +174,6 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
         }
     }
     
-    private func _didTakePhotoFinish(cameraView: KSMediaPickerCameraView, image: UIImage) {
-        var createdAssetID: String? = nil
-        try? PHPhotoLibrary.shared().performChangesAndWait {
-            let request = PHAssetChangeRequest.creationRequestForAsset(from: image)
-            createdAssetID = request.placeholderForCreatedAsset?.localIdentifier
-        }
-        guard let k_id = createdAssetID,
-            let asset = PHAsset.fetchAssets(withLocalIdentifiers: [k_id], options: nil).firstObject else {
-                return
-        }
-        _update(asset: asset)
-    }
-    
-    private func _didTakeVideoFinish(cameraView: KSMediaPickerCameraView, fileURL: URL) {
-        var createdAssetID: String? = nil
-        try? PHPhotoLibrary.shared().performChangesAndWait {
-            let request = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: fileURL)
-            createdAssetID = request?.placeholderForCreatedAsset?.localIdentifier
-        }
-        guard let k_id = createdAssetID,
-            let asset = PHAsset.fetchAssets(withLocalIdentifiers: [k_id], options: nil).firstObject else {
-                return
-        }
-        _update(asset: asset)
-    }
     
     private func _update(asset: PHAsset) {
         _updateHighlightedItemStatus()
@@ -233,7 +197,6 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
             }
             collectionView.reloadItems(at: [indexPath])
             view.collectionViewScrollToTop()
-            view.didClick(segmentedControl: view.segmentedControl, index: 0)
         }
     }
     
@@ -542,3 +505,9 @@ extension KSMediaPickerController {
         }
     }
 }
+
+extension KSMediaPickerController : JXSegmentedListContainerViewListDelegate {
+    public func listView() -> UIView {
+        return view
+    }
+}

+ 0 - 33
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSSegmentedControl/KSSegmentedControl.h

@@ -1,33 +0,0 @@
-//
-//  KSSegmentedControl.h
-// 
-//
-//  Created by kinsun on 2018/11/25.
-//  Copyright © 2018年 kinsun. All rights reserved.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface KSSegmentedControl : UIView
-
-@property (nonatomic, strong, readonly) NSArray <NSString *> *items;
-@property (nonatomic, assign) CGFloat egdeMargin;
-@property (nonatomic, strong) UIFont *font;
-@property (nonatomic, strong) UIColor *normalTextColor;
-@property (nonatomic, strong) UIColor *selectedTextColor;
-@property (nonatomic, assign) NSUInteger selectedSegmentIndex;
-@property (nonatomic, copy, nullable) void (^didClickItem)(KSSegmentedControl *segmentedControl, NSInteger index);
-
-@property (nonatomic, assign, getter=isShowIndicator) BOOL showIndicator;
-@property (nonatomic, assign) CGFloat indicatorHeight;
-@property (nonatomic, assign) CGFloat indicatorBottomEgdeInset;
-@property (nonatomic) UIColor *indndicatorColor;
-
-- (instancetype)initWithFrame:(CGRect)frame items:(NSArray <NSString *> *)items;
-- (void)updateIndicatorProportion:(CGFloat)proportion;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 258
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/KSSegmentedControl/KSSegmentedControl.m

@@ -1,258 +0,0 @@
-//
-//  KSSegmentedControl.m
-// 
-//
-//  Created by kinsun on 2018/11/25.
-//  Copyright © 2018年 kinsun. All rights reserved.
-//
-
-#import "KSSegmentedControl.h"
-
-@interface _KSSCItemLayer : CATextLayer
-
-@property (nonatomic, assign) CGColorRef normalColor;
-@property (nonatomic, assign) CGColorRef selectedColor;
-@property (nonatomic, assign, getter=isSelected) BOOL selected;
-
-@end
-
-@implementation _KSSCItemLayer
-
-- (instancetype)init {
-    if (self = [super init]) {
-        self.wrapped = NO;
-        self.alignmentMode = kCAAlignmentCenter;
-    }
-    return self;
-}
-
-- (void)setNormalColor:(CGColorRef)normalColor {
-    _normalColor = normalColor;
-    if (!_selected) self.foregroundColor = normalColor;
-}
-
-- (void)setSelectedColor:(CGColorRef)selectedColor {
-    _selectedColor = selectedColor;
-    if (_selected) self.foregroundColor = selectedColor;
-}
-
-- (void)setSelected:(BOOL)selected {
-    _selected = selected;
-    self.foregroundColor = selected ? _selectedColor : _normalColor;
-}
-
-@end
-
-#import "KSLayout.h"
-
-@implementation KSSegmentedControl {
-    NSArray <NSNumber *> *_itemsWidthArray;
-    NSPointerArray *_textLayerArray;
-    __weak _KSSCItemLayer *_selectedTextlayer;
-    __weak CALayer *_indLayer;
-    
-    CGFloat _itemMargin;
-    CGFloat _tempProportion;
-}
-
-- (instancetype)initWithFrame:(CGRect)frame items:(NSArray <NSString *> *)items {
-    if (self = [super initWithFrame:frame]) {
-        _items = items;
-        [self _initView];
-    }
-    return self;
-}
-
-- (void)_initView {
-    _indicatorHeight = 3.f;
-    CALayer *layer = self.layer;
-    
-    CALayer *indLayer = [CALayer layer];
-    [layer addSublayer:indLayer];
-    _indLayer = indLayer;
-    self.indndicatorColor = self.tintColor;
-    
-    CGFloat scale = UIScreen.mainScreen.scale;
-    NSPointerArray *textLayerArray = [NSPointerArray weakObjectsPointerArray];
-    for (NSString *title in _items) {
-        _KSSCItemLayer *textLayer = [_KSSCItemLayer layer];
-        textLayer.contentsScale = scale;
-        textLayer.string = title;
-        [layer addSublayer:textLayer];
-        [textLayerArray addPointer:(__bridge void *)textLayer];
-    }
-    _textLayerArray = textLayerArray;
-    
-    [self _forceUpdateSelectedSegmentIndex:0];
-    self.font = [UIFont systemFontOfSize:18.f];
-    self.normalTextColor = UIColor.lightTextColor;
-    self.selectedTextColor = UIColor.blackColor;
-}
-
-- (void)layoutSublayersOfLayer:(CALayer *)layer {
-    [super layoutSublayersOfLayer:layer];
-    CGSize size = layer.frame.size;
-    k_creatSizeElementOfSize(size);
-    k_creatFrameElement;
-    
-    CGFloat remainderWidth = windowWidth;
-    NSUInteger count = _itemsWidthArray.count;
-    for (NSUInteger i = 0; i < count; i++) {
-        NSNumber *value = [_itemsWidthArray objectAtIndex:i];
-        CGFloat width = value.doubleValue;
-        remainderWidth -= width;
-    }
-    CGFloat margin = floor((remainderWidth-_egdeMargin*2.f)/count);
-    _itemMargin = margin;
-    viewX = _egdeMargin+margin*0.5f; viewH = self.font.lineHeight; viewY = (windowHeight-viewH)*0.5f;
-    for (NSUInteger i = 0; i < count; i++) {
-        NSNumber *value = [_itemsWidthArray objectAtIndex:i];
-        viewW = value.doubleValue;
-        _KSSCItemLayer *textLayer = [_textLayerArray pointerAtIndex:i];
-        CGRect frame = k_setFrame;
-        textLayer.frame = frame;
-        viewX = CGRectGetMaxX(frame)+margin;
-    }
-    
-    if (windowHeight > 1.f && !_indLayer.hidden && _indLayer.frame.size.width < 1.f) {
-        _KSSCItemLayer *textLayer = [_textLayerArray pointerAtIndex:_selectedSegmentIndex];
-        CGRect frame = textLayer.frame;
-        frame.size.height = _indicatorHeight;
-        frame.origin.y = windowHeight-_indicatorBottomEgdeInset-_indicatorHeight;
-        _indLayer.frame = frame;
-    }
-}
-
-- (void)setShowIndicator:(BOOL)showIndicator {
-    _indLayer.hidden = !showIndicator;
-}
-
-- (BOOL)isShowIndicator {
-    return !_indLayer.hidden;
-}
-
-- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
-    [super touchesEnded:touches withEvent:event];
-    if (_didClickItem != nil) {
-        UITouch *touch = touches.anyObject;
-        CGPoint location = [touch locationInView:self];
-        CGRect bounds = self.bounds;
-        if (CGRectContainsPoint(bounds, location)) {
-            for (NSUInteger i = 0; i < _textLayerArray.count; i++) {
-                _KSSCItemLayer *textLayer = [_textLayerArray pointerAtIndex:i];
-                if (CGRectContainsPoint(textLayer.frame, location)) {
-                    _didClickItem(self, i);
-                }
-            }
-        }
-    }
-}
-
-- (void)setSelectedSegmentIndex:(NSUInteger)selectedSegmentIndex {
-    if (_selectedSegmentIndex != selectedSegmentIndex) {
-        [self _forceUpdateSelectedSegmentIndex:selectedSegmentIndex];
-    }
-}
-
-- (void)_forceUpdateSelectedSegmentIndex:(NSUInteger)selectedSegmentIndex {
-    if (selectedSegmentIndex >= 0 && selectedSegmentIndex < _textLayerArray.count) {
-        _selectedSegmentIndex = selectedSegmentIndex;
-        if (_selectedTextlayer != nil)
-            _selectedTextlayer.selected = NO;
-        
-        _KSSCItemLayer *textLayer = [_textLayerArray pointerAtIndex:selectedSegmentIndex];
-        textLayer.selected = YES;
-        _selectedTextlayer = textLayer;
-    }
-}
-
-- (void)setFont:(UIFont *)font {
-    if (font == nil) return;
-    _font = font;
-    
-    NSUInteger count = _textLayerArray.count;
-    CGFloat pointSize = font.pointSize;
-    CFStringRef fontCFString = (__bridge CFStringRef)font.fontName;
-    CGFontRef fontRef = CGFontCreateWithFontName(fontCFString);
-    
-    CGSize maxSize = (CGSize){MAXFLOAT, MAXFLOAT};
-    NSStringDrawingOptions options = NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading;
-    NSDictionary <NSAttributedStringKey, UIFont *> *attributes = @{NSFontAttributeName: font};
-    NSMutableArray <NSNumber *> *itemsWidthArray = [NSMutableArray arrayWithCapacity:count];
-    
-    for (NSUInteger i = 0; i < count; i++) {
-        NSString *string = [_items objectAtIndex:i];
-        CGSize size = [string boundingRectWithSize:maxSize options:options attributes:attributes context:nil].size;
-        NSNumber *width = [NSNumber numberWithDouble:size.width+3];
-        [itemsWidthArray addObject:width];
-        
-        _KSSCItemLayer *textLayer = [_textLayerArray pointerAtIndex:i];
-        textLayer.font = fontRef;
-        textLayer.fontSize = pointSize;
-    }
-    CGFontRelease(fontRef);
-    _itemsWidthArray = itemsWidthArray;
-}
-
-- (void)setNormalTextColor:(UIColor *)normalTextColor {
-    _normalTextColor = normalTextColor;
-    CGColorRef cgColor = normalTextColor.CGColor;
-    for (_KSSCItemLayer *textLayer in _textLayerArray) {
-        textLayer.normalColor = cgColor;
-    }
-}
-
-- (void)setSelectedTextColor:(UIColor *)selectedTextColor {
-    _selectedTextColor = selectedTextColor;
-    CGColorRef cgColor = selectedTextColor.CGColor;
-    for (_KSSCItemLayer *textLayer in _textLayerArray) {
-        textLayer.selectedColor = cgColor;
-    }
-}
-
-- (void)setIndndicatorColor:(UIColor *)indndicatorColor {
-    _indLayer.backgroundColor = indndicatorColor.CGColor;
-}
-
-- (UIColor *)indndicatorColor {
-    return [UIColor colorWithCGColor:_indLayer.backgroundColor];
-}
-
-- (void)updateIndicatorProportion:(CGFloat)proportion {
-    NSInteger index = floor(proportion);
-    NSInteger toIndex = index+1;
-    if ([self checkIndexAvailable:index] && [self checkIndexAvailable:toIndex]) {
-        _KSSCItemLayer *textLayer = [_textLayerArray pointerAtIndex:index];
-        _KSSCItemLayer *toTextLayer = [_textLayerArray pointerAtIndex:toIndex];
-        CGRect textLayerFrame = textLayer.frame;
-        CGRect toTextLayerFrame = toTextLayer.frame;
-        
-        CGFloat scale = proportion-index;
-        
-        CGFloat width = textLayerFrame.size.width;
-        CGFloat toWidth = toTextLayerFrame.size.width;
-        CGFloat defWidth = toWidth-width;
-        CGFloat resultWidth = defWidth*scale+width;
-        
-        CGFloat x = textLayerFrame.origin.x;
-        CGFloat toX = toTextLayerFrame.origin.x;
-        CGFloat defX = toX-x;
-        CGFloat resultX = defX*scale+x;
-
-        CGRect frame = _indLayer.frame;
-        frame.size.width = resultWidth;
-        frame.origin.x = resultX;
-        [CATransaction begin];
-        [CATransaction setDisableActions:YES];
-        _indLayer.frame = frame;
-        [CATransaction commit];
-    }
-    _tempProportion = proportion;
-}
-
-- (BOOL)checkIndexAvailable:(NSInteger)index {
-    return index >= 0 && index < _textLayerArray.count;
-}
-
-@end
-

+ 0 - 227
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerCameraToolBar.swift

@@ -1,227 +0,0 @@
-//
-//  KSMediaPickerCameraToolBar.swift
-// 
-//
-//  Created by kinsun on 2019/3/11.
-//
-
-import UIKit
-
-extension KSMediaPickerCameraToolBar {
-    
-    open class button: UIControl {
-        
-        public enum style: UInt {
-            case lightContent
-            case darkContent
-        }
-        
-        public enum status {
-            case status1
-            case status2
-            case status3
-        }
-        
-        required public init?(coder aDecoder: NSCoder) {
-            fatalError("init(coder:) has not been implemented")
-        }
-        
-        private let _imageView = {() -> UIImageView in
-            let imageView = UIImageView()
-            imageView.contentMode = .scaleAspectFit
-            return imageView
-        }()
-        
-        override public init(frame: CGRect) {
-            super.init(frame: frame)
-            addSubview(_imageView)
-        }
-        
-        override open func layoutSubviews() {
-            super.layoutSubviews()
-            _imageView.frame = bounds
-        }
-        
-        open var status = button.status.status1 {
-            didSet {
-                _didSet(status: self.status, style: self.style)
-            }
-        }
-        
-        open var style = button.style.darkContent {
-            didSet {
-                _didSet(status: self.status, style: self.style)
-            }
-        }
-        
-        private func _didSet(status: button.status, style: button.style) {
-            _imageView.image = image(of: status, of: style) ?? image(of: .status1, of: style)
-        }
-        
-        private var _lightContentStatusImageArray = [button.status: UIImage]()
-        private var _darkContentStatusImageArray = [button.status: UIImage]()
-        
-        open func set(image: UIImage, for status: button.status, of style: button.style) {
-            switch style {
-            case .lightContent:
-                _lightContentStatusImageArray[status] = image
-                break
-            case .darkContent:
-                _darkContentStatusImageArray[status] = image
-                break
-            }
-            if self.status == status, self.style == style {
-                _imageView.image = image
-            }
-        }
-        
-        open func image(of status: button.status, of style: button.style) -> UIImage? {
-            let array: [button.status: UIImage]
-            switch style {
-            case .lightContent:
-                array = _lightContentStatusImageArray
-                break
-            case .darkContent:
-                array = _darkContentStatusImageArray
-                break
-            }
-            return array[status]
-        }
-    }
-}
-
-open class KSMediaPickerCameraToolBar: UIView {
-    
-    public enum toolBarType: UInt {
-        case photos
-        case noFlashlightPhotos
-        case videos
-    }
-
-    required public init?(coder aDecoder: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-    
-    public let closeButton = {() -> KSMediaPickerCameraToolBar.button in
-        let closeButton = KSMediaPickerCameraToolBar.button()
-        closeButton.set(image: UIImage(named: "icon_mediaPicker_camera_close")!, for: .status1, of: .lightContent)
-        closeButton.set(image: UIImage(named: "icon_mediaPicker_camera_close_b")!, for: .status1, of: .darkContent)
-        return closeButton
-    }()
-    public let priviewSizeButton = {() -> KSMediaPickerCameraToolBar.button in
-        let priviewSizeButton = KSMediaPickerCameraToolBar.button()
-        priviewSizeButton.set(image: UIImage(named: "icon_mediaPicker_camera_square")!, for: .status1, of: .lightContent)
-        priviewSizeButton.set(image: UIImage(named: "icon_mediaPicker_camera_square_b")!, for: .status1, of: .darkContent)
-        priviewSizeButton.set(image: UIImage(named: "icon_mediaPicker_camera_rectangle")!, for: .status2, of: .lightContent)
-        priviewSizeButton.set(image: UIImage(named: "icon_mediaPicker_camera_rectangle_16_9")!, for: .status3, of: .lightContent)
-        return priviewSizeButton
-    }()
-    public let flashlightButton = {() -> KSMediaPickerCameraToolBar.button in
-        let flashlightButton = KSMediaPickerCameraToolBar.button()
-        flashlightButton.set(image: UIImage(named: "icon_mediaPicker_camera_flashlight_auto")!, for: .status1, of: .lightContent)
-        flashlightButton.set(image: UIImage(named: "icon_mediaPicker_camera_flashlight_auto_b")!, for: .status1, of: .darkContent)
-        flashlightButton.set(image: UIImage(named: "icon_mediaPicker_camera_flashlight_on")!, for: .status2, of: .lightContent)
-        flashlightButton.set(image: UIImage(named: "icon_mediaPicker_camera_flashlight_on_b")!, for: .status2, of: .darkContent)
-        flashlightButton.set(image: UIImage(named: "icon_mediaPicker_camera_flashlight_off")!, for: .status3, of: .lightContent)
-        flashlightButton.set(image: UIImage(named: "icon_mediaPicker_camera_flashlight_off_b")!, for: .status3, of: .darkContent)
-        return flashlightButton
-    }()
-    public let cameraOrientation = {() -> KSMediaPickerCameraToolBar.button in
-        let cameraOrientation = KSMediaPickerCameraToolBar.button()
-        cameraOrientation.set(image: UIImage(named: "icon_mediaPicker_camera_switch")!, for: .status1, of: .lightContent)
-        cameraOrientation.set(image: UIImage(named: "icon_mediaPicker_camera_switch_b")!, for: .status1, of: .darkContent)
-        return cameraOrientation
-    }()
-    
-    open var didChangedStyleCallback: ((KSMediaPickerCameraToolBar.button.style) -> Void)?
-    
-    open var style: KSMediaPickerCameraToolBar.button.style {
-        didSet {
-            if oldValue != style {
-                _didSet(style: style)
-                if didChangedStyleCallback != nil {
-                    didChangedStyleCallback!(style)
-                }
-            }
-        }
-    }
-    open var type = KSMediaPickerCameraToolBar.toolBarType.photos {
-        didSet {
-            let flashlightIsHidden = type != .photos
-            var isNeedAnimation = false
-            if flashlightIsHidden != flashlightButton.isHidden {
-                flashlightButton.isHidden = flashlightIsHidden
-                isNeedAnimation = true
-            }
-            let priviewSizeIsHidden = type == .videos
-            if priviewSizeIsHidden != priviewSizeButton.isHidden {
-                priviewSizeButton.isHidden = priviewSizeIsHidden
-                isNeedAnimation = true
-            }
-            if isNeedAnimation {
-                UIView.animate(withDuration: 0.2) {[weak self] in
-                    self?.layoutSubviews()
-                }
-            }
-        }
-    }
-     
-    public init(frame: CGRect, style: KSMediaPickerCameraToolBar.button.style) {
-        self.style = style
-        super.init(frame: frame)
-        _didSet(style: style)
-        backgroundColor = .clear
-        
-        addSubview(closeButton)
-        addSubview(priviewSizeButton)
-        addSubview(flashlightButton)
-        addSubview(cameraOrientation)
-    }
-    
-    public convenience init(style: KSMediaPickerCameraToolBar.button.style) {
-        self.init(frame: .zero, style: style)
-    }
-    
-    override open func layoutSubviews() {
-        super.layoutSubviews()
-        let windowSize = bounds.size
-        let windowWidth = windowSize.width
-        let windowHeight = windowSize.height
-        let floatZore = CGFloat(0.0)
-        
-        var buttons = [closeButton, cameraOrientation]
-        switch type {
-        case .photos:
-            buttons.insert(priviewSizeButton, at: 1)
-            buttons.insert(flashlightButton, at: 2)
-            break
-        case .noFlashlightPhotos:
-            buttons.insert(priviewSizeButton, at: 1)
-            break
-        case .videos:
-            break
-        }
-        
-        let count = CGFloat(buttons.count)
-        var viewX = floatZore
-        let viewY = floatZore
-        let viewW = CGFloat(70.0)
-        let viewH = windowHeight
-        let margin = (windowWidth-(viewW*count))/(count-1)
-        
-        for (i, button) in buttons.enumerated() {
-            viewX = (viewW+margin)*CGFloat(i)
-            button.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        }
-    }
-    
-    private func _didSet(style: KSMediaPickerCameraToolBar.button.style) {
-        closeButton.style = style
-        priviewSizeButton.style = style
-        priviewSizeButton.style = style
-        flashlightButton.style = style
-        flashlightButton.style = style
-        cameraOrientation.style = style
-        cameraOrientation.style = style
-    }
-}

+ 0 - 447
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerCameraView.swift

@@ -1,447 +0,0 @@
-//
-//  KSMediaPickerCameraView.swift
-// 
-//
-//  Created by kinsun on 2019/3/11.
-//
-
-import UIKit
-
-extension KSMediaPickerCameraView {
-    
-    public enum style {
-        case unknown
-        case photo
-        case video
-    }
-    
-    private enum previewSize: UInt {
-        case square
-        case hdPicture
-        case hdVideo
-        
-        private static let _squareSize = CGSize(width: 1.0, height: 1.0)
-        private static let _hdPictureSize = CGSize(width: 3.0, height: 4.0)
-        private static let _hdVideoSize = CGSize(width: 9.0, height: 16.0)
-        
-        public var cgSizeValue: CGSize {
-            get {
-                switch self {
-                case .square:
-                    return previewSize._squareSize
-                case .hdPicture:
-                    return previewSize._hdPictureSize
-                case .hdVideo:
-                    return previewSize._hdVideoSize
-                }
-            }
-        }
-    }
-}
-
-import AVFoundation
-
-open class KSMediaPickerCameraView: UIView, AVCaptureFileOutputRecordingDelegate {
-
-    required public init?(coder aDecoder: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-    
-    #if arch(i386) || arch(x86_64)
-    private let _frontCameraDevice: AVCaptureDevice?
-    private let _backCameraDevice: AVCaptureDevice?
-    #else
-    private let _frontCameraDevice: AVCaptureDevice
-    private let _backCameraDevice: AVCaptureDevice
-    #endif
-    private var _videoInput: AVCaptureDeviceInput?
-    private lazy var _audioInput = {() -> AVCaptureDeviceInput? in
-        if let audio = AVCaptureDevice.default(for: .audio) {
-            return try? AVCaptureDeviceInput(device: audio)
-        }
-        return nil
-    }()
-    private lazy var _imageOutput = AVCaptureStillImageOutput()
-    private lazy var _videoOutput = {() -> AVCaptureMovieFileOutput in
-        let videoOutput = AVCaptureMovieFileOutput()
-        videoOutput.movieFragmentInterval = CMTime(value: 1, timescale: 1)
-        return videoOutput
-    }()
-    private let _session = {() -> AVCaptureSession in
-        let session = AVCaptureSession()
-        session.sessionPreset = .photo
-        return session
-    }()
-    private let _previewLayer: AVCaptureVideoPreviewLayer
-    public let toolBar = KSMediaPickerCameraToolBar(style: .darkContent)
-    
-    public let scrollView = {() -> KSMediaPickerScrollView in
-        let scrollView = KSMediaPickerScrollView()
-        scrollView.backgroundColor = .clear
-        scrollView.showsHorizontalScrollIndicator = false
-        scrollView.bounces = false
-        scrollView.isPagingEnabled = true
-        return scrollView
-    }()
-    private let _takePhotoButton = {() -> UIButton in
-        let frame = CGRect(origin: .zero, size: CGSize(width: 80.0, height: 80.0))
-        let takePhotoButton = KSBorderButton(type: .custom)
-        takePhotoButton.frame = frame
-        let layer = takePhotoButton.layer
-        layer.masksToBounds = true
-        layer.borderWidth = 8.0
-        layer.cornerRadius = frame.size.height*0.5
-        let color = UIColor.ks_main
-        let borderColor = UIColor.ks_lightMain
-        takePhotoButton.setBackgroundColor(color, for: .normal)
-        takePhotoButton.setBackgroundColor(color.withAlphaComponent(0.5), for: .highlighted)
-        takePhotoButton.setBorderColor(borderColor, for: .normal)
-        takePhotoButton.setBorderColor(borderColor.withAlphaComponent(0.5), for: .highlighted)
-        return takePhotoButton
-    }()
-    private let _takeVideoButton = RECButton(frame: CGRect(origin: .zero, size: CGSize(width: 80.0, height: 80.0)))
-    
-    override public init(frame: CGRect) {
-        #if arch(i386) || arch(x86_64)
-        _frontCameraDevice = nil
-        _backCameraDevice = nil
-        #else
-        var frontCameraDevice: AVCaptureDevice? = nil
-        var backCameraDevice: AVCaptureDevice? = nil
-        let devices = AVCaptureDevice.devices(for: .video)
-        for device in devices {
-            switch device.position {
-            case .back:
-                backCameraDevice = device
-                break
-            case .front:
-                frontCameraDevice = device
-                break
-            default:
-                break
-            }
-        }
-        _frontCameraDevice = frontCameraDevice!
-        _backCameraDevice = backCameraDevice!
-        #endif
-        
-        _previewLayer = AVCaptureVideoPreviewLayer(session: _session)
-        _previewLayer.videoGravity = .resizeAspectFill
-        _previewLayer.backgroundColor = UIColor.ks_black.cgColor
-        startRunning = _session.startRunning
-        stopRunning = _session.stopRunning
-        super.init(frame: frame)
-        backgroundColor = .clear
-        #if arch(i386) || arch(x86_64)
-        _videoInput = nil
-        #else
-        _videoInput = _videoInputFrom(device: _backCameraDevice)
-        #endif
-        if let input = _videoInput, _session.canAddInput(input) {
-            _session.addInput(input)
-        }
-        
-        layer.addSublayer(_previewLayer)
-        
-        _takePhotoButton.addTarget(self, action: #selector(_didClick(takePhotoButton:)), for: .touchUpInside)
-        scrollView.addSubview(_takePhotoButton)
-        _takeVideoButton.addTarget(self, action: #selector(_didClick(takeVideoButton:)), for: .touchUpInside)
-        _takeVideoButton.didStopRunningCallback = {[weak self] (button) in
-            self?._didFinishRecVideo(button: button)
-        }
-        scrollView.addSubview(_takeVideoButton)
-        addSubview(scrollView)
-        toolBar.cameraOrientation.addTarget(self, action: #selector(_didClick(cameraOrientation:)), for: .touchUpInside)
-        toolBar.priviewSizeButton.addTarget(self, action: #selector(_didClick(priviewSizeButton:)), for: .touchUpInside)
-        toolBar.flashlightButton.addTarget(self, action: #selector(_didClick(flashlightButton:)), for: .touchUpInside)
-        addSubview(toolBar)
-    }
-    
-    override open func layoutSubviews() {
-        super.layoutSubviews()
-        let bounds = self.bounds
-        let windowSize = bounds.size
-        let windowWidth = windowSize.width
-        let floatZore = CGFloat(0.0)
-        
-        var viewX = floatZore
-        var viewY = UIView.statusBarSize.height
-        var viewW = windowWidth
-        var viewH = UIView.navigationBarSize.height
-        toolBar.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        
-        scrollView.frame = bounds
-        scrollView.contentSize = CGSize(width: windowWidth*2.0, height: 0.0)
-        
-        let size = _takePhotoButton.bounds.size
-        viewW = size.width
-        viewH = size.height
-        viewX = (windowWidth-viewW)*0.5
-        viewY = scrollView.bounds.size.height-viewH
-        _takePhotoButton.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        
-        viewX += windowWidth
-        _takeVideoButton.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-    }
-    
-    override open func layoutSublayers(of layer: CALayer) {
-        let windowSize = layer.bounds.size
-        let windowWidth = windowSize.width
-        let floatZore = CGFloat(0.0)
-        
-        let viewX = floatZore
-        let viewY: CGFloat
-        let viewW = windowWidth
-        let viewH: CGFloat
-        switch _previewSizeType {
-        case .square:
-            viewY = UIView.statusBarNavigationBarSize.height
-            viewH = viewW
-            break
-        default:
-            viewY = floatZore
-            let size = _previewSizeType.cgSizeValue
-            viewH = floor(size.height/size.width*viewW)
-            break
-        }
-        _previewLayer.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        super.layoutSublayers(of: layer)
-    }
-    
-    open var style = KSMediaPickerCameraView.style.unknown {
-        didSet {
-            let style = self.style
-            if oldValue != style {
-                let priviewSizeButton = toolBar.priviewSizeButton
-                priviewSizeButton.status = style == .photo ? .status2 : .status1
-                _didClick(priviewSizeButton: priviewSizeButton)
-                _didSet(style: style)
-            }
-        }
-    }
-    
-    private func _didSet(style: KSMediaPickerCameraView.style) {
-        _session.beginConfiguration()
-        switch style {
-        case .photo:
-            _session.sessionPreset = .photo
-            _session.removeOutput(_videoOutput)
-            if let audioInput = _audioInput {
-                _session.removeInput(audioInput)
-            }
-            if _session.canAddOutput(_imageOutput) {
-                _session.addOutput(_imageOutput)
-            }
-            break
-        case .video:
-            _session.sessionPreset = .iFrame960x540
-            _session.removeOutput(_imageOutput)
-            if let audioInput = _audioInput, _session.canAddInput(audioInput) {
-                _session.addInput(audioInput)
-            }
-            if _session.canAddOutput(_videoOutput) {
-                _session.addOutput(_videoOutput)
-                if let connection = _videoOutput.connections.first,
-                    connection.isVideoOrientationSupported,
-                    connection.videoOrientation != .portrait {
-                    connection.videoOrientation = .portrait
-                }
-            }
-            break
-        default:
-            break
-        }
-        _session.commitConfiguration()
-    }
-    
-    private var _previewSizeType = KSMediaPickerCameraView.previewSize.square {
-        didSet {
-            setNeedsLayout()
-        }
-    }
-
-    public let startRunning: () -> Void
-    public let stopRunning: () -> Void
-    open var didTakePhotoCallback: ((KSMediaPickerCameraView, UIImage) -> Void)?
-    open var didTakeVideoCallback: ((KSMediaPickerCameraView, URL) -> Void)?
-    
-    open var isBackCameraDevice: Bool {
-        return _videoInput?.device == _backCameraDevice
-    }
-    
-    @objc private func _didClick(cameraOrientation: KSMediaPickerCameraToolBar.button) {
-        #if arch(i386) || arch(x86_64)
-        #else
-        guard let input = _videoInput else {
-            return
-        }
-        
-        let trans = CATransition()
-        trans.duration = 0.5
-        trans.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
-        trans.type = CATransitionType(rawValue: "oglFlip")
-        
-        var device = input.device
-        if device == _frontCameraDevice {
-            device = _backCameraDevice
-            trans.subtype = .fromLeft
-        } else if device == _backCameraDevice {
-            device = _frontCameraDevice
-            trans.subtype = .fromRight
-        }
-        guard let newInput = _videoInputFrom(device: device) else {
-            return
-        }
-        _session.beginConfiguration()
-        _session.removeInput(input)
-        if _session.canAddInput(newInput) {
-            _session.addInput(newInput)
-            _videoInput = newInput
-            if self.style == .video {
-                toolBar.type = .videos
-            } else {
-                toolBar.type = device == _backCameraDevice ? .photos : .noFlashlightPhotos
-            }
-        } else {
-            _session.addInput(input)
-        }
-        _session.commitConfiguration()
-        _previewLayer.add(trans, forKey: nil)
-        #endif
-    }
-    
-    private func _videoInputFrom(device: AVCaptureDevice) -> AVCaptureDeviceInput? {
-        let input: AVCaptureDeviceInput?
-        do {
-            try input = AVCaptureDeviceInput(device: device)
-        } catch {
-            input = nil
-        }
-        return input
-    }
-    
-    @objc private func _didClick(priviewSizeButton: KSMediaPickerCameraToolBar.button) {
-        let status = priviewSizeButton.status
-        let newStatus: KSMediaPickerCameraToolBar.button.status
-        let sizeType: KSMediaPickerCameraView.previewSize
-        switch self.style {
-        case .photo:
-            switch status {
-            case .status1://1:1
-                newStatus = .status2
-                sizeType = .hdPicture
-                toolBar.style = .lightContent
-                break
-            case .status2://3:4
-                newStatus = .status1
-                sizeType = .square
-                toolBar.style = .darkContent
-                break
-            default:
-                return
-            }
-            break
-        case .video:
-            switch status {
-            case .status1://1:1
-                newStatus = .status3
-                sizeType = .hdVideo
-                break
-            case .status3://9:16
-                newStatus = .status1
-                sizeType = .square
-                break
-            default:
-                return
-            }
-            break
-        default:
-            return
-        }
-        priviewSizeButton.status = newStatus
-        _previewSizeType = sizeType
-    }
-    
-    @objc private func _didClick(flashlightButton: KSMediaPickerCameraToolBar.button) {
-        guard let device = _videoInput?.device,
-        self.style == .photo else {
-            return
-        }
-        try? device.lockForConfiguration()
-        let status = flashlightButton.status
-        let newStatus: KSMediaPickerCameraToolBar.button.status
-        let flashMode: AVCaptureDevice.FlashMode
-        switch status {
-        case .status1://auto
-            newStatus = .status2
-            flashMode = .on
-            break
-        case .status2://on
-            newStatus = .status3
-            flashMode = .off
-            break
-        case .status3://off
-            newStatus = .status1
-            flashMode = .auto
-            break
-        }
-        if device.isFlashModeSupported(flashMode) {
-            flashlightButton.status = newStatus
-            device.flashMode = flashMode
-        }
-    }
-    
-    @objc private func _didClick(takePhotoButton: KSBorderButton) {
-        guard let conntion = _imageOutput.connection(with: .video) else {
-            return
-        }
-        _imageOutput.captureStillImageAsynchronously(from: conntion, completionHandler: _didTakePhotoAfter)
-    }
-    
-    private func _didTakePhotoAfter(imageDataSampleBuffer: CMSampleBuffer?, error: Error?) {
-        guard let k_imageDataSampleBuffer = imageDataSampleBuffer,
-            let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(k_imageDataSampleBuffer) else {
-            return
-        }
-        let image = UIImage(JPEGData: imageData, of: _previewSizeType.cgSizeValue)
-        stopRunning()
-        if didTakePhotoCallback != nil {
-            didTakePhotoCallback!(self, image)
-        }
-    }
-    
-    @objc private func _didClick(takeVideoButton: RECButton) {
-        if takeVideoButton.isRunning {
-            _session.stopRunning()
-            _videoOutput.stopRecording()
-        } else {
-            takeVideoButton.startRunning()
-            let dateFormat = DateFormatter()
-            dateFormat.dateFormat = "yyyy_MM_dd_HH_mm_ss"
-            let tmpPath = NSTemporaryDirectory()
-            let filePath = tmpPath+dateFormat.string(from: Date())+".mov"
-            let fileURL = URL(fileURLWithPath: filePath)
-            _videoOutput.startRecording(to: fileURL, recordingDelegate: self)
-            _session.startRunning()
-        }
-    }
-    
-    private func _didFinishRecVideo(button: RECButton) {
-        if _videoFileURL != nil {
-            if didTakeVideoCallback != nil {
-                didTakeVideoCallback!(self, _videoFileURL!)
-            }
-            _videoFileURL = nil
-        }
-    }
-    
-    public func fileOutput(_ output: AVCaptureFileOutput, didStartRecordingTo fileURL: URL, from connections: [AVCaptureConnection]) {
-        
-    }
-    
-    private var _videoFileURL: URL?
-    public func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) {
-        _videoFileURL = outputFileURL
-        _takeVideoButton.stopRunning()
-    }
-}

+ 0 - 196
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerRECButton.swift

@@ -1,196 +0,0 @@
-//
-//  KSMediaPickerRECButton.swift
-// 
-//
-//  Created by kinsun on 2019/3/13.
-//
-
-import UIKit
-
-extension KSMediaPickerCameraView {
-    
-    open class RECButton: UIControl {
-        
-        required public init?(coder aDecoder: NSCoder) {
-            fatalError("init(coder:) has not been implemented")
-        }
-        
-        private let _recLayer = RECButton.RECLayer()
-        
-        override public init(frame: CGRect) {
-            super.init(frame: frame)
-            backgroundColor = .clear
-            layer.addSublayer(_recLayer)
-        }
-        
-        override open func layoutSublayers(of layer: CALayer) {
-            super.layoutSublayers(of: layer)
-            _recLayer.frame = layer.bounds
-        }
-        
-        override open var isHighlighted: Bool {
-            didSet {
-                alpha = isHighlighted ? 0.5 : 1.0
-            }
-        }
-        
-        open var didStopRunningCallback: ((RECButton) -> Void)?
-        open var numberOfSecondsSpentInATurn = TimeInterval(30.0)
-        open var maxRunningSeconds = TimeInterval(60.0)
-        private var _currentTime = TimeInterval(0.0)
-        private var _isRunning = false
-        open var isRunning: Bool {
-            get {
-                return _isRunning
-            }
-        }
-        
-        private var _timer: Timer?
-        
-        open func startRunning() {
-            stopRunning()
-            if !_isRunning {
-                _isRunning = true
-                let timer = Timer(timeInterval: 0.1, target: self, selector: #selector(_timerArrive(_:)), userInfo: nil, repeats: true)
-                RunLoop.main.add(timer, forMode: .common)
-                _timer = timer
-                _recLayer.isChangeToSquare = true
-                _timer?.fire()
-            }
-        }
-        
-        open func stopRunning() {
-            if _isRunning {
-                _timer?.invalidate()
-                _timer = nil
-                _recLayer.isChangeToSquare = false
-                _recLayer.progress = 0.0
-                _currentTime = 0.0
-                _isRunning = false
-                if didStopRunningCallback != nil {
-                    didStopRunningCallback!(self)
-                }
-            }
-        }
-        
-        @objc private func _timerArrive(_ timer: Timer) {
-            _currentTime += 0.1
-            _recLayer.progress = Double(_currentTime/numberOfSecondsSpentInATurn)
-            if _currentTime >= maxRunningSeconds {
-                stopRunning()
-            }
-        }
-    }
-
-}
-
-extension KSMediaPickerCameraView.RECButton {
-    
-    private class RECLayer: CALayer {
-        
-        required init?(coder aDecoder: NSCoder) {
-            fatalError("init(coder:) has not been implemented")
-        }
-        
-        private let _backCircleLayer = {() -> CAShapeLayer in
-            let backCircleLayer = CAShapeLayer()
-            backCircleLayer.fillColor = UIColor.clear.cgColor
-            backCircleLayer.strokeColor = UIColor.ks_white.withAlphaComponent(0.4).cgColor
-            backCircleLayer.lineWidth = 8.0
-            return backCircleLayer
-        }()
-        
-        private let _frontCircleLayer = {() -> CAShapeLayer in
-            let frontCircleLayer = CAShapeLayer()
-            frontCircleLayer.fillColor = UIColor.clear.cgColor
-            frontCircleLayer.strokeColor = UIColor.ks_white.cgColor
-            frontCircleLayer.lineWidth = 8.0
-            return frontCircleLayer
-        }()
-        
-        private let _centerLayer = {() -> CALayer in
-            let centerLayer = CALayer()
-            centerLayer.backgroundColor = UIColor.ks_white.cgColor
-            centerLayer.masksToBounds = true
-            return centerLayer
-        }()
-        
-        open var isChangeToSquare = false {
-            didSet {
-                setNeedsLayout()
-            }
-        }
-        
-        open var progress = 0.0 {
-            didSet {
-                setNeedsDisplay()
-            }
-        }
-        
-        override public init() {
-            super.init()
-            backgroundColor = UIColor.clear.cgColor
-            addSublayer(_backCircleLayer)
-            addSublayer(_frontCircleLayer)
-            addSublayer(_centerLayer)
-        }
-        
-        override func layoutSublayers() {
-            super.layoutSublayers()
-            let windowSize = bounds.size
-            let windowWidth = windowSize.width
-            let windowHeight = windowSize.height
-            
-            let lineWidth = _backCircleLayer.lineWidth
-            let x = lineWidth*0.5
-            let y = x
-            let width = windowWidth-x*2.0
-            let height = windowHeight-y*2.0
-            let frame = CGRect(x: x, y: y, width: width, height: height)
-            _backCircleLayer.frame = frame
-            _frontCircleLayer.frame = frame
-            _backCircleLayer.path = UIBezierPath(ovalIn: _backCircleLayer.bounds).cgPath
-            
-            let viewX: CGFloat
-            let viewY: CGFloat
-            let viewW: CGFloat
-            let viewH: CGFloat
-            if isChangeToSquare {
-                viewW = windowWidth*0.5
-                viewH = viewW
-                viewX = (windowWidth-viewW)*0.5
-                viewY = (windowHeight-viewH)*0.5
-                _centerLayer.cornerRadius = 5.0
-            } else {
-                viewX = _backCircleLayer.lineWidth
-                viewY = viewX
-                viewW = windowWidth-viewX*2.0
-                viewH = windowHeight-viewY*2.0
-                _centerLayer.cornerRadius = viewW*0.5
-            }
-            _centerLayer.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        }
-        
-        override func draw(in ctx: CGContext) {
-            super.draw(in: ctx)
-            let circlePath: UIBezierPath
-            let size = _frontCircleLayer.bounds.size
-            let width = size.width
-            let height = size.height
-            let center = CGPoint(x: width*0.5, y: height*0.5)
-            let radius = min(width, height)*0.5
-            let pi = CGFloat.pi*2.0
-            let startAngle = -(pi*0.25)
-            let endAngle = CGFloat(progress)*pi+startAngle
-            
-            let isDoubleLoop = Int(progress)%2 == 0
-            if isDoubleLoop {
-                circlePath = UIBezierPath(arcCenter: center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: true)
-            } else {
-                circlePath = UIBezierPath(arcCenter: center, radius: radius, startAngle: endAngle, endAngle: startAngle, clockwise: true)
-            }
-            _frontCircleLayer.path = circlePath.cgPath
-        }
-    }
-
-}

+ 4 - 185
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerView.swift

@@ -7,63 +7,6 @@
 
 import UIKit
 
-extension KSMediaPickerView {
-    
-    private class segmentedControl: KSSegmentedControl {
-        
-        fileprivate enum style {
-            case light
-            case dark
-        }
-        
-        private var _style = KSMediaPickerView.segmentedControl.style.light {
-            didSet {
-                _didSet(style: _style)
-            }
-        }
-        open var style: KSMediaPickerView.segmentedControl.style {
-            set {
-                if newValue != _style {
-                    _style = newValue
-                }
-            }
-            get {
-                return _style
-            }
-        }
-        
-        override public init(frame: CGRect) {
-            let bundle = Bundle.main
-            let items = ["MEDIA_PICKER_ALBUM_TAB_TITLE".ks_mediaPickerKeyToLocalized(in: bundle),
-                         "MEDIA_PICKER_CAMERA_TAB_TITLE".ks_mediaPickerKeyToLocalized(in: bundle),
-                         "MEDIA_PICKER_VIDEOCORDER_TAB_TITLE".ks_mediaPickerKeyToLocalized(in: bundle)]
-            super.init(frame: frame, items: items)
-            font = UIFont.systemFont(ofSize: 17.0)
-            _didSet(style: .light)
-        }
-        
-        private func _didSet(style: KSMediaPickerView.segmentedControl.style) {
-            switch style {
-            case .light:
-                normalTextColor = .ks_wordMain_2
-                selectedTextColor = .ks_main
-                indndicatorColor = .ks_main
-                break
-            case .dark:
-                let color = UIColor.ks_white
-                normalTextColor = color
-                selectedTextColor = color
-                indndicatorColor = color
-                break
-            }
-        }
-        
-        required init?(coder aDecoder: NSCoder) {
-            fatalError("init(coder:) has not been implemented")
-        }
-    }
-}
-
 open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
     
     required public init?(coder aDecoder: NSCoder) {
@@ -106,8 +49,6 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         return toolBarSafeAreaView
     }()
     
-    public let segmentedControl: KSSegmentedControl = KSMediaPickerView.segmentedControl(frame: .zero)
-    
     private let _blackBackgroundLayer = {() -> CALayer in
         let blackBackgroundLayer = CALayer()
         blackBackgroundLayer.opacity = 0.0
@@ -115,8 +56,6 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         return blackBackgroundLayer
     }()
     
-    public let cameraView = KSMediaPickerCameraView()
-    
     override public init(frame: CGRect) {
         super.init(frame: frame)
         backgroundColor = .ks_white
@@ -126,9 +65,7 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         scrollView.addSubview(previewView)
         albumNavigationView.nextButton.isEnabled = false
         scrollView.addSubview(albumNavigationView)
-        
-        cameraView.scrollView.delegate = self
-        scrollView.addSubview(cameraView)
+                
         
         scrollView.delegate = self
         addSubview(scrollView)
@@ -141,13 +78,7 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         }
         collectionView.scrollViewDidEndDraggingCallback = {[weak self] (scrollView, decelerate) in
             self?._collectionViewDidEndDragging(scrollView, decelerate: decelerate)
-        }
-        self.segmentedControl.didClickItem = {[weak self] (segmentedControl, index) in
-            self?.didClick(segmentedControl: segmentedControl, index: index)
-        }
-        
-        _toolBarSafeAreaView.addSubview(self.segmentedControl)
-        addSubview(_toolBarSafeAreaView)
+        }        
     }
     
     override open func layoutSublayers(of layer: CALayer) {
@@ -175,11 +106,7 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         var viewX = floatZore
         var viewY = windowHeight-viewH
         _toolBarSafeAreaView.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        
-        viewY = floatZore
-        viewH = 48.0
-        self.segmentedControl.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        
+                
         let margin = CGFloat(3.0)
         let columnCount = UInt(4)
         let itemW = floor((windowWidth-margin*CGFloat(columnCount-1))/CGFloat(columnCount))
@@ -223,13 +150,7 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         collectionView.frame = frame
         let conetntInset = UIEdgeInsets(top: previewViewFrameMaxY+3.0, left: 0.0, bottom: 0.0, right: 0.0)
         collectionView.contentInset = conetntInset
-        collectionView.scrollIndicatorInsets = conetntInset
-        
-        viewX = collectionView.frame.maxX
-        viewY = floatZore
-        viewW = windowWidth
-        viewH = windowHeight-toolBarSafeAreaViewHeight
-        cameraView.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
+        collectionView.scrollIndicatorInsets = conetntInset                
     }
     
     private var _baseY: CGFloat?
@@ -381,106 +302,4 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         }
     }
     
-    public func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        switch scrollView {
-        case self.scrollView:
-            let offsetX = scrollView.contentOffset.x
-            let width = scrollView.bounds.size.width
-            guard offsetX <= scrollView.contentSize.width-width else {
-                return
-            }
-            let segmentedControl = self.segmentedControl
-            let page = UInt(ceil((offsetX-width*0.5)/width))
-            if page != segmentedControl.selectedSegmentIndex {
-                segmentedControl.selectedSegmentIndex = page
-            }
-            segmentedControl.updateIndicatorProportion(offsetX/width)
-            return
-        case cameraView.scrollView:
-            let offsetX = scrollView.contentOffset.x
-            let width = scrollView.contentSize.width-scrollView.bounds.size.width
-            CATransaction.begin()
-            _blackBackgroundLayer.opacity = Float(offsetX/width)
-            CATransaction.commit()
-            let seg = self.segmentedControl as! KSMediaPickerView.segmentedControl
-            let toolBar = cameraView.toolBar
-            let page = ceil((offsetX-width*0.5)/width)
-            if page == 0.0 {
-                seg.style = .light
-                toolBar.style = .darkContent
-                toolBar.type = cameraView.isBackCameraDevice ? .photos : .noFlashlightPhotos
-            } else {
-                seg.style = .dark
-                toolBar.style = .lightContent
-                toolBar.type = .videos
-            }
-            let u_page = UInt(page)+1
-            if u_page != seg.selectedSegmentIndex {
-                seg.selectedSegmentIndex = u_page
-            }
-            seg.updateIndicatorProportion((offsetX+width)/width)
-            return
-        default:
-            return
-        }
-    }
-    
-    public func scrollViewDidEndScroll(_ scrollView: UIScrollView) {
-        let page = self.segmentedControl.selectedSegmentIndex
-        if page == 0 {
-            cameraView.stopRunning()
-            if let callback = cameraView.toolBar.didChangedStyleCallback {
-                callback(.darkContent)
-            }
-            previewView.videoPlay()
-        } else {
-            previewView.videoPause()
-            if page == 1 {
-                cameraView.style = .photo
-            } else {
-                cameraView.style = .video
-            }
-            if let callback = cameraView.toolBar.didChangedStyleCallback {
-                callback(cameraView.toolBar.style)
-            }
-            cameraView.startRunning()
-        }
-    }
-    
-    public func didClick(segmentedControl: KSSegmentedControl, index: Int) {
-        switch index {
-        case 0:
-            scrollView.setContentOffset(.zero, animated: true)
-            cameraView.scrollView.contentOffset = .zero
-            break
-        case 1:
-            switch segmentedControl.selectedSegmentIndex {
-            case 0:
-                scrollView.setContentOffset(CGPoint(x: bounds.size.width, y: 0.0), animated: true)
-                cameraView.scrollView.contentOffset = .zero
-                break
-            case 2:
-                cameraView.scrollView.setContentOffset(.zero, animated: true)
-                break
-            default:
-                break
-            }
-            break
-        case 2:
-            switch segmentedControl.selectedSegmentIndex {
-            case 0:
-                scrollView.contentOffset = CGPoint(x: bounds.size.width, y: 0.0)
-                cameraView.scrollView.setContentOffset(CGPoint(x: bounds.size.width, y: 0.0), animated: true)
-                break
-            case 1:
-                cameraView.scrollView.setContentOffset(CGPoint(x: bounds.size.width, y: 0.0), animated: true)
-                break
-            default:
-                break
-            }
-            break
-        default:
-            break
-        }
-    }
 }

+ 537 - 71
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPickerController.swift

@@ -6,74 +6,540 @@
 //  Copyright © 2019 RainbowPlanet. All rights reserved.
 //
 
-import UIKit
-import RxSwift
-import JXSegmentedView
-
-class PublishMediaPickerController: BaseViewController {
-    
-    var orderNumber: String? {
-        didSet {
-            numLbl.text = self.orderNumber
-        }
-    }
-    
-    override func viewDidLoad() {
-        super.viewDidLoad()
-        setupViews()
-        setupData()
-        
-    }
-    
-    override func setupViews() {
-        navigationBar.title = "mediaPicker"
-        
-        self.view.backgroundColor = kf7f8faColor
-        
-        let serialNumView = UIView()
-        serialNumView.backgroundColor = kffffffColor
-        self.view.addSubview(serialNumView)
-        serialNumView.snp.makeConstraints { (make) in
-            make.left.right.equalToSuperview()
-            make.top.equalToSuperview().offset(kSafeStatusBarHeight+40+10)
-            make.height.equalTo(44)
-        }
-        
-        let titleLbl = UILabel()
-        titleLbl.text = "订单编号"
-        titleLbl.textColor = k999999Color
-        titleLbl.font = kRegularFont13
-        serialNumView.addSubview(titleLbl)
-        titleLbl.snp.makeConstraints { (make) in
-            make.left.equalTo(14)
-            make.centerY.equalToSuperview()
-            make.height.equalTo(20)
-        }
-        
-        serialNumView.addSubview(numLbl)
-        numLbl.snp.makeConstraints { (make) in
-            make.centerY.equalTo(titleLbl.snp_centerY)
-            make.left.equalTo(titleLbl.snp_right).offset(20)
-            make.height.equalTo(titleLbl)
-        }
-        
-    }
-    
-    override func setupData() {
-        
-    }
-    
-    private lazy var numLbl: UILabel = {
-        let numLbl = UILabel()
-        numLbl.textColor = k333333Color
-        numLbl.font = kRegularFont13
-        return numLbl
-    }()
-    
-}
-
-extension PublishMediaPickerController : JXSegmentedListContainerViewListDelegate {
-    func listView() -> UIView {
-        return view
-    }
-}
+//import UIKit
+//import Photos
+//import RxSwift
+//import JXSegmentedView
+//
+//
+//@objc public protocol PublishMediaPickerControllerDelegate: NSObjectProtocol {
+//
+//    @objc optional func mediaPicker(_ mediaPicker: PublishMediaPickerController, didFinishSelected outputArray: [KSMediaPickerOutputModel])
+//}
+//
+//open class PublishMediaPickerController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
+//
+//    @objc public enum mediaType : Int {
+//        case all        = 0
+//        case picture    = 1
+//        case video      = 2
+//    }
+//
+//    @objc public let maxItemCount: UInt
+//    @objc public let maxVideoItemCount: UInt
+//    @objc public let maxPictureItemCount: UInt
+//    @objc public let mediaType: PublishMediaPickerController.mediaType
+//    @objc open weak var delegate: PublishMediaPickerControllerDelegate?
+//
+//    /// 限制单一媒体类型混合显示构造函数,此函数为指定初始化器
+//    ///
+//    /// - Parameters:
+//    ///   - maxVideoItemCount: 选择视频的最大数量
+//    ///   - maxPictureItemCount: 选择图片的最大数量
+//    @objc public init(maxVideoItemCount: UInt, maxPictureItemCount: UInt) {
+//        if maxVideoItemCount == 0 {
+//            self.mediaType = .picture
+//        } else if maxPictureItemCount == 0 {
+//            self.mediaType = .video
+//        } else {
+//            self.mediaType = .all
+//        }
+//        maxItemCount = maxVideoItemCount+maxPictureItemCount
+//        self.maxPictureItemCount = maxPictureItemCount
+//        self.maxVideoItemCount = maxVideoItemCount
+//        super.init(nibName: nil, bundle: nil)
+//    }
+//
+//    /// 自由视频与图片构造函数,就是图片加视频的总数为maxItemCount,不对每种做限制只对总数做限制,此函数为指定初始化器
+//    ///
+//    /// - Parameter maxItemCount: 选择媒体的最大总数
+//    @objc public init(maxItemCount: UInt = 9) {
+//        self.mediaType = .all
+//        self.maxItemCount = maxItemCount
+//        maxPictureItemCount = 0
+//        maxVideoItemCount = 0
+//        super.init(nibName: nil, bundle: nil)
+//    }
+//
+//    @nonobjc required public init?(coder aDecoder: NSCoder) {
+//        fatalError("init(coder:) has not been implemented")
+//    }
+//
+//    private static let k_image_item_class = KSMediaPickerViewImageCell.self
+//    private static let k_video_item_class = KSMediaPickerViewVideoCell.self
+//    private static let k_image_item_iden = NSStringFromClass(k_image_item_class)
+//    private static let k_video_item_iden = NSStringFromClass(k_video_item_class)
+//
+//    override open func loadView() {
+//        let view = KSMediaPickerView()
+//
+//        let nav = view.albumNavigationView
+//        nav.closeButton.addTarget(self, action: #selector(_didClick(closeButton:)), for: .touchUpInside)
+//        nav.nextButton.addTarget(self, action: #selector(_didClick(nextButton:)), for: .touchUpInside)
+//
+//        let classObj = PublishMediaPickerController.self
+//        let collectionView = view.collectionView
+//        collectionView.register(classObj.k_image_item_class, forCellWithReuseIdentifier: classObj.k_image_item_iden)
+//        collectionView.register(classObj.k_video_item_class, forCellWithReuseIdentifier: classObj.k_video_item_iden)
+//        collectionView.delegate = self
+//        collectionView.dataSource = self
+//
+//        let cameraView = view.cameraView
+//        cameraView.didTakePhotoCallback = {[weak self] (cameraView, image) in
+//            self?._didTakePhotoFinish(cameraView: cameraView, image: image)
+//        }
+//        cameraView.didTakeVideoCallback = {[weak self] (cameraView, fileURL) in
+//            self?._didTakeVideoFinish(cameraView: cameraView, fileURL: fileURL)
+//        }
+//        let toolBar = cameraView.toolBar
+//        toolBar.closeButton.addTarget(self, action: #selector(_didClick(closeButton:)), for: .touchUpInside)
+//        toolBar.didChangedStyleCallback = { (style) in
+//            UIApplication.shared.setStatusBarStyle(style == .lightContent ? .lightContent : .default, animated: true)
+//        }
+//        self.view = view
+//    }
+//
+//    override open func viewDidDisappear(_ animated: Bool) {
+//        super.viewDidDisappear(animated)
+//        (view as! KSMediaPickerView).previewView.videoPause()
+//    }
+//
+//    override open func viewDidAppear(_ animated: Bool) {
+//        super.viewDidAppear(animated)
+//        (view as! KSMediaPickerView).previewView.videoPlay()
+//    }
+//
+//    override open func viewDidLoad() {
+//        super.viewDidLoad()
+//        let cancelHandler: ((UIAlertAction) -> Void) = {[weak self] (action) in
+//            self?._didClick(closeButton: nil)
+//        }
+//        PublishMediaPickerController.authorityCheckUp(controller: self, type: .picture, completionHandler: {[weak self] (type) in
+//            if let obj = self {
+//                PublishMediaPickerController.authorityCheckUp(controller: obj, type: .video, completionHandler: { (type) in
+//                    PublishMediaPickerController.authorityAudioCheckUp(controller: obj, completionHandler: {
+//                        DispatchQueue.global().async {
+//                            let assetCollections = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .any, options: nil)
+//                            let regularAssetCollections = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .albumRegular, options: nil)
+//                            let array = [assetCollections, regularAssetCollections]
+//                            self?._set(assetData: array)
+//                        }
+//                    }, cancelHandler: cancelHandler)
+//                }, cancelHandler: cancelHandler)
+//            }
+//            }, cancelHandler: cancelHandler)
+//    }
+//
+//    private var _albumList: [KSMediaPickerAlbumModel]?
+//
+//    private func _set(assetData: [PHFetchResult<PHAssetCollection>]) {
+//        _albumList = KSMediaPickerAlbumModel.albumModel(from: assetData, mediaType: self.mediaType)
+//        DispatchQueue.main.async(execute: _loadAssetDataFinish)
+//    }
+//
+//    private var _selectedAlbum: KSMediaPickerAlbumModel? {
+//        didSet {
+//            let view = self.view as! KSMediaPickerView
+//            _updateHighlightedItemStatus()
+//            if let itemModel = _selectedAlbum?.assetList.first {
+//                let isStandard = _selectedAssetArray.count == 0 || itemModel == (_selectedAssetArray.firstObject as! KSMediaPickerItemModel)
+//                view.previewView.set(itemModel: itemModel, isStandard: isStandard)
+//                itemModel.isHighlight = true
+//            }
+//            _highlightedItemIndexPath = IndexPath(item: 0, section: 0)
+//            view.collectionView.reloadData()
+//        }
+//    }
+//
+//    private func _loadAssetDataFinish() {
+//        _selectedAlbum = _albumList?.first
+//    }
+//
+//    @objc private func _didClick(closeButton: UIButton?) {
+//        self.dismiss(animated: true, completion: nil)
+//    }
+//
+//    @objc private func _didClick(nextButton: UIButton) {
+//        (view as! KSMediaPickerView).previewView.saveCurrentState()
+//        print("----选择完成,传递_selectedAssetArray")
+//    }
+//
+//    private func _didClickCell(collectionViewCell: KSMediaPickerViewImageCell) -> UInt {
+//        guard let itemModel = collectionViewCell.itemModel, !itemModel.isLoseFocus else {
+//            return 0
+//        }
+//        let indexPath = (view as! KSMediaPickerView).collectionView.indexPath(for: collectionViewCell)
+//        if indexPath != nil {
+//            _updateHighlightItem(at: indexPath!)
+//        }
+//
+//        if itemModel.index > 0 {
+//            return _remove(itemModel: itemModel)
+//        } else {
+//            return _add(itemModel: itemModel)
+//        }
+//    }
+//
+//    private func _didTakePhotoFinish(cameraView: KSMediaPickerCameraView, image: UIImage) {
+//        var createdAssetID: String? = nil
+//        try? PHPhotoLibrary.shared().performChangesAndWait {
+//            let request = PHAssetChangeRequest.creationRequestForAsset(from: image)
+//            createdAssetID = request.placeholderForCreatedAsset?.localIdentifier
+//        }
+//        guard let k_id = createdAssetID,
+//            let asset = PHAsset.fetchAssets(withLocalIdentifiers: [k_id], options: nil).firstObject else {
+//                return
+//        }
+//        _update(asset: asset)
+//    }
+//
+//    private func _didTakeVideoFinish(cameraView: KSMediaPickerCameraView, fileURL: URL) {
+//        var createdAssetID: String? = nil
+//        try? PHPhotoLibrary.shared().performChangesAndWait {
+//            let request = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: fileURL)
+//            createdAssetID = request?.placeholderForCreatedAsset?.localIdentifier
+//        }
+//        guard let k_id = createdAssetID,
+//            let asset = PHAsset.fetchAssets(withLocalIdentifiers: [k_id], options: nil).firstObject else {
+//                return
+//        }
+//        _update(asset: asset)
+//    }
+//
+//    private func _update(asset: PHAsset) {
+//        _updateHighlightedItemStatus()
+//        let itemModel = KSMediaPickerItemModel(asset)
+//        itemModel.isHighlight = true
+//        _selectedAlbum?.assetList.insert(itemModel, at: 0)
+//        let indexPath = IndexPath(item: 0, section: 0)
+//        _highlightedItemIndexPath = indexPath
+//        let isStandard = _selectedAssetArray.count == 0 || itemModel == (_selectedAssetArray.firstObject as! KSMediaPickerItemModel)
+//        let view = self.view as! KSMediaPickerView
+//        view.previewView.set(itemModel: itemModel, isStandard: isStandard)
+//        let collectionView = view.collectionView
+//        collectionView.performBatchUpdates({
+//            collectionView.insertItems(at: [indexPath])
+//        }) {[weak self] (finished) in
+//            let index = self?._add(itemModel: itemModel) ?? 0
+//            if index > 0 {
+//                itemModel.index = index
+//            } else {
+//                itemModel.isLoseFocus = true
+//            }
+//            collectionView.reloadItems(at: [indexPath])
+//            view.collectionViewScrollToTop()
+//            view.didClick(segmentedControl: view.segmentedControl, index: 0)
+//        }
+//    }
+//
+//    private lazy var _selectedAssetArray = NSMutableArray(capacity: Int(maxItemCount))
+//
+//    private func _add(itemModel: KSMediaPickerItemModel) -> UInt {
+//        let selectedAssetArray = _selectedAssetArray
+//        let count = UInt(selectedAssetArray.count)
+//        var k_maxItemCount = maxItemCount
+//        let assetMediaType = (selectedAssetArray.firstObject as? KSMediaPickerItemModel)?.asset.mediaType ?? itemModel.asset.mediaType
+//        var isSingleType = false
+//        if self.mediaType == .all {
+//            if assetMediaType == .video && maxVideoItemCount != 0 {
+//                k_maxItemCount = maxVideoItemCount
+//                _currentSingleType = .video
+//            } else if assetMediaType == .image && maxPictureItemCount != 0 {
+//                k_maxItemCount = maxPictureItemCount
+//                _currentSingleType = .picture
+//            }
+//            if _currentSingleType != nil && count == 0 {
+//                isSingleType = true
+//            }
+//        }
+//        guard count < k_maxItemCount else {
+//            return 0
+//        }
+//        selectedAssetArray.add(itemModel)
+//        let lastCount = count+1
+//        let isLastItem = lastCount == k_maxItemCount
+//        let view = self.view as! KSMediaPickerView
+//        if isSingleType || isLastItem {
+//            let assetList = _selectedAlbum!.assetList
+//            var indexPaths = Array<IndexPath>()
+//            for (i, k_itemModel) in assetList.enumerated() {
+//                let isOk = (isSingleType && k_itemModel.asset.mediaType != assetMediaType) || (isLastItem && !selectedAssetArray.contains(k_itemModel))
+//                if isOk && !k_itemModel.isLoseFocus {
+//                    k_itemModel.isLoseFocus = true
+//                    let indexPath = IndexPath(item: i, section: 0)
+//                    indexPaths.append(indexPath)
+//                }
+//            }
+//
+//            let collectionView = view.collectionView
+//            collectionView.performBatchUpdates({
+//                collectionView.reloadItems(at: indexPaths)
+//            }, completion: nil)
+//        }
+//        view.albumNavigationView.nextButton.isEnabled = lastCount > 0
+//        return lastCount
+//    }
+//
+//    private var _currentSingleType: PublishMediaPickerController.mediaType?
+//
+//    private func _remove(itemModel: KSMediaPickerItemModel) -> UInt {
+//        let selectedAssetArray = _selectedAssetArray
+//        let index = selectedAssetArray.index(of: itemModel)
+//        let count = selectedAssetArray.count
+//        guard index >= 0, index < count else {
+//            return 0
+//        }
+//        itemModel.index = 0
+//        selectedAssetArray.removeObject(at: index)
+//
+//        let view = self.view as! KSMediaPickerView
+//        let assetMediaType = itemModel.asset.mediaType
+//        var k_maxItemCount = maxItemCount
+//        var needUpdateSingleType = false
+//        let isSingleType = _currentSingleType != nil
+//        if isSingleType {
+//            if _currentSingleType! == .video {
+//                k_maxItemCount = maxVideoItemCount
+//            } else if _currentSingleType! == .picture {
+//                k_maxItemCount = maxPictureItemCount
+//            }
+//            needUpdateSingleType = count == 1
+//        }
+//        let needUpdateIndexNumber = index != count-1
+//        let needUpdateFocus = count == k_maxItemCount
+//        if needUpdateIndexNumber && needUpdateFocus {
+//            let assetList = _selectedAlbum!.assetList
+//            var j = Int(1)
+//            for k_itemModel in assetList {
+//                if selectedAssetArray.contains(k_itemModel) {
+//                    k_itemModel.index = UInt(j)
+//                    j += 1
+//                } else {
+//                    let ok = isSingleType ? (assetMediaType == k_itemModel.asset.mediaType) : true
+//                    if (needUpdateSingleType || (ok && k_itemModel.isLoseFocus)) {
+//                        k_itemModel.isLoseFocus = false
+//                    }
+//                }
+//            }
+//            let collectionView = view.collectionView
+//            collectionView.reloadData()
+//        } else if needUpdateIndexNumber {
+//            let assetList = _selectedAlbum!.assetList as NSArray
+//            let assetListCount = assetList.count
+//            var indexPaths = Array<IndexPath>()
+//            for (i, k_itemModel) in selectedAssetArray.enumerated() {
+//                let l_itemModel = k_itemModel as! KSMediaPickerItemModel
+//                l_itemModel.index = UInt(i+1)
+//                let k_index = assetList.index(of: l_itemModel)
+//                if k_index >= 0 && k_index < assetListCount {
+//                    let indexPath = IndexPath(item: k_index, section: 0)
+//                    indexPaths.append(indexPath)
+//                }
+//            }
+//            let collectionView = view.collectionView
+//            collectionView.performBatchUpdates({
+//                collectionView.reloadItems(at: indexPaths)
+//            }, completion: nil)
+//        } else {
+//            let collectionView = view.collectionView
+//            let assetList = _selectedAlbum!.assetList
+//            if needUpdateSingleType {
+//                for k_itemModel in assetList {
+//                    k_itemModel.isLoseFocus = false
+//                }
+//                collectionView.reloadData()
+//            } else if needUpdateFocus {
+//                var indexPaths = Array<IndexPath>()
+//                for (i, k_itemModel) in assetList.enumerated() {
+//                    let ok = isSingleType ? (assetMediaType == k_itemModel.asset.mediaType) : true
+//                    if (ok && k_itemModel.isLoseFocus) {
+//                        k_itemModel.isLoseFocus = false
+//                        let indexPath = IndexPath(item: i, section: 0)
+//                        indexPaths.append(indexPath)
+//                    }
+//                }
+//                collectionView.performBatchUpdates({
+//                    collectionView.reloadItems(at: indexPaths)
+//                }, completion: nil)
+//            }
+//        }
+//        let albumNavigationView = view.albumNavigationView
+//        albumNavigationView.nextButton.isEnabled = selectedAssetArray.count > 0
+//        return 0
+//    }
+//
+//    public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+//        return _selectedAlbum?.assetList.count ?? 0
+//    }
+//
+//    public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+//        let itemModel = _selectedAlbum?.assetList[indexPath.item]
+//        let mediaType = itemModel?.asset.mediaType
+//        let isPictureCell = mediaType == .image
+//        let iden = isPictureCell ? PublishMediaPickerController.k_image_item_iden : PublishMediaPickerController.k_video_item_iden
+//        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: iden, for: indexPath) as! KSMediaPickerViewImageCell
+//        if cell.didSelectedItem == nil {
+//            cell.didSelectedItem = {[weak self] (collectionViewCell) -> UInt in
+//                return self?._didClickCell(collectionViewCell: collectionViewCell) ?? 0
+//            }
+//            cell.isMultipleSelected = maxItemCount > 1
+//        }
+//        cell.itemModel = itemModel
+//        return cell
+//    }
+//
+//    private var _highlightedItemIndexPath: IndexPath?
+//
+//    public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+//        collectionView.deselectItem(at: indexPath, animated: true)
+//        _updateHighlightItem(at: indexPath)
+//    }
+//
+//    private func _updateHighlightItem(at indexPath: IndexPath) {
+//        let view = self.view as! KSMediaPickerView
+//        guard indexPath != _highlightedItemIndexPath,
+//            let cell = view.collectionView.cellForItem(at: indexPath) as? KSMediaPickerViewImageCell,
+//            let itemModel = cell.itemModel,
+//            !itemModel.isLoseFocus else {
+//                return
+//        }
+//        let isStandard = _selectedAssetArray.count == 0 || itemModel == (_selectedAssetArray.firstObject as! KSMediaPickerItemModel)
+//        let previewView = view.previewView
+//        previewView.set(itemModel: itemModel, isStandard: isStandard)
+//        ///滚动至选择item区域
+//        let collectionView = view.collectionView
+//        let top = collectionView.contentInset.top
+//        var frame = collectionView.frame
+//        frame.origin.y = top
+//        frame.size.height -= top
+//        let cellFrame = cell.frame
+//        let frameInSuper = collectionView.convert(cellFrame, to: view)
+//        if !frame.contains(frameInSuper) {
+//            var point = CGPoint(x: 0.0, y: cellFrame.origin.y-top)
+//            let contentSizeHeight = collectionView.contentSize.height
+//            if cellFrame.maxY >= contentSizeHeight {
+//                point.y = contentSizeHeight-collectionView.bounds.size.height
+//            }
+//            collectionView.setContentOffset(point, animated: true)
+//        }
+//        ///滚动至选择item区域end
+//        view.showPreview(true)
+//
+//        _updateHighlightedItemStatus()
+//
+//        itemModel.isHighlight = true
+//        cell.itemIsHighlight = true
+//        _highlightedItemIndexPath = indexPath
+//    }
+//
+//    private func _updateHighlightedItemStatus() {
+//        guard let indexPath = _highlightedItemIndexPath else {
+//            return
+//        }
+//        let highlightedItemModel: KSMediaPickerItemModel
+//        let highlightedCell = (view as! KSMediaPickerView).collectionView.cellForItem(at: indexPath) as? KSMediaPickerViewImageCell
+//        if highlightedCell == nil {
+//            highlightedItemModel = _selectedAlbum!.assetList[indexPath.item]
+//        } else {
+//            highlightedItemModel = highlightedCell!.itemModel
+//            highlightedCell?.itemIsHighlight = false
+//        }
+//        highlightedItemModel.isHighlight = false
+//    }
+//
+//}
+//
+//extension PublishMediaPickerController {
+//
+//    open class func authorityCheckUp(controller: UIViewController, type: PublishMediaPickerController.mediaType, completionHandler: @escaping ((PublishMediaPickerController.mediaType) -> Void), cancelHandler: ((UIAlertAction) -> Void)?) {
+//        switch type {
+//        case .picture:
+//            let authorization = {(status: PHAuthorizationStatus) in
+//                switch status {
+//                case .authorized:
+//                    completionHandler(type)
+//                    break
+//                case .denied:
+//                    authorityAlert(controller: controller, name: "IMAGE_PICKER_PHOTOS".ks_mediaPickerKeyToLocalized, cancelHandler: cancelHandler)
+//                    break
+//                default:
+//                    break
+//                }
+//            }
+//            let status = PHPhotoLibrary.authorizationStatus()
+//            if status == .notDetermined {
+//                PHPhotoLibrary.requestAuthorization(authorization)
+//            } else {
+//                authorization(status)
+//            }
+//            break
+//        case .video:
+//            let authorization = {(granted: Bool) in
+//                if granted {
+//                    completionHandler(type)
+//                } else {
+//                    authorityAlert(controller: controller, name: "IMAGE_PICKER_CAMERA".ks_mediaPickerKeyToLocalized, cancelHandler: cancelHandler)
+//                }
+//            }
+//            let mediaType = AVMediaType.video
+//            let status = AVCaptureDevice.authorizationStatus(for: mediaType)
+//            if status == .notDetermined {
+//                AVCaptureDevice.requestAccess(for: mediaType, completionHandler: authorization)
+//            } else {
+//                authorization(status == .authorized)
+//            }
+//            break
+//        default :
+//            break
+//        }
+//    }
+//
+//    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 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 application = UIApplication.shared
+//            let url = URL(string: UIApplication.openSettingsURLString)!
+//            if application.canOpenURL(url) {
+//                if #available(iOS 10.0, *) {
+//                    application.open(url, options: [.universalLinksOnly: false], completionHandler: nil)
+//                } else {
+//                    application.openURL(url)
+//                }
+//                if cancelHandler != nil {
+//                    cancelHandler!(action)
+//                }
+//            }
+//        }
+//        alert.addAction(go)
+//        let cancel = UIAlertAction(title: "CANCEL".ks_mediaPickerKeyToLocalized(in: bundle), style: .cancel, handler: cancelHandler)
+//        alert.addAction(cancel)
+//        controller.present(alert, animated: true, completion: nil)
+//    }
+//
+//    open class func authorityAudioCheckUp(controller: UIViewController, completionHandler: @escaping (() -> Void), cancelHandler: ((UIAlertAction) -> Void)?) {
+//        let authorization = {(granted: Bool) in
+//            if granted {
+//                completionHandler()
+//            } else {
+//                authorityAlert(controller: controller, name: "IMAGE_PICKER_MICROPHONE".ks_mediaPickerKeyToLocalized, cancelHandler: cancelHandler)
+//            }
+//        }
+//        let mediaType = AVMediaType.audio
+//        let status = AVCaptureDevice.authorizationStatus(for: mediaType)
+//        if status == .notDetermined {
+//            AVCaptureDevice.requestAccess(for: mediaType, completionHandler: authorization)
+//        } else {
+//            authorization(status == .authorized)
+//        }
+//    }
+//}
+//
+//extension PublishMediaPickerController : JXSegmentedListContainerViewListDelegate {
+//    func listView() -> UIView {
+//        return view
+//    }
+//}