react-native - 隐藏在 DrawerNavigator 下的自定义 TabBarIcon - React Navigation v5
问题描述
我遇到了定制TabBarIcon
未完全显示的问题。我已阅读文档、github 以尝试为此找到解决方案。
我可以弄清楚的是,将 BottomTabsNavigator 嵌套在 DrawerNavigator 中可能会产生影响,如果我错了,请纠正我。
这就是我的导航容器的样子
AppNavigator
Authenticated ? DrawerNavigator : AuthNavigator
// Inside DrawerNavigator:
DrawerNavigator
BottomTabsNavigator
Rest of the screens
用于说明我的问题的图像:
AppNavigator.js:
// AppNav uses StackNavigation
<NavigationContainer>
<Navigator headerMode='none'>
{authenticated && !isLoading ? (
<Screen name='DrawerNavigator' component={DrawerNavigator} />
) : !authenticated && !isLoading ? (
<Screen name='AuthNavigator' component={AuthNavigator} />
) : (
<Screen name='Loading' component={LoadingScreen} />
)}
</Navigator>
</NavigationContainer>
DrawerNavigator.js:
// I am using a UI library, UI kitten for the Drawer. But I don't think this is the cause
const { Navigator, Screen } = createDrawerNavigator();
const DrawerNavigator = () => (
<Navigator
drawerContent={props => <DrawerContent {...props} />}
initialRouteName='BottomTabsNavigator'
>
<Screen name='BottomTabsNavigator' component={BottomTabsNavigator} />
<Screen name='ChangePassword' component={ChangePasswordScreen} />
<Screen name='AuthNavigator' component={AuthNavigator} />
<Screen name='UserProfile' component={UserProfileScreen} />
<Screen name='EditProfile' component={EditProfileScreen} />
<Screen name='ActivityFeed' component={ActivityFeedScreen} />
</Navigator>
);
BottomTabsNavigator.js:
const BottomTabs = createBottomTabNavigator();
const BottomTabsNavigator = ({ navigation }) => {
return (
<BottomTabs.Navigator
tabBarOptions={{
showLabel: false,
activeTintColor: '#407BFF'
}}
initialRouteName='Home'
>
<BottomTabs.Screen
name='Home'
component={MainAppScreen}
options={{
tabBarIcon: Some Icon
}}
/>
<BottomTabs.Screen
name='TeamUp'
component={TeamUpScreen}
options={{
tabBarIcon: () => <TeamUpBottomTab navigation={navigation} /> // Custom made 'Icon'
}}
/>
<BottomTabs.Screen
name='ChatOverview'
component={ChatOverviewScreen}
options={{
tabBarIcon: Some Icon
}}
/>
</BottomTabs.Navigator>
);
};
定制的图标是这样的:
import { Platform, Pressable, StyleSheet, Animated, Image } from 'react-native';
<Pressable onPress={pressHandler} style={styles.teamUp}>
<Animated.View style={[{ transform: [{ scale: animatedScale }] }]}>
<Image
style={styles.logo}
source={require('../../assets/images/orbital-logo.png')}
/>
</Animated.View>
</Pressable>
被困了几天,寻找解决方案并没有太大帮助。
感谢任何帮助,谢谢
解决方案
推荐阅读
- reactjs - React Page 点击链接后刷新整个页面
- python - 将 spark 连接到 cassandra,java.lang.IllegalArgumentException:帧长度应为正
- swift - IOS 13中的iOS后台任务不起作用
- terraform - 每次多次调用模块时,Terraform 都会尝试复制资源
- routes - 使用 OctoberCMS 显示单个类别的帖子
- mongodb - 使用 Logstash 将数据从 mongoDB 同步到 elasticsearch
- node.js - Npm install 忽略版本号中的波浪号 (~)
- mongodb - OpsManager mongodb 部署问题添加 PLAIN auth
- python - 使用 cronjob 运行杂乱无章但不是预期的结果
- julia - 如何在 Julia 中重复数组中的值?