From 4d68c112bc8ccfc9dd4788891d0353b9481a190b Mon Sep 17 00:00:00 2001 From: Beef Date: Sat, 15 Apr 2023 00:49:59 +0100 Subject: [PATCH] [UI > Components] Add Discord's SafeAreaView --- src/def.d.ts | 3 ++- src/ui/components/index.ts | 3 +++ src/ui/safeMode.tsx | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/def.d.ts b/src/def.d.ts index 1a9b7cd..52378ab 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -415,7 +415,8 @@ interface VendettaObject { Search: _React.ComponentType; Alert: _React.ComponentType; Button: _React.ComponentType & { Looks: any, Colors: ButtonColors, Sizes: any }; - HelpMessage: _React.ComponentType; + HelpMessage: _React.ComponentType; + SafeAreaView: typeof _RN.SafeAreaView; // Vendetta Summary: _React.ComponentType; ErrorBoundary: _React.ComponentType; diff --git a/src/ui/components/index.ts b/src/ui/components/index.ts index f406a8b..c11a51e 100644 --- a/src/ui/components/index.ts +++ b/src/ui/components/index.ts @@ -1,3 +1,4 @@ +import { ReactNative as RN } from "@metro/common"; import { findByName, findByProps } from "@metro/filters"; // Discord @@ -7,6 +8,8 @@ export const Search = findByName("StaticSearchBarContainer"); export const Alert = findByProps("alertDarkStyles", "alertLightStyles").default; export const Button = findByProps("Looks", "Colors", "Sizes") as React.ComponentType & { Looks: any, Colors: any, Sizes: any }; export const HelpMessage = findByName("HelpMessage"); +// React Native's included SafeAreaView only adds padding on iOS. +export const SafeAreaView = findByProps("useSafeAreaInsets").SafeAreaView as typeof RN.SafeAreaView; // Vendetta export { default as Summary } from "@ui/components/Summary"; diff --git a/src/ui/safeMode.tsx b/src/ui/safeMode.tsx index 013fd14..736d717 100644 --- a/src/ui/safeMode.tsx +++ b/src/ui/safeMode.tsx @@ -5,13 +5,11 @@ import { after } from "@lib/patcher"; import { DeviceManager } from "@lib/native"; import { toggleSafeMode } from "@lib/debug"; import { semanticColors } from "@ui/color"; -import { Button, Codeblock, ErrorBoundary as _ErrorBoundary } from "@ui/components"; +import { Button, Codeblock, ErrorBoundary as _ErrorBoundary, SafeAreaView } from "@ui/components"; import settings from "@lib/settings"; const ErrorBoundary = findByName("ErrorBoundary"); -// React Native's included SafeAreaView only adds padding on iOS. -const { SafeAreaView } = findByProps("useSafeAreaInsets"); // Let's just pray they have this. const { BadgableTabBar } = findByProps("BadgableTabBar");