Skip to content

Commit 14bfad5

Browse files
huntiereact-native-bot
authored andcommitted
Add optional safeAreaInsets prop to NewAppScreen (replacing SafeAreaView) (#52507)
Summary: Pull Request resolved: #52507 Resolves reactwg/react-native-releases#1011. Changelog: [General][Changed] - `NewAppScreen` no longer internally handles device safe area, use optional `safeAreaInsets` prop (aligned in 0.81 template) Reviewed By: cortinico Differential Revision: D78006238 fbshipit-source-id: 01fb16d6754b69a722ea11838d558bebd4748026
1 parent 10b63c1 commit 14bfad5

2 files changed

Lines changed: 25 additions & 12 deletions

File tree

packages/new-app-screen/src/NewAppScreen.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import {ThemedText, useTheme} from './Theme';
1313
import * as React from 'react';
1414
import {
1515
Image,
16-
Platform,
17-
SafeAreaView,
1816
ScrollView,
19-
StatusBar,
2017
StyleSheet,
2118
Text,
2219
TouchableHighlight,
@@ -29,24 +26,32 @@ import {version as ReactNativeVersion} from 'react-native/Libraries/Core/ReactNa
2926

3027
export type NewAppScreenProps = $ReadOnly<{
3128
templateFileName?: string,
29+
safeAreaInsets?: $ReadOnly<{
30+
top: number,
31+
bottom: number,
32+
left: number,
33+
right: number,
34+
}>,
3235
}>;
3336

34-
const statusBarHeightOffset = Platform.select({
35-
android: StatusBar.currentHeight || 0,
36-
default: 0,
37-
});
38-
3937
export default function NewAppScreen({
4038
templateFileName = 'App.tsx',
39+
safeAreaInsets = {top: 0, bottom: 0, left: 0, right: 0},
4140
}: NewAppScreenProps): React.Node {
4241
const {colors} = useTheme();
4342
const isDarkMode = useColorScheme() === 'dark';
4443
const isLargeScreen = useWindowDimensions().width > 600;
4544

4645
return (
47-
<SafeAreaView style={{backgroundColor: colors.background}}>
48-
<ScrollView>
49-
<View style={[styles.container, {paddingTop: statusBarHeightOffset}]}>
46+
<View
47+
style={{
48+
backgroundColor: colors.background,
49+
paddingTop: safeAreaInsets.top,
50+
paddingLeft: safeAreaInsets.left,
51+
paddingRight: safeAreaInsets.right,
52+
}}>
53+
<ScrollView style={{paddingBottom: safeAreaInsets.bottom}}>
54+
<View style={styles.container}>
5055
<View style={styles.header}>
5156
<Image
5257
style={styles.logo}
@@ -99,7 +104,7 @@ export default function NewAppScreen({
99104
</View>
100105
</View>
101106
</ScrollView>
102-
</SafeAreaView>
107+
</View>
103108
);
104109
}
105110

packages/new-app-screen/src/index.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import type * as React from 'react';
1111

1212
export type NewAppScreenProps = Readonly<{
1313
templateFileName?: string | undefined;
14+
safeAreaInsets?:
15+
| Readonly<{
16+
top: number;
17+
bottom: number;
18+
left: number;
19+
right: number;
20+
}>
21+
| undefined;
1422
}>;
1523

1624
export function NewAppScreen(props: NewAppScreenProps): React.ReactNode;

0 commit comments

Comments
 (0)