繁体   English   中英

@gorhom/react-native-bottom-sheet 不适用于 Android

[英]@gorhom/react-native-bottom-sheet doesn't work on Android

我一直在使用该库为我的 React 本机应用程序创建底部工作表模态,但它似乎不适用于 Android,但它适用于 iOS。 我使用了文档中建议的相同背景组件和句柄组件,所有内容都是提供者,SafeAreaView 我的 package.json 包括

"@gorhom/bottom-sheet": "^3.6.5", 
"react-native-reanimated": "^2.0.0",

代码结构如下:

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

我为 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));

更多细节

我知道为您回答有点晚了,但我想为其他人补充。 假设您已经安装了react-native-gesture-handler ,您还应该在 MainActivity.java 中添加一些代码行。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM