From 96b27cbcb032e089c55e8110d7c92e5cd2786ab0 Mon Sep 17 00:00:00 2001 From: Ran Greenberg Date: Sat, 30 Dec 2017 09:55:57 +0200 Subject: [PATCH 1/3] add imageStrokeWidth --- .../CKGalleryCollectionViewCell.h | 1 + .../CKGalleryCollectionViewCell.m | 17 ++++++++++++----- .../ReactNativeCameraKit/CKGalleryViewManager.m | 6 ++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.h b/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.h index b151758..a44ed4b 100644 --- a/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.h +++ b/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.h @@ -25,6 +25,7 @@ +(void)setUnSlectedImageIcon:(UIImage*)image; +(void)setSupported:(NSDictionary*)newSupported; +(void)setImageStrokeColor:(UIColor*)strokeColor; ++(void)setImageStrokeWidth:(NSNumber*)width; +(void)setSelection:(NSDictionary*)selectionDict; +(void)setRemoteDownloadIndicatorColor:(UIColor*)color; +(void)setRemoteDownloadIndicatorType:(NSString*)type; diff --git a/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.m b/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.m index c7122c4..1387a87 100644 --- a/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.m +++ b/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.m @@ -21,9 +21,9 @@ -#define BADGE_MARGIN 5 -#define BADGE_COLOR 0x00ADF5 -#define IMAGE_OVERLAY_ALPHA 0.5 +#define BADGE_MARGIN 5 +#define BADGE_COLOR 0x00ADF5 +#define IMAGE_OVERLAY_ALPHA 0.5 #define SELECTION_SELECTED_IMAGE @"selectedImage" #define SELECTION_UNSELECTED_IMAGE @"unselectedImage" @@ -42,6 +42,7 @@ static UIImage *selectedImageIcon = nil; static UIImage *unSelectedImageIcon = nil; static NSDictionary *supported = nil; static UIColor *imageStrokeColor = nil; +static NSNumber *imageStrokeWidth = nil; static NSDictionary *selection = nil; static NSString *imagePosition = nil; static UIColor *selectionOverlayColor = nil; @@ -84,6 +85,11 @@ static NSString *remoteDownloadIndicatorType = REMOTE_DOWNLOAD_INDICATOR_TYPE_SP if (strokeColor) imageStrokeColor = strokeColor; } ++(void)setImageStrokeWidth:(NSNumber*)width { + if (width) imageStrokeWidth = width; +} + + +(void)setSelection:(NSDictionary*)selectionDict { if (selectionDict) selection = selectionDict; } @@ -94,6 +100,7 @@ static NSString *remoteDownloadIndicatorType = REMOTE_DOWNLOAD_INDICATOR_TYPE_SP unSelectedImageIcon = nil; supported = nil; imageStrokeColor = nil; + imageStrokeWidth = nil; selection = nil; imagePosition = nil; selectionOverlayColor = nil; @@ -163,8 +170,8 @@ static NSString *remoteDownloadIndicatorType = REMOTE_DOWNLOAD_INDICATOR_TYPE_SP CGRect imageViewFrame = self.bounds; if(imageStrokeColor) { - imageViewFrame.size.height -= 2; - imageViewFrame.size.width -= 2; + imageViewFrame.size.height -= imageStrokeWidth.floatValue; + imageViewFrame.size.width -= imageStrokeWidth.floatValue; self.backgroundColor = imageStrokeColor; } diff --git a/ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m b/ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m index 6bba60f..33f609a 100644 --- a/ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m +++ b/ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m @@ -56,6 +56,7 @@ typedef void (^CompletionBlock)(BOOL success); @property (nonatomic, strong) UIImage *selectedImageIcon; @property (nonatomic, strong) UIImage *unSelectedImageIcon; @property (nonatomic, strong) UIColor *imageStrokeColor; +@property (nonatomic, strong) NSNumber *imageStrokeWidth; @property (nonatomic, strong) NSNumber *disableSelectionIcons; @property (nonatomic, strong) NSDictionary *selection; @property (nonatomic) UIEdgeInsets contentInset; @@ -220,6 +221,10 @@ static NSString * const CustomCellReuseIdentifier = @"CustomCell"; [CKGalleryCollectionViewCell setImageStrokeColor:imageStrokeColor]; } +-(void)setImageStrokeWidth:(NSNumber *)imageStrokeWidth { + [CKGalleryCollectionViewCell setImageStrokeWidth:imageStrokeWidth]; +} + -(void)setSelection:(NSDictionary *)selection { [CKGalleryCollectionViewCell setSelection:selection]; } @@ -706,6 +711,7 @@ RCT_EXPORT_VIEW_PROPERTY(unSelectedImageIcon, UIImage); RCT_EXPORT_VIEW_PROPERTY(selectedImages, NSArray); RCT_EXPORT_VIEW_PROPERTY(fileTypeSupport, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(imageStrokeColor, UIColor); +RCT_EXPORT_VIEW_PROPERTY(imageStrokeWidth, NSNumber); RCT_EXPORT_VIEW_PROPERTY(disableSelectionIcons, NSNumber); RCT_EXPORT_VIEW_PROPERTY(customButtonStyle, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(onCustomButtonPress, RCTDirectEventBlock); From 92b7d3876791504cc63b35cb7c393a41df494e11 Mon Sep 17 00:00:00 2001 From: Ran Greenberg Date: Sat, 30 Dec 2017 09:56:19 +0200 Subject: [PATCH 2/3] update readme with imageStrokeWidth --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1a1f45e..8eb3211 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ Attribute | Values | Description `minimumInteritemSpacing` | Float | Minimum inner Item spacing `minimumLineSpacing` | Float | Minimum line spacing `imageStrokeColor` | Color | Image stroke color +`imageStrokeWidth` | Number | Image stroke width `albumName` | String | Album name to show `columnCount` | Integer | How many clumns in one row `onTapImage` | Function | Callback when image tapped From 9da6665e597d0762a2fac63809c726a57dfd037d Mon Sep 17 00:00:00 2001 From: Ran Greenberg Date: Sun, 31 Dec 2017 10:14:19 +0200 Subject: [PATCH 3/3] handle negative numbers and rename to imageStrokeColorWidth --- README.md | 2 +- .../CKGalleryCollectionViewCell.h | 2 +- .../CKGalleryCollectionViewCell.m | 14 ++++++++------ .../ReactNativeCameraKit/CKGalleryViewManager.m | 8 ++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8eb3211..aa9ddb0 100644 --- a/README.md +++ b/README.md @@ -166,7 +166,7 @@ Attribute | Values | Description `minimumInteritemSpacing` | Float | Minimum inner Item spacing `minimumLineSpacing` | Float | Minimum line spacing `imageStrokeColor` | Color | Image stroke color -`imageStrokeWidth` | Number | Image stroke width +`imageStrokeColorWidth` | Number > 0 | Image stroke color width `albumName` | String | Album name to show `columnCount` | Integer | How many clumns in one row `onTapImage` | Function | Callback when image tapped diff --git a/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.h b/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.h index a44ed4b..4474b9e 100644 --- a/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.h +++ b/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.h @@ -25,7 +25,7 @@ +(void)setUnSlectedImageIcon:(UIImage*)image; +(void)setSupported:(NSDictionary*)newSupported; +(void)setImageStrokeColor:(UIColor*)strokeColor; -+(void)setImageStrokeWidth:(NSNumber*)width; ++(void)setImageStrokeColorWidth:(NSNumber*)width; +(void)setSelection:(NSDictionary*)selectionDict; +(void)setRemoteDownloadIndicatorColor:(UIColor*)color; +(void)setRemoteDownloadIndicatorType:(NSString*)type; diff --git a/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.m b/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.m index 1387a87..e31f12b 100644 --- a/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.m +++ b/ios/lib/ReactNativeCameraKit/CKGalleryCollectionViewCell.m @@ -42,7 +42,7 @@ static UIImage *selectedImageIcon = nil; static UIImage *unSelectedImageIcon = nil; static NSDictionary *supported = nil; static UIColor *imageStrokeColor = nil; -static NSNumber *imageStrokeWidth = nil; +static NSNumber *imageStrokeColorWidth = nil; static NSDictionary *selection = nil; static NSString *imagePosition = nil; static UIColor *selectionOverlayColor = nil; @@ -85,8 +85,8 @@ static NSString *remoteDownloadIndicatorType = REMOTE_DOWNLOAD_INDICATOR_TYPE_SP if (strokeColor) imageStrokeColor = strokeColor; } -+(void)setImageStrokeWidth:(NSNumber*)width { - if (width) imageStrokeWidth = width; ++(void)setImageStrokeColorWidth:(NSNumber*)width { + if (width) imageStrokeColorWidth = width; } @@ -100,7 +100,7 @@ static NSString *remoteDownloadIndicatorType = REMOTE_DOWNLOAD_INDICATOR_TYPE_SP unSelectedImageIcon = nil; supported = nil; imageStrokeColor = nil; - imageStrokeWidth = nil; + imageStrokeColorWidth = nil; selection = nil; imagePosition = nil; selectionOverlayColor = nil; @@ -170,8 +170,10 @@ static NSString *remoteDownloadIndicatorType = REMOTE_DOWNLOAD_INDICATOR_TYPE_SP CGRect imageViewFrame = self.bounds; if(imageStrokeColor) { - imageViewFrame.size.height -= imageStrokeWidth.floatValue; - imageViewFrame.size.width -= imageStrokeWidth.floatValue; + if (imageStrokeColorWidth && imageStrokeColorWidth.floatValue > 0) { + imageViewFrame.size.height -= imageStrokeColorWidth.floatValue; + imageViewFrame.size.width -= imageStrokeColorWidth.floatValue; + } self.backgroundColor = imageStrokeColor; } diff --git a/ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m b/ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m index 33f609a..31ba415 100644 --- a/ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m +++ b/ios/lib/ReactNativeCameraKit/CKGalleryViewManager.m @@ -56,7 +56,7 @@ typedef void (^CompletionBlock)(BOOL success); @property (nonatomic, strong) UIImage *selectedImageIcon; @property (nonatomic, strong) UIImage *unSelectedImageIcon; @property (nonatomic, strong) UIColor *imageStrokeColor; -@property (nonatomic, strong) NSNumber *imageStrokeWidth; +@property (nonatomic, strong) NSNumber *imageStrokeColorWidth; @property (nonatomic, strong) NSNumber *disableSelectionIcons; @property (nonatomic, strong) NSDictionary *selection; @property (nonatomic) UIEdgeInsets contentInset; @@ -221,8 +221,8 @@ static NSString * const CustomCellReuseIdentifier = @"CustomCell"; [CKGalleryCollectionViewCell setImageStrokeColor:imageStrokeColor]; } --(void)setImageStrokeWidth:(NSNumber *)imageStrokeWidth { - [CKGalleryCollectionViewCell setImageStrokeWidth:imageStrokeWidth]; +-(void)setImageStrokeColorWidth:(NSNumber *)imageStrokeColorWidth { + [CKGalleryCollectionViewCell setImageStrokeColorWidth:imageStrokeColorWidth]; } -(void)setSelection:(NSDictionary *)selection { @@ -711,7 +711,7 @@ RCT_EXPORT_VIEW_PROPERTY(unSelectedImageIcon, UIImage); RCT_EXPORT_VIEW_PROPERTY(selectedImages, NSArray); RCT_EXPORT_VIEW_PROPERTY(fileTypeSupport, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(imageStrokeColor, UIColor); -RCT_EXPORT_VIEW_PROPERTY(imageStrokeWidth, NSNumber); +RCT_EXPORT_VIEW_PROPERTY(imageStrokeColorWidth, NSNumber); RCT_EXPORT_VIEW_PROPERTY(disableSelectionIcons, NSNumber); RCT_EXPORT_VIEW_PROPERTY(customButtonStyle, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(onCustomButtonPress, RCTDirectEventBlock);