-
-
Notifications
You must be signed in to change notification settings - Fork 537
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(iOS): full screen modal crash on paper (#2336)
## Description Full screen modal was crashing sometimes on Paper. Fixes #2317. ## Test code and steps to reproduce Added `Test2317` to tests. ## Checklist - [x] Included code example that can be used to test this change - [ ] Ensured that CI passes --------- Co-authored-by: Kacper Kafara <[email protected]>
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import * as React from 'react'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
import { createNativeStackNavigator, NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
import { DarkTheme, DefaultTheme } from '@react-navigation/native'; | ||
import { Button, StyleSheet, Text, useColorScheme } from 'react-native'; | ||
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; | ||
import { Colors } from 'react-native/Libraries/NewAppScreen'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
const App = (): React.JSX.Element => { | ||
const isDarkMode = useColorScheme(); | ||
|
||
return ( | ||
<SafeAreaProvider> | ||
<NavigationContainer theme={isDarkMode ? DarkTheme : DefaultTheme}> | ||
<Stack.Navigator> | ||
<Stack.Screen | ||
name="main" | ||
component={MainScreen} | ||
options={{ headerShown: false }} | ||
/> | ||
<Stack.Screen | ||
name="modal" | ||
component={FullScreenModal} | ||
options={({}) => ({ | ||
presentation: 'fullScreenModal', | ||
headerTitle: () => ( | ||
<Text style={{ color: isDarkMode ? Colors.light : Colors.dark }}> | ||
Header Title | ||
</Text> | ||
) | ||
})} | ||
/> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
</SafeAreaProvider> | ||
); | ||
}; | ||
|
||
const FullScreenModal = ({ navigation }: NativeStackScreenProps<{}>) => { | ||
const isDarkMode = useColorScheme() === 'dark'; | ||
|
||
return ( | ||
<SafeAreaView | ||
style={[ | ||
styles.container, | ||
{ backgroundColor: isDarkMode ? Colors.darker : Colors } | ||
]} | ||
> | ||
<Text style={{ color: Colors.light }}>FullScreenModal</Text> | ||
<Button title="Go back" onPress={navigation.goBack} /> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
const MainScreen = ({ | ||
navigation | ||
}: NativeStackScreenProps<Record<string, object | undefined>>) => { | ||
const isDarkMode = useColorScheme() === 'dark'; | ||
|
||
return ( | ||
<SafeAreaView | ||
style={[ | ||
styles.container, | ||
{ backgroundColor: isDarkMode ? Colors.darker : Colors.lighter } | ||
]} | ||
> | ||
<Text style={{ color: isDarkMode ? Colors.light : Colors.dark }}> | ||
Main Screen | ||
</Text> | ||
<Button title="Press" onPress={() => navigation.navigate('modal')} /> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center' | ||
} | ||
}); | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters