Merge pull request #37 from wix/enhancements

Enhancements
This commit is contained in:
Ran 2017-05-14 19:23:50 +03:00 committed by GitHub
commit 7e7384388c
3 changed files with 28 additions and 0 deletions

View File

@ -57,6 +57,7 @@
@property (nonatomic, strong) NSNumber *disableSelectionIcons;
@property (nonatomic, strong) NSDictionary *selection;
@property (nonatomic) UIEdgeInsets contentInset;
@property (nonatomic) BOOL alwaysBounce;
//custom button props
@property (nonatomic, strong) NSDictionary *customButtonStyle;
@ -132,6 +133,7 @@ static NSString * const CustomCellReuseIdentifier = @"CustomCell";
self.collectionView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:flowLayout];
self.collectionView.contentInset = self.contentInset;
self.collectionView.scrollIndicatorInsets = self.contentInset;
self.collectionView.alwaysBounceVertical = self.alwaysBounce;
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
@ -208,6 +210,13 @@ static NSString * const CustomCellReuseIdentifier = @"CustomCell";
_contentInset = contentInset;
}
-(void)setAlwaysBounce:(BOOL)alwaysBounce {
if(self.collectionView) {
self.collectionView.alwaysBounceVertical = alwaysBounce;
}
_alwaysBounce = alwaysBounce;
}
-(void)setFileTypeSupport:(NSDictionary *)supported {
_fileTypeSupport = supported;
@ -507,6 +516,7 @@ RCT_EXPORT_VIEW_PROPERTY(autoSyncSelection, NSNumber);
RCT_EXPORT_VIEW_PROPERTY(selection, NSDictionary);
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets);
RCT_EXPORT_VIEW_PROPERTY(imageQualityOnTap, NSString);
RCT_EXPORT_VIEW_PROPERTY(alwaysBounce, BOOL);
RCT_EXPORT_METHOD(getSelectedImages:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject) {
@ -568,6 +578,16 @@ RCT_EXPORT_METHOD(refreshGalleryView:(NSArray*)selectedImages
resolve(@YES);
}
RCT_EXPORT_METHOD(modifyGalleryViewContentOffset:(NSDictionary*)params) {
CGPoint newOffset = self.galleryView.collectionView.contentOffset;
if(params[@"x"] != nil) {
newOffset.x += [params[@"x"] floatValue];
}
if(params[@"y"] != nil) {
newOffset.y += [params[@"y"] floatValue];
}
[self.galleryView.collectionView setContentOffset:newOffset];
}
#pragma mark - Static functions

View File

@ -27,6 +27,10 @@ export default class CameraKitGalleryView extends Component {
return true;
}
modifyGalleryViewContentOffset (offset) {
//do nothing. compatability with ios
}
render() {
const transformedProps = {...this.props};
transformedProps.albumName = this.props.albumName ? this.props.albumName : ALL_PHOTOS;

View File

@ -55,4 +55,8 @@ export default class CameraKitGalleryView extends Component {
const isSuccess = await GalleryViewManager.refreshGalleryView(selectedImages);
return isSuccess;
}
modifyGalleryViewContentOffset (offset) {
GalleryViewManager.modifyGalleryViewContentOffset(offset);
}
}