首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SafeAreaView的React导航抽屉

使用SafeAreaView的React导航抽屉
EN

Stack Overflow用户
提问于 2020-12-22 22:25:34
回答 1查看 304关注 0票数 0

正在尝试将react导航抽屉与安全区域视图一起使用。顺便说一句,我使用的是自定义抽屉。

我的抽屉的工作原理如下(红色的是抽屉。蓝色的是安全区域的休息区,底部也是白色的区域)。

我想让drawer覆盖所有的安全区域字段。(它必须覆盖顶部的蓝色和底部的白色区域)

这是我的代码;

我的App.js:

代码语言:javascript
复制
 <Provider store={store}>
      <PersistGate loading={null} persistor={persistor}>
        <SafeAreaView style={{ flex: 0, backgroundColor: '#3b7a99' }} />
        <SafeAreaView style={[Layout.fill, { backgroundColor: '#fff' }]}>
          <NavigationContainer ref={navigationRef}>
            <StatusBar barStyle="light-content" backgroundColor="#3b7a99" />
            <ApplicationNavigator />
          </NavigationContainer>
        </SafeAreaView>
      </PersistGate>
    </Provider>

我的导航器:

代码语言:javascript
复制
import React, { useEffect, useState } from 'react'
import { createDrawerNavigator } from '@react-navigation/drawer'
import { DashboardNavigator, OrderNavigator, TireNavigator } from '@/Navigators'
import { useSelector } from 'react-redux'

import DrawerContent from './DrawerContent'

const Drawer = createDrawerNavigator()

let MainNavigator

// @refresh reset
const ApplicationNavigator = () => {
  const [isApplicationLoaded, setIsApplicationLoaded] = useState(false)
  const applicationIsLoading = useSelector((state) => state.startup.loading)

  useEffect(() => {
    if (MainNavigator == null && !applicationIsLoading) {
      MainNavigator = require('@/Navigators/Main').default
      setIsApplicationLoaded(true)
    }
  }, [applicationIsLoading])

  return (
    <Drawer.Navigator
      drawerStyle={{ width: '100%' }}
      drawerContent={(props) => <DrawerContent {...props} />}
    >
      <Drawer.Screen name="Dashboard" component={DashboardNavigator} />
      <Drawer.Screen name="Order" component={OrderNavigator} />
      <Drawer.Screen name="Tire" component={TireNavigator} />
    </Drawer.Navigator>
  )
}

export default ApplicationNavigator
EN

回答 1

Stack Overflow用户

发布于 2020-12-23 04:51:56

子组件不能覆盖父组件应用的填充。

你不应该在SafeAreaView中包装你的整个应用,相反,如果合适的话,在你的屏幕中包装特定的内容。

更多信息https://reactnavigation.org/docs/handling-safe-area

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65410410

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档