-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RNTester: Text Adjusts Dynamic Layout Example
Summary: Creates a new RNTester example to verify #31538 (D28631465). Changelog: [Android][Added] - RNTester example for adjusting text with dynamic layout. Reviewed By: kacieb Differential Revision: D28779870 fbshipit-source-id: 5297a823645d1e9e35d4c86b491f3c225ecc9543
- Loading branch information
1 parent
b85572a
commit 78caaca
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
packages/rn-tester/js/examples/Text/TextAdjustsDynamicLayoutExample.js
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,55 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow strict-local | ||
*/ | ||
|
||
import {Button, Text, StyleSheet, View} from 'react-native'; | ||
import * as React from 'react'; | ||
import {useState} from 'react'; | ||
|
||
export default function TextAdjustsDynamicLayoutExample(props: {}): React.Node { | ||
const [height, setHeight] = useState(20); | ||
|
||
return ( | ||
<> | ||
<View> | ||
<View style={[styles.subjectContainer, {height}]}> | ||
<Text | ||
adjustsFontSizeToFit={true} | ||
numberOfLines={1} | ||
style={styles.subjectText}> | ||
This is adjusting text. | ||
</Text> | ||
</View> | ||
</View> | ||
<View style={styles.row}> | ||
<Button onPress={() => setHeight(20)} title="Set Height to 20" /> | ||
</View> | ||
<View style={styles.row}> | ||
<Button onPress={() => setHeight(40)} title="Set Height to 40" /> | ||
</View> | ||
<View style={styles.row}> | ||
<Button onPress={() => setHeight(60)} title="Set Height to 60" /> | ||
</View> | ||
</> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
subjectContainer: { | ||
backgroundColor: 'rgba(254, 255, 0, 0.75)', | ||
justifyContent: 'center', | ||
}, | ||
subjectText: { | ||
fontSize: 40, | ||
textAlign: 'center', | ||
}, | ||
row: { | ||
marginTop: 10, | ||
}, | ||
}); |
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