File tree Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -635,17 +635,24 @@ + (UIImage *)UIImage:(id)json
635635 return nil ;
636636 }
637637
638- if (RCT_DEBUG && ![json isKindOfClass: [NSString class ]]) {
638+ if (RCT_DEBUG && ![json isKindOfClass: [NSString class ]] && ![json isKindOfClass: [ NSDictionary class ]] ) {
639639 RCTLogConvertError (json, " an image" );
640640 return nil ;
641641 }
642642
643- if ([json length ] == 0 ) {
644- return nil ;
643+ UIImage *image;
644+ NSString *path;
645+ CGFloat scale = 0.0 ;
646+ if ([json isKindOfClass: [NSString class ]]) {
647+ if ([json length ] == 0 ) {
648+ return nil ;
649+ }
650+ path = json;
651+ } else {
652+ path = [self NSString: json[@" uri" ]];
653+ scale = [self CGFloat: json[@" scale" ]];
645654 }
646655
647- UIImage *image = nil ;
648- NSString *path = json;
649656 if ([path hasPrefix: @" data:" ]) {
650657 NSURL *url = [NSURL URLWithString: path];
651658 NSData *imageData = [NSData dataWithContentsOfURL: url];
@@ -658,6 +665,11 @@ + (UIImage *)UIImage:(id)json
658665 image = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle ] pathForResource: path ofType: nil ]];
659666 }
660667 }
668+
669+ if (scale > 0 ) {
670+ image = [UIImage imageWithCGImage: image.CGImage scale: scale orientation: image.imageOrientation];
671+ }
672+
661673 // NOTE: we don't warn about nil images because there are legitimate
662674 // case where we find out if a string is an image by using this method
663675 return image;
Original file line number Diff line number Diff line change 1111
1212@interface RCTTabBarItem : UIView
1313
14- @property (nonatomic , copy ) NSString * icon;
14+ @property (nonatomic , copy ) id icon;
1515@property (nonatomic , assign , getter =isSelected) BOOL selected;
1616@property (nonatomic , readonly ) UITabBarItem *barItem;
1717
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ - (UITabBarItem *)barItem
2525 return _barItem;
2626}
2727
28- - (void )setIcon : (NSString * )icon
28+ - (void )setIcon : (id )icon
2929{
3030 static NSDictionary *systemIcons;
3131 static dispatch_once_t onceToken;
@@ -54,7 +54,7 @@ - (void)setIcon:(NSString *)icon
5454 UIImage *image = [RCTConvert UIImage: _icon];
5555 UITabBarItem *oldItem = _barItem;
5656 if (image) {
57-
57+
5858 // Recreate barItem if previous item was a system icon
5959 if (wasSystemIcon) {
6060 _barItem = nil ;
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ - (UIView *)view
2222}
2323
2424RCT_EXPORT_VIEW_PROPERTY (selected, BOOL );
25- RCT_EXPORT_VIEW_PROPERTY (icon, NSString );
25+ RCT_EXPORT_VIEW_PROPERTY (icon, id );
2626RCT_REMAP_VIEW_PROPERTY (selectedIcon, barItem.selectedImage, UIImage);
2727RCT_REMAP_VIEW_PROPERTY (badge, barItem.badgeValue, NSString );
2828RCT_CUSTOM_VIEW_PROPERTY (title, NSString , RCTTabBarItem)
You can’t perform that action at this time.
0 commit comments