import Styles from "@/constants/Styles";
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
import { Text, ToastAndroid, View } from "react-native";
import BorderBottomItem from "./borderBottomItem";
import { useState } from "react";
import { router } from "expo-router";
import AlertKonfirmasi from "./alertKonfirmasi";
import DrawerBottom from "./drawerBottom";
import MenuItemRow from "./menuItemRow";

export default function SectionFile() {
   const [isModal, setModal] = useState(false)

   return (
      <>
         <View style={[Styles.mb15]}>
            <Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>File</Text>
            <View style={[Styles.wrapPaper]}>
               <BorderBottomItem
                  borderType="all"
                  icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
                  title="image_pertama.jpg"
                  titleWeight="normal"
                  onPress={() => { setModal(true) }}
               />
               <BorderBottomItem
                  borderType="all"
                  icon={<MaterialCommunityIcons name="file-outline" size={25} color="black" />}
                  title="file_kedua.pdf"
                  titleWeight="normal"
                  onPress={() => { setModal(true) }}
               />
            </View>
         </View>

         <DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
            <View style={Styles.rowItemsCenter}>
               <MenuItemRow
                  icon={<MaterialCommunityIcons name="file-eye" color="black" size={25} />}
                  title="Lihat File"
                  onPress={() => {
                     setModal(false)
                  }}
               />
               <MenuItemRow
                  icon={<MaterialCommunityIcons name="download" color="black" size={25} />}
                  title="Download"
                  onPress={() => {
                     setModal(false)
                  }}
               />

               <MenuItemRow
                  icon={<Ionicons name="trash" color="black" size={25} />}
                  title="Hapus"
                  onPress={() => {
                     AlertKonfirmasi({
                        title: 'Konfirmasi',
                        desc: 'Apakah Anda yakin ingin menghapus file ini? File yang dihapus tidak dapat dikembalikan',
                        onPress: () => {
                           setModal(false)
                           ToastAndroid.show('Berhasil menghapus data', ToastAndroid.SHORT)
                        }
                     })

                  }}
               />
            </View>
         </DrawerBottom>
      </>
   )
}