Commit 2ad7fb49 authored by Syan's avatar Syan

0.1.7

parent dfa49399
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
基于已有原生第三方框架封装的多图片选择组件,适用于 React Native App。 基于已有原生第三方框架封装的多图片选择组件,适用于 React Native App。
### 原生框架依赖 ### 原生框架依赖
* Android: [PictureSelector 2.2.2](https://github.com/LuckSiege/PictureSelector) - by [LuckSiege](https://github.com/LuckSiege) * Android: [PictureSelector 2.2.3](https://github.com/LuckSiege/PictureSelector) - by [LuckSiege](https://github.com/LuckSiege)
* iOS:[TZImagePickerController 2.0.0.4](https://github.com/banchichen/TZImagePickerController) - by [banchichen](https://github.com/banchichen) * iOS:[TZImagePickerController 2.1.8](https://github.com/banchichen/TZImagePickerController) - by [banchichen](https://github.com/banchichen)
### 功能特点 ### 功能特点
* 支持 iOS、Android 两端 * 支持 iOS、Android 两端
......
...@@ -13,7 +13,6 @@ apply plugin: 'com.android.library' ...@@ -13,7 +13,6 @@ apply plugin: 'com.android.library'
android { android {
compileSdkVersion 26 compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
...@@ -32,5 +31,5 @@ repositories { ...@@ -32,5 +31,5 @@ repositories {
dependencies { dependencies {
compile 'com.facebook.react:react-native:+' compile 'com.facebook.react:react-native:+'
compile 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.2' compile 'com.github.LuckSiege.PictureSelector:picture_library:v2.2.3'
} }
...@@ -19,9 +19,10 @@ typedef enum : NSUInteger { ...@@ -19,9 +19,10 @@ typedef enum : NSUInteger {
@class TZAssetModel; @class TZAssetModel;
@interface TZAssetCell : UICollectionViewCell @interface TZAssetCell : UICollectionViewCell
@property (weak, nonatomic) UIButton *selectPhotoButton; @property (weak, nonatomic) UIButton *selectPhotoButton;
@property (weak, nonatomic) UIButton *cannotSelectLayerButton;
@property (nonatomic, strong) TZAssetModel *model; @property (nonatomic, strong) TZAssetModel *model;
@property (assign, nonatomic) NSInteger index;
@property (nonatomic, copy) void (^didSelectPhotoBlock)(BOOL); @property (nonatomic, copy) void (^didSelectPhotoBlock)(BOOL);
@property (nonatomic, assign) TZAssetCellType type; @property (nonatomic, assign) TZAssetCellType type;
@property (nonatomic, assign) BOOL allowPickingGif; @property (nonatomic, assign) BOOL allowPickingGif;
...@@ -29,27 +30,28 @@ typedef enum : NSUInteger { ...@@ -29,27 +30,28 @@ typedef enum : NSUInteger {
@property (nonatomic, copy) NSString *representedAssetIdentifier; @property (nonatomic, copy) NSString *representedAssetIdentifier;
@property (nonatomic, assign) int32_t imageRequestID; @property (nonatomic, assign) int32_t imageRequestID;
@property (nonatomic, copy) NSString *photoSelImageName; @property (nonatomic, strong) UIImage *photoSelImage;
@property (nonatomic, copy) NSString *photoDefImageName; @property (nonatomic, strong) UIImage *photoDefImage;
@property (nonatomic, assign) BOOL showSelectBtn; @property (nonatomic, assign) BOOL showSelectBtn;
@property (assign, nonatomic) BOOL allowPreview; @property (assign, nonatomic) BOOL allowPreview;
@property (assign, nonatomic) BOOL useCachedImage;
@property (nonatomic, copy) void (^assetCellDidSetModelBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView);
@property (nonatomic, copy) void (^assetCellDidLayoutSubviewsBlock)(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView);
@end @end
@class TZAlbumModel; @class TZAlbumModel;
@interface TZAlbumCell : UITableViewCell @interface TZAlbumCell : UITableViewCell
@property (nonatomic, strong) TZAlbumModel *model; @property (nonatomic, strong) TZAlbumModel *model;
@property (weak, nonatomic) UIButton *selectedCountButton; @property (weak, nonatomic) UIButton *selectedCountButton;
@property (nonatomic, copy) void (^albumCellDidSetModelBlock)(TZAlbumCell *cell, UIImageView *posterImageView, UILabel *titleLabel);
@property (nonatomic, copy) void (^albumCellDidLayoutSubviewsBlock)(TZAlbumCell *cell, UIImageView *posterImageView, UILabel *titleLabel);
@end @end
@interface TZAssetCameraCell : UICollectionViewCell @interface TZAssetCameraCell : UICollectionViewCell
@property (nonatomic, strong) UIImageView *imageView; @property (nonatomic, strong) UIImageView *imageView;
@end @end
This diff is collapsed.
...@@ -23,7 +23,9 @@ typedef enum : NSUInteger { ...@@ -23,7 +23,9 @@ typedef enum : NSUInteger {
@property (nonatomic, strong) id asset; ///< PHAsset or ALAsset @property (nonatomic, strong) id asset; ///< PHAsset or ALAsset
@property (nonatomic, assign) BOOL isSelected; ///< The select status of a photo, default is No @property (nonatomic, assign) BOOL isSelected; ///< The select status of a photo, default is No
@property (nonatomic, assign) TZAssetModelMediaType type; @property (nonatomic, assign) TZAssetModelMediaType type;
@property (assign, nonatomic) BOOL needOscillatoryAnimation;
@property (nonatomic, copy) NSString *timeLength; @property (nonatomic, copy) NSString *timeLength;
@property (strong, nonatomic) UIImage *cachedImage;
/// Init a photo dataModel With a asset /// Init a photo dataModel With a asset
/// 用一个PHAsset/ALAsset实例,初始化一个照片模型 /// 用一个PHAsset/ALAsset实例,初始化一个照片模型
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
_result = result; _result = result;
if (needFetchAssets) { if (needFetchAssets) {
[[TZImageManager manager] getAssetsFromFetchResult:result completion:^(NSArray<TZAssetModel *> *models) { [[TZImageManager manager] getAssetsFromFetchResult:result completion:^(NSArray<TZAssetModel *> *models) {
_models = models; self->_models = models;
if (_selectedModels) { if (self->_selectedModels) {
[self checkSelectedModels]; [self checkSelectedModels];
} }
}]; }];
......
...@@ -90,6 +90,10 @@ ...@@ -90,6 +90,10 @@
[_toolBar addSubview:byteLabel]; [_toolBar addSubview:byteLabel];
[self.view addSubview:_toolBar]; [self.view addSubview:_toolBar];
if (tzImagePickerVc.gifPreviewPageUIConfigBlock) {
tzImagePickerVc.gifPreviewPageUIConfigBlock(_toolBar, _doneButton);
}
} }
#pragma mark - Layout #pragma mark - Layout
...@@ -102,6 +106,11 @@ ...@@ -102,6 +106,11 @@
CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 44 + (83 - 49) : 44; CGFloat toolBarHeight = [TZCommonTools tz_isIPhoneX] ? 44 + (83 - 49) : 44;
_toolBar.frame = CGRectMake(0, self.view.tz_height - toolBarHeight, self.view.tz_width, toolBarHeight); _toolBar.frame = CGRectMake(0, self.view.tz_height - toolBarHeight, self.view.tz_width, toolBarHeight);
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44); _doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.gifPreviewPageDidLayoutSubviewsBlock) {
tzImagePickerVc.gifPreviewPageDidLayoutSubviewsBlock(_toolBar, _doneButton);
}
} }
#pragma mark - Click Event #pragma mark - Click Event
...@@ -120,12 +129,14 @@ ...@@ -120,12 +129,14 @@
} }
- (void)doneButtonClick { - (void)doneButtonClick {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if (self.navigationController) { if (self.navigationController) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if (imagePickerVc.autoDismiss) { if (imagePickerVc.autoDismiss) {
[self.navigationController dismissViewControllerAnimated:YES completion:^{ [self.navigationController dismissViewControllerAnimated:YES completion:^{
[self callDelegateMethod]; [self callDelegateMethod];
}]; }];
} else {
[self callDelegateMethod];
} }
} else { } else {
[self dismissViewControllerAnimated:YES completion:^{ [self dismissViewControllerAnimated:YES completion:^{
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
- (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion; - (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
- (int32_t)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed; - (int32_t)getPhotoWithAsset:(id)asset completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed;
- (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed; - (int32_t)getPhotoWithAsset:(id)asset photoWidth:(CGFloat)photoWidth completion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler networkAccessAllowed:(BOOL)networkAccessAllowed;
- (int32_t)requestImageDataForAsset:(id)asset completion:(void (^)(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info))completion progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler;
/// Get full Image 获取原图 /// Get full Image 获取原图
/// 如下两个方法completion一般会调多次,一般会先返回缩略图,再返回原图(详见方法内部使用的系统API的说明),如果info[PHImageResultIsDegradedKey] 为 YES,则表明当前返回的是缩略图,否则是原图。 /// 如下两个方法completion一般会调多次,一般会先返回缩略图,再返回原图(详见方法内部使用的系统API的说明),如果info[PHImageResultIsDegradedKey] 为 YES,则表明当前返回的是缩略图,否则是原图。
...@@ -72,11 +73,16 @@ ...@@ -72,11 +73,16 @@
- (void)getOriginalPhotoWithAsset:(id)asset newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion; - (void)getOriginalPhotoWithAsset:(id)asset newCompletion:(void (^)(UIImage *photo,NSDictionary *info,BOOL isDegraded))completion;
// 该方法中,completion只会走一次 // 该方法中,completion只会走一次
- (void)getOriginalPhotoDataWithAsset:(id)asset completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion; - (void)getOriginalPhotoDataWithAsset:(id)asset completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion;
- (void)getOriginalPhotoDataWithAsset:(id)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler completion:(void (^)(NSData *data,NSDictionary *info,BOOL isDegraded))completion;
/// Save photo 保存照片 /// Save photo 保存照片
- (void)savePhotoWithImage:(UIImage *)image completion:(void (^)(NSError *error))completion; - (void)savePhotoWithImage:(UIImage *)image completion:(void (^)(NSError *error))completion;
- (void)savePhotoWithImage:(UIImage *)image location:(CLLocation *)location completion:(void (^)(NSError *error))completion; - (void)savePhotoWithImage:(UIImage *)image location:(CLLocation *)location completion:(void (^)(NSError *error))completion;
/// Save video 保存视频
- (void)saveVideoWithUrl:(NSURL *)url completion:(void (^)(NSError *error))completion;
- (void)saveVideoWithUrl:(NSURL *)url location:(CLLocation *)location completion:(void (^)(NSError *error))completion;
/// Get video 获得视频 /// Get video 获得视频
- (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem * playerItem, NSDictionary * info))completion; - (void)getVideoWithAsset:(id)asset completion:(void (^)(AVPlayerItem * playerItem, NSDictionary * info))completion;
- (void)getVideoWithAsset:(id)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler completion:(void (^)(AVPlayerItem *, NSDictionary *))completion; - (void)getVideoWithAsset:(id)asset progressHandler:(void (^)(double progress, NSError *error, BOOL *stop, NSDictionary *info))progressHandler completion:(void (^)(AVPlayerItem *, NSDictionary *))completion;
...@@ -105,10 +111,12 @@ ...@@ -105,10 +111,12 @@
/// 获取asset的资源类型 /// 获取asset的资源类型
- (TZAssetModelMediaType)getAssetType:(id)asset; - (TZAssetModelMediaType)getAssetType:(id)asset;
/// 缩放图片至新尺寸 /// 缩放图片至新尺寸
- (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)size; - (UIImage *)scaleImage:(UIImage *)image toSize:(CGSize)size;
/// 判断asset是否是视频
- (BOOL)isVideo:(id)asset;
@end @end
//@interface TZSortDescriptor : NSSortDescriptor //@interface TZSortDescriptor : NSSortDescriptor
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
if (_geocodeBlock && locations.count) { if (_geocodeBlock && locations.count) {
CLGeocoder *geocoder = [[CLGeocoder alloc] init]; CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:[locations firstObject] completionHandler:^(NSArray *array, NSError *error) { [geocoder reverseGeocodeLocation:[locations firstObject] completionHandler:^(NSArray *array, NSError *error) {
_geocodeBlock(array); self->_geocodeBlock(array);
}]; }];
} }
} }
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
@interface TZPhotoPreviewView ()<UIScrollViewDelegate> @interface TZPhotoPreviewView ()<UIScrollViewDelegate>
@property (assign, nonatomic) BOOL isRequestingGIF;
@end @end
@implementation TZPhotoPreviewView @implementation TZPhotoPreviewView
...@@ -113,6 +113,9 @@ ...@@ -113,6 +113,9 @@
_scrollView.delaysContentTouches = NO; _scrollView.delaysContentTouches = NO;
_scrollView.canCancelContentTouches = YES; _scrollView.canCancelContentTouches = YES;
_scrollView.alwaysBounceVertical = NO; _scrollView.alwaysBounceVertical = NO;
if (@available(iOS 11, *)) {
_scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
[self addSubview:_scrollView]; [self addSubview:_scrollView];
_imageContainerView = [[UIView alloc] init]; _imageContainerView = [[UIView alloc] init];
...@@ -146,15 +149,35 @@ ...@@ -146,15 +149,35 @@
- (void)setModel:(TZAssetModel *)model { - (void)setModel:(TZAssetModel *)model {
_model = model; _model = model;
self.isRequestingGIF = NO;
[_scrollView setZoomScale:1.0 animated:NO]; [_scrollView setZoomScale:1.0 animated:NO];
if (model.type == TZAssetModelMediaTypePhotoGif) { if (model.type == TZAssetModelMediaTypePhotoGif) {
// 先显示缩略图 // 先显示缩略图
[[TZImageManager manager] getPhotoWithAsset:model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) { [[TZImageManager manager] getPhotoWithAsset:model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
self.imageView.image = photo; self.imageView.image = photo;
[self resizeSubviews]; [self resizeSubviews];
if (self.isRequestingGIF) {
return;
}
// 再显示gif动图 // 再显示gif动图
[[TZImageManager manager] getOriginalPhotoDataWithAsset:model.asset completion:^(NSData *data, NSDictionary *info, BOOL isDegraded) { self.isRequestingGIF = YES;
[[TZImageManager manager] getOriginalPhotoDataWithAsset:model.asset progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
progress = progress > 0.02 ? progress : 0.02;
dispatch_async(dispatch_get_main_queue(), ^{
self.progressView.progress = progress;
if (progress >= 1) {
self.progressView.hidden = YES;
} else {
self.progressView.hidden = NO;
}
});
#ifdef DEBUG
NSLog(@"[TZImagePickerController] getOriginalPhotoDataWithAsset:%f error:%@", progress, error);
#endif
} completion:^(NSData *data, NSDictionary *info, BOOL isDegraded) {
if (!isDegraded) { if (!isDegraded) {
self.isRequestingGIF = NO;
self.progressView.hidden = YES;
self.imageView.image = [UIImage sd_tz_animatedGIFWithData:data]; self.imageView.image = [UIImage sd_tz_animatedGIFWithData:data];
[self resizeSubviews]; [self resizeSubviews];
} }
...@@ -172,10 +195,10 @@ ...@@ -172,10 +195,10 @@
_asset = asset; _asset = asset;
self.imageRequestID = [[TZImageManager manager] getPhotoWithAsset:asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) { self.imageRequestID = [[TZImageManager manager] getPhotoWithAsset:asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (![asset isEqual:_asset]) return; if (![asset isEqual:self->_asset]) return;
self.imageView.image = photo; self.imageView.image = photo;
[self resizeSubviews]; [self resizeSubviews];
_progressView.hidden = YES; self->_progressView.hidden = YES;
if (self.imageProgressUpdateBlock) { if (self.imageProgressUpdateBlock) {
self.imageProgressUpdateBlock(1); self.imageProgressUpdateBlock(1);
} }
...@@ -183,17 +206,17 @@ ...@@ -183,17 +206,17 @@
self.imageRequestID = 0; self.imageRequestID = 0;
} }
} progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) { } progressHandler:^(double progress, NSError *error, BOOL *stop, NSDictionary *info) {
if (![asset isEqual:_asset]) return; if (![asset isEqual:self->_asset]) return;
_progressView.hidden = NO; self->_progressView.hidden = NO;
[self bringSubviewToFront:_progressView]; [self bringSubviewToFront:self->_progressView];
progress = progress > 0.02 ? progress : 0.02; progress = progress > 0.02 ? progress : 0.02;
_progressView.progress = progress; self->_progressView.progress = progress;
if (self.imageProgressUpdateBlock && progress < 1) { if (self.imageProgressUpdateBlock && progress < 1) {
self.imageProgressUpdateBlock(progress); self.imageProgressUpdateBlock(progress);
} }
if (progress >= 1) { if (progress >= 1) {
_progressView.hidden = YES; self->_progressView.hidden = YES;
self.imageRequestID = 0; self.imageRequestID = 0;
} }
} networkAccessAllowed:YES]; } networkAccessAllowed:YES];
...@@ -355,17 +378,17 @@ ...@@ -355,17 +378,17 @@
} }
[[TZImageManager manager] getPhotoWithAsset:self.model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) { [[TZImageManager manager] getPhotoWithAsset:self.model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
_cover = photo; self->_cover = photo;
}]; }];
[[TZImageManager manager] getVideoWithAsset:self.model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) { [[TZImageManager manager] getVideoWithAsset:self.model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
_player = [AVPlayer playerWithPlayerItem:playerItem]; self->_player = [AVPlayer playerWithPlayerItem:playerItem];
_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player]; self->_playerLayer = [AVPlayerLayer playerLayerWithPlayer:self->_player];
_playerLayer.backgroundColor = [UIColor blackColor].CGColor; self->_playerLayer.backgroundColor = [UIColor blackColor].CGColor;
_playerLayer.frame = self.bounds; self->_playerLayer.frame = self.bounds;
[self.layer addSublayer:_playerLayer]; [self.layer addSublayer:self->_playerLayer];
[self configPlayButton]; [self configPlayButton];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:AVPlayerItemDidPlayToEndTimeNotification object:_player.currentItem]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:AVPlayerItemDidPlayToEndTimeNotification object:self->_player.currentItem];
}); });
}]; }];
} }
......
...@@ -60,20 +60,20 @@ ...@@ -60,20 +60,20 @@
- (void)configMoviePlayer { - (void)configMoviePlayer {
[[TZImageManager manager] getPhotoWithAsset:_model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) { [[TZImageManager manager] getPhotoWithAsset:_model.asset completion:^(UIImage *photo, NSDictionary *info, BOOL isDegraded) {
if (!isDegraded && photo) { if (!isDegraded && photo) {
_cover = photo; self->_cover = photo;
_doneButton.enabled = YES; self->_doneButton.enabled = YES;
} }
}]; }];
[[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) { [[TZImageManager manager] getVideoWithAsset:_model.asset completion:^(AVPlayerItem *playerItem, NSDictionary *info) {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
_player = [AVPlayer playerWithPlayerItem:playerItem]; self->_player = [AVPlayer playerWithPlayerItem:playerItem];
_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player]; self->_playerLayer = [AVPlayerLayer playerLayerWithPlayer:self->_player];
_playerLayer.frame = self.view.bounds; self->_playerLayer.frame = self.view.bounds;
[self.view.layer addSublayer:_playerLayer]; [self.view.layer addSublayer:self->_playerLayer];
[self addProgressObserver]; [self addProgressObserver];
[self configPlayButton]; [self configPlayButton];
[self configBottomToolBar]; [self configBottomToolBar];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:AVPlayerItemDidPlayToEndTimeNotification object:_player.currentItem]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pausePlayerAndShowNaviBar) name:AVPlayerItemDidPlayToEndTimeNotification object:self->_player.currentItem];
}); });
}]; }];
} }
...@@ -121,6 +121,10 @@ ...@@ -121,6 +121,10 @@
[_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled]; [_doneButton setTitleColor:tzImagePickerVc.oKButtonTitleColorDisabled forState:UIControlStateDisabled];
[_toolBar addSubview:_doneButton]; [_toolBar addSubview:_doneButton];
[self.view addSubview:_toolBar]; [self.view addSubview:_toolBar];
if (tzImagePickerVc.videoPreviewPageUIConfigBlock) {
tzImagePickerVc.videoPreviewPageUIConfigBlock(_playButton, _toolBar, _doneButton);
}
} }
#pragma mark - Layout #pragma mark - Layout
...@@ -135,6 +139,11 @@ ...@@ -135,6 +139,11 @@
_toolBar.frame = CGRectMake(0, self.view.tz_height - toolBarHeight, self.view.tz_width, toolBarHeight); _toolBar.frame = CGRectMake(0, self.view.tz_height - toolBarHeight, self.view.tz_width, toolBarHeight);
_doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44); _doneButton.frame = CGRectMake(self.view.tz_width - 44 - 12, 0, 44, 44);
_playButton.frame = CGRectMake(0, statusBarAndNaviBarHeight, self.view.tz_width, self.view.tz_height - statusBarAndNaviBarHeight - toolBarHeight); _playButton.frame = CGRectMake(0, statusBarAndNaviBarHeight, self.view.tz_width, self.view.tz_height - statusBarAndNaviBarHeight - toolBarHeight);
TZImagePickerController *tzImagePickerVc = (TZImagePickerController *)self.navigationController;
if (tzImagePickerVc.videoPreviewPageDidLayoutSubviewsBlock) {
tzImagePickerVc.videoPreviewPageDidLayoutSubviewsBlock(_playButton, _toolBar, _doneButton);
}
} }
#pragma mark - Click Event #pragma mark - Click Event
...@@ -155,8 +164,8 @@ ...@@ -155,8 +164,8 @@
} }
- (void)doneButtonClick { - (void)doneButtonClick {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if (self.navigationController) { if (self.navigationController) {
TZImagePickerController *imagePickerVc = (TZImagePickerController *)self.navigationController;
if (imagePickerVc.autoDismiss) { if (imagePickerVc.autoDismiss) {
[self.navigationController dismissViewControllerAnimated:YES completion:^{ [self.navigationController dismissViewControllerAnimated:YES completion:^{
[self callDelegateMethod]; [self callDelegateMethod];
......
{ {
"name": "react-native-syan-image-picker", "name": "react-native-syan-image-picker",
"version": "0.1.6", "version": "0.1.7",
"description": "React-Native 多图片选择 支持裁剪 压缩", "description": "React-Native 多图片选择 支持裁剪 压缩",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment