Skip to content

Commit 7630a61

Browse files
sherginfacebook-github-bot
authored andcommittedFeb 16, 2018
Demo illustrated base-line metric exposure
Summary: A demo illustrated `base-line` metric exposure to layout system was added to RNTester. And currently it shows that we don't support it at all. https://cl.ly/1F0B0D430U3e Reviewed By: sahrens Differential Revision: D6957056 fbshipit-source-id: 28776300fc8e11950ac5ba1a5416f68d31d4e9fb
1 parent ad4f54f commit 7630a61

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed
 

‎RNTester/js/TextExample.ios.js

+71-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Platform = require('Platform');
1515
var React = require('react');
1616
var createReactClass = require('create-react-class');
1717
var ReactNative = require('react-native');
18-
var {Image, Text, View, LayoutAnimation, Button} = ReactNative;
18+
var {Image, Text, TextInput, View, LayoutAnimation, Button} = ReactNative;
1919

2020
type TextAlignExampleRTLState = {|
2121
isRTL: boolean,
@@ -224,6 +224,70 @@ var AdjustingFontSize = createReactClass({
224224
},
225225
});
226226

227+
class TextBaseLineLayoutExample extends React.Component<*, *> {
228+
render() {
229+
var texts = [];
230+
for (var i = 9; i >= 0; i--) {
231+
texts.push(<Text key={i} style={{fontSize: 8 + i * 5, backgroundColor: '#eee'}}>{i}</Text>);
232+
}
233+
234+
const marker = <View style={{width: 20, height: 20, backgroundColor: 'gray'}} />;
235+
const subtitleStyle = {fontSize: 16, marginTop: 8, fontWeight: 'bold'};
236+
237+
return (
238+
<View>
239+
<Text style={subtitleStyle}>{'Nested <Text/>s:'}</Text>
240+
<View style={{flexDirection: 'row', alignItems: 'baseline'}}>
241+
{marker}
242+
<Text>
243+
{texts}
244+
</Text>
245+
{marker}
246+
</View>
247+
248+
<Text style={subtitleStyle}>{'Array of <Text/>s in <View>:'}</Text>
249+
<View style={{flexDirection: 'row', alignItems: 'baseline'}}>
250+
{marker}
251+
{texts}
252+
{marker}
253+
</View>
254+
255+
<Text style={subtitleStyle}>{'Interleaving <View> and <Text>:'}</Text>
256+
<View style={{flexDirection: 'row', alignItems: 'baseline'}}>
257+
{marker}
258+
<Text selectable={true}>
259+
Some text.
260+
<View style={{flexDirection: 'row', alignItems: 'baseline', backgroundColor: '#eee'}}>
261+
{marker}
262+
<Text>Text inside View.</Text>
263+
{marker}
264+
</View>
265+
</Text>
266+
{marker}
267+
</View>
268+
269+
<Text style={subtitleStyle}>{'<TextInput/>:'}</Text>
270+
<View style={{flexDirection: 'row', alignItems: 'baseline'}}>
271+
{marker}
272+
<TextInput style={{margin: 0, padding: 0}}>
273+
{texts}
274+
</TextInput>
275+
{marker}
276+
</View>
277+
278+
<Text style={subtitleStyle}>{'<TextInput multiline/>:'}</Text>
279+
<View style={{flexDirection: 'row', alignItems: 'baseline'}}>
280+
{marker}
281+
<TextInput multiline={true} style={{margin: 0, padding: 0}}>
282+
{texts}
283+
</TextInput>
284+
{marker}
285+
</View>
286+
</View>
287+
);
288+
}
289+
}
290+
227291
exports.title = '<Text>';
228292
exports.description = 'Base component for rendering styled text.';
229293
exports.displayName = 'TextExample';
@@ -780,4 +844,10 @@ exports.examples = [
780844
return <TextAlignRTLExample />;
781845
},
782846
},
847+
{
848+
title: 'Text `alignItems: \'baseline\'` style',
849+
render: function() {
850+
return <TextBaseLineLayoutExample />;
851+
},
852+
},
783853
];

0 commit comments

Comments
 (0)
Please sign in to comment.