This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-demo/src/FlexDemo.ts

101 lines
3.8 KiB
TypeScript
Raw Normal View History

2020-04-09 20:01:22 +08:00
import { Group, Panel, text, gravity, Color, LayoutSpec, vlayout, hlayout, scroller, IVLayout, IHLayout, layoutConfig, stack, Gravity, flexlayout, image, ScaleType } from "doric";
2020-04-10 20:41:43 +08:00
import { FlexDirection, Wrap, Justify, Align, FlexTypedValue, OverFlow } from "doric/lib/src/util/flexbox";
import { icon_refresh } from "./utils";
2020-04-09 20:01:22 +08:00
@Entry
class LayoutDemo extends Panel {
build(root: Group) {
scroller(
flexlayout(
[
image({
imageBase64: icon_refresh,
scaleType: ScaleType.ScaleAspectFit,
backgroundColor: Color.GRAY,
layoutConfig: {
widthSpec: LayoutSpec.FIT,
heightSpec: LayoutSpec.JUST,
},
flexConfig: {
marginRight: 10,
},
height: 16,
}),
image({
imageBase64: icon_refresh,
scaleType: ScaleType.ScaleAspectFit,
backgroundColor: Color.GRAY,
layoutConfig: {
widthSpec: LayoutSpec.FIT,
heightSpec: LayoutSpec.JUST,
},
flexConfig: {
alignSelf: Align.CENTER,
},
height: 16,
}),
image({
imageBase64: icon_refresh,
scaleType: ScaleType.ScaleAspectFit,
backgroundColor: Color.GRAY,
layoutConfig: {
widthSpec: LayoutSpec.FIT,
heightSpec: LayoutSpec.JUST,
},
height: 50,
}),
image({
imageBase64: icon_refresh,
scaleType: ScaleType.ScaleAspectFit,
backgroundColor: Color.GRAY,
layoutConfig: {
widthSpec: LayoutSpec.FIT,
heightSpec: LayoutSpec.JUST,
},
height: 16,
}),
image({
imageBase64: icon_refresh,
scaleType: ScaleType.ScaleAspectFit,
backgroundColor: Color.GRAY,
layoutConfig: {
widthSpec: LayoutSpec.FIT,
heightSpec: LayoutSpec.JUST,
},
flexConfig: {
marginTop: 20,
alignContent: Align.CENTER,
},
height: 16,
}),
],
{
flexConfig: {
flexDirection: FlexDirection.ROW,
width: 200,
height: 100,
flexWrap: Wrap.WRAP,
alignContent: Align.CENTER,
},
backgroundColor: Color.GRAY.alpha(0.1),
}
),
2020-04-09 20:01:22 +08:00
{
layoutConfig: layoutConfig().most()
2020-04-09 20:01:22 +08:00
}
).in(root)
// image({
// imageBase64: ICON_GENDER_MAN,
// backgroundColor: Color.GRAY,
// layoutConfig: {
// widthSpec: LayoutSpec.FIT,
// heightSpec: LayoutSpec.JUST,
// alignment: Gravity.Center,
// },
// height: 30,
// }).in(root)
2020-04-09 20:01:22 +08:00
}
}