Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade SDWebImage 5.0, using SDAnimatedImageView instead of FLAnimatedImageView for better animation support #454

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
82 changes: 18 additions & 64 deletions ios/FastImage.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
objects = {

/* Begin PBXBuildFile section */
FCC6D1391EB3912D0065F944 /* libSDWebImage iOS static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FCC6D0D01EB38D2F0065F944 /* libSDWebImage iOS static.a */; };
FCC6D1391EB3912D0065F944 /* libSDWebImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FCC6D0D01EB38D2F0065F944 /* libSDWebImage.a */; };
FCFB253F1EA5562700F59778 /* FFFastImageSource.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFB25381EA5562700F59778 /* FFFastImageSource.m */; };
FCFB25401EA5562700F59778 /* FFFastImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFB253A1EA5562700F59778 /* FFFastImageView.m */; };
FCFB25411EA5562700F59778 /* FFFastImageViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFB253C1EA5562700F59778 /* FFFastImageViewManager.m */; };
FCFB25421EA5562700F59778 /* RCTConvert+FFFastImage.m in Sources */ = {isa = PBXBuildFile; fileRef = FCFB253E1EA5562700F59778 /* RCTConvert+FFFastImage.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
FCC6D0CF1EB38D2F0065F944 /* PBXContainerItemProxy */ = {
3236AC0D226EC00400425AA3 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FCC6D0C61EB38D2F0065F944 /* SDWebImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 53761325155AD0D5005750A4;
remoteInfo = "SDWebImage iOS static";
remoteGlobalIDString = 80B6DFEE2142B71600BCB334;
remoteInfo = SDWebImageMapKit;
};
FCC6D0D11EB38D2F0065F944 /* PBXContainerItemProxy */ = {
FCC6D0CF1EB38D2F0065F944 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FCC6D0C61EB38D2F0065F944 /* SDWebImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 4314D1991D0E0E3B004B36C9;
remoteInfo = "SDWebImage watchOS static";
remoteGlobalIDString = 53761325155AD0D5005750A4;
remoteInfo = "SDWebImage iOS static";
};
FCC6D0D31EB38D2F0065F944 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
Expand All @@ -36,27 +36,6 @@
remoteGlobalIDString = 4A2CADFF1AB4BB5300B6BC39;
remoteInfo = "SDWebImage iOS";
};
FCC6D0D51EB38D2F0065F944 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FCC6D0C61EB38D2F0065F944 /* SDWebImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 00733A4C1BC487C000A5A117;
remoteInfo = "SDWebImage tvOS";
};
FCC6D0D71EB38D2F0065F944 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FCC6D0C61EB38D2F0065F944 /* SDWebImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 431BB7031D06D2C1006A3455;
remoteInfo = "SDWebImage watchOS";
};
FCC6D0D91EB38D2F0065F944 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FCC6D0C61EB38D2F0065F944 /* SDWebImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 4397D2F21D0DDD8C00BB2784;
remoteInfo = "SDWebImage OSX";
};
FCC6D1281EB3908E0065F944 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = FCC6D0C61EB38D2F0065F944 /* SDWebImage.xcodeproj */;
Expand Down Expand Up @@ -96,7 +75,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FCC6D1391EB3912D0065F944 /* libSDWebImage iOS static.a in Frameworks */,
FCC6D1391EB3912D0065F944 /* libSDWebImage.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -131,12 +110,9 @@
FCC6D0C71EB38D2F0065F944 /* Products */ = {
isa = PBXGroup;
children = (
FCC6D0D01EB38D2F0065F944 /* libSDWebImage iOS static.a */,
FCC6D0D21EB38D2F0065F944 /* libSDWebImage watchOS static.a */,
FCC6D0D01EB38D2F0065F944 /* libSDWebImage.a */,
FCC6D0D41EB38D2F0065F944 /* SDWebImage.framework */,
FCC6D0D61EB38D2F0065F944 /* SDWebImage.framework */,
FCC6D0D81EB38D2F0065F944 /* SDWebImage.framework */,
FCC6D0DA1EB38D2F0065F944 /* SDWebImage.framework */,
3236AC0E226EC00400425AA3 /* SDWebImageMapKit.framework */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -197,6 +173,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = A28797141DE0C0A60081BDFA;
Expand All @@ -216,18 +193,18 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
FCC6D0D01EB38D2F0065F944 /* libSDWebImage iOS static.a */ = {
3236AC0E226EC00400425AA3 /* SDWebImageMapKit.framework */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libSDWebImage iOS static.a";
remoteRef = FCC6D0CF1EB38D2F0065F944 /* PBXContainerItemProxy */;
fileType = wrapper.framework;
path = SDWebImageMapKit.framework;
remoteRef = 3236AC0D226EC00400425AA3 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FCC6D0D21EB38D2F0065F944 /* libSDWebImage watchOS static.a */ = {
FCC6D0D01EB38D2F0065F944 /* libSDWebImage.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libSDWebImage watchOS static.a";
remoteRef = FCC6D0D11EB38D2F0065F944 /* PBXContainerItemProxy */;
path = libSDWebImage.a;
remoteRef = FCC6D0CF1EB38D2F0065F944 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FCC6D0D41EB38D2F0065F944 /* SDWebImage.framework */ = {
Expand All @@ -237,27 +214,6 @@
remoteRef = FCC6D0D31EB38D2F0065F944 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FCC6D0D61EB38D2F0065F944 /* SDWebImage.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = SDWebImage.framework;
remoteRef = FCC6D0D51EB38D2F0065F944 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FCC6D0D81EB38D2F0065F944 /* SDWebImage.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = SDWebImage.framework;
remoteRef = FCC6D0D71EB38D2F0065F944 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
FCC6D0DA1EB38D2F0065F944 /* SDWebImage.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = SDWebImage.framework;
remoteRef = FCC6D0D91EB38D2F0065F944 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -376,7 +332,6 @@
"$(SRCROOT)/../../react-native/Libraries/Image",
"$(SRCROOT)/../../../ios/Pods/Headers/Public/**",
"$(SRCROOT)/Vendor/SDWebImage",
"$(SRCROOT)/Vendor/SDWebImage/Vendors/FLAnimatedImage",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -393,7 +348,6 @@
"$(SRCROOT)/../../react-native/Libraries/Image",
"$(SRCROOT)/../../../ios/Pods/Headers/Public/**",
"$(SRCROOT)/Vendor/SDWebImage",
"$(SRCROOT)/Vendor/SDWebImage/Vendors/FLAnimatedImage",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
12 changes: 2 additions & 10 deletions ios/FastImage/FFFastImageView.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
#import <UIKit/UIKit.h>

#import <SDWebImage/UIImageView+WebCache.h>
#import <SDWebImage/SDAnimatedImageView+WebCache.h>
#import <SDWebImage/SDWebImageDownloader.h>

// Import from the FLAnimated image CocoaPod if it's available.
#if __has_include(<FLAnimatedImage/FLAnimatedImageView.h>)
#import <FLAnimatedImage/FLAnimatedImageView.h>
// Import from the version within SDWebImage otherwise.
#elif __has_include(<SDWebImage/FLAnimatedImageView.h>)
#import <SDWebImage/FLAnimatedImageView.h>
#endif

#import <React/RCTComponent.h>
#import <React/RCTResizeMode.h>

#import "FFFastImageSource.h"

@interface FFFastImageView : FLAnimatedImageView
@interface FFFastImageView : SDAnimatedImageView

@property (nonatomic, copy) RCTDirectEventBlock onFastImageLoadStart;
@property (nonatomic, copy) RCTDirectEventBlock onFastImageProgress;
Expand Down
4 changes: 3 additions & 1 deletion ios/FastImage/FFFastImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ - (void)setSource:(FFFastImageSource *)source {
options |= SDWebImageRefreshCached;
break;
case FFFCacheControlCacheOnly:
options |= SDWebImageCacheMemoryOnly;
// old version using `SDWebImageFromCacheOnly`
// which control the store cache type but not avoiding network
options |= SDWebImageFromCacheOnly;
break;
case FFFCacheControlImmutable:
break;
Expand Down
2 changes: 1 addition & 1 deletion ios/Vendor/SDWebImage
5 changes: 1 addition & 4 deletions react-native-fast-image.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,5 @@ Pod::Spec.new do |s|
s.exclude_files = "ios/Vendor/**/*.{h,m}"

s.dependency 'React'
s.dependency 'SDWebImage/Core'
s.dependency 'SDWebImage/GIF'
s.dependency 'SDWebImage/WebP'
Copy link
Contributor Author

@dreampiggy dreampiggy Apr 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 5.0, all external image format (Not supported by Apple's built-in framework), is a coder plugin.

The user, can choose to use any format, don't need a CocoaPods subspec for this. Which make it more modular and under control. See more on : https://github.com/SDWebImage/SDWebImage/wiki/Coder-Plugin-List

For example, if user want to use WebP format, they can do this:

pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image'
pod 'SDWebImageWebPCoder'

Then register the coder plugin, in AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
// Register WebP format support
[SDImageCodersManager.sharedManager addCoder:SDImageWebPCoder.sharedCoder];
// ...
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would mean that by default this module would no longer support as many formats though right?

Copy link
Contributor Author

@dreampiggy dreampiggy May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would mean that by default this module would no longer support as many formats though right?

Whether SDWebImage supports some format, or not. It's now, totally controlled by the users (the Pod integrator). If users want, they can supports all the format, listed in : Coder Plugin List.

The main repo (SDWebImage pod itself), only supports the built-in format by Apple's SDK. Typically the JPEG/PNG/APNG/TIFF/GIF/HEIF, etc.

As I see, react-native-fast-image SDK, didn't rely on any dependency on what original image format is. Isn't it ? We just care about the animation, and their meta info (loop count/ frame count), but not what detailed the original compressed data is. Both APNG/GIF/WebP/BPG(more) supports animation, they can be abstracted as the same.

s.dependency 'FLAnimatedImage'
s.dependency 'SDWebImage', '~> 5.0'
end