2019-12-04 18:15:41 +08:00
|
|
|
import { Panel, Group, vlayout, image, layoutConfig, ScaleType, refreshable, Color, pullable, stack, Image, Refreshable, TranslationAnimation, loge, log, list, listItem, text } from "doric";
|
|
|
|
import { title, icon_refresh, colors } from "./utils";
|
2019-12-04 14:07:14 +08:00
|
|
|
|
|
|
|
@Entry
|
|
|
|
class MyDemo extends Panel {
|
|
|
|
build(root: Group) {
|
|
|
|
let refreshed: Refreshable
|
|
|
|
let headerImage: Image
|
|
|
|
stack([
|
|
|
|
refreshed = refreshable({
|
|
|
|
onRefresh: () => {
|
|
|
|
refreshed.setRefreshing(context, false)
|
|
|
|
},
|
2019-12-04 18:15:41 +08:00
|
|
|
header: pullable(
|
2019-12-04 14:07:14 +08:00
|
|
|
stack([]).apply({
|
|
|
|
backgroundColor: Color.RED,
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().just(),
|
2019-12-04 14:07:14 +08:00
|
|
|
width: 100,
|
|
|
|
height: 30,
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
startAnimation: () => {
|
|
|
|
},
|
|
|
|
stopAnimation: () => {
|
|
|
|
},
|
|
|
|
setPullingDistance: (distance: number) => {
|
|
|
|
headerImage.scaleX = headerImage.scaleY = (headerImage.height + distance * 2) / headerImage.height
|
|
|
|
},
|
|
|
|
}),
|
2019-12-04 18:15:41 +08:00
|
|
|
content: list({
|
|
|
|
itemCount: 20,
|
|
|
|
renderItem: (idx) => {
|
|
|
|
return listItem(text({
|
|
|
|
text: `Item :${idx}`,
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().just(),
|
2019-12-04 18:15:41 +08:00
|
|
|
width: root.width,
|
|
|
|
height: 50,
|
|
|
|
textColor: Color.WHITE,
|
|
|
|
backgroundColor: colors[idx % colors.length],
|
|
|
|
}))
|
|
|
|
}
|
2019-12-04 14:07:14 +08:00
|
|
|
}),
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().most(),
|
2019-12-04 14:07:14 +08:00
|
|
|
}).also(v => {
|
|
|
|
v.top = 200
|
|
|
|
}),
|
|
|
|
|
|
|
|
headerImage = image({
|
|
|
|
imageUrl: "https://img.zcool.cn/community/01e75b5da933daa801209e1ffa4649.jpg@1280w_1l_2o_100sh.jpg",
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().just(),
|
2019-12-04 14:07:14 +08:00
|
|
|
width: root.width,
|
|
|
|
height: 200,
|
|
|
|
scaleType: ScaleType.ScaleAspectFill,
|
|
|
|
}),
|
|
|
|
]).in(root)
|
|
|
|
}
|
|
|
|
}
|