android - 如何在 react-native 中滑动平面列表中的组件?

标签 android ios react-native

目的是从平面列表中滑动组件,从右或左滑动以显示选项,就像我们在 Instagram 上一样。 Instagram 的 slider 报告功能仅适用于 iOS,不适用于 Android Instagram has the slider report functionality only for iOS not for android

我们已经尝试使用 react-native-navigation-drawer,因为它可以在特定 View 内创建菜单,但它与我们对项目的依赖性冲突,因此我们正在寻找其他选项。

最佳答案

你可以使用react-native-gesture-handler来实现它

例子

import React, { Component } from "react";
import { Animated, StyleSheet, View } from "react-native";
import { RectButton } from "react-native-gesture-handler";
import Swipeable from "react-native-gesture-handler/Swipeable";

class AppleStyleSwipeableRow extends Component {
  renderLeftActions = (progress, dragX) => {
    const trans = dragX.interpolate({
      inputRange: [0, 50, 100, 101],
      outputRange: [-20, 0, 0, 1],
    });
    return (
      <RectButton style={styles.leftAction} onPress={this.close}>
        <Animated.Text
          style={[
            styles.actionText,
            {
              transform: [{ translateX: trans }],
            },
          ]}>
          Archive
        </Animated.Text>
      </RectButton>
    );
  };
  render() {
    return (
      <Swipeable
        renderLeftActions={this.renderLeftActions}>
        <Text>
           "hello"
         </Text>
      </Swipeable>
    );
  }
}

关于android - 如何在 react-native 中滑动平面列表中的组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59217215/

相关文章:

android - BroadcastReceiver 多次触发 (PROVIDERS_CHANGED_ACTION)

java - 单击在 Listitem Listview android 上不起作用

android - 使用嵌套导航进行深度链接(react-native)

react-native - appcenter codepush 更新 Android 但不更新 iOS : not released because it is identical to the contents of the specified deployment's current release

ios - 如何检测 UIButton 的触摸结束事件?

android - 如何设置高程颜色?

android - 是否可以在层列表中定义 XferMode?

java - Android onPause()没有被调用

ios - xcode 6.1 启动屏幕启动图像空白

iOS:在调用 view.hidden = NO 之后,有没有办法确定 UIView 何时出现