2019-11-29 13:27:02 +08:00
|
|
|
import { animate, Group, Panel, gravity, Color, LayoutSpec, vlayout, scroller, layoutConfig, IVLayout, modal, IText, network, View, stack } from "doric";
|
2019-11-29 11:59:16 +08:00
|
|
|
import { title, label, colors, box } from "./utils";
|
|
|
|
|
|
|
|
@Entry
|
|
|
|
class AnimatorDemo extends Panel {
|
|
|
|
build(rootView: Group): void {
|
|
|
|
const view = box(2)
|
|
|
|
scroller(vlayout([
|
|
|
|
title("Animator Demo"),
|
|
|
|
label('Reset').apply({
|
|
|
|
width: 100,
|
|
|
|
height: 50,
|
|
|
|
bgColor: colors[4],
|
|
|
|
textSize: 20,
|
|
|
|
textColor: Color.WHITE,
|
|
|
|
layoutConfig: layoutConfig().exactly(),
|
|
|
|
} as IText).also(v => {
|
|
|
|
v.onClick = () => {
|
2019-11-29 13:27:02 +08:00
|
|
|
animate(this)({
|
2019-11-29 11:59:16 +08:00
|
|
|
animations: () => {
|
|
|
|
view.width = view.height = 20
|
|
|
|
},
|
|
|
|
duration: 3000,
|
2019-11-29 13:27:02 +08:00
|
|
|
}).then(() => {
|
|
|
|
modal(context).toast('Fininshed')
|
|
|
|
}, (e: any) => {
|
|
|
|
modal(context).toast(`${e}`)
|
2019-11-29 11:59:16 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
label('Width').apply({
|
|
|
|
width: 100,
|
|
|
|
height: 50,
|
|
|
|
bgColor: colors[0],
|
|
|
|
textSize: 20,
|
|
|
|
textColor: Color.WHITE,
|
|
|
|
layoutConfig: layoutConfig().exactly(),
|
|
|
|
} as IText).also(v => {
|
|
|
|
v.onClick = () => {
|
2019-11-29 13:27:02 +08:00
|
|
|
animate(this)({
|
2019-11-29 11:59:16 +08:00
|
|
|
animations: () => {
|
2019-11-29 13:10:00 +08:00
|
|
|
view.width = 300
|
2019-11-29 11:59:16 +08:00
|
|
|
},
|
|
|
|
duration: 3000,
|
2019-11-29 13:27:02 +08:00
|
|
|
}).then(() => {
|
|
|
|
modal(context).toast('Fininshed')
|
|
|
|
}, (e: any) => {
|
|
|
|
modal(context).toast(`${e}`)
|
2019-11-29 11:59:16 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
label('Height').apply({
|
|
|
|
width: 100,
|
|
|
|
height: 50,
|
|
|
|
bgColor: colors[0],
|
|
|
|
textSize: 20,
|
|
|
|
textColor: Color.WHITE,
|
|
|
|
layoutConfig: layoutConfig().exactly(),
|
|
|
|
} as IText).also(v => {
|
|
|
|
v.onClick = () => {
|
2019-11-29 13:27:02 +08:00
|
|
|
animate(this)({
|
2019-11-29 11:59:16 +08:00
|
|
|
animations: () => {
|
2019-11-29 13:27:02 +08:00
|
|
|
view.height = 300
|
2019-11-29 11:59:16 +08:00
|
|
|
},
|
|
|
|
duration: 3000,
|
2019-11-29 13:27:02 +08:00
|
|
|
}).then(() => {
|
|
|
|
modal(context).toast('Fininshed')
|
|
|
|
}, (e: any) => {
|
|
|
|
modal(context).toast(`${e}`)
|
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({
|
|
|
|
layoutConfig: layoutConfig().atmost().h(LayoutSpec.WRAP_CONTENT),
|
|
|
|
gravity: gravity().center(),
|
|
|
|
space: 10,
|
|
|
|
} as IVLayout)).apply({
|
|
|
|
layoutConfig: layoutConfig().atmost(),
|
|
|
|
}).in(rootView)
|
|
|
|
}
|
|
|
|
}
|