|
13 | 13 | import RNTesterText from '../components/RNTesterText'; |
14 | 14 | import * as React from 'react'; |
15 | 15 | 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; |
17 | 20 |
|
18 | 21 | function Basic(): React.Node { |
19 | 22 | return ( |
@@ -106,6 +109,82 @@ function ClippedByText(): React.Node { |
106 | 109 | ); |
107 | 110 | } |
108 | 111 |
|
| 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 | + |
109 | 188 | function ChangeImageSize(): React.Node { |
110 | 189 | const [width, setWidth] = useState(50); |
111 | 190 | return ( |
@@ -203,6 +282,7 @@ module.exports = { |
203 | 282 | Basic, |
204 | 283 | NestedTexts, |
205 | 284 | ClippedByText, |
| 285 | + SmallFontScale, |
206 | 286 | ChangeImageSize, |
207 | 287 | ChangeViewSize, |
208 | 288 | ChangeInnerViewSize, |
|
0 commit comments