tec*_*int 6 android ios react-native react-native-reanimated react-native-reanimated-v2
我一直在使用该库为我的 React Native 应用程序创建底部表单模式,但它似乎不适用于 Android,但在 iOS 上却可以。我使用了文档中建议的相同背景组件和句柄组件,并且包含的所有内容都是提供程序,并且 SafeAreaView 我的 package.json 包括
"@gorhom/bottom-sheet": "^3.6.5",
"react-native-reanimated": "^2.0.0",
Run Code Online (Sandbox Code Playgroud)
代码结构如下:
<BottomSheetModal ref={reference_settings}
index = {1}
enableOverDrag={true}
onChange = {(index) => { if(index === 0) { reference_settings.current.dismiss(); } }}
snapPoints = {[-1, '50%', '70%']}
backdropComponent={Backdrop}
handleComponent ={(props) => (<Belt {...props} />)}
style ={styles.sheet}
>
<BottomSheetView style={[styles.content]}>
<View style={{ width, height: '100%', overflow: 'hidden', backgroundColor: scheme === 'dark' ? '#000' : '#FFF', paddingHorizontal: 10 }}>
// the functions inside
</View>
</BottomSheetView>
</BottomSheetModal>
Run Code Online (Sandbox Code Playgroud)
我对 babel 使用了正确的配置来进行react-native-reanimated(包括插件),但它显示出来,然后我无法拖动关闭。
不要忘记将您的根应用程序组件像这样包装在 index.js 文件中
将 import 语句放在 index.js 的顶部
import { gestureHandlerRootHOC } from 'react-native-gesture-handler';
import {AppRegistry} from 'react-native';
AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(App));
Run Code Online (Sandbox Code Playgroud)
我知道现在回答你有点晚了,但我想为其他人补充一下。假设您已经安装,react-native-gesture-handler您还应该向 MainActivity.java 添加一些代码行。
| 归档时间: |
|
| 查看次数: |
5957 次 |
| 最近记录: |