You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CustomDrawer.jsx 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import React from "react";
  2. import {
  3. View,
  4. Text,
  5. ImageBackground,
  6. Image,
  7. TouchableOpacity,
  8. StyleSheet,
  9. Linking,
  10. } from "react-native";
  11. import {
  12. DrawerContentScrollView,
  13. DrawerItemList,
  14. } from "@react-navigation/drawer";
  15. import { MaterialIcons } from "@expo/vector-icons";
  16. import { Ionicons } from "@expo/vector-icons";
  17. import { useDispatch } from "react-redux";
  18. import { logoutUser } from "../../store/actions/login/loginActions";
  19. import useAuthHook from "../../hooks/useAuthHook";
  20. const CustomDrawer = (props) => {
  21. const {logoutAuthProvider} = useAuthHook()
  22. const dispatch = useDispatch();
  23. const handleLogout = async () => {
  24. logoutAuthProvider()
  25. dispatch(logoutUser());
  26. }
  27. return (
  28. <View style={styles.container}>
  29. <DrawerContentScrollView {...props} contentContainerStyle={styles.drawer}>
  30. <ImageBackground
  31. source={require("../../assets/images/menu-bg.jpeg")}
  32. style={styles.backgroundImage}
  33. >
  34. <Image
  35. source={require("../../assets/images/diligent-purple.png")}
  36. style={styles.profileImage}
  37. />
  38. <Text style={styles.userName}>Diligent Software</Text>
  39. </ImageBackground>
  40. <View style={styles.drawerItems}>
  41. <DrawerItemList {...props} />
  42. </View>
  43. </DrawerContentScrollView>
  44. <View style={styles.footer}>
  45. <TouchableOpacity
  46. onPress={() => Linking.openURL("mailto:office@dilig.net")}
  47. style={styles.footerButton}
  48. >
  49. <View style={styles.buttonContent}>
  50. <Ionicons name="mail-outline" size={24} color="#333" />
  51. <Text style={styles.footerButtonText}>Contact Us</Text>
  52. </View>
  53. </TouchableOpacity>
  54. <TouchableOpacity onPress={handleLogout} style={styles.footerButton}>
  55. <View style={styles.buttonContent}>
  56. <MaterialIcons name="logout" size={22} color="#333" />
  57. <Text style={styles.footerButtonText}>Sign Out</Text>
  58. </View>
  59. </TouchableOpacity>
  60. </View>
  61. </View>
  62. );
  63. };
  64. const styles = StyleSheet.create({
  65. container: {
  66. flex: 1,
  67. },
  68. drawer: {
  69. backgroundColor: "#8200d6",
  70. },
  71. backgroundImage: {
  72. padding: 20,
  73. },
  74. profileImage: {
  75. height: 80,
  76. width: 80,
  77. borderRadius: 40,
  78. marginBottom: 10,
  79. },
  80. userName: {
  81. color: "#fff",
  82. fontSize: 18,
  83. marginBottom: 5,
  84. fontFamily: "poppins-regular",
  85. },
  86. drawerItems: {
  87. flex: 1,
  88. backgroundColor: "#fff",
  89. paddingTop: 10,
  90. },
  91. footer: {
  92. padding: 20,
  93. borderTopWidth: 1,
  94. borderTopColor: "#ccc",
  95. },
  96. footerButton: {
  97. paddingVertical: 15,
  98. },
  99. buttonContent: {
  100. flexDirection: "row",
  101. alignItems: "center",
  102. },
  103. footerButtonText: {
  104. fontSize: 15,
  105. marginLeft: 5,
  106. fontFamily: "poppins-regular",
  107. },
  108. });
  109. export default CustomDrawer;