feat:fix Android weight props blend error

This commit is contained in:
pengfei.zhou
2019-11-16 17:35:42 +08:00
parent 1b08c227ef
commit b3ef2004fc
3 changed files with 52 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout } from "doric";
import { Group, Panel, List, text, gravity, Color, Stack, LayoutSpec, list, NativeCall, listItem, log, vlayout, Gravity, hlayout } from "doric";
const colors = [
"#f0932b",
"#eb4d4b",
@@ -26,23 +26,44 @@ class ListPanel extends Panel {
list({
itemCount: 1000,
renderItem: (idx: number) => {
return listItem(text({
layoutConfig: {
widthSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.WRAP_CONTENT,
margin: {
left: 10,
right: 50,
top: 50,
bottom: 10,
},
},
text: `Cell At Line ${idx}`,
textAlignment: gravity().center(),
textColor: Color.parse("#ffffff"),
textSize: 20,
})).also(it => {
it.gravity = gravity().center()
return listItem(
hlayout([
text({
layoutConfig: {
widthSpec: LayoutSpec.WRAP_CONTENT,
heightSpec: LayoutSpec.EXACTLY,
alignment: gravity().center(),
},
text: `Cell At Line ${idx}`,
textAlignment: gravity().center(),
textColor: Color.parse("#ffffff"),
textSize: 20,
height: 50,
bgColor: Color.parse('#00ff00'),
}),
text({
layoutConfig: {
widthSpec: LayoutSpec.EXACTLY,
heightSpec: LayoutSpec.EXACTLY,
alignment: gravity().center(),
weight: 1,
},
text: `Right`,
textAlignment: gravity().right(),
textColor: Color.parse("#ffffff"),
textSize: 20,
height: 50,
bgColor: Color.parse('#00ffff'),
}),
]).also(it => {
it.layoutConfig = {
widthSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.WRAP_CONTENT,
alignment: gravity().center(),
}
it.bgColor = Color.parse('#ffffff')
})
).also(it => {
it.bgColor = Color.parse(colors[idx % colors.length])
it.layoutConfig = {
widthSpec: LayoutSpec.AT_MOST,
@@ -51,8 +72,7 @@ class ListPanel extends Panel {
it.height = 100
it.onClick = () => {
log(`Click item at ${idx}`)
it.bgColor = Color.parse('#000000')
log(`bgcolor is ${Color.parse('#000000').toModel()}`)
it.height += 10
}
})
},