Advertisement
Sweetening

Untitled

Dec 4th, 2023
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import React from 'react';
  2. import { View, Text, Button, DrawerLayout } from 'react-native';
  3.  
  4. const HomeScreen = () => {
  5. return (
  6. <View>
  7. <Text>Home Screen</Text>
  8. <Button title="Open Drawer" onPress={() => this.drawerLayout.openDrawer()} />
  9. </View>
  10. );
  11. };
  12.  
  13. const OtherScreen = () => {
  14. return (
  15. <View>
  16. <Text>Other Screen</Text>
  17. </View>
  18. );
  19. };
  20.  
  21. const App = () => {
  22. return (
  23. <DrawerLayout
  24. drawerWidth={300}
  25. drawerPosition={DrawerLayout.DrawerPosition.left}
  26. ref={(ref) => { this.drawerLayout = ref; }}
  27. renderNavigationView={() => (
  28. <View style={{ flex: 1, backgroundColor: '#fff' }}>
  29. <Text>Drawer Content</Text>
  30. <Button title="Close Drawer" onPress={() => this.drawerLayout.closeDrawer()} />
  31. </View>
  32. )}
  33. >
  34. <NavigationContainer>
  35. <Stack.Navigator>
  36. <Stack.Screen name="Home" component={HomeScreen} />
  37. <Stack.Screen name="Other" component={OtherScreen} options={{ drawerVisible: false }} />
  38. </Stack.Navigator>
  39. </NavigationContainer>
  40. </DrawerLayout>
  41. );
  42. };
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement