Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -619,17 +619,24 @@ + (UIImage *)UIImage:(id)json
return nil;
}

if (RCT_DEBUG && ![json isKindOfClass:[NSString class]]) {
if (RCT_DEBUG && ![json isKindOfClass:[NSString class]] && ![json isKindOfClass:[NSDictionary class]]) {
RCTLogConvertError(json, "an image");
return nil;
}

if ([json length] == 0) {
return nil;
UIImage *image;
NSString *path;
CGFloat scale = 0.0;
if ([json isKindOfClass:[NSString class]]) {
if ([json length] == 0) {
return nil;
}
path = json;
} else {
path = [self NSString:json[@"uri"]];
scale = [self CGFloat:json[@"scale"]];
}

UIImage *image = nil;
NSString *path = json;
if ([path hasPrefix:@"data:"]) {
NSURL *url = [NSURL URLWithString:path];
NSData *imageData = [NSData dataWithContentsOfURL:url];
Expand All @@ -642,6 +649,11 @@ + (UIImage *)UIImage:(id)json
image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:path ofType:nil]];
}
}

if (scale > 0) {
image = [UIImage imageWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation];
}

// NOTE: we don't warn about nil images because there are legitimate
// case where we find out if a string is an image by using this method
return image;
Expand Down
2 changes: 1 addition & 1 deletion React/Views/RCTTabBarItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@interface RCTTabBarItem : UIView

@property (nonatomic, copy) NSString *icon;
@property (nonatomic, copy) id icon;
@property (nonatomic, assign, getter=isSelected) BOOL selected;
@property (nonatomic, readonly) UITabBarItem *barItem;

Expand Down
4 changes: 2 additions & 2 deletions React/Views/RCTTabBarItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ - (UITabBarItem *)barItem
return _barItem;
}

- (void)setIcon:(NSString *)icon
- (void)setIcon:(id)icon
{
static NSDictionary *systemIcons;
static dispatch_once_t onceToken;
Expand Down Expand Up @@ -54,7 +54,7 @@ - (void)setIcon:(NSString *)icon
UIImage *image = [RCTConvert UIImage:_icon];
UITabBarItem *oldItem = _barItem;
if (image) {

// Recreate barItem if previous item was a system icon
if (wasSystemIcon) {
_barItem = nil;
Expand Down
2 changes: 1 addition & 1 deletion React/Views/RCTTabBarItemManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ - (UIView *)view
}

RCT_EXPORT_VIEW_PROPERTY(selected, BOOL);
RCT_EXPORT_VIEW_PROPERTY(icon, NSString);
RCT_EXPORT_VIEW_PROPERTY(icon, id);
RCT_REMAP_VIEW_PROPERTY(selectedIcon, barItem.selectedImage, UIImage);
RCT_REMAP_VIEW_PROPERTY(badge, barItem.badgeValue, NSString);
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
Expand Down