From bffbb94201a5637cb6b55b59b499fb0ec67218d6 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Mon, 11 Mar 2024 09:39:23 +0000
Subject: mobile: Setup share intent

---
 packages/mobile/app/_layout.tsx | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

(limited to 'packages/mobile/app/_layout.tsx')

diff --git a/packages/mobile/app/_layout.tsx b/packages/mobile/app/_layout.tsx
index 7403c6ff..c578d07f 100644
--- a/packages/mobile/app/_layout.tsx
+++ b/packages/mobile/app/_layout.tsx
@@ -1,12 +1,29 @@
 import "@/globals.css";
+import "expo-dev-client";
 
-import { Slot } from "expo-router";
+import { Slot, useRouter } from "expo-router";
+import { useShareIntent } from "expo-share-intent";
 import { StatusBar } from "expo-status-bar";
+import { useEffect } from "react";
 import { View } from "react-native";
 
 export default function RootLayout() {
+  const router = useRouter();
+  const { hasShareIntent, shareIntent, resetShareIntent } = useShareIntent({
+    debug: true,
+  });
+
+  useEffect(() => {
+    if (hasShareIntent) {
+      router.replace({
+        pathname: "shareintent",
+        params: { shareIntent: JSON.stringify(shareIntent) },
+      });
+      resetShareIntent();
+    }
+  }, [hasShareIntent]);
   return (
-    <View className="w-full h-full bg-white">
+    <View className="h-full w-full bg-white">
       <Slot />
       <StatusBar style="auto" />
     </View>
-- 
cgit v1.2.3-70-g09d2

