2015-09-02 15:25:10 +00:00
|
|
|
/**
|
2017-05-06 03:50:47 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
2015-09-02 15:25:10 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-09-02 15:25:10 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-11-23 15:47:52 +00:00
|
|
|
#import <React/RCTImageLoader.h>
|
2015-09-02 15:25:10 +00:00
|
|
|
|
|
|
|
typedef BOOL (^RCTImageURLLoaderCanLoadImageURLHandler)(NSURL *requestURL);
|
2016-01-20 19:03:22 +00:00
|
|
|
typedef RCTImageLoaderCancellationBlock (^RCTImageURLLoaderLoadImageURLHandler)(NSURL *imageURL, CGSize size, CGFloat scale, RCTResizeMode resizeMode, RCTImageLoaderProgressBlock progressHandler, RCTImageLoaderCompletionBlock completionHandler);
|
2015-09-02 15:25:10 +00:00
|
|
|
|
|
|
|
@interface RCTConcreteImageURLLoader : NSObject <RCTImageURLLoader>
|
|
|
|
|
|
|
|
- (instancetype)initWithPriority:(float)priority
|
|
|
|
canLoadImageURLHandler:(RCTImageURLLoaderCanLoadImageURLHandler)canLoadImageURLHandler
|
|
|
|
loadImageURLHandler:(RCTImageURLLoaderLoadImageURLHandler)loadImageURLHandler;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-10-19 16:04:54 +00:00
|
|
|
typedef BOOL (^RCTImageDataDecoderCanDecodeImageDataHandler)(NSData *imageData);
|
2016-01-20 19:03:22 +00:00
|
|
|
typedef RCTImageLoaderCancellationBlock (^RCTImageDataDecoderDecodeImageDataHandler)(NSData *imageData, CGSize size, CGFloat scale, RCTResizeMode resizeMode, RCTImageLoaderCompletionBlock completionHandler);
|
2015-09-02 15:25:10 +00:00
|
|
|
|
2015-10-19 16:04:54 +00:00
|
|
|
@interface RCTConcreteImageDecoder : NSObject <RCTImageDataDecoder>
|
2015-09-02 15:25:10 +00:00
|
|
|
|
|
|
|
- (instancetype)initWithPriority:(float)priority
|
2015-10-19 16:04:54 +00:00
|
|
|
canDecodeImageDataHandler:(RCTImageDataDecoderCanDecodeImageDataHandler)canDecodeImageDataHandler
|
|
|
|
decodeImageDataHandler:(RCTImageDataDecoderDecodeImageDataHandler)decodeImageDataHandler;
|
2015-09-02 15:25:10 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
#define _RCTDefineImageHandler(SUPERCLASS, CLASS_NAME) \
|
|
|
|
@interface CLASS_NAME : SUPERCLASS @end \
|
|
|
|
@implementation CLASS_NAME RCT_EXPORT_MODULE() @end
|
|
|
|
|
|
|
|
#define RCTDefineImageURLLoader(CLASS_NAME) \
|
|
|
|
_RCTDefineImageHandler(RCTConcreteImageURLLoader, CLASS_NAME)
|
|
|
|
|
|
|
|
#define RCTDefineImageDecoder(CLASS_NAME) \
|
|
|
|
_RCTDefineImageHandler(RCTConcreteImageDecoder, CLASS_NAME)
|