Skip to content

Commit 4b40daf

Browse files
artus9033meta-codesync[bot]
authored andcommitted
Update apps for SceneDelegate support
Summary: 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 Reviewed By: javache Differential Revision: D113758227 Pulled By: cipolleschi
1 parent 40c47da commit 4b40daf

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

packages/rn-tester/IntegrationTests/IntegrationTestsApp.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ const TESTS = [
3232
require('./WebSocketTest'),
3333
require('./AccessibilityManagerTest'),
3434
require('./GlobalEvalWithSourceUrlTest'),
35-
].map(mod => mod.default);
35+
// $FlowFixMe[incompatible-type] (>=0.319.0) `require()` modules have unknown shape
36+
].map(mod => mod.default) as Array<React.ComponentType<{...}>>;
3637

3738
TESTS.forEach(test =>
3839
AppRegistry.registerComponent(
39-
(test as React.ComponentType<any>).displayName || test.name || '',
40+
test.displayName || test.name || '',
4041
/* $FlowFixMe[incompatible-type] (>=0.54.0 site=react_native_fb,react_native_
4142
* oss) This comment suppresses an error found when Flow v0.54 was deployed.
4243
* To see the error delete this comment and run Flow. */
@@ -84,7 +85,7 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMe> {
8485
*/
8586
style={styles.row}>
8687
<Text style={styles.testName}>
87-
{(test as React.ComponentType<any>).displayName || test.name}
88+
{test.displayName || test.name}
8889
</Text>
8990
</TouchableOpacity>,
9091
<View style={styles.separator} />,

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)