import { BlurView } from "expo-blur"; import React from "react"; import { Platform, Pressable, Text, View } from "react-native"; import { SheetManager } from "react-native-actions-sheet"; import useMinuit from "react-native-minuit/src/hooks/useMinuit"; import Animated, { Easing, FadeIn, FadeOut } from "react-native-reanimated"; import { arrayRemove, playlistsRef } from "../config/firebase"; import { Palette } from "../styles"; import { FONT_FAMILY } from "../styles/Fonts"; import { Portal } from "@gorhom/portal"; const MoreMenu = ({ visible = false, top = 0, onClose = () => {}, inPlaylist = false, playlistId = null, projectId = null, extraItems = [], }) => { const { setTooltip } = useMinuit(); if (!visible) return null; const removeFromPlaylist = async () => { try { if (inPlaylist && playlistId && projectId) { await playlistsRef .doc(playlistId) .update({ musics: arrayRemove(projectId), updatedAt: new Date() }); setTooltip({ type: "success", text: "Supprimé de la playlist" }); } } catch (e) { console.log("Remove from playlist error", e?.message); setTooltip({ type: "error", text: e?.message || "Suppression impossible", }); } finally { onClose?.(); } }; const addToPlaylist = () => { if (projectId) { SheetManager.show("Playlist", { payload: { projectId } }); } else { SheetManager.show("Playlist"); } onClose?.(); }; return ( {/* Background overlay to close on outside press */} {inPlaylist && ( Supprimer de la playlist )} Ajouter à une playlist {Array.isArray(extraItems) && extraItems.map((item, idx) => ( { try { item?.onPress?.(); } finally { onClose?.(); } }} > {item?.label || "Action"} ))} ); }; export default MoreMenu;