mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
d5943b0e47
Summary: Remote images now support the `tintColor` prop. Also picked nicer demo colors for the UIExplorer example. Fixes #1867 Closes https://github.com/facebook/react-native/pull/1932 Github Author: James Ide <ide@jameside.com>
57 lines
1.6 KiB
Objective-C
57 lines
1.6 KiB
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import "RCTNetworkImageViewManager.h"
|
|
|
|
#import "RCTBridge.h"
|
|
#import "RCTConvert.h"
|
|
#import "RCTImageDownloader.h"
|
|
#import "RCTNetworkImageView.h"
|
|
#import "RCTUtils.h"
|
|
|
|
@implementation RCTNetworkImageViewManager
|
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
@synthesize bridge = _bridge;
|
|
@synthesize methodQueue = _methodQueue;
|
|
|
|
- (UIView *)view
|
|
{
|
|
return [[RCTNetworkImageView alloc] initWithEventDispatcher:self.bridge.eventDispatcher imageDownloader:[RCTImageDownloader sharedInstance]];
|
|
}
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(defaultImageSrc, defaultImage, UIImage)
|
|
RCT_REMAP_VIEW_PROPERTY(src, imageURL, NSURL)
|
|
RCT_REMAP_VIEW_PROPERTY(resizeMode, contentMode, UIViewContentMode)
|
|
RCT_EXPORT_VIEW_PROPERTY(progressHandlerRegistered, BOOL)
|
|
RCT_CUSTOM_VIEW_PROPERTY(tintColor, UIColor, RCTNetworkImageView)
|
|
{
|
|
if (json) {
|
|
view.tinted = YES;
|
|
view.tintColor = [RCTConvert UIColor:json];
|
|
} else {
|
|
view.tinted = defaultView.tinted;
|
|
view.tintColor = defaultView.tintColor;
|
|
}
|
|
}
|
|
|
|
- (NSDictionary *)customDirectEventTypes
|
|
{
|
|
return @{
|
|
@"loadStart": @{ @"registrationName": @"onLoadStart" },
|
|
@"loadProgress": @{ @"registrationName": @"onLoadProgress" },
|
|
@"loaded": @{ @"registrationName": @"onLoaded" },
|
|
@"loadError": @{ @"registrationName": @"onLoadError" },
|
|
@"loadAbort": @{ @"registrationName": @"onLoadAbort" },
|
|
};
|
|
}
|
|
|
|
@end
|