2015-01-30 01:10:49 +00:00
|
|
|
/**
|
2017-05-06 03:50:47 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
2016-07-12 12:51:57 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-07-12 12:51:57 +00:00
|
|
|
*
|
2018-05-11 20:32:37 +00:00
|
|
|
* @format
|
2015-03-23 17:06:16 +00:00
|
|
|
* @flow
|
2015-01-30 01:10:49 +00:00
|
|
|
*/
|
2018-05-11 20:32:37 +00:00
|
|
|
|
2015-01-30 01:10:49 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-09 03:36:40 +00:00
|
|
|
var React = require('react');
|
|
|
|
var ReactNative = require('react-native');
|
2018-05-11 20:32:37 +00:00
|
|
|
var {StyleSheet, Text, View} = ReactNative;
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
var RNTesterBlock = require('./RNTesterBlock');
|
|
|
|
var RNTesterPage = require('./RNTesterPage');
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class Circle extends React.Component<$FlowFixMeProps> {
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2015-01-30 01:10:49 +00:00
|
|
|
var size = this.props.size || 20;
|
2016-06-10 10:14:54 +00:00
|
|
|
var backgroundColor = this.props.bgColor || '#527fe4';
|
2015-01-30 01:10:49 +00:00
|
|
|
return (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
borderRadius: size / 2,
|
2016-06-10 10:14:54 +00:00
|
|
|
backgroundColor: backgroundColor,
|
2015-01-30 01:10:49 +00:00
|
|
|
width: size,
|
|
|
|
height: size,
|
|
|
|
margin: 1,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class CircleBlock extends React.Component<$FlowFixMeProps> {
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2015-01-30 01:10:49 +00:00
|
|
|
var circleStyle = {
|
|
|
|
flexDirection: 'row',
|
|
|
|
backgroundColor: '#f6f7f8',
|
|
|
|
borderWidth: 0.5,
|
|
|
|
borderColor: '#d6d7da',
|
|
|
|
marginBottom: 2,
|
|
|
|
};
|
|
|
|
return (
|
2018-05-11 20:32:37 +00:00
|
|
|
<View style={[circleStyle, this.props.style]}>{this.props.children}</View>
|
2015-01-30 01:10:49 +00:00
|
|
|
);
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class LayoutExample extends React.Component<$FlowFixMeProps> {
|
2016-07-26 08:00:02 +00:00
|
|
|
static title = 'Layout - Flexbox';
|
|
|
|
static description = 'Examples of using the flexbox API to layout views.';
|
|
|
|
static displayName = 'LayoutExample';
|
2015-07-07 23:19:40 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2016-06-10 10:14:54 +00:00
|
|
|
var fiveColoredCircles = [
|
|
|
|
<Circle bgColor="#527fe4" key="blue" />,
|
|
|
|
<Circle bgColor="#D443E3" key="violet" />,
|
|
|
|
<Circle bgColor="#FF9049" key="orange" />,
|
|
|
|
<Circle bgColor="#FFE649" key="yellow" />,
|
2018-05-11 20:32:37 +00:00
|
|
|
<Circle bgColor="#7FE040" key="green" />,
|
2016-06-10 10:14:54 +00:00
|
|
|
];
|
|
|
|
|
2015-01-30 01:10:49 +00:00
|
|
|
return (
|
2017-05-06 03:50:47 +00:00
|
|
|
<RNTesterPage title={this.props.navigator ? null : 'Layout'}>
|
|
|
|
<RNTesterBlock title="Flex Direction">
|
2015-01-30 01:10:49 +00:00
|
|
|
<Text>row</Text>
|
|
|
|
<CircleBlock style={{flexDirection: 'row'}}>
|
2016-06-10 10:14:54 +00:00
|
|
|
{fiveColoredCircles}
|
|
|
|
</CircleBlock>
|
|
|
|
<Text>row-reverse</Text>
|
|
|
|
<CircleBlock style={{flexDirection: 'row-reverse'}}>
|
|
|
|
{fiveColoredCircles}
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
|
|
|
<Text>column</Text>
|
|
|
|
<CircleBlock style={{flexDirection: 'column'}}>
|
2016-06-10 10:14:54 +00:00
|
|
|
{fiveColoredCircles}
|
|
|
|
</CircleBlock>
|
|
|
|
<Text>column-reverse</Text>
|
|
|
|
<CircleBlock style={{flexDirection: 'column-reverse'}}>
|
|
|
|
{fiveColoredCircles}
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
2018-05-11 20:32:37 +00:00
|
|
|
<View
|
|
|
|
style={[
|
|
|
|
styles.overlay,
|
|
|
|
{position: 'absolute', top: 15, left: 160},
|
|
|
|
]}>
|
2015-01-30 01:10:49 +00:00
|
|
|
<Text>{'top: 15, left: 160'}</Text>
|
|
|
|
</View>
|
2017-05-06 03:50:47 +00:00
|
|
|
</RNTesterBlock>
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
<RNTesterBlock title="Justify Content - Main Direction">
|
2015-01-30 01:10:49 +00:00
|
|
|
<Text>flex-start</Text>
|
|
|
|
<CircleBlock style={{justifyContent: 'flex-start'}}>
|
2016-06-10 10:14:54 +00:00
|
|
|
{fiveColoredCircles}
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
|
|
|
<Text>center</Text>
|
|
|
|
<CircleBlock style={{justifyContent: 'center'}}>
|
2016-06-10 10:14:54 +00:00
|
|
|
{fiveColoredCircles}
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
|
|
|
<Text>flex-end</Text>
|
|
|
|
<CircleBlock style={{justifyContent: 'flex-end'}}>
|
2016-06-10 10:14:54 +00:00
|
|
|
{fiveColoredCircles}
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
|
|
|
<Text>space-between</Text>
|
|
|
|
<CircleBlock style={{justifyContent: 'space-between'}}>
|
2016-06-10 10:14:54 +00:00
|
|
|
{fiveColoredCircles}
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
|
|
|
<Text>space-around</Text>
|
|
|
|
<CircleBlock style={{justifyContent: 'space-around'}}>
|
2016-06-10 10:14:54 +00:00
|
|
|
{fiveColoredCircles}
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
2017-05-06 03:50:47 +00:00
|
|
|
</RNTesterBlock>
|
|
|
|
<RNTesterBlock title="Align Items - Other Direction">
|
2015-01-30 01:10:49 +00:00
|
|
|
<Text>flex-start</Text>
|
|
|
|
<CircleBlock style={{alignItems: 'flex-start', height: 30}}>
|
2018-05-11 20:32:37 +00:00
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={8} />
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
|
|
|
<Text>center</Text>
|
|
|
|
<CircleBlock style={{alignItems: 'center', height: 30}}>
|
2018-05-11 20:32:37 +00:00
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={8} />
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
|
|
|
<Text>flex-end</Text>
|
|
|
|
<CircleBlock style={{alignItems: 'flex-end', height: 30}}>
|
2018-05-11 20:32:37 +00:00
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={10} />
|
|
|
|
<Circle size={20} />
|
|
|
|
<Circle size={17} />
|
|
|
|
<Circle size={12} />
|
|
|
|
<Circle size={15} />
|
|
|
|
<Circle size={8} />
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
2017-05-06 03:50:47 +00:00
|
|
|
</RNTesterBlock>
|
|
|
|
<RNTesterBlock title="Flex Wrap">
|
2015-01-30 01:10:49 +00:00
|
|
|
<CircleBlock style={{flexWrap: 'wrap'}}>
|
2015-02-08 01:23:25 +00:00
|
|
|
{'oooooooooooooooo'.split('').map((char, i) => <Circle key={i} />)}
|
2015-01-30 01:10:49 +00:00
|
|
|
</CircleBlock>
|
2017-05-06 03:50:47 +00:00
|
|
|
</RNTesterBlock>
|
|
|
|
</RNTesterPage>
|
2015-01-30 01:10:49 +00:00
|
|
|
);
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
overlay: {
|
|
|
|
backgroundColor: '#aaccff',
|
|
|
|
borderRadius: 10,
|
|
|
|
borderWidth: 0.5,
|
|
|
|
opacity: 0.5,
|
|
|
|
padding: 5,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = LayoutExample;
|