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 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 { logOut } from "@features/auth/authSlice";
  19. import useAuthHook from "../../hooks/useAuthHook";
  20. import { useTheme } from "@styles";
  21. import { useTranslation } from "react-i18next";
  22. const CustomDrawer = (props) => {
  23. const { colors } = useTheme();
  24. const { t } = useTranslation();
  25. const { logoutAuthProvider } = useAuthHook();
  26. const dispatch = useDispatch();
  27. const handleLogout = async () => {
  28. logoutAuthProvider();
  29. dispatch(logOut());
  30. };
  31. return (
  32. <View style={styles.container}>
  33. <DrawerContentScrollView {...props} contentContainerStyle={styles.drawer}>
  34. <ImageBackground
  35. source={require("../../assets/images/menu-bg.jpeg")}
  36. style={styles.backgroundImage}
  37. >
  38. <Image
  39. source={require("../../assets/images/diligent-purple.png")}
  40. style={styles.profileImage}
  41. />
  42. <Text style={styles.userName}>Diligent Software</Text>
  43. </ImageBackground>
  44. <View
  45. style={[styles.drawerItems, { backgroundColor: colors.background }]}
  46. >
  47. <DrawerItemList {...props} />
  48. </View>
  49. </DrawerContentScrollView>
  50. <View style={[styles.footer, { backgroundColor: colors.background }]}>
  51. <TouchableOpacity
  52. onPress={() => Linking.openURL("mailto:office@dilig.net")}
  53. style={styles.footerButton}
  54. >
  55. <View style={styles.buttonContent}>
  56. <Ionicons
  57. name="mail-outline"
  58. size={24}
  59. color={colors.iconsPrimary}
  60. />
  61. <Text
  62. style={[styles.footerButtonText, { color: colors.textPrimary }]}
  63. >
  64. {t("sidebar.contact")}
  65. </Text>
  66. </View>
  67. </TouchableOpacity>
  68. <TouchableOpacity onPress={handleLogout} style={styles.footerButton}>
  69. <View style={styles.buttonContent}>
  70. <MaterialIcons
  71. name="logout"
  72. size={22}
  73. color={colors.iconsPrimary}
  74. />
  75. <Text
  76. style={[styles.footerButtonText, { color: colors.textPrimary }]}
  77. >
  78. {t("sidebar.signout")}
  79. </Text>
  80. </View>
  81. </TouchableOpacity>
  82. </View>
  83. </View>
  84. );
  85. };
  86. const styles = StyleSheet.create({
  87. container: {
  88. flex: 1,
  89. },
  90. drawer: {
  91. flex: 1,
  92. backgroundColor: "#8200d6",
  93. },
  94. backgroundImage: {
  95. padding: 20,
  96. },
  97. profileImage: {
  98. height: 80,
  99. width: 80,
  100. borderRadius: 40,
  101. marginBottom: 10,
  102. },
  103. userName: {
  104. color: "#fff",
  105. fontSize: 18,
  106. marginBottom: 5,
  107. fontFamily: "poppins-regular",
  108. },
  109. drawerItems: {
  110. flex: 1,
  111. paddingTop: 10,
  112. },
  113. footer: {
  114. padding: 20,
  115. borderTopWidth: 1,
  116. borderTopColor: "#ccc",
  117. },
  118. footerButton: {
  119. paddingVertical: 15,
  120. },
  121. buttonContent: {
  122. flexDirection: "row",
  123. alignItems: "center",
  124. },
  125. footerButtonText: {
  126. fontSize: 15,
  127. marginLeft: 5,
  128. fontFamily: "poppins-regular",
  129. },
  130. });
  131. export default CustomDrawer;