feat:fix click subview of ListItem or PageItem

This commit is contained in:
pengfei.zhou 2019-11-19 15:31:23 +08:00
parent 353ff356a5
commit 1dba8d7b10
5 changed files with 25 additions and 9 deletions

View File

@ -44,7 +44,12 @@ public class ListNode extends SuperNode<RecyclerView> {
@Override
protected void blendSubNode(JSObject subProperties) {
listAdapter.blendSubNode(subProperties);
ViewNode node = getSubNodeById(subProperties.getProperty("id").asString().value());
if (node != null) {
node.blend(subProperties.getProperty("props").asObject());
} else {
listAdapter.blendSubNode(subProperties);
}
}
@Override

View File

@ -77,7 +77,12 @@ public class SliderNode extends SuperNode<RecyclerView> {
@Override
protected void blendSubNode(JSObject subProperties) {
slideAdapter.blendSubNode(subProperties);
ViewNode node = getSubNodeById(subProperties.getProperty("id").asString().value());
if (node != null) {
node.blend(subProperties.getProperty("props").asObject());
} else {
slideAdapter.blendSubNode(subProperties);
}
}
@Override

View File

@ -3,4 +3,5 @@ export default [
'src/Snake',
'src/ListDemo',
'src/ScrollerDemo',
'src/SliderDemo',
]

View File

@ -24,25 +24,30 @@ class SliderPanel extends Panel {
height: 50,
}),
slider({
itemCount: 3,
itemCount: 100,
renderPage: (idx) => {
return slideItem(text({
layoutConfig: {
widthSpec: LayoutSpec.WRAP_CONTENT,
widthSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.EXACTLY,
alignment: gravity().center(),
},
text: `Cell At Line ${idx}`,
text: `Page At Line ${idx}`,
textAlignment: gravity().center(),
textColor: Color.parse("#ffffff"),
textSize: 20,
height: 50,
bgColor: Color.parse('#00ff00'),
height: 300,
bgColor: Color.parse(colors[idx % colors.length]),
}).also(it => {
let start = idx
it.onClick = () => {
it.bgColor = Color.parse(colors[++start % colors.length])
}
}))
},
layoutConfig: {
widthSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.WRAP_CONTENT,
},
}),
]).also(it => {

View File

@ -4,7 +4,7 @@ import { Stack } from "./layout";
export function slideItem(item: View) {
return (new SlideItem).also((it) => {
it.layoutConfig = {
widthSpec: LayoutSpec.WRAP_CONTENT,
widthSpec: LayoutSpec.AT_MOST,
heightSpec: LayoutSpec.WRAP_CONTENT,
}
it.addChild(item)