From ea1aec9638f0a17e67ff38bf7d79655d19835f70 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sun, 27 Oct 2024 01:53:08 +0700 Subject: [PATCH] feat: wrap `App` in `SafeAreaProvider` --- src/core/patches/wrapSafeAreaProvider.tsx | 15 +++++++++++++++ .../reporter/components/ErrorBoundaryScreen.tsx | 2 -- src/index.ts | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/core/patches/wrapSafeAreaProvider.tsx diff --git a/src/core/patches/wrapSafeAreaProvider.tsx b/src/core/patches/wrapSafeAreaProvider.tsx new file mode 100644 index 00000000..90de450e --- /dev/null +++ b/src/core/patches/wrapSafeAreaProvider.tsx @@ -0,0 +1,15 @@ +import { after } from "@lib/api/patcher"; +import { _lazyContextSymbol } from "@metro/lazy"; +import { findByNameLazy, findByPropsLazy } from "@metro/wrappers"; + +export default function wrapSafeAreaProvider() { + const { SafeAreaProvider } = findByPropsLazy('useSafeAreaInsets'); + + return after("default", findByNameLazy('App', false), function (_, ret) { + return ( + + {ret} + + ) + }); +} diff --git a/src/core/ui/reporter/components/ErrorBoundaryScreen.tsx b/src/core/ui/reporter/components/ErrorBoundaryScreen.tsx index 9c6174b6..af164ad8 100644 --- a/src/core/ui/reporter/components/ErrorBoundaryScreen.tsx +++ b/src/core/ui/reporter/components/ErrorBoundaryScreen.tsx @@ -17,12 +17,10 @@ const useStyles = createStyles({ backgroundColor: tokens.colors.BG_BASE_SECONDARY, paddingHorizontal: 16, height: "100%", - padding: 8, gap: 12 } }); - export default function ErrorBoundaryScreen(props: { error: Error; rerender: () => void; diff --git a/src/index.ts b/src/index.ts index baf2d907..09424f9a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import patchErrorBoundary from "@core/debug/patches/patchErrorBoundary"; +import wrapSafeAreaProvider from "@core/patches/wrapSafeAreaProvider"; import initFixes from "@core/fixes"; import { initFetchI18nStrings } from "@core/i18n"; import initSettings from "@core/ui/settings"; @@ -36,6 +37,7 @@ export default async () => { // Load everything in parallel await Promise.all([ + wrapSafeAreaProvider(), injectFluxInterceptor(), patchSettings(), patchLogHook(),