From bffbb94201a5637cb6b55b59b499fb0ec67218d6 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Mon, 11 Mar 2024 09:39:23 +0000 Subject: mobile: Setup share intent --- packages/mobile/app/_layout.tsx | 21 +++++++++++++++++++-- packages/mobile/app/signin.tsx | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'packages/mobile/app') 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 ( - + diff --git a/packages/mobile/app/signin.tsx b/packages/mobile/app/signin.tsx index f500e36e..491f3007 100644 --- a/packages/mobile/app/signin.tsx +++ b/packages/mobile/app/signin.tsx @@ -6,7 +6,7 @@ import { Input } from "@/components/ui/Input"; export default function Signin() { return ( - + -- cgit v1.2.3-70-g09d2