React-Native笔记--react-native-swipe-list-view

项目中用到了侧滑组件 react-native-swipe-list-view,简单做个笔记。
npm install --save react-native-swipe-list-view
import { SwipeListView } from ‘react-native-swipe-list-view’;

import { SwipeListView } from 'react-native-swipe-list-view';
 
onRowDidOpen = rowKey => {
    console.log('This row opened', rowKey);
  };
 
  onSwipeValueChange = swipeData => {
    const { key, value } = swipeData; 
  };
 
  closeRow = (rowMap, rowKey) => {
    console.log(' closeRow rowKey:::', rowKey);
    if (rowMap[rowKey]) {
        rowMap[rowKey].closeRow();
    }
  }
 
 <SwipeListView
          data={this.state.optionalDataSource}     //JSON数据
          keyExtractor={item => String(item.id)}  //关键 手动关闭row
          renderItem={data => (
            <TouchableHighlight
              onPress={() => console.log('You touched me')}
              style={styles.rowFront}
              underlayColor={'#ECECEC 100%'}
            >
              <View style={{ flexDirection: 'row' }}>
                <Image
                  style={{ marginTop: 10, marginBottom: 10 }}
                  source={showActions(data.item.image_url)}
                />
                <View style={{ flexDirection: 'column', }}>
                  <Text style={{ marginTop: 10 }}>
                    {data.item.title}
                  </Text>
                </View>
              </View>
            </TouchableHighlight>
          )}
          renderHiddenItem={(data, rowMap) => ( //隐藏的Item
            <View style={styles.rowBack}>
              <TouchableOpacity
                style={[
                  styles.backRightBtnS,
                  styles.backRightBtnRight,
                ]}
                onPress={() => {
                  this.setState({ showDetailModal: true, exercise: data.item });
                  this.closeRow(rowMap,String(data.item.id)); 
                }
                }
              >
                <Text style={styles.backTextWhite}>
                  Detail
                  </Text>
              </TouchableOpacity>
            </View>
 
          )}
          leftOpenValue={0}
          rightOpenValue={-76} //左滑时 右侧打开的距离
          previewRowKey={'0'}
          previewOpenValue={-40}
          previewOpenDelay={3000}
          onRowDidOpen={this.onRowDidOpen}
          onSwipeValueChange={this.onSwipeValueChange}
        />

官网

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值