2019-12-04 14:07:14 +08:00
|
|
|
import { refreshable, Group, Panel, pullable, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout, Text, scroller, layoutConfig, image, IView, IVLayout, ScaleType, modal, IText, network, navigator, stack, Image } from "doric";
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
} as IText),
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
} as IText),
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
} as IText),
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
} as IText),
|
|
|
|
]).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,
|
|
|
|
} as IVLayout))
|
|
|
|
}).apply({
|
|
|
|
backgroundColor: Color.YELLOW
|
|
|
|
}).in(rootView)
|
|
|
|
}
|
|
|
|
}
|