Ящик не открывается в реакции-родной - PullRequest
1 голос
/ 26 июня 2019

Я использую навигацию по ящикам в навигации по материалам сверху.

Это код навигации моего ящика

import { createDrawerNavigator, createStackNavigator } from "react-navigation";
import { UserProfileComponent } from "../components/standalone/userProfile/userProfile.component";
import { RecordMeetingComponent } from "../components/standalone/recordMeeting/recordMeeting.component";
import { ChatBotComponent } from "../components/standalone/chatBot/chatBot.component";
import DrawerScreen from "../components/shared/drawerToggler/drawerToggle.component";
import userDashBoardTabsStack from "./userDashBoardTabs";

const userDrawerNavigator = createDrawerNavigator({
    Home:{
        screen: userDashBoardTabsStack,
        navigationOptions:{
            drawerLabel: "Home"
        }
    },
    Record: {
        screen: RecordMeetingComponent,
        navigationOptions:{
            drawerLabel: "Record"
        }
    },
    Profile: {
        screen: UserProfileComponent,
        navigationOptions: {
            drawerLabel: "My Profile"
        }
    },
    ChatBot: {
        screen: ChatBotComponent,
        navigationOptions: {
            drawerLabel: "Chat Bot"
        }
    },
    },{
        initialRouteName: "Record",
        contentComponent: DrawerScreen,
        drawerWidth: 300
    }
)
export default userDrawerNavigator;

Это навигация моей вкладки

import { createMaterialTopTabNavigator } from "react-navigation";
import { UserDashboardTodayTab } from "../components/standalone/usersTabs/today/today.component";
import { UserDashboardWeekTab } from "../components/standalone/usersTabs/week/week.component";
import { UserDashboardMonthTab } from "../components/standalone/usersTabs/month/month.component";

const userDashBoardTabsStack = createMaterialTopTabNavigator({
        today:{ 
            screen: UserDashboardTodayTab,
            navigationOptions: (navigation)=>({
                title: "TODAY"
            }),
        },
        week: {
            screen: UserDashboardWeekTab,
            navigationOptions: (navigation)=>({
                title: "WEEK" 
            }),
        },
        month:{
            screen: UserDashboardMonthTab,
            navigationOptions: (navigation)=>({
                title: "MONTH",
                headerTitle: "#000000"
            })
        }
    },{
        order: ["today", "week", "month"],
        tabBarOptions : {
            activeTintColor: "#000000",
            inactiveTintColor: "#ADB2BF",
            pressColor: "#25B7AF",
            indicatorStyle: {
                backgroundColor: "#25B7AF",
            },
            activeBackgroundColor: "#25B7AF",
            style: {
                fontFamily: "nunito_regular",
                backgroundColor: "#ffffff"
            }
        },
    swipeEnabled: true,
    animationEnabled: true,
    lazy: true,
    backBehavior: "initialRoute"
})

export default userDashBoardTabsStack;

Я звоню этим двум в createStacknavigator

import { createStackNavigator } from "react-navigation";
import userDrawerNavigator from "./userDrawer";
import React from "react";
import { TouchableOpacity } from "react-native";
import Icon from "react-native-vector-icons/Feather";

const OnboardingStack = createStackNavigator({

    userDrawerNavigator: {
            screen: userDrawerNavigator
        },
    },{
        navigationOptions: ({ navigation }) => ({
            title: 'ReactNavigation',  // Title to appear in status bar
            headerLeft: 
            <TouchableOpacity  onPress={ () => { navigation.dispatch(DrawerActions.toggleDrawer())} }>
                <MenuImage navigation={ navigation }/>
            </TouchableOpacity>,
            headerStyle: {
                backgroundColor: '#333',
            },
            headerTintColor: '#fff',
            headerTitleStyle: {
              fontWeight: 'bold',
            },
        })
    },
    {
        initialRouteName: "userDrawerNavigator",
        headerLayoutPreset: "center",
    }
)

const MenuImage = ({navigation}) => {
    if(!navigation.state.isDrawerOpen){
        return <Icon name="menu" color="#000000"/>
    }else{
        return <Icon name="arrow-left" color="#000000"/>
    }
}

export default OnboardingStack;

И повторение этих компонентов в навигаторе-переключателе

import { createSwitchNavigator, createAppContainer } from "react-navigation";
import { SplashComponent } from "../components/standalone/splash/splash.component";
import AuthStack from "./loggedOut";
import UserStack from "./loggedIn";
import OnboardingStack from "./freshInstall";

export const AppStack = createAppContainer(createSwitchNavigator(
    {
        Splash: SplashComponent,
        LoggedIn: UserStack,
        LoggedOut: AuthStack,
        Onboarding: OnboardingStack
    },
    {
        initialRouteName: "Splash"
    }
))

Это мой пользовательский компонент для ящика

class DrawerScreen extends React.Component {


  navigateToScreen = (route) => () => {
    const navigateAction = NavigationActions.navigate({
      routeName: route
    });
    this.props.navigation.dispatch(navigateAction);
    this.props.navigation.dispatch(DrawerActions.closeDrawer())
  }

  render () {
    return (
      <View>
        <ScrollView>
          <View>
            <View >
              <Text onPress={this.navigateToScreen('RecordMeetingComponent')}>
                Record
              </Text>
            </View>
            <View>
              <Text onPress={this.navigateToScreen('UserProfileComponent')}>
               My Profile
              </Text>
            </View>
            <View >
              <Text onPress={this.navigateToScreen('ChatBotComponent')}>
              Chat Bot
              </Text>
            </View>
          </View>
        </ScrollView>
      </View>
    );
  }
}

DrawerScreen.propTypes = {
  navigation: PropTypes.object
};

export default DrawerScreen;

Но навигация по ящику не отображается на экране.Что я здесь не так делаю?

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