This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-demo/src/ImageDemo.ts

73 lines
2.4 KiB
TypeScript
Raw Normal View History

2020-04-23 17:42:32 +08:00
import { Group, Panel, coordinator, text, gravity, Color, LayoutSpec, log, vlayout, scroller, layoutConfig, image, ScaleType, Image, modal } from "doric";
2019-12-04 14:07:14 +08:00
import { colors, label } from "./utils";
import { img_base64 } from "./image_base64";
2020-04-18 15:59:21 +08:00
2019-12-04 14:07:14 +08:00
const imageUrl = 'https://img.zcool.cn/community/01e75b5da933daa801209e1ffa4649.jpg@1280w_1l_2o_100sh.jpg'
2020-04-18 15:59:21 +08:00
import logo from "./images/logo_w.png"
import button from "./images/button.png"
2020-04-18 15:59:21 +08:00
2019-12-04 14:07:14 +08:00
@Entry
class ImageDemo extends Panel {
build(rootView: Group): void {
let imageView: Image
2020-01-06 10:43:18 +08:00
scroller(
vlayout(
[
text({
text: "Image Demo",
layoutConfig: layoutConfig().configWidth(LayoutSpec.MOST),
textSize: 30,
textColor: Color.WHITE,
backgroundColor: colors[5],
textAlignment: gravity().center(),
height: 50,
}),
label('Animated WebP'),
image({
imageUrl: "https://p.upyun.com/demo/webp/webp/animated-gif-0.webp",
loadCallback: (ret) => {
}
}),
],
{
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT),
gravity: gravity().center(),
space: 10,
}),
{
layoutConfig: layoutConfig().most(),
}
2020-02-13 22:18:13 +08:00
).also(it => {
coordinator(context).verticalScrolling({
scrollable: it,
scrollRange: {
start: 0,
end: 100,
},
target: "NavBar",
changing: {
name: "backgroundColor",
start: Color.WHITE,
end: Color.RED,
}
})
coordinator(context).verticalScrolling({
scrollable: it,
scrollRange: {
start: 0,
end: 100,
},
target: imageView,
changing: {
name: "width",
start: 10,
end: 200,
}
})
2020-02-13 22:18:13 +08:00
}).in(rootView)
2019-12-04 14:07:14 +08:00
}
2020-04-23 17:42:32 +08:00
onDestroy() {
modal(context).toast('onDestroy')
}
2019-12-04 14:07:14 +08:00
}