mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Update apps for SceneDelegate support (#57717)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/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 fbshipit-source-id: 20831f84335b1d6c7f6bf4176d1dbba98a13bdce
This commit is contained in:
1 parent
9d10e39d32
commit
609bdddabf
2 files changed
+34
-4
No files matched your search
@@ -13,7 +13,7 @@ import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
|
||||
import RNTesterText from '../../components/RNTesterText';
|
||||
import * as React from 'react';
|
||||
import {useEffect, useState} from 'react';
|
||||
import {Dimensions, useWindowDimensions} from 'react-native';
|
||||
import {Button, Dimensions, View, useWindowDimensions} from 'react-native';
|
||||
|
||||
type Props = {dim: string};
|
||||
|
||||
@@ -40,6 +40,22 @@ const DimensionsViaHook = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const DimensionsViaCall = ({dim}: Props) => {
|
||||
const [info, setInfo] = useState(() => Dimensions.get(dim));
|
||||
return (
|
||||
<View>
|
||||
<Button
|
||||
onPress={() => setInfo(Dimensions.get(dim))}
|
||||
title={`Invoke get('${dim}')`}
|
||||
/>
|
||||
|
||||
<RNTesterText variant="label">
|
||||
{JSON.stringify(info, null, 2)}
|
||||
</RNTesterText>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
exports.title = 'Dimensions';
|
||||
exports.category = 'UI';
|
||||
exports.documentationURL = 'https://reactnative.dev/docs/dimensions';
|
||||
@@ -52,15 +68,27 @@ exports.examples = [
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Non-component `get` API: window',
|
||||
title: 'Non-component `get` API (subscription): window',
|
||||
render(): React.MixedElement {
|
||||
return <DimensionsSubscription dim="window" />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Non-component `get` API: screen',
|
||||
title: 'Non-component `get` API (subscription): screen',
|
||||
render(): React.MixedElement {
|
||||
return <DimensionsSubscription dim="screen" />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Non-component `get` API (manual call): window',
|
||||
render(): React.MixedElement {
|
||||
return <DimensionsViaCall dim="window" />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Non-component `get` API (manual call): screen',
|
||||
render(): React.MixedElement {
|
||||
return <DimensionsViaCall dim="screen" />;
|
||||
},
|
||||
},
|
||||
] as Array<RNTesterModuleExample>;
|
||||
@@ -26,7 +26,9 @@ function App(): React.ReactNode {
|
||||
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
|
||||
<ScrollView contentInsetAdjustmentBehavior="automatic">
|
||||
<View>
|
||||
<Text style={styles.title}>Hello, World!</Text>
|
||||
<Text style={[styles.title, {color: isDarkMode ? 'white' : 'black'}]}>
|
||||
Hello, World!
|
||||
</Text>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
|
||||
Reference in new issue
Block a user