From c74a394a6af594f5d77ce326a3a002cb251b6a85 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Tue, 30 Sep 2025 10:20:05 +0200 Subject: [PATCH] wip: global modal provider --- GLOBAL_MODAL_GUIDE.md | 193 +++++++++++++++++++++++ app/_layout.tsx | 111 ++++++++------ bun.lock | 6 - components/ExampleGlobalModalUsage.tsx | 203 +++++++++++++++++++++++++ components/GlobalModal.tsx | 72 +++++++++ package.json | 5 +- providers/GlobalModalProvider.tsx | 95 ++++++++++++ 7 files changed, 627 insertions(+), 58 deletions(-) create mode 100644 GLOBAL_MODAL_GUIDE.md create mode 100644 components/ExampleGlobalModalUsage.tsx create mode 100644 components/GlobalModal.tsx create mode 100644 providers/GlobalModalProvider.tsx diff --git a/GLOBAL_MODAL_GUIDE.md b/GLOBAL_MODAL_GUIDE.md new file mode 100644 index 00000000..28e96cf5 --- /dev/null +++ b/GLOBAL_MODAL_GUIDE.md @@ -0,0 +1,193 @@ +# Global Modal System with Gorhom Bottom Sheet + +This guide explains how to use the global modal system implemented in this project. + +## Overview + +The global modal system allows you to trigger a bottom sheet modal from anywhere in your app programmatically, and render any component inside it. + +## Architecture + +The system consists of three main parts: + +1. **GlobalModalProvider** (`providers/GlobalModalProvider.tsx`) - Context provider that manages modal state +2. **GlobalModal** (`components/GlobalModal.tsx`) - The actual modal component rendered at root level +3. **useGlobalModal** hook - Hook to interact with the modal from anywhere + +## Setup (Already Configured) + +The system is already integrated into your app: + +```tsx +// In app/_layout.tsx + + + {/* Your app content */} + + + +``` + +## Usage + +### Basic Usage + +```tsx +import { useGlobalModal } from "@/providers/GlobalModalProvider"; +import { View, Text } from "react-native"; + +function MyComponent() { + const { showModal, hideModal } = useGlobalModal(); + + const handleOpenModal = () => { + showModal( + + Hello from Modal! + + ); + }; + + return ( +