forked from wordpress-mobile/MediaPicker-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WPMediaPickerViewController.h
187 lines (156 loc) · 6.28 KB
/
WPMediaPickerViewController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@import UIKit;
#import "WPMediaCollectionDataSource.h"
#import "WPAssetViewController.h"
@class WPMediaPickerViewController;
/**
* The `WPMediaPickerViewControllerDelegate` protocol defines methods that allow you to to interact with the assets picker interface
* and manage the selection and highlighting of assets in the picker.
*
* The methods of this protocol notify your delegate when the user selects, finish picking assets, or cancels the picker operation.
*
* The delegate methods are responsible for dismissing the picker when the operation completes.
* To dismiss the picker, call the `dismissViewControllerAnimated:completion:` method of the presenting controller
* responsible for displaying `WPMediaPickerController` object.
*
*/
@protocol WPMediaPickerViewControllerDelegate <NSObject>
/**
* @name Closing the Picker
*/
/**
* Tells the delegate that the user finish picking photos or videos.
*
* @param picker The controller object managing the assets picker interface.
* @param assets An array containing picked `WPMediaAsset` objects.
*
*/
- (void)mediaPickerController:(nonnull WPMediaPickerViewController *)picker didFinishPickingAssets:(nonnull NSArray<WPMediaAsset> *)assets;
@optional
/**
* Tells the delegate that the user cancelled the pick operation.
*
* @param picker The controller object managing the assets picker interface.
*
*/
- (void)mediaPickerControllerDidCancel:(nonnull WPMediaPickerViewController *)picker;
/**
* @name Enabling Assets
*/
/**
* Ask the delegate if the specified asset shoule be shown.
*
* @param picker The controller object managing the assets picker interface.
* @param asset The asset to be shown.
*
* @return `YES` if the asset should be shown or `NO` if it should not.
*
*/
- (BOOL)mediaPickerController:(nonnull WPMediaPickerViewController *)picker shouldShowAsset:(nonnull id<WPMediaAsset>)asset;
/**
* Ask the delegate if the specified asset should be enabled for selection.
*
* @param picker The controller object managing the assets picker interface.
* @param asset The asset to be enabled.
*
* @return `YES` if the asset should be enabled or `NO` if it should not.
*
*/
- (BOOL)mediaPickerController:(nonnull WPMediaPickerViewController *)picker shouldEnableAsset:(nonnull id<WPMediaAsset>)asset;
/**
* @name Managing the Selected Assets
*/
/**
* Asks the delegate if the specified asset should be selected.
*
* @param picker The controller object managing the assets picker interface.
* @param asset The asset to be selected.
*
* @return `YES` if the asset should be selected or `NO` if it should not.
*
*/
- (BOOL)mediaPickerController:(nonnull WPMediaPickerViewController *)picker shouldSelectAsset:(nonnull id<WPMediaAsset>)asset;
/**
* Tells the delegate that the asset was selected.
*
* @param picker The controller object managing the assets picker interface.
* @param asset The asset that was selected.
*
*/
- (void)mediaPickerController:(nonnull WPMediaPickerViewController *)picker didSelectAsset:(nonnull id<WPMediaAsset>)asset;
/**
* Asks the delegate if the specified asset should be deselected.
*
* @param picker The controller object managing the assets picker interface.
* @param asset The asset to be deselected.
*
* @return `YES` if the asset should be deselected or `NO` if it should not.
*
* @see assetsPickerController:shouldSelectAsset:
*/
- (BOOL)mediaPickerController:(nonnull WPMediaPickerViewController *)picker shouldDeselectAsset:(nonnull id<WPMediaAsset>)asset;
/**
* Tells the delegate that the item at the specified path was deselected.
*
* @param picker The controller object managing the assets picker interface.
* @param asset The asset that was deselected.
*
*/
- (void)mediaPickerController:(nonnull WPMediaPickerViewController *)picker didDeselectAsset:(nonnull id<WPMediaAsset>)asset;
/**
* Asks the delegate for a view controller to push when previewing the specified asset.
* If this method isn't implemented, the default view controller will be used.
* If it returns nil, no preview will be displayed.
*
* @param picker The controller object managing the assets picker interface.
* @param asset The asset to be previewed.
*/
- (nullable UIViewController *)mediaPickerController:(nonnull WPMediaPickerViewController *)picker previewViewControllerForAsset:(nonnull id<WPMediaAsset>)asset;
@end
@interface WPMediaPickerViewController : UICollectionViewController<WPAssetViewControllerDelegate>
@property (nonatomic, readonly, nonnull) NSMutableArray *selectedAssets;
/**
If set the picker will show a cell that allows capture of new media, that can be used immediatelly
*/
@property (nonatomic, assign) BOOL allowCaptureOfMedia;
/**
If the media picker allows media capturing, it will use the front camera by default when possible
*/
@property (nonatomic, assign) BOOL preferFrontCamera;
/**
If set the picker will show the most recent items on the top left. If not set it will show on the bottom right. Either way it will always scroll to the most recent item when showing the picker.
*/
@property (nonatomic, assign) BOOL showMostRecentFirst;
/**
* Sets what kind of elements the picker show: allAssets, allPhotos, allVideos
*/
@property (nonatomic, assign) WPMediaType filter;
/**
If set the picker will allow the selection of multiple items. By default this value is YES.
*/
@property (nonatomic, assign) BOOL allowMultipleSelection;
/**
The object that acts as the data source of the media picker.
*/
@property (nonatomic, weak, nullable) id<WPMediaCollectionDataSource> dataSource;
/**
The delegate for the WPMediaPickerViewController events
*/
@property (nonatomic, weak, nullable) id<WPMediaPickerViewControllerDelegate> mediaPickerDelegate;
/**
Allows to set a group as the current display group on the data source.
*/
- (void)setGroup:(nonnull id<WPMediaGroup>)group;
@property (nonatomic, assign) CGSize cameraPreviewSize;
/**
* Clears the current asset selection in the picker.
*/
- (void)clearSelectedAssets:(BOOL)animated;
/**
View controller to use when picker needs to present another controller. By default this is set to self.
*/
@property (nonatomic, weak, nullable) UIViewController *viewControllerToUseToPresent;
/**
Clears all selection and scroll the picker to the starting position
*/
- (void)resetState:(BOOL)animated;
@end