Как скрыть определенную вкладку от tabnavigator? - PullRequest
0 голосов
/ 28 июня 2019

Я пытаюсь скрыть вкладку «Сводка» в панели вкладок ниже, но не могу понять, как мне это сделать.

const Tab = createBottomTabNavigator({
Overview: {
    screen: Overview
},
Camera: {
    screen: Camera
},
Summary: {
    screen: Summary
}
}, {
tabBarPosition: 'top',
swipeEnabled: true,
tabBarOptions: {
    activeTintColor: '#f2f2f2',
    activeBackgroundColor: '#2EC4B6',
    inactiveTintColor: '#666',
    labelStyle: {
        fontSize: 22,
        padding: 12
    }
}
});

export default createAppContainer(Tab);

Как я могу это сделать?

1 Ответ

0 голосов
/ 28 июня 2019

Я решил это с помощью пользовательского BottomBar и скрыл вкладку, когда появился экран:

    tabBarComponent: (props) => (<BottomBar {...props} ></BottomBar>) //Navigator Configs

Bottombar, который у меня есть, выглядит так:

import React from 'react'
import { BottomTabBar } from 'react-navigation-tabs'
import { View, TouchableWithoutFeedback, Dimensions } from 'react-native'
import { StyleSheet } from 'react-native';
var { height } = Dimensions.get("window")
const HiddenView = () => <View style={{ display: 'none' }} />
const TouchableWithoutFeedbackWrapper = ({
    onPress,
    onLongPress,
    testID,
    accessibilityLabel,
    ...props
}) => {
    return (
        <TouchableWithoutFeedback
            onPress={onPress}
            onLongPress={onLongPress}
            testID={testID}
            hitSlop={{
                left: 15,
                right: 15,
                top: 5,
                bottom: 5,
            }}
            accessibilityLabel={accessibilityLabel}
        >
            <View {...props} />
        </TouchableWithoutFeedback>
    )
}
export default TabBarComponent = props => {
    return <BottomTabBar
        {...props}
        style={styles.bottomBarStyle}
        getButtonComponent={({ route }) => {
            if (route.key === "Summary" )
                return HiddenView
            else return TouchableWithoutFeedbackWrapper
        }}
    />
}


const styles = StyleSheet.create({
    bottomBarStyle: {
        height: (height * 10.625) / 100
    }
})

Позвольте мнезнать, если это создает новые проблемы

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...