Skip to content

Commit 1d85262

Browse files
committed
Refactored RCTImageDownloader to use RCTNetworking instead of a separate download system
1 parent 3cff9be commit 1d85262

File tree

11 files changed

+159
-326
lines changed

11 files changed

+159
-326
lines changed

Libraries/Image/RCTDownloadTaskWrapper.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

Libraries/Image/RCTDownloadTaskWrapper.m

Lines changed: 0 additions & 98 deletions
This file was deleted.

Libraries/Image/RCTImage.xcodeproj/project.pbxproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
03559E7F1B064DAF00730281 /* RCTDownloadTaskWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 03559E7E1B064DAF00730281 /* RCTDownloadTaskWrapper.m */; };
1110
1304D5AB1AA8C4A30002E2BE /* RCTImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1304D5A81AA8C4A30002E2BE /* RCTImageView.m */; };
1211
1304D5AC1AA8C4A30002E2BE /* RCTImageViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1304D5AA1AA8C4A30002E2BE /* RCTImageViewManager.m */; };
1312
1304D5B21AA8C50D0002E2BE /* RCTGIFImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 1304D5B11AA8C50D0002E2BE /* RCTGIFImage.m */; };
@@ -33,8 +32,6 @@
3332
/* End PBXCopyFilesBuildPhase section */
3433

3534
/* Begin PBXFileReference section */
36-
03559E7D1B064D3A00730281 /* RCTDownloadTaskWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTDownloadTaskWrapper.h; sourceTree = "<group>"; };
37-
03559E7E1B064DAF00730281 /* RCTDownloadTaskWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDownloadTaskWrapper.m; sourceTree = "<group>"; };
3835
1304D5A71AA8C4A30002E2BE /* RCTImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageView.h; sourceTree = "<group>"; };
3936
1304D5A81AA8C4A30002E2BE /* RCTImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageView.m; sourceTree = "<group>"; };
4037
1304D5A91AA8C4A30002E2BE /* RCTImageViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageViewManager.h; sourceTree = "<group>"; };
@@ -74,8 +71,6 @@
7471
children = (
7572
143879331AAD238D00F088A5 /* RCTCameraRollManager.h */,
7673
143879341AAD238D00F088A5 /* RCTCameraRollManager.m */,
77-
03559E7D1B064D3A00730281 /* RCTDownloadTaskWrapper.h */,
78-
03559E7E1B064DAF00730281 /* RCTDownloadTaskWrapper.m */,
7974
1304D5B01AA8C50D0002E2BE /* RCTGIFImage.h */,
8075
1304D5B11AA8C50D0002E2BE /* RCTGIFImage.m */,
8176
58B511891A9E6BD600147676 /* RCTImageDownloader.h */,
@@ -172,7 +167,6 @@
172167
1304D5B21AA8C50D0002E2BE /* RCTGIFImage.m in Sources */,
173168
143879351AAD238D00F088A5 /* RCTCameraRollManager.m in Sources */,
174169
143879381AAD32A300F088A5 /* RCTImageLoader.m in Sources */,
175-
03559E7F1B064DAF00730281 /* RCTDownloadTaskWrapper.m in Sources */,
176170
1304D5AB1AA8C4A30002E2BE /* RCTImageView.m in Sources */,
177171
134B00A21B54232B00EC8DFB /* RCTImageUtils.m in Sources */,
178172
);
@@ -275,6 +269,7 @@
275269
"$(inherited)",
276270
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
277271
"$(SRCROOT)/../../React/**",
272+
"$(SRCROOT)/../Network/**",
278273
);
279274
LIBRARY_SEARCH_PATHS = (
280275
"$(inherited)",
@@ -295,6 +290,7 @@
295290
"$(inherited)",
296291
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
297292
"$(SRCROOT)/../../React/**",
293+
"$(SRCROOT)/../Network/**",
298294
);
299295
LIBRARY_SEARCH_PATHS = (
300296
"$(inherited)",

Libraries/Image/RCTImageDownloader.h

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,28 @@
99

1010
#import <UIKit/UIKit.h>
1111

12-
#import "RCTDownloadTaskWrapper.h"
12+
#import "RCTBridge.h"
13+
#import "RCTImageLoader.h"
1314

14-
typedef void (^RCTDataDownloadBlock)(NSData *data, NSError *error);
15-
typedef void (^RCTImageDownloadBlock)(UIImage *image, NSError *error);
16-
typedef void (^RCTImageDownloadCancellationBlock)(void);
17-
18-
@interface RCTImageDownloader : NSObject
19-
20-
+ (RCTImageDownloader *)sharedInstance;
21-
22-
/**
23-
* Downloads a block of raw data and returns it. Note that the callback block
24-
* will not be executed on the same thread you called the method from, nor on
25-
* the main thread. Returns a token that can be used to cancel the download.
26-
*/
27-
- (RCTImageDownloadCancellationBlock)downloadDataForURL:(NSURL *)url
28-
progressBlock:(RCTDataProgressBlock)progressBlock
29-
block:(RCTDataDownloadBlock)block;
15+
@interface RCTImageDownloader : NSObject <RCTBridgeModule>
3016

3117
/**
3218
* Downloads an image and decompresses it a the size specified. The compressed
3319
* image will be cached in memory and to disk. Note that the callback block
3420
* will not be executed on the same thread you called the method from, nor on
3521
* the main thread. Returns a token that can be used to cancel the download.
3622
*/
37-
- (RCTImageDownloadCancellationBlock)downloadImageForURL:(NSURL *)url
38-
size:(CGSize)size
39-
scale:(CGFloat)scale
40-
resizeMode:(UIViewContentMode)resizeMode
41-
tintColor:(UIColor *)tintColor
42-
backgroundColor:(UIColor *)backgroundColor
43-
progressBlock:(RCTDataProgressBlock)progressBlock
44-
block:(RCTImageDownloadBlock)block;
23+
- (RCTImageLoaderCancellationBlock)downloadImageForURL:(NSURL *)url
24+
size:(CGSize)size
25+
scale:(CGFloat)scale
26+
resizeMode:(UIViewContentMode)resizeMode
27+
progressBlock:(RCTImageLoaderProgressBlock)progressBlock
28+
completionBlock:(RCTImageLoaderCompletionBlock)block;
29+
30+
@end
31+
32+
@interface RCTBridge (RCTImageDownloader)
33+
34+
@property (nonatomic, readonly) RCTImageDownloader *imageDownloader;
4535

4636
@end

0 commit comments

Comments
 (0)