From a68155a0ec95b4047172729263a75b46f8a8a73c Mon Sep 17 00:00:00 2001 From: pengfeizhou Date: Thu, 28 Jan 2021 19:14:04 +0800 Subject: [PATCH] iOS:Remove dependency of YYImage --- DoricCore.podspec | 6 --- doric-iOS/Example/Podfile | 5 +++ doric-iOS/Pod/Classes/Shader/DoricImageNode.m | 40 ++++++++++++++++++- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/DoricCore.podspec b/DoricCore.podspec index 788b94f2..7b489429 100644 --- a/DoricCore.podspec +++ b/DoricCore.podspec @@ -21,13 +21,7 @@ Doric iOS SDK for cross platform develpment } s.public_header_files = 'doric-iOS/Pod/Classes/**/*.h' - s.dependency 'YYWebImage' - #s.dependency 'YYImage/WebP' s.dependency 'YYCache' s.dependency 'YogaKit/Core' s.dependency 'Yoga' - - # https://github.com/CocoaPods/CocoaPods/issues/10065 - #s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } - #s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } end diff --git a/doric-iOS/Example/Podfile b/doric-iOS/Example/Podfile index 3c21e843..4708a764 100644 --- a/doric-iOS/Example/Podfile +++ b/doric-iOS/Example/Podfile @@ -7,6 +7,11 @@ target 'Example' do pod 'DoricCore', :path => '../../' pod 'DoricDevkit', :path => '../../' + + #pod 'YYWebImage' + + #pod 'YYImage/WebP' + target 'ExampleTests' do inherit! :search_paths # Pods for testing diff --git a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m index f8a2d888..f9cbdf39 100644 --- a/doric-iOS/Pod/Classes/Shader/DoricImageNode.m +++ b/doric-iOS/Pod/Classes/Shader/DoricImageNode.m @@ -21,10 +21,12 @@ // #import "DoricImageNode.h" -#import "YYWebImage.h" #import "DoricExtensions.h" #import "DoricUtil.h" -#import "DoricSuperNode.h" + +#if __has_include() + +#import @interface DoricImageView : YYAnimatedImageView @end @@ -42,6 +44,16 @@ - (void)displayLayer:(CALayer *)layer { } } @end +#else + +@interface DoricImageView : UIImageView +@end + +@implementation DoricImageView +@end + +#endif + @interface DoricImageNode () @property(nonatomic, copy) NSString *loadCallbackId; @@ -104,7 +116,11 @@ - (UIImage *)currentPlaceHolderImage { } NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64 options:NSDataBase64DecodingIgnoreUnknownCharacters]; +#if __has_include() YYImage *image = [YYImage imageWithData:imageData scale:self.imageScale]; +#else + UIImage *image = [UIImage imageWithData:imageData scale:self.imageScale]; +#endif return image; } @@ -137,7 +153,11 @@ - (UIImage *)currentErrorImage { } NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64 options:NSDataBase64DecodingIgnoreUnknownCharacters]; +#if __has_include() YYImage *image = [YYImage imageWithData:imageData scale:self.imageScale]; +#else + UIImage *image = [UIImage imageWithData:imageData scale:self.imageScale]; +#endif return image; } @@ -163,6 +183,7 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id __weak typeof(self) _self = self; __block BOOL async = NO; view.doricLayout.undefined = YES; +#if __has_include() [view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:[self currentPlaceHolderImage] options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) { __strong typeof(_self) self = _self; if (self.placeHolderColor || self.errorColor) { @@ -195,6 +216,9 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id } } }]; +#else + DoricLog(@"Do not support load image url"); +#endif async = YES; } else if ([@"scaleType" isEqualToString:name]) { switch ([prop integerValue]) { @@ -221,7 +245,11 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id } NSData *imageData = [[NSData alloc] initWithBase64EncodedString:base64 options:NSDataBase64DecodingIgnoreUnknownCharacters]; +#if __has_include() YYImage *image = [YYImage imageWithData:imageData scale:self.imageScale]; +#else + UIImage *image = [UIImage imageWithData:imageData scale:self.imageScale]; +#endif view.image = image; } else if ([@"isBlur" isEqualToString:name]) { NSInteger value = [prop intValue]; @@ -254,7 +282,11 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id } } else if ([@"imageRes" isEqualToString:name]) { +#if __has_include() YYImage *image = [YYImage imageNamed:prop]; +#else + UIImage *image = [UIImage imageNamed:prop]; +#endif if (image) { view.image = image; } else { @@ -275,7 +307,11 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id NSString *path = [[NSBundle mainBundle] bundlePath]; NSString *fullPath = [path stringByAppendingPathComponent:prop]; NSData *imgData = [[NSData alloc] initWithContentsOfFile:fullPath]; +#if __has_include() YYImage *image = [YYImage imageWithData:imgData scale:self.imageScale]; +#else + UIImage *image = [UIImage imageWithData:imgData scale:self.imageScale]; +#endif view.image = image; if (self.loadCallbackId.length > 0) { if (image) {