android:fix list item set action cannot respond to click

This commit is contained in:
pengfei.zhou
2021-06-08 16:52:39 +08:00
committed by osborn
parent 4da1f3be9d
commit 23a39f20fc
4 changed files with 78 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
import { Group, Panel, List, text, gravity, Color, LayoutSpec, list, listItem, log, vlayout, Gravity, hlayout, Text, refreshable, Refreshable, ListItem, layoutConfig, ViewHolder, ViewModel, VMPanel, loge, modal } from "doric";
import { Group, Panel, List, text, gravity, Color, LayoutSpec, list, listItem, log, vlayout, Gravity, hlayout, Text, refreshable, Refreshable, ListItem, layoutConfig, ViewHolder, ViewModel, VMPanel, loge, modal, stack } from "doric";
interface ItemModel {
text: string
@@ -67,34 +67,37 @@ class ListVM extends ViewModel<ListModel, ListVH> {
vh.list.apply({
renderItem: (index) => {
const data = state.data[index]
return listItem(text({
text: data.text,
textSize: 20,
layoutConfig: {
widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.JUST,
},
height: 50,
onClick: () => {modal(context).alert(data.text)}
}), {
return listItem(stack([
text({
text: data.text,
textSize: 20,
layoutConfig: {
widthSpec: LayoutSpec.FIT,
heightSpec: LayoutSpec.JUST,
},
height: 50,
onClick: () => { modal(context).alert(data.text) }
})
]), {
layoutConfig: {
widthSpec: LayoutSpec.MOST,
heightSpec: LayoutSpec.FIT,
}
},
//onClick: () => { modal(context).alert("Item Clicked " + index) }
}).apply({
actions: [
{
title: "First",
backgroundColor: Color.RED,
callback: () => {
modal(context).alert("First action")
modal(context).alert("First action " + index)
}
},
{
title: "Second",
backgroundColor: Color.BLUE,
callback: () => {
modal(context).alert("Second action")
modal(context).alert("Second action " + index)
}
}
]