我是 react-native 的新手,我想要一个带有滑动删除功能的部分列表。我找到了这个库: react-native-swipeout 与 FlatList 配合得很好,我设法只将滑动添加到部分标题,但我想将整个部分作为一个单元一起滑动。
添加当前情况的图像
灰色背景是节标题,白色是数据代码片段数组
renderSectionHeader = ({section, index}) => {
const swipeSettings = {
autoClose: true,
onColse: (secId, rowId, direction) => {
},
onOpen: (secId, rowId, direction) => {
},
right: [
{
onPress: () => {
},
text: 'Remove', type: 'delete'
}
],
rowId: 1,
sectionId: index,
// set active swipeout item
_handleSwipeout: (sectionID, rowID) => {
for (var i = 0; i < rows.length; i++) {
rows[i].active = i == rowID;
}
this._updateDataSource(rows)
},
};
return (
<Swipeout
{...swipeSettings}
>
<View style={{justifyContent: 'space-between'}}>
<Text>{section.itemName}</Text>
<Text>${section.itemTotalPrice}</Text>
</View>
</Swipeout>
)
};