mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 14:43:25 +00:00
fix: use native modals on iOS & respect safe area
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
"react-native-change-icon": "^5.0.0",
|
||||
"react-native-context-menu-view": "^1.14.1",
|
||||
"react-native-gesture-handler": "~2.14.1",
|
||||
"react-native-ios-modal": "^0.1.8",
|
||||
"react-native-modal": "^13.0.1",
|
||||
"react-native-quick-base64": "^2.0.8",
|
||||
"react-native-quick-crypto": "^0.6.1",
|
||||
|
@@ -1,10 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
import { useEffect } from "react";
|
||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||
// @ts-expect-error - No exported types
|
||||
import { ModalView } from "react-native-ios-modal";
|
||||
import { useFonts } from "expo-font";
|
||||
import { SplashScreen, Stack } from "expo-router";
|
||||
import FontAwesome from "@expo/vector-icons/FontAwesome";
|
||||
import { DarkTheme, ThemeProvider } from "@react-navigation/native";
|
||||
import { setupNativeSheet } from "@tamagui/sheet";
|
||||
import { ToastProvider, ToastViewport } from "@tamagui/toast";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { TamaguiProvider, Theme, useTheme } from "tamagui";
|
||||
@@ -20,6 +23,8 @@ export {
|
||||
ErrorBoundary,
|
||||
} from "expo-router";
|
||||
|
||||
setupNativeSheet("ios", ModalView);
|
||||
|
||||
export const unstable_settings = {
|
||||
// Ensure that reloading on `/modal` keeps a back button present.
|
||||
initialRouteName: "(tabs)",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import type { SheetProps, ViewProps } from "tamagui";
|
||||
import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import {
|
||||
ScrollView,
|
||||
Separator,
|
||||
@@ -22,6 +22,7 @@ function SettingsSheet(props: SheetProps) {
|
||||
snapPoints={[90]}
|
||||
dismissOnSnapToBottom
|
||||
modal
|
||||
native
|
||||
animation="spring"
|
||||
{...props}
|
||||
>
|
||||
@@ -52,27 +53,29 @@ function SettingsSheetFrame({
|
||||
children: React.ReactNode;
|
||||
isLoading?: boolean;
|
||||
}) {
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
return (
|
||||
<SafeAreaProvider>
|
||||
<SafeAreaView style={{ flex: 1 }}>
|
||||
<Sheet.Frame
|
||||
backgroundColor="$playerSettingsBackground"
|
||||
padding="$5"
|
||||
gap="$4"
|
||||
>
|
||||
{isLoading && (
|
||||
<Spinner
|
||||
size="large"
|
||||
color="$loadingIndicator"
|
||||
style={{
|
||||
position: "absolute",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!isLoading && children}
|
||||
</Sheet.Frame>
|
||||
</SafeAreaView>
|
||||
</SafeAreaProvider>
|
||||
<View style={{flex: 1}} backgroundColor='black'>
|
||||
<Sheet.Frame
|
||||
backgroundColor="$playerSettingsBackground"
|
||||
padding="$5"
|
||||
left={insets.left}
|
||||
right={insets.right}
|
||||
gap="$4"
|
||||
>
|
||||
{isLoading && (
|
||||
<Spinner
|
||||
size="large"
|
||||
color="$loadingIndicator"
|
||||
style={{
|
||||
position: "absolute",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{!isLoading && children}
|
||||
</Sheet.Frame>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,9 +88,11 @@ function SettingsHeader({
|
||||
title: string;
|
||||
rightButton?: React.ReactNode;
|
||||
}) {
|
||||
const insets = useSafeAreaInsets();
|
||||
|
||||
return (
|
||||
<>
|
||||
<View flexDirection="row" alignItems="center" gap="$4">
|
||||
<View style={{ paddingRight: insets.right }} flexDirection="row" alignItems="center" gap="$4">
|
||||
{icon}
|
||||
<PlayerText flexGrow={1}>{title}</PlayerText>
|
||||
{rightButton}
|
||||
|
Reference in New Issue
Block a user