From 313ef8d91532537960bbdf26c01323c7c33a1232 Mon Sep 17 00:00:00 2001 From: Pokai Chang Date: Sun, 12 May 2024 23:21:58 +0800 Subject: [PATCH 1/5] feat: add PreventRemove example --- Example/App.tsx | 6 ++ Example/src/screens/PreventRemove.tsx | 124 ++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 Example/src/screens/PreventRemove.tsx diff --git a/Example/App.tsx b/Example/App.tsx index ff2e0cfac2..26d73dc071 100644 --- a/Example/App.tsx +++ b/Example/App.tsx @@ -22,6 +22,7 @@ import StatusBarExample from './src/screens/StatusBar'; import Animations from './src/screens/Animations'; import BottomTabsAndStack from './src/screens/BottomTabsAndStack'; import Modals from './src/screens/Modals'; +import PreventRemove from './src/screens/PreventRemove'; import Orientation from './src/screens/Orientation'; import SearchBar from './src/screens/SearchBar'; import Events from './src/screens/Events'; @@ -70,6 +71,11 @@ const SCREENS: Record< component: Modals, type: 'example', }, + PreventRemove: { + title: 'Prevent Remove', + component: PreventRemove, + type: 'example', + }, HeaderOptions: { title: 'Header Options', component: HeaderOptions, diff --git a/Example/src/screens/PreventRemove.tsx b/Example/src/screens/PreventRemove.tsx new file mode 100644 index 0000000000..6da2700d69 --- /dev/null +++ b/Example/src/screens/PreventRemove.tsx @@ -0,0 +1,124 @@ +import React from 'react'; +import { View, StyleSheet, TextInput, Platform, Alert, ScrollView, Text } from 'react-native'; +import { usePreventRemove } from '@react-navigation/native'; +import { + createNativeStackNavigator, + NativeStackNavigationProp, +} from '@react-navigation/native-stack'; +import { Button } from '../shared'; + +type StackParamList = { + Main: undefined; + PreventRemoveScreen: undefined; + PreventRemoveModal: undefined; +}; + +interface MainScreenProps { + navigation: NativeStackNavigationProp; +} + +const MainScreen = ({ navigation }: MainScreenProps): JSX.Element => ( + +