import React from 'react';
import {
Button,
Dimensions,
TouchableOpacity,
ScrollView,
StyleSheet,
View,
} from 'react-native';
import {
ThemeColors,
useTheme,
Themed,
SafeAreaView,
NavigationRoute,
} from 'react-navigation';
import {
createDrawerNavigator,
DrawerContentComponentProps,
NavigationDrawerOptions,
NavigationDrawerProp,
NavigationDrawerScreenComponent,
} from 'react-navigation-drawer';
import Animated from 'react-native-reanimated';
import { MaterialIcons } from '@expo/vector-icons';
type Params = { drawerLockMode: 'unlocked' | 'locked-open' | 'locked-closed' };
const SampleText = ({ children }: { children: React.ReactNode }) => (
{children}
);
const MyNavScreen = ({
navigation,
banner,
}: {
navigation: NavigationDrawerProp;
banner: string;
}) => {
let theme = useTheme();
return (
{banner}
);
};
const InboxScreen: NavigationDrawerScreenComponent = ({
navigation,
}) => ;
const EmailScreen: NavigationDrawerScreenComponent = ({
navigation,
}) => ;
const DraftsScreen: NavigationDrawerScreenComponent = ({
navigation,
}) => ;
const DrawerContents = ({
drawerOpenProgress,
descriptors,
navigation,
}: DrawerContentComponentProps) => {
// `contentComponent` is passed an Animated.Value called drawerOpenProgress
// that can be used to do interesting things like a simple parallax drawe
const translateX = Animated.interpolate(drawerOpenProgress, {
inputRange: [0, 1],
outputRange: [-100, 0],
});
return (
{navigation.state.routes.map((route) => (
))}
);
};
const DrawerItem = (props: {
navigation: NavigationDrawerProp;
item: string;
}) => {
return (
props.navigation.navigate(props.item)}>
{props.item}
);
};
function createDrawerExample(options = {}) {
let DrawerExample = createDrawerNavigator(
{
Inbox: {
path: '/',
screen: InboxScreen,
navigationOptions: ({ navigation }) => {
const options: NavigationDrawerOptions = {
drawerLabel: 'Inbox',
drawerLockMode: (
navigation.state.routes[navigation.state.index].params || {}
).drawerLockMode,
drawerIcon: ({ tintColor }) => (
),
};
return options;
},
},
Drafts: {
path: '/sent',
screen: DraftsScreen,
navigationOptions: ({ navigation }) => {
const options: NavigationDrawerOptions = {
drawerLabel: 'Drafts',
drawerLockMode: (
navigation.state.routes[navigation.state.index].params || {}
).drawerLockMode,
drawerIcon: ({ tintColor }) => (
),
};
return options;
},
},
Email: {
path: '/sent',
screen: EmailScreen,
},
},
{
overlayColor: 'rgba(0,0,0,0)',
drawerType: 'back',
drawerBackgroundColor: {
light: '#eee',
dark: '#888',
},
screenContainerStyle: {
shadowColor: '#000000',
shadowOpacity: 0.4,
shadowRadius: 8,
shadowOffset: { height: 0, width: -4 },
},
contentComponent: DrawerContents,
drawerWidth: Dimensions.get('window').width * 0.8,
navigationOptions: {
headerShown: false,
},
contentOptions: {
activeTintColor: '#e91e63',
},
...options,
}
);
return DrawerExample;
}
export default createDrawerExample();