@@ -3,7 +3,19 @@ import Photos
33import TLPhotoPicker
44import UIKit
55
6- var MultipleImagePickerConfigure = TLPhotosPickerConfigure ( )
6+ extension TLPhotosPickerConfigure {
7+ var isPreview : Bool {
8+ get { return true }
9+ set { }
10+ }
11+
12+ var isCrop : Bool {
13+ get { return true }
14+ set { }
15+ }
16+ }
17+
18+ var config = TLPhotosPickerConfigure ( )
719
820@objc ( MultipleImagePicker)
921class MultipleImagePicker : NSObject , TLPhotosPickerViewControllerDelegate , UINavigationControllerDelegate , TLPhotosPickerLogDelegate , CropViewControllerDelegate {
@@ -59,7 +71,7 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate, UINav
5971 viewController. didExceedMaximumNumberOfSelection = { [ weak self] picker in
6072 self ? . showExceededMaximumAlert ( vc: picker, isVideo: false )
6173 }
62- viewController. configure = MultipleImagePickerConfigure
74+ viewController. configure = config
6375 viewController. selectedAssets = self . selectedAssets
6476 viewController. logDelegate = self
6577
@@ -91,33 +103,35 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate, UINav
91103 self . videoRequestOptions. isNetworkAccessAllowed = true
92104
93105 // config options
94- MultipleImagePickerConfigure . tapHereToChange = self . options [ " tapHereToChange " ] as! String
95- MultipleImagePickerConfigure . numberOfColumn = self . options [ " numberOfColumn " ] as! Int
96- MultipleImagePickerConfigure . cancelTitle = self . options [ " cancelTitle " ] as! String
97- MultipleImagePickerConfigure . doneTitle = self . options [ " doneTitle " ] as! String
98- MultipleImagePickerConfigure . emptyMessage = self . options [ " emptyMessage " ] as! String
99- MultipleImagePickerConfigure . selectMessage = self . options [ " selectMessage " ] as! String
100- MultipleImagePickerConfigure . deselectMessage = self . options [ " deselectMessage " ] as! String
101- MultipleImagePickerConfigure . usedCameraButton = self . options [ " usedCameraButton " ] as! Bool
102- MultipleImagePickerConfigure . usedPrefetch = self . options [ " usedPrefetch " ] as! Bool
103- MultipleImagePickerConfigure . allowedLivePhotos = self . options [ " allowedLivePhotos " ] as! Bool
104- MultipleImagePickerConfigure . allowedVideo = self . options [ " allowedVideo " ] as! Bool
105- MultipleImagePickerConfigure . allowedAlbumCloudShared = self . options [ " allowedAlbumCloudShared " ] as! Bool
106- MultipleImagePickerConfigure . allowedVideoRecording = self . options [ " allowedVideoRecording " ] as! Bool
107- MultipleImagePickerConfigure . maxVideoDuration = self . options [ " maxVideoDuration " ] as? TimeInterval
108- MultipleImagePickerConfigure . autoPlay = self . options [ " autoPlay " ] as! Bool
109- MultipleImagePickerConfigure . muteAudio = self . options [ " muteAudio " ] as! Bool
110- MultipleImagePickerConfigure . singleSelectedMode = ( self . options [ " singleSelectedMode " ] ) ! as! Bool
111- MultipleImagePickerConfigure . maxSelectedAssets = self . options [ " maxSelectedAssets " ] as? Int
112- MultipleImagePickerConfigure . selectedColor = UIColor ( hex: self . options [ " selectedColor " ] as! String )
106+ config. tapHereToChange = self . options [ " tapHereToChange " ] as! String
107+ config. numberOfColumn = self . options [ " numberOfColumn " ] as! Int
108+ config. cancelTitle = self . options [ " cancelTitle " ] as! String
109+ config. doneTitle = self . options [ " doneTitle " ] as! String
110+ config. emptyMessage = self . options [ " emptyMessage " ] as! String
111+ config. selectMessage = self . options [ " selectMessage " ] as! String
112+ config. deselectMessage = self . options [ " deselectMessage " ] as! String
113+ config. usedCameraButton = self . options [ " usedCameraButton " ] as! Bool
114+ config. usedPrefetch = self . options [ " usedPrefetch " ] as! Bool
115+ config. allowedLivePhotos = self . options [ " allowedLivePhotos " ] as! Bool
116+ config. allowedVideo = self . options [ " allowedVideo " ] as! Bool
117+ config. allowedAlbumCloudShared = self . options [ " allowedAlbumCloudShared " ] as! Bool
118+ config. allowedVideoRecording = self . options [ " allowedVideoRecording " ] as! Bool
119+ config. maxVideoDuration = self . options [ " maxVideoDuration " ] as? TimeInterval
120+ config. autoPlay = self . options [ " autoPlay " ] as! Bool
121+ config. muteAudio = self . options [ " muteAudio " ] as! Bool
122+ config. singleSelectedMode = ( self . options [ " singleSelectedMode " ] ) ! as! Bool
123+ config. maxSelectedAssets = self . options [ " maxSelectedAssets " ] as? Int
124+ config. selectedColor = UIColor ( hex: self . options [ " selectedColor " ] as! String )
125+
126+ config. isPreview = self . options [ " isPreview " ] as? Bool ?? false
113127
114128 let mediaType = self . options [ " mediaType " ] as! String
115129
116- MultipleImagePickerConfigure . mediaType = mediaType == " video " ? PHAssetMediaType . video : mediaType == " image " ? PHAssetMediaType . image : nil
130+ config . mediaType = mediaType == " video " ? PHAssetMediaType . video : mediaType == " image " ? PHAssetMediaType . image : nil
117131
118- MultipleImagePickerConfigure . nibSet = ( nibName: " Cell " , bundle: MultipleImagePickerBundle . bundle ( ) )
132+ config . nibSet = ( nibName: " Cell " , bundle: MultipleImagePickerBundle . bundle ( ) )
119133
120- MultipleImagePickerConfigure . allowedPhotograph = self . options [ " allowedPhotograph " ] as! Bool
134+ config . allowedPhotograph = self . options [ " allowedPhotograph " ] as! Bool
121135 // configure.preventAutomaticLimitedAccessAlert = self.options["preventAutomaticLimitedAccessAlert"]
122136
123137 if options [ " selectedAssets " ] != nil {
@@ -128,10 +142,7 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate, UINav
128142 func handleSelectedAssets( selectedList: NSArray ) {
129143 let assetsExist = selectedList. filter { ( $0 as! NSObject ) . value ( forKey: " localIdentifier " ) != nil }
130144 self . videoCount = selectedList. filter { ( $0 as! NSObject ) . value ( forKey: " type " ) as? String == " video " } . count
131-
132- let existLastItem = ( assetsExist. last as? [ String : Any ] ) ? [ " localIdentifier " ] as? String
133- let selectedLastItem = self . selectedAssets. last? . phAsset? . localIdentifier as? String
134-
145+
135146 var assets = [ TLPHAsset] ( )
136147 for index in 0 ..< assetsExist. count {
137148 let value = assetsExist [ index]
@@ -194,10 +205,10 @@ class MultipleImagePicker: NSObject, TLPhotosPickerViewControllerDelegate, UINav
194205 func presentCropViewController( image: UIImage ) {
195206 let cropViewController = CropViewController ( croppingStyle: ( self . options [ " isCropCircle " ] as! Bool ) ? . circular : . default, image: image)
196207 cropViewController. delegate = self
197- cropViewController. doneButtonTitle = MultipleImagePickerConfigure . doneTitle
198- cropViewController. doneButtonColor = MultipleImagePickerConfigure . selectedColor
208+ cropViewController. doneButtonTitle = config . doneTitle
209+ cropViewController. doneButtonColor = config . selectedColor
199210
200- cropViewController. cancelButtonTitle = MultipleImagePickerConfigure . cancelTitle
211+ cropViewController. cancelButtonTitle = config . cancelTitle
201212
202213 self . getTopMostViewController ( ) ? . present ( cropViewController, animated: true , completion: nil )
203214 }
0 commit comments