import { PortalProvider } from "@gorhom/portal"; import React, { useState } from "react"; import { Alert, Platform, Text } from "react-native"; import { BlurView } from "expo-blur"; import { View } from "react-native"; import { Fonts, gutters } from "../styles"; import GradientButton from "./GradientButton"; import Overlay from "./Overlay"; const WebAlertModal = ({ title, description, options }) => { const [visible, setVisible] = useState(true); const confirmOption = options?.find(({ style }) => style !== "cancel"); const cancelOption = options?.find(({ style }) => style === "cancel"); const onConfirm = () => { setVisible(false); confirmOption?.onPress(); }; const onCancel = () => { setVisible(false); cancelOption?.onPress(); }; return ( {title} {description} {cancelOption && ( )} ); }; const alertPolyfill = (title, description, options, extra) => { const rootDiv = document.createElement("div"); document.body.appendChild(rootDiv); const closeModal = () => { document.body.removeChild(rootDiv); }; const WebAlertComponent = () => ( ); // Render the React component into the div require("react-dom").render(, rootDiv); }; const customAlert = (title, description, options, extra) => { // Utilisation de la propriété userInterfaceStyle pour le mettre en mode sombre Alert.alert(title, description, options, { ...extra, userInterfaceStyle: "dark", }); }; const alert = Platform.OS === "web" ? alertPolyfill : customAlert; export default alert;