2020-04-16 19:21:24 +08:00
|
|
|
import { refreshable, Group, Panel, pullable, gravity, Color, LayoutSpec, log, vlayout, Image, layoutConfig, stack, image } from "doric";
|
2019-12-04 14:07:14 +08:00
|
|
|
import { title, label, colors, icon_refresh } from "./utils";
|
|
|
|
|
|
|
|
@Entry
|
|
|
|
class RefreshableDemo extends Panel {
|
|
|
|
build(rootView: Group): void {
|
|
|
|
let refreshImage: Image
|
|
|
|
let refreshView = refreshable({
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().most(),
|
2019-12-04 14:07:14 +08:00
|
|
|
onRefresh: () => {
|
|
|
|
log('onRefresh')
|
|
|
|
setTimeout(() => {
|
|
|
|
refreshView.setRefreshing(context, false)
|
|
|
|
}, 5000)
|
|
|
|
},
|
2019-12-04 18:15:41 +08:00
|
|
|
header: pullable(
|
2019-12-04 14:07:14 +08:00
|
|
|
stack([
|
|
|
|
image({
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().just().configMargin({ top: 50, bottom: 10, }),
|
2019-12-04 14:07:14 +08:00
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
imageBase64: icon_refresh,
|
|
|
|
}).also(v => {
|
|
|
|
refreshImage = v
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
{
|
|
|
|
startAnimation: () => {
|
|
|
|
log('startAnimation')
|
|
|
|
},
|
|
|
|
stopAnimation: () => {
|
|
|
|
log('stopAnimation')
|
|
|
|
},
|
|
|
|
setPullingDistance: (distance: number) => {
|
|
|
|
refreshImage.rotation = distance / 30
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
content: (vlayout([
|
|
|
|
title("Refreshable Demo"),
|
|
|
|
label('start Refresh').apply({
|
|
|
|
width: 300,
|
|
|
|
height: 50,
|
|
|
|
backgroundColor: colors[0],
|
|
|
|
textSize: 30,
|
|
|
|
textColor: Color.WHITE,
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().just(),
|
2019-12-04 14:07:14 +08:00
|
|
|
onClick: () => {
|
|
|
|
refreshView.setRefreshing(context, true)
|
|
|
|
}
|
2020-04-16 19:21:24 +08:00
|
|
|
}),
|
2019-12-04 14:07:14 +08:00
|
|
|
label('stop Refresh').apply({
|
|
|
|
width: 300,
|
|
|
|
height: 50,
|
|
|
|
backgroundColor: colors[0],
|
|
|
|
textSize: 30,
|
|
|
|
textColor: Color.WHITE,
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().just(),
|
2019-12-04 14:07:14 +08:00
|
|
|
onClick: () => {
|
|
|
|
refreshView.setRefreshing(context, false)
|
|
|
|
}
|
2020-04-16 19:21:24 +08:00
|
|
|
}),
|
2019-12-04 14:07:14 +08:00
|
|
|
|
|
|
|
label('Enable Refresh').apply({
|
|
|
|
width: 300,
|
|
|
|
height: 50,
|
|
|
|
backgroundColor: colors[0],
|
|
|
|
textSize: 30,
|
|
|
|
textColor: Color.WHITE,
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().just(),
|
2019-12-04 14:07:14 +08:00
|
|
|
onClick: () => {
|
|
|
|
refreshView.setRefreshable(context, true)
|
|
|
|
}
|
2020-04-16 19:21:24 +08:00
|
|
|
}),
|
2019-12-04 14:07:14 +08:00
|
|
|
|
|
|
|
label('Disable Refresh').apply({
|
|
|
|
width: 300,
|
|
|
|
height: 50,
|
|
|
|
backgroundColor: colors[0],
|
|
|
|
textSize: 30,
|
|
|
|
textColor: Color.WHITE,
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().just(),
|
2019-12-04 14:07:14 +08:00
|
|
|
onClick: () => {
|
|
|
|
refreshView.setRefreshable(context, false)
|
|
|
|
}
|
2020-04-16 19:21:24 +08:00
|
|
|
}),
|
2019-12-04 14:07:14 +08:00
|
|
|
]).apply({
|
2019-12-14 16:32:04 +08:00
|
|
|
layoutConfig: layoutConfig().most().configHeight(LayoutSpec.FIT),
|
2019-12-04 14:07:14 +08:00
|
|
|
gravity: gravity().centerX(),
|
|
|
|
space: 10,
|
2020-04-16 19:21:24 +08:00
|
|
|
}))
|
2019-12-04 14:07:14 +08:00
|
|
|
}).apply({
|
|
|
|
backgroundColor: Color.YELLOW
|
|
|
|
}).in(rootView)
|
|
|
|
}
|
|
|
|
}
|