feat:Image support animated image

This commit is contained in:
pengfei.zhou 2019-11-27 19:15:57 +08:00
parent ea8ea4a8ff
commit 8b1ed0acc8
6 changed files with 31 additions and 34 deletions

View File

@ -34,6 +34,7 @@ import com.bumptech.glide.request.target.Target;
import pub.doric.DoricContext;
import pub.doric.extension.bridge.DoricPlugin;
import pub.doric.utils.DoricUtils;
import com.github.pengfeizhou.jscore.JSONBuilder;
import com.github.pengfeizhou.jscore.JSValue;
@ -77,8 +78,8 @@ public class ImageNode extends ViewNode<ImageView> {
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
if (!TextUtils.isEmpty(loadCallbackId)) {
callJSResponse(loadCallbackId, new JSONBuilder()
.put("width", resource.getIntrinsicWidth())
.put("height", resource.getIntrinsicHeight())
.put("width", DoricUtils.px2dp(resource.getIntrinsicWidth()))
.put("height", DoricUtils.px2dp(resource.getIntrinsicHeight()))
.toJSONObject());
}
return false;

View File

@ -1,4 +1,4 @@
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType } from "doric";
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType, Image } from "doric";
import { colors, label } from "./utils";
import { img_base64 } from "./image_base64";
const imageUrl = 'https://img.zcool.cn/community/01e75b5da933daa801209e1ffa4649.jpg@1280w_1l_2o_100sh.jpg'
@ -6,6 +6,7 @@ const imageUrl = 'https://img.zcool.cn/community/01e75b5da933daa801209e1ffa4649.
@Entry
class ImageDemo extends Panel {
build(rootView: Group): void {
let imageView: Image
scroller(vlayout([
text({
text: "Image Demo",
@ -38,9 +39,13 @@ class ImageDemo extends Panel {
}
}),
label('WebP'),
image({
imageView = image({
imageUrl: "https://p.upyun.com/demo/webp/webp/jpg-0.webp",
loadCallback: (ret) => {
if (ret) {
imageView.width = ret.width
imageView.height = ret.height
}
}
}),
label('ScaleToFill'),

View File

@ -39,8 +39,9 @@ TODO: Add long description of the pod here.
s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
s.dependency 'SDWebImage', '~> 4.4.7'
s.dependency 'SDWebImage/WebP'
# s.dependency 'SDWebImage', '~> 5.0'
s.dependency 'YYWebImage', '~>1.0.5'
s.dependency 'YYImage/WebP'
s.dependency 'SocketRocket', '~> 0.5.1'
s.dependency 'GCDWebServer', '~> 3.0'
s.dependency 'YYCache', '~> 1.0.4'

View File

@ -1,30 +1,23 @@
PODS:
- Doric (0.1.0):
- GCDWebServer (~> 3.0)
- SDWebImage (~> 4.4.7)
- SDWebImage/WebP
- SocketRocket (~> 0.5.1)
- YYCache (~> 1.0.4)
- YYImage/WebP
- YYWebImage
- GCDWebServer (3.5.3):
- GCDWebServer/Core (= 3.5.3)
- GCDWebServer/Core (3.5.3)
- libwebp (1.0.3):
- libwebp/demux (= 1.0.3)
- libwebp/mux (= 1.0.3)
- libwebp/webp (= 1.0.3)
- libwebp/demux (1.0.3):
- libwebp/webp
- libwebp/mux (1.0.3):
- libwebp/demux
- libwebp/webp (1.0.3)
- SDWebImage (4.4.7):
- SDWebImage/Core (= 4.4.7)
- SDWebImage/Core (4.4.7)
- SDWebImage/WebP (4.4.7):
- libwebp (< 2.0, >= 0.5)
- SDWebImage/Core
- SocketRocket (0.5.1)
- YYCache (1.0.4)
- YYImage (1.0.4):
- YYImage/Core (= 1.0.4)
- YYImage/Core (1.0.4)
- YYImage/WebP (1.0.4):
- YYImage/Core
- YYWebImage (1.0.5):
- YYCache
- YYImage
DEPENDENCIES:
- Doric (from `../`)
@ -32,22 +25,22 @@ DEPENDENCIES:
SPEC REPOS:
https://github.com/cocoapods/specs.git:
- GCDWebServer
- libwebp
- SDWebImage
- SocketRocket
- YYCache
- YYImage
- YYWebImage
EXTERNAL SOURCES:
Doric:
:path: "../"
SPEC CHECKSUMS:
Doric: c71287d68afeeb79bfd3c680ed2dd3b90d515c12
Doric: e73b17b0e46198994f5c3d8af49f26fd9f49df09
GCDWebServer: c0ab22c73e1b84f358d1e2f74bf6afd1c60829f2
libwebp: 057912d6d0abfb6357d8bb05c0ea470301f5d61e
SDWebImage: c10d14a8883ebd89664f02a422006f66a85c0c5d
SocketRocket: d57c7159b83c3c6655745cd15302aa24b6bae531
YYCache: 8105b6638f5e849296c71f331ff83891a4942952
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
YYWebImage: 5f7f36aee2ae293f016d418c7d6ba05c4863e928
PODFILE CHECKSUM: 012563d71439e7e33e976dca3b59664ed56cee39

View File

@ -22,7 +22,7 @@
#import "DoricImageNode.h"
#import "Doric.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "YYWebImage.h"
@interface DoricImageNode ()
@property(nonatomic, copy) NSString *loadCallbackId;
@ -31,7 +31,7 @@ @interface DoricImageNode ()
@implementation DoricImageNode
- (UIImageView *)build {
return [[UIImageView new] also:^(UIImageView *it) {
return [[YYAnimatedImageView new] also:^(UIImageView *it) {
it.clipsToBounds = YES;
}];
}
@ -39,7 +39,7 @@ - (UIImageView *)build {
- (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id)prop {
if ([@"imageUrl" isEqualToString:name]) {
__weak typeof(self) _self = self;
[view sd_setImageWithURL:[NSURL URLWithString:prop] completed:^(UIImage *_Nullable image, NSError *_Nullable error, SDImageCacheType cacheType, NSURL *_Nullable imageURL) {
[view yy_setImageWithURL:[NSURL URLWithString:prop] placeholder:nil options:0 completion:^(UIImage *image, NSURL *url, YYWebImageFromType from, YYWebImageStage stage, NSError *error) {
__strong typeof(_self) self = _self;
if (error) {
if (self.loadCallbackId.length > 0) {
@ -53,7 +53,6 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
}
[self requestLayout];
}
}];
} else if ([@"scaleType" isEqualToString:name]) {
switch ([prop integerValue]) {

View File

@ -176,8 +176,6 @@ - (void)layoutSubviews {
@interface DoricStackView ()
@property(nonatomic, assign) CGFloat contentWidth;
@property(nonatomic, assign) CGFloat contentHeight;
@end
@implementation DoricStackView