2019-11-29 15:07:32 +08:00
|
|
|
import { animate, Group, Panel, gravity, Color, LayoutSpec, vlayout, scroller, layoutConfig, IVLayout, modal, IText, network, View, stack, IHLayout, hlayout, IView, text } from "doric";
|
|
|
|
import { title, colors, box } from "./utils";
|
|
|
|
|
|
|
|
function thisLabel(str: string) {
|
|
|
|
return text({
|
|
|
|
text: str,
|
|
|
|
width: 100,
|
|
|
|
height: 50,
|
|
|
|
bgColor: colors[4],
|
|
|
|
textSize: 20,
|
|
|
|
textColor: Color.WHITE,
|
|
|
|
layoutConfig: layoutConfig().exactly(),
|
|
|
|
})
|
|
|
|
}
|
2019-11-29 11:59:16 +08:00
|
|
|
|
|
|
|
@Entry
|
|
|
|
class AnimatorDemo extends Panel {
|
|
|
|
build(rootView: Group): void {
|
|
|
|
const view = box(2)
|
2019-11-29 15:07:32 +08:00
|
|
|
let idx = 0
|
2019-11-29 14:37:42 +08:00
|
|
|
vlayout([
|
2019-11-29 11:59:16 +08:00
|
|
|
title("Animator Demo"),
|
2019-11-29 15:07:32 +08:00
|
|
|
vlayout(
|
|
|
|
[
|
|
|
|
hlayout([
|
|
|
|
thisLabel('Reset').apply({
|
|
|
|
onClick: () => {
|
|
|
|
animate(this)({
|
|
|
|
animations: () => {
|
|
|
|
view.width = view.height = 20
|
|
|
|
},
|
|
|
|
duration: 3000,
|
|
|
|
}).then(() => {
|
|
|
|
modal(context).toast('Fininshed')
|
|
|
|
}).catch(e => {
|
|
|
|
modal(context).toast(`${e}`)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
hlayout([
|
|
|
|
thisLabel('Width').apply({
|
|
|
|
onClick: () => {
|
|
|
|
animate(this)({
|
|
|
|
animations: () => {
|
|
|
|
view.width = 200
|
|
|
|
},
|
|
|
|
duration: 3000,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
thisLabel('Height').apply({
|
|
|
|
onClick: () => {
|
|
|
|
animate(this)({
|
|
|
|
animations: () => {
|
|
|
|
view.height = 200
|
|
|
|
},
|
|
|
|
duration: 3000,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
]).apply({ space: 10 } as IHLayout),
|
|
|
|
hlayout([
|
|
|
|
thisLabel('BgColor').apply({
|
|
|
|
onClick: () => {
|
|
|
|
animate(this)({
|
|
|
|
animations: () => {
|
|
|
|
view.bgColor = colors[(idx++) % colors.length]
|
|
|
|
},
|
|
|
|
duration: 3000,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
]).apply({ space: 10 } as IHLayout),
|
|
|
|
]
|
|
|
|
).apply({ space: 10 } as IVLayout),
|
2019-11-29 11:59:16 +08:00
|
|
|
stack([
|
|
|
|
view.also(v => {
|
|
|
|
v.left = 20
|
|
|
|
})
|
|
|
|
]).apply({
|
|
|
|
layoutConfig: layoutConfig().atmost(),
|
2019-11-29 13:10:00 +08:00
|
|
|
bgColor: colors[1].alpha(0.3 * 255),
|
2019-11-29 11:59:16 +08:00
|
|
|
}),
|
|
|
|
]).apply({
|
2019-11-29 14:37:42 +08:00
|
|
|
layoutConfig: layoutConfig().atmost(),
|
2019-11-29 11:59:16 +08:00
|
|
|
gravity: gravity().center(),
|
|
|
|
space: 10,
|
2019-11-29 14:37:42 +08:00
|
|
|
} as IVLayout).in(rootView)
|
2019-11-29 11:59:16 +08:00
|
|
|
}
|
|
|
|
}
|