feat:Image support animated image
This commit is contained in:
parent
ea8ea4a8ff
commit
8b1ed0acc8
@ -34,6 +34,7 @@ import com.bumptech.glide.request.target.Target;
|
|||||||
|
|
||||||
import pub.doric.DoricContext;
|
import pub.doric.DoricContext;
|
||||||
import pub.doric.extension.bridge.DoricPlugin;
|
import pub.doric.extension.bridge.DoricPlugin;
|
||||||
|
import pub.doric.utils.DoricUtils;
|
||||||
|
|
||||||
import com.github.pengfeizhou.jscore.JSONBuilder;
|
import com.github.pengfeizhou.jscore.JSONBuilder;
|
||||||
import com.github.pengfeizhou.jscore.JSValue;
|
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) {
|
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||||
if (!TextUtils.isEmpty(loadCallbackId)) {
|
if (!TextUtils.isEmpty(loadCallbackId)) {
|
||||||
callJSResponse(loadCallbackId, new JSONBuilder()
|
callJSResponse(loadCallbackId, new JSONBuilder()
|
||||||
.put("width", resource.getIntrinsicWidth())
|
.put("width", DoricUtils.px2dp(resource.getIntrinsicWidth()))
|
||||||
.put("height", resource.getIntrinsicHeight())
|
.put("height", DoricUtils.px2dp(resource.getIntrinsicHeight()))
|
||||||
.toJSONObject());
|
.toJSONObject());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -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 { colors, label } from "./utils";
|
||||||
import { img_base64 } from "./image_base64";
|
import { img_base64 } from "./image_base64";
|
||||||
const imageUrl = 'https://img.zcool.cn/community/01e75b5da933daa801209e1ffa4649.jpg@1280w_1l_2o_100sh.jpg'
|
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
|
@Entry
|
||||||
class ImageDemo extends Panel {
|
class ImageDemo extends Panel {
|
||||||
build(rootView: Group): void {
|
build(rootView: Group): void {
|
||||||
|
let imageView: Image
|
||||||
scroller(vlayout([
|
scroller(vlayout([
|
||||||
text({
|
text({
|
||||||
text: "Image Demo",
|
text: "Image Demo",
|
||||||
@ -38,9 +39,13 @@ class ImageDemo extends Panel {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
label('WebP'),
|
label('WebP'),
|
||||||
image({
|
imageView = image({
|
||||||
imageUrl: "https://p.upyun.com/demo/webp/webp/jpg-0.webp",
|
imageUrl: "https://p.upyun.com/demo/webp/webp/jpg-0.webp",
|
||||||
loadCallback: (ret) => {
|
loadCallback: (ret) => {
|
||||||
|
if (ret) {
|
||||||
|
imageView.width = ret.width
|
||||||
|
imageView.height = ret.height
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
label('ScaleToFill'),
|
label('ScaleToFill'),
|
||||||
|
@ -39,8 +39,9 @@ TODO: Add long description of the pod here.
|
|||||||
s.public_header_files = 'Pod/Classes/**/*.h'
|
s.public_header_files = 'Pod/Classes/**/*.h'
|
||||||
# s.frameworks = 'UIKit', 'MapKit'
|
# s.frameworks = 'UIKit', 'MapKit'
|
||||||
# s.dependency 'AFNetworking', '~> 2.3'
|
# s.dependency 'AFNetworking', '~> 2.3'
|
||||||
s.dependency 'SDWebImage', '~> 4.4.7'
|
# s.dependency 'SDWebImage', '~> 5.0'
|
||||||
s.dependency 'SDWebImage/WebP'
|
s.dependency 'YYWebImage', '~>1.0.5'
|
||||||
|
s.dependency 'YYImage/WebP'
|
||||||
s.dependency 'SocketRocket', '~> 0.5.1'
|
s.dependency 'SocketRocket', '~> 0.5.1'
|
||||||
s.dependency 'GCDWebServer', '~> 3.0'
|
s.dependency 'GCDWebServer', '~> 3.0'
|
||||||
s.dependency 'YYCache', '~> 1.0.4'
|
s.dependency 'YYCache', '~> 1.0.4'
|
||||||
|
@ -1,30 +1,23 @@
|
|||||||
PODS:
|
PODS:
|
||||||
- Doric (0.1.0):
|
- Doric (0.1.0):
|
||||||
- GCDWebServer (~> 3.0)
|
- GCDWebServer (~> 3.0)
|
||||||
- SDWebImage (~> 4.4.7)
|
|
||||||
- SDWebImage/WebP
|
|
||||||
- SocketRocket (~> 0.5.1)
|
- SocketRocket (~> 0.5.1)
|
||||||
- YYCache (~> 1.0.4)
|
- YYCache (~> 1.0.4)
|
||||||
|
- YYImage/WebP
|
||||||
|
- YYWebImage
|
||||||
- GCDWebServer (3.5.3):
|
- GCDWebServer (3.5.3):
|
||||||
- GCDWebServer/Core (= 3.5.3)
|
- GCDWebServer/Core (= 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)
|
- SocketRocket (0.5.1)
|
||||||
- YYCache (1.0.4)
|
- 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:
|
DEPENDENCIES:
|
||||||
- Doric (from `../`)
|
- Doric (from `../`)
|
||||||
@ -32,22 +25,22 @@ DEPENDENCIES:
|
|||||||
SPEC REPOS:
|
SPEC REPOS:
|
||||||
https://github.com/cocoapods/specs.git:
|
https://github.com/cocoapods/specs.git:
|
||||||
- GCDWebServer
|
- GCDWebServer
|
||||||
- libwebp
|
|
||||||
- SDWebImage
|
|
||||||
- SocketRocket
|
- SocketRocket
|
||||||
- YYCache
|
- YYCache
|
||||||
|
- YYImage
|
||||||
|
- YYWebImage
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
Doric:
|
Doric:
|
||||||
:path: "../"
|
:path: "../"
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
Doric: c71287d68afeeb79bfd3c680ed2dd3b90d515c12
|
Doric: e73b17b0e46198994f5c3d8af49f26fd9f49df09
|
||||||
GCDWebServer: c0ab22c73e1b84f358d1e2f74bf6afd1c60829f2
|
GCDWebServer: c0ab22c73e1b84f358d1e2f74bf6afd1c60829f2
|
||||||
libwebp: 057912d6d0abfb6357d8bb05c0ea470301f5d61e
|
|
||||||
SDWebImage: c10d14a8883ebd89664f02a422006f66a85c0c5d
|
|
||||||
SocketRocket: d57c7159b83c3c6655745cd15302aa24b6bae531
|
SocketRocket: d57c7159b83c3c6655745cd15302aa24b6bae531
|
||||||
YYCache: 8105b6638f5e849296c71f331ff83891a4942952
|
YYCache: 8105b6638f5e849296c71f331ff83891a4942952
|
||||||
|
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
|
||||||
|
YYWebImage: 5f7f36aee2ae293f016d418c7d6ba05c4863e928
|
||||||
|
|
||||||
PODFILE CHECKSUM: 012563d71439e7e33e976dca3b59664ed56cee39
|
PODFILE CHECKSUM: 012563d71439e7e33e976dca3b59664ed56cee39
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#import "DoricImageNode.h"
|
#import "DoricImageNode.h"
|
||||||
#import "Doric.h"
|
#import "Doric.h"
|
||||||
#import <SDWebImage/UIImageView+WebCache.h>
|
#import "YYWebImage.h"
|
||||||
|
|
||||||
@interface DoricImageNode ()
|
@interface DoricImageNode ()
|
||||||
@property(nonatomic, copy) NSString *loadCallbackId;
|
@property(nonatomic, copy) NSString *loadCallbackId;
|
||||||
@ -31,7 +31,7 @@ @interface DoricImageNode ()
|
|||||||
@implementation DoricImageNode
|
@implementation DoricImageNode
|
||||||
|
|
||||||
- (UIImageView *)build {
|
- (UIImageView *)build {
|
||||||
return [[UIImageView new] also:^(UIImageView *it) {
|
return [[YYAnimatedImageView new] also:^(UIImageView *it) {
|
||||||
it.clipsToBounds = YES;
|
it.clipsToBounds = YES;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ - (UIImageView *)build {
|
|||||||
- (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id)prop {
|
- (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id)prop {
|
||||||
if ([@"imageUrl" isEqualToString:name]) {
|
if ([@"imageUrl" isEqualToString:name]) {
|
||||||
__weak typeof(self) _self = self;
|
__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;
|
__strong typeof(_self) self = _self;
|
||||||
if (error) {
|
if (error) {
|
||||||
if (self.loadCallbackId.length > 0) {
|
if (self.loadCallbackId.length > 0) {
|
||||||
@ -53,7 +53,6 @@ - (void)blendView:(UIImageView *)view forPropName:(NSString *)name propValue:(id
|
|||||||
}
|
}
|
||||||
[self requestLayout];
|
[self requestLayout];
|
||||||
}
|
}
|
||||||
|
|
||||||
}];
|
}];
|
||||||
} else if ([@"scaleType" isEqualToString:name]) {
|
} else if ([@"scaleType" isEqualToString:name]) {
|
||||||
switch ([prop integerValue]) {
|
switch ([prop integerValue]) {
|
||||||
|
@ -176,8 +176,6 @@ - (void)layoutSubviews {
|
|||||||
|
|
||||||
|
|
||||||
@interface DoricStackView ()
|
@interface DoricStackView ()
|
||||||
@property(nonatomic, assign) CGFloat contentWidth;
|
|
||||||
@property(nonatomic, assign) CGFloat contentHeight;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricStackView
|
@implementation DoricStackView
|
||||||
|
Reference in New Issue
Block a user