Skip to content

Instantly share code, notes, and snippets.

@ahmetozalp
Last active June 21, 2018 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmetozalp/a822b3c301dec96847912d16f9930dc7 to your computer and use it in GitHub Desktop.
Save ahmetozalp/a822b3c301dec96847912d16f9930dc7 to your computer and use it in GitHub Desktop.
import React from "react";
import { Platform, StatusBar } from "react-native";
import {
DrawerNavigator,
StackNavigator,
TabNavigator,
SwitchNavigator
} from "react-navigation";
import Icon from 'react-native-vector-icons/Ionicons';
import Home from './tabs/Home';
import Settings from './tabs/Settings';
import Profile from './screens/Profile';
import Modal from './screens/Modal';
import Drawer from './components/Drawer';
import Login from './screens/user/Login';
const headerStyle = {
marginTop: Platform.OS === "android" ? StatusBar.currentHeight : 0
};
// Stack navigation for Settings and Profile screens
const SettingsTab = StackNavigator({
Settings: {
screen: Settings,
navigationOptions: {
header: null,
headerBackTitle: 'Back',
},
},
Profile: {
screen: Profile,
navigationOptions: ({ navigation }) => ({
title: `${navigation.state.params.user} Profili`,
}),
},
}, {
headerMode: 'screen',
});
// Tab navigation for Home and Settings screens
const TabNavigation = TabNavigator({
Home: {
screen: Home,
navigationOptions: {
tabBarLabel: 'Home',
tabBarIcon: ({ tintColor, focused }) => <Icon
name={focused ? 'ios-home' : 'ios-home-outline'}
size={26}
style={{ color: tintColor }}
/>
},
},
Settings: {
screen: SettingsTab,
navigationOptions: {
tabBarLabel: 'Settings',
tabBarIcon: ({ tintColor, focused }) => <Icon
name={focused ? 'ios-settings' : 'ios-settings-outline'}
size={26}
style={{ color: tintColor }}
/>
},
},
});
const TabsWithDrawerNavigation = DrawerNavigator({
Tabs: {
screen: TabNavigation,
}
}, {
contentComponent: props => <Drawer {...props} />
});
export const createRootNavigator = (signedIn = false) => {
return StackNavigator(
{
// bunlarda normal alttan açılmayacak modelsiz sayfalar olcak
SignedIn: {
screen: TabsWithDrawerNavigation,
},
SignedOut: {
screen: Login
},
// alttan açılcak sayfa bu
Modal: {
screen: Modal
},
},
{
// alttan açılmayı saglayan func.
mode: 'modal',
headerMode: 'none',
initialRouteName: signedIn ? "SignedIn" : "SignedOut"
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment