Skip to content

Commit 478fc61

Browse files
artus9033meta-codesync[bot]
authored andcommitted
Update apps for SceneDelegate support (#57717)
Summary: Pull Request resolved: #57717 Update the RNTester and HelloWorld JS layers for SceneDelegate-based window resizing and app lifecycle behavior. Changelog: [iOS][Changed] - Update RNTester and HelloWorld for SceneDelegate lifecycle behavior Test Plan: - Verify Dimensions updates after resizing the RNTester window. - Verify the HelloWorld app renders with the SceneDelegate bootstrap. - `arc f` - `arc lint` Reviewed By: javache Differential Revision: D113758227 Pulled By: cipolleschi
1 parent aa2b1fc commit 478fc61

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

packages/rn-tester/js/examples/Dimensions/DimensionsExample.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
1313
import RNTesterText from '../../components/RNTesterText';
1414
import * as React from 'react';
1515
import {useEffect, useState} from 'react';
16-
import {Dimensions, useWindowDimensions} from 'react-native';
16+
import {Button, Dimensions, View, useWindowDimensions} from 'react-native';
1717

1818
type Props = {dim: string};
1919

@@ -40,6 +40,22 @@ const DimensionsViaHook = () => {
4040
);
4141
};
4242

43+
const DimensionsViaCall = ({dim}: Props) => {
44+
const [info, setInfo] = useState(() => Dimensions.get(dim));
45+
return (
46+
<View>
47+
<Button
48+
onPress={() => setInfo(Dimensions.get(dim))}
49+
title={`Invoke get('${dim}')`}
50+
/>
51+
52+
<RNTesterText variant="label">
53+
{JSON.stringify(info, null, 2)}
54+
</RNTesterText>
55+
</View>
56+
);
57+
};
58+
4359
exports.title = 'Dimensions';
4460
exports.category = 'UI';
4561
exports.documentationURL = 'https://reactnative.dev/docs/dimensions';
@@ -52,15 +68,27 @@ exports.examples = [
5268
},
5369
},
5470
{
55-
title: 'Non-component `get` API: window',
71+
title: 'Non-component `get` API (subscription): window',
5672
render(): React.MixedElement {
5773
return <DimensionsSubscription dim="window" />;
5874
},
5975
},
6076
{
61-
title: 'Non-component `get` API: screen',
77+
title: 'Non-component `get` API (subscription): screen',
6278
render(): React.MixedElement {
6379
return <DimensionsSubscription dim="screen" />;
6480
},
6581
},
82+
{
83+
title: 'Non-component `get` API (manual call): window',
84+
render(): React.MixedElement {
85+
return <DimensionsViaCall dim="window" />;
86+
},
87+
},
88+
{
89+
title: 'Non-component `get` API (manual call): screen',
90+
render(): React.MixedElement {
91+
return <DimensionsViaCall dim="screen" />;
92+
},
93+
},
6694
] as Array<RNTesterModuleExample>;

private/helloworld/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ function App(): React.ReactNode {
2626
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
2727
<ScrollView contentInsetAdjustmentBehavior="automatic">
2828
<View>
29-
<Text style={styles.title}>Hello, World!</Text>
29+
<Text style={[styles.title, {color: isDarkMode ? 'white' : 'black'}]}>
30+
Hello, World!
31+
</Text>
3032
</View>
3133
</ScrollView>
3234
</SafeAreaView>

0 commit comments

Comments
 (0)