| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- import React from "react";
- import {
- View,
- Text,
- ImageBackground,
- Image,
- TouchableOpacity,
- StyleSheet,
- Linking,
- } from "react-native";
- import {
- DrawerContentScrollView,
- DrawerItemList,
- } from "@react-navigation/drawer";
- import { MaterialIcons } from "@expo/vector-icons";
- import { Ionicons } from "@expo/vector-icons";
- import { useDispatch } from "react-redux";
- import { logOut } from "@features/auth/authSlice";
- import useAuthHook from "../../hooks/useAuthHook";
- import { useTheme } from "@styles";
- import { useTranslation } from "react-i18next";
-
- const CustomDrawer = (props) => {
- const { colors } = useTheme();
- const { t } = useTranslation();
-
- const { logoutAuthProvider } = useAuthHook();
-
- const dispatch = useDispatch();
-
- const handleLogout = async () => {
- logoutAuthProvider();
- dispatch(logOut());
- };
-
- return (
- <View style={styles.container}>
- <DrawerContentScrollView {...props} contentContainerStyle={styles.drawer}>
- <ImageBackground
- source={require("../../assets/images/menu-bg.jpeg")}
- style={styles.backgroundImage}
- >
- <Image
- source={require("../../assets/images/diligent-purple.png")}
- style={styles.profileImage}
- />
- <Text style={styles.userName}>Diligent Software</Text>
- </ImageBackground>
- <View
- style={[styles.drawerItems, { backgroundColor: colors.background }]}
- >
- <DrawerItemList {...props} />
- </View>
- </DrawerContentScrollView>
- <View style={[styles.footer, { backgroundColor: colors.background }]}>
- <TouchableOpacity
- onPress={() => Linking.openURL("mailto:office@dilig.net")}
- style={styles.footerButton}
- >
- <View style={styles.buttonContent}>
- <Ionicons
- name="mail-outline"
- size={24}
- color={colors.iconsPrimary}
- />
- <Text
- style={[styles.footerButtonText, { color: colors.textPrimary }]}
- >
- {t("sidebar.contact")}
- </Text>
- </View>
- </TouchableOpacity>
- <TouchableOpacity onPress={handleLogout} style={styles.footerButton}>
- <View style={styles.buttonContent}>
- <MaterialIcons
- name="logout"
- size={22}
- color={colors.iconsPrimary}
- />
- <Text
- style={[styles.footerButtonText, { color: colors.textPrimary }]}
- >
- {t("sidebar.signout")}
- </Text>
- </View>
- </TouchableOpacity>
- </View>
- </View>
- );
- };
-
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- },
- drawer: {
- flex: 1,
- backgroundColor: "#8200d6",
- },
- backgroundImage: {
- padding: 20,
- },
- profileImage: {
- height: 80,
- width: 80,
- borderRadius: 40,
- marginBottom: 10,
- },
- userName: {
- color: "#fff",
- fontSize: 18,
- marginBottom: 5,
- fontFamily: "poppins-regular",
- },
- drawerItems: {
- flex: 1,
- paddingTop: 10,
- },
- footer: {
- padding: 20,
- borderTopWidth: 1,
- borderTopColor: "#ccc",
- },
- footerButton: {
- paddingVertical: 15,
- },
- buttonContent: {
- flexDirection: "row",
- alignItems: "center",
- },
- footerButtonText: {
- fontSize: 15,
- marginLeft: 5,
- fontFamily: "poppins-regular",
- },
- });
-
- export default CustomDrawer;
|