Skip to content

Commit 9d2f6d8

Browse files
committed
test: add RNTester inline view small font scale case
1 parent 453c624 commit 9d2f6d8

2 files changed

Lines changed: 88 additions & 1 deletion

File tree

packages/rn-tester/js/components/TextInlineView.js

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import RNTesterText from '../components/RNTesterText';
1414
import * as React from 'react';
1515
import {useState} from 'react';
16-
import {Image, TouchableHighlight, View} from 'react-native';
16+
import {Image, StyleSheet, TouchableHighlight, View} from 'react-native';
17+
18+
const SMALL_FONT_SCALE_INLINE_VIEW_WIDTH = 155;
19+
const SMALL_FONT_SCALE_INLINE_VIEW_HEIGHT = 32;
1720

1821
function Basic(): React.Node {
1922
return (
@@ -106,6 +109,82 @@ function ClippedByText(): React.Node {
106109
);
107110
}
108111

112+
function SmallFontScale(): React.Node {
113+
return (
114+
<View>
115+
<RNTesterText>
116+
The blue inline view should keep its full 155dp width when Android
117+
system font size is smaller than the default.
118+
</RNTesterText>
119+
<View style={styles.smallFontScaleContainer}>
120+
<RNTesterText
121+
testID="inline-view-small-font-scale"
122+
style={styles.smallFontScaleLine}>
123+
Prefix |{' '}
124+
<View style={styles.smallFontScaleInlineView}>
125+
<View style={styles.smallFontScaleInlineViewFill}>
126+
<RNTesterText style={styles.smallFontScaleInlineViewText}>
127+
Inline view
128+
</RNTesterText>
129+
</View>
130+
</View>{' '}
131+
| Suffix
132+
</RNTesterText>
133+
</View>
134+
<View style={styles.smallFontScaleReference}>
135+
<View style={styles.smallFontScaleReferenceBar} />
136+
<RNTesterText style={styles.smallFontScaleReferenceText}>
137+
Expected inline view width: 155dp
138+
</RNTesterText>
139+
</View>
140+
</View>
141+
);
142+
}
143+
144+
const styles = StyleSheet.create({
145+
smallFontScaleContainer: {
146+
backgroundColor: 'lightgrey',
147+
borderColor: 'darkgrey',
148+
borderWidth: 1,
149+
marginTop: 12,
150+
paddingHorizontal: 12,
151+
paddingVertical: 10,
152+
},
153+
smallFontScaleInlineView: {
154+
height: SMALL_FONT_SCALE_INLINE_VIEW_HEIGHT,
155+
width: SMALL_FONT_SCALE_INLINE_VIEW_WIDTH,
156+
},
157+
smallFontScaleInlineViewFill: {
158+
alignItems: 'center',
159+
backgroundColor: 'steelblue',
160+
borderColor: 'navy',
161+
borderWidth: 1,
162+
height: SMALL_FONT_SCALE_INLINE_VIEW_HEIGHT,
163+
justifyContent: 'center',
164+
width: SMALL_FONT_SCALE_INLINE_VIEW_WIDTH,
165+
},
166+
smallFontScaleInlineViewText: {
167+
color: 'white',
168+
fontSize: 12,
169+
fontWeight: 'bold',
170+
},
171+
smallFontScaleLine: {
172+
fontSize: 16,
173+
},
174+
smallFontScaleReference: {
175+
marginTop: 8,
176+
},
177+
smallFontScaleReferenceBar: {
178+
backgroundColor: 'steelblue',
179+
height: 4,
180+
width: SMALL_FONT_SCALE_INLINE_VIEW_WIDTH,
181+
},
182+
smallFontScaleReferenceText: {
183+
fontSize: 12,
184+
marginTop: 4,
185+
},
186+
});
187+
109188
function ChangeImageSize(): React.Node {
110189
const [width, setWidth] = useState(50);
111190
return (
@@ -203,6 +282,7 @@ module.exports = {
203282
Basic,
204283
NestedTexts,
205284
ClippedByText,
285+
SmallFontScale,
206286
ChangeImageSize,
207287
ChangeViewSize,
208288
ChangeInnerViewSize,

packages/rn-tester/js/examples/Text/TextExample.android.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,13 @@ const examples = [
16561656
return <TextInlineView.ClippedByText />;
16571657
},
16581658
},
1659+
{
1660+
title: 'Inline view with small font scale',
1661+
name: 'inlineViewsSmallFontScale',
1662+
render(): React.Node {
1663+
return <TextInlineView.SmallFontScale />;
1664+
},
1665+
},
16591666
{
16601667
title: 'Relayout inline image',
16611668
name: 'relayoutInlineImage',

0 commit comments

Comments
 (0)