首页 > 解决方案 > 使用滑动 sectionList 删除部分

问题描述

我是 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>

    )
};

标签: react-nativereact-native-sectionlist

解决方案


推荐阅读