update layout test demo
This commit is contained in:
parent
98db105a73
commit
f53f57ccd9
@ -1,117 +1,201 @@
|
||||
import { Panel, Group, vlayout, LayoutSpec, text, Color, gravity, stack, layoutConfig } from "doric";
|
||||
import { Panel, Group, vlayout, LayoutSpec, text, Color, gravity, stack, layoutConfig, scroller, Gravity, View } from "doric";
|
||||
|
||||
@Entry
|
||||
class LayoutTest extends Panel {
|
||||
build(root: Group) {
|
||||
vlayout(
|
||||
function grid(title: string, view: View) {
|
||||
return vlayout(
|
||||
[
|
||||
text({
|
||||
text: "Fit -> Most",
|
||||
text: title,
|
||||
backgroundColor: Color.parse("#3498db"),
|
||||
textColor: Color.WHITE,
|
||||
textAlignment: Gravity.CenterX,
|
||||
layoutConfig: {
|
||||
widthSpec: LayoutSpec.MOST,
|
||||
heightSpec: LayoutSpec.JUST,
|
||||
},
|
||||
textSize: 30,
|
||||
textColor: Color.parse("#535c68"),
|
||||
backgroundColor: Color.parse("#dff9fb"),
|
||||
textAlignment: gravity().center(),
|
||||
height: 50,
|
||||
height: 30
|
||||
}),
|
||||
stack(
|
||||
[
|
||||
stack(
|
||||
[
|
||||
|
||||
text({
|
||||
text: "This is a stack content xxxxx",
|
||||
textSize: 20,
|
||||
textColor: Color.WHITE,
|
||||
}),
|
||||
view
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().most(),
|
||||
backgroundColor: Color.BLUE
|
||||
}
|
||||
),
|
||||
stack(
|
||||
[
|
||||
layoutConfig: layoutConfig().just(),
|
||||
width: 300,
|
||||
height: 300,
|
||||
backgroundColor: Color.parse("#ecf0f1"),
|
||||
})
|
||||
])
|
||||
|
||||
text({
|
||||
text: "This is a stack content 000000000",
|
||||
textSize: 20,
|
||||
textColor: Color.WHITE,
|
||||
}),
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().most(),
|
||||
backgroundColor: Color.YELLOW,
|
||||
alpha: 0.1
|
||||
}
|
||||
),
|
||||
text({
|
||||
text: "This is a stack content",
|
||||
textSize: 20,
|
||||
textColor: Color.WHITE,
|
||||
}),
|
||||
],
|
||||
function content() {
|
||||
return stack(
|
||||
[],
|
||||
{
|
||||
layoutConfig: {
|
||||
widthSpec: LayoutSpec.FIT,
|
||||
heightSpec: LayoutSpec.FIT,
|
||||
widthSpec: LayoutSpec.JUST,
|
||||
heightSpec: LayoutSpec.JUST,
|
||||
margin: {
|
||||
left: 10,
|
||||
right: 10,
|
||||
top: 10,
|
||||
bottom: 10
|
||||
}
|
||||
},
|
||||
backgroundColor: Color.RED
|
||||
}),
|
||||
width: 100,
|
||||
height: 100,
|
||||
backgroundColor: Color.parse("#34495e")
|
||||
})
|
||||
}
|
||||
|
||||
function case1() {
|
||||
return stack(
|
||||
[
|
||||
stack(
|
||||
[
|
||||
content(),
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().most(),
|
||||
})
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().fit(),
|
||||
padding: {
|
||||
left: 10, right: 10,
|
||||
top: 10, bottom: 10
|
||||
},
|
||||
backgroundColor: Color.parse("#9b59b6")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function case2() {
|
||||
return stack(
|
||||
[
|
||||
stack(
|
||||
[],
|
||||
{
|
||||
layoutConfig: layoutConfig().most(),
|
||||
backgroundColor: Color.BLUE
|
||||
}
|
||||
),
|
||||
text({
|
||||
text: "This is a stack content",
|
||||
textSize: 20,
|
||||
textColor: Color.WHITE,
|
||||
backgroundColor: Color.parse("#1abc9c")
|
||||
}),
|
||||
content(),
|
||||
],
|
||||
{
|
||||
layoutConfig: {
|
||||
widthSpec: LayoutSpec.FIT,
|
||||
heightSpec: LayoutSpec.FIT,
|
||||
layoutConfig: layoutConfig().fit(),
|
||||
padding: {
|
||||
left: 10, right: 10,
|
||||
top: 10, bottom: 10
|
||||
},
|
||||
backgroundColor: Color.RED
|
||||
}),
|
||||
backgroundColor: Color.parse("#9b59b6")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function case3() {
|
||||
return stack(
|
||||
[
|
||||
case1(),
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().fit(),
|
||||
padding: {
|
||||
left: 10, right: 10,
|
||||
top: 10, bottom: 10
|
||||
},
|
||||
backgroundColor: Color.parse("#2ecc71")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function case4() {
|
||||
return stack(
|
||||
[
|
||||
case2(),
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().fit(),
|
||||
padding: {
|
||||
left: 10, right: 10,
|
||||
top: 10, bottom: 10
|
||||
},
|
||||
backgroundColor: Color.parse("#2ecc71")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function case5() {
|
||||
return stack(
|
||||
[
|
||||
case3(),
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().fit(),
|
||||
padding: {
|
||||
left: 10, right: 10,
|
||||
top: 10, bottom: 10
|
||||
},
|
||||
backgroundColor: Color.parse("#3498db")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
function case6() {
|
||||
return stack(
|
||||
[
|
||||
case3(),
|
||||
],
|
||||
{
|
||||
layoutConfig: layoutConfig().fit(),
|
||||
padding: {
|
||||
left: 10, right: 10,
|
||||
top: 10, bottom: 10
|
||||
},
|
||||
backgroundColor: Color.parse("#3498db")
|
||||
}
|
||||
)
|
||||
}
|
||||
@Entry
|
||||
class LayoutTest extends Panel {
|
||||
build(root: Group) {
|
||||
scroller(
|
||||
vlayout(
|
||||
[
|
||||
stack(
|
||||
[],
|
||||
{
|
||||
layoutConfig: layoutConfig().most(),
|
||||
backgroundColor: Color.BLUE
|
||||
}
|
||||
grid(
|
||||
"Stack fit -> most -> just",
|
||||
case1(),
|
||||
),
|
||||
grid(
|
||||
"Stack fit -> most, just",
|
||||
case2(),
|
||||
),
|
||||
grid(
|
||||
"Stack fit -> fit -> most -> just",
|
||||
case3(),
|
||||
),
|
||||
grid(
|
||||
"Stack fit -> fit -> most, just",
|
||||
case4(),
|
||||
),
|
||||
grid(
|
||||
"Stack fit -> fit -> fit -> most -> just",
|
||||
case5(),
|
||||
),
|
||||
grid(
|
||||
"Stack fit -> fit -> fit -> most, just",
|
||||
case6(),
|
||||
),
|
||||
text({
|
||||
text: "This is a vlayout content",
|
||||
textSize: 20,
|
||||
textColor: Color.WHITE,
|
||||
}),
|
||||
],
|
||||
{
|
||||
layoutConfig: {
|
||||
widthSpec: LayoutSpec.FIT,
|
||||
heightSpec: LayoutSpec.FIT,
|
||||
},
|
||||
backgroundColor: Color.RED
|
||||
})
|
||||
],
|
||||
{
|
||||
layoutConfig: {
|
||||
widthSpec: LayoutSpec.MOST,
|
||||
heightSpec: LayoutSpec.FIT,
|
||||
},
|
||||
gravity: Gravity.CenterX,
|
||||
space: 20,
|
||||
}),
|
||||
{
|
||||
layoutConfig: layoutConfig().most(),
|
||||
}).in(root)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user