Pārlūkot izejas kodu

MediaPicker -- less is more

Chris 5 gadi atpakaļ
vecāks
revīzija
3165b6fc66

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

@@ -394,7 +394,6 @@
 		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 */; };
-		BD12B69822B4F7C700AEB10B /* KSMediaPickerViewAlbumCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B69722B4F7C700AEB10B /* KSMediaPickerViewAlbumCell.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 */; };
@@ -905,7 +904,6 @@
 		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>"; };
-		BD12B69722B4F7C700AEB10B /* KSMediaPickerViewAlbumCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerViewAlbumCell.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>"; };
@@ -3437,7 +3435,6 @@
 				BD12B69022B4F60200AEB10B /* KSMediaPickerScrollView.m */,
 				BD12B69922B4FA8400AEB10B /* KSMediaPickerSelectIndicator.swift */,
 				BD12B68222B4EFF000AEB10B /* KSMediaPickerView.swift */,
-				BD12B69722B4F7C700AEB10B /* KSMediaPickerViewAlbumCell.swift */,
 				BD12B67E22B4EF2600AEB10B /* KSMediaPickerViewImageCell.swift */,
 				BD12B67F22B4EF2600AEB10B /* KSMediaPickerViewVideoCell.swift */,
 			);
@@ -4445,7 +4442,6 @@
 				A72A72D222321E2700B21995 /* Common.swift in Sources */,
 				A70B2C64228875DE00B2449F /* ShopViewShopInfoTableViewCell.swift in Sources */,
 				BD1FC17F22B08D3C00D55081 /* CommunityMyFollowTopicController.swift in Sources */,
-				BD12B69822B4F7C700AEB10B /* KSMediaPickerViewAlbumCell.swift in Sources */,
 				BDEF7791228571DC00ED0AC0 /* CommonPayView.swift in Sources */,
 				A71AF0A6226EDDC8001730FE /* SearchViewController.swift in Sources */,
 				BD20F1CF2283CE2300677D8E /* OrderFinishPayView.swift in Sources */,

+ 1 - 42
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/Controller/KSMediaPickerController.swift

@@ -22,7 +22,7 @@ import Photos
     @objc optional func mediaPicker(_ mediaPicker: KSMediaPickerController, didFinishSelected outputArray: [KSMediaPickerOutputModel])
 }
 
-open class KSMediaPickerController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UITableViewDelegate, UITableViewDataSource {
+open class KSMediaPickerController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
     
     @objc public enum mediaType : Int {
         case all        = 0
@@ -81,8 +81,6 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
         let nav = view.albumNavigationView
         nav.closeButton.addTarget(self, action: #selector(_didClick(closeButton:)), for: .touchUpInside)
         nav.nextButton.addTarget(self, action: #selector(_didClick(nextButton:)), for: .touchUpInside)
-        //FIXME: disable
-//        nav.centerButton.addTarget(self, action: #selector(_chengedAlbumListStatus(_:)), for: .touchUpInside)
         
         let classObj = KSMediaPickerController.self
         let collectionView = view.collectionView
@@ -91,10 +89,6 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
         collectionView.delegate = self
         collectionView.dataSource = self
         
-        let tableView = view.albumTableView
-        tableView.delegate = self
-        tableView.dataSource = self
-        
         let cameraView = view.cameraView
         cameraView.didTakePhotoCallback = {[weak self] (cameraView, image) in
             self?._didTakePhotoFinish(cameraView: cameraView, image: image)
@@ -151,8 +145,6 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
     private var _selectedAlbum: KSMediaPickerAlbumModel? {
         didSet {
             let view = self.view as! KSMediaPickerView
-            //FIXME: disable
-//            view.albumNavigationView.title = _selectedAlbum?.albumTitle
             _updateHighlightedItemStatus()
             if let itemModel = _selectedAlbum?.assetList.first {
                 let isStandard = _selectedAssetArray.count == 0 || itemModel == (_selectedAssetArray.firstObject as! KSMediaPickerItemModel)
@@ -165,16 +157,9 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
     }
     
     private func _loadAssetDataFinish() {
-        (view as! KSMediaPickerView).albumTableView.reloadData()
         _selectedAlbum = _albumList?.first
     }
     
-    //FIXME: disable
-//    @objc private func _chengedAlbumListStatus(_ button: KSTriangleIndicatorButton) {
-//        let isShow = (view as! KSMediaPickerView).chengedAlbumListStatus()
-//        button.rotationDirection = isShow ? .down : .up
-//    }
-    
     @objc private func _didClick(closeButton: UIButton?) {
 //        navigationController?.dismiss(animated: true, completion: nil)
         
@@ -474,32 +459,6 @@ open class KSMediaPickerController: UIViewController, UICollectionViewDelegate,
         highlightedItemModel.isHighlight = false
     }
     
-    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return _albumList?.count ?? 0
-    }
-    
-    private static let k_iden = "KSMediaPickerViewAlbumCell"
-    
-    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        let iden = KSMediaPickerController.k_iden
-        var cell = tableView.dequeueReusableCell(withIdentifier: iden) as? KSMediaPickerViewAlbumCell
-        if cell == nil {
-            cell = KSMediaPickerViewAlbumCell(style: .subtitle, reuseIdentifier: iden)
-        }
-        cell?.albumModel = _albumList?[indexPath.row]
-        return cell!
-    }
-    
-    public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        let cell = tableView.cellForRow(at: indexPath) as? KSMediaPickerViewAlbumCell
-        tableView.deselectRow(at: indexPath, animated: true)
-        guard cell != nil, let albumModel = cell?.albumModel else {
-            return
-        }
-        _selectedAlbum = albumModel
-        //FIXME: disable
-//        _chengedAlbumListStatus((view as! KSMediaPickerView).albumNavigationView.centerButton)
-    }
 }
 
 extension KSMediaPickerController {

+ 0 - 29
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerView.swift

@@ -108,18 +108,6 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
     
     public let segmentedControl: KSSegmentedControl = KSMediaPickerView.segmentedControl(frame: .zero)
     
-    public let albumTableView = {() -> UITableView in
-        let albumTableView = UITableView(frame: .zero, style: .plain)
-        albumTableView.isHidden = true
-        albumTableView.backgroundColor = .ks_white
-        albumTableView.rowHeight = 75.0
-        albumTableView.separatorStyle = .none
-        if #available(iOS 11.0, *) {
-            albumTableView.contentInsetAdjustmentBehavior = .never
-        }
-        return albumTableView
-    }()
-    
     private let _blackBackgroundLayer = {() -> CALayer in
         let blackBackgroundLayer = CALayer()
         blackBackgroundLayer.opacity = 0.0
@@ -136,7 +124,6 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         
         scrollView.addSubview(collectionView)
         scrollView.addSubview(previewView)
-        scrollView.addSubview(albumTableView)
         albumNavigationView.nextButton.isEnabled = false
         scrollView.addSubview(albumNavigationView)
         
@@ -238,11 +225,6 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         collectionView.contentInset = conetntInset
         collectionView.scrollIndicatorInsets = conetntInset
         
-        let inset = UIEdgeInsets(top: navHeight, left: 0.0, bottom: 0.0, right: 0.0)
-        albumTableView.frame = frame
-        albumTableView.contentInset = inset
-        albumTableView.scrollIndicatorInsets = inset
-        
         viewX = collectionView.frame.maxX
         viewY = floatZore
         viewW = windowWidth
@@ -399,17 +381,6 @@ open class KSMediaPickerView: UIView, KSMediaPickerScrollViewDelegate {
         }
     }
     
-    public func chengedAlbumListStatus() -> Bool {
-        let isShow = !albumTableView.isHidden
-        let trans = CATransition()
-        trans.duration = 0.2
-        trans.type = .push
-        trans.subtype = isShow ? .fromTop : .fromBottom
-        albumTableView.isHidden = isShow
-        albumTableView.layer.add(trans, forKey: nil)
-        return isShow
-    }
-    
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
         switch scrollView {
         case self.scrollView:

+ 0 - 85
RainbowPlanet/RainbowPlanet/Modules/PublishModule/PublishMediaPicker/View/KSMediaPickerViewAlbumCell.swift

@@ -1,85 +0,0 @@
-//
-//  KSMediaPickerViewAlbumCell.swift
-// 
-//
-//  Created by kinsun on 2019/3/5.
-//
-
-import UIKit
-import Photos
-
-open class KSMediaPickerViewAlbumCell: UITableViewCell {
-
-    open var albumModel: KSMediaPickerAlbumModel! {
-        didSet {
-            let itemModel = albumModel.assetList.first
-            if itemModel != nil {
-                PHImageManager.default().requestImage(for: itemModel!.asset, targetSize: KSMediaPickerItemModel.thumbSize, contentMode: .aspectFill, options: KSMediaPickerItemModel.pictureViewerOptions) {[weak self] (image, info) in
-                    self?.imageView?.image = image
-                }
-                textLabel?.text = albumModel.albumTitle
-                detailTextLabel?.text = String(albumModel.assetList.count)
-            }
-        }
-    }
-    
-    private let _lineView = {() -> UIView in
-        let lineView = UIView()
-        lineView.backgroundColor = .ks_lightGray
-        lineView.isUserInteractionEnabled = false
-        return lineView
-    }()
-    
-    override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
-        super.init(style: style, reuseIdentifier: reuseIdentifier)
-        
-        imageView?.image = .ks_defaultPlaceholder
-        imageView?.contentMode = .scaleAspectFill
-        imageView?.clipsToBounds = true
-        
-        textLabel?.font = UIFont.systemFont(ofSize: 16.0)
-        textLabel?.textColor = .ks_wordMain
-        
-        detailTextLabel?.font = UIFont.systemFont(ofSize: 13.0)
-        detailTextLabel?.textColor = .ks_wordMain_2
-        
-        contentView.addSubview(_lineView)
-    }
-    
-    required public init?(coder aDecoder: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-    
-    override open func layoutSubviews() {
-        super.layoutSubviews()
-        let windowSize = contentView.bounds.size
-        let windowWidth = windowSize.width
-        let windowHeight = windowSize.height
-        
-        var viewW = CGFloat(50.0)
-        var viewH = viewW
-        var viewX = CGFloat(12.0)
-        var viewY = (windowHeight-viewH)*0.5
-        imageView?.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        
-        let titleHeight = textLabel?.font.lineHeight ?? 0.0
-        let detailHeight = detailTextLabel?.font.lineHeight ?? 0.0
-        let margin = CGFloat(2.0)
-        
-        viewH = titleHeight
-        viewX = (imageView?.frame.maxX ?? 0.0) + 12.0
-        viewW = windowWidth-viewX-12.0
-        viewY = (windowHeight-(viewH+margin+detailHeight))*0.5
-        textLabel?.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        
-        viewY = (textLabel?.frame.maxY ?? 0.0)+margin
-        viewH = detailHeight
-        detailTextLabel?.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-        
-        viewX = CGFloat(0.0)
-        viewH = CGFloat(0.5)
-        viewW = windowWidth
-        viewY = windowHeight-viewH
-        _lineView.frame = CGRect(x: viewX, y: viewY, width: viewW, height: viewH)
-    }
-}