2015-02-20 04:10:52 +00:00
|
|
|
/**
|
2017-05-06 03:50:47 +00:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
2016-07-12 12:51:57 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*
|
2017-05-06 03:50:47 +00:00
|
|
|
* @providesModule RNTesterBlock
|
2015-03-23 18:36:57 +00:00
|
|
|
* @flow
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2016-04-08 04:13:12 +00:00
|
|
|
var React = require('react');
|
2017-04-12 23:09:48 +00:00
|
|
|
var PropTypes = require('prop-types');
|
2016-04-08 04:13:12 +00:00
|
|
|
var ReactNative = require('react-native');
|
2015-02-20 04:10:52 +00:00
|
|
|
var {
|
|
|
|
StyleSheet,
|
|
|
|
Text,
|
|
|
|
View,
|
2016-04-08 04:13:12 +00:00
|
|
|
} = ReactNative;
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
class RNTesterBlock extends React.Component {
|
2016-07-26 08:00:02 +00:00
|
|
|
props: {
|
|
|
|
title?: string,
|
|
|
|
description?: string,
|
|
|
|
};
|
|
|
|
|
|
|
|
static propTypes = {
|
2017-04-12 23:09:48 +00:00
|
|
|
title: PropTypes.string,
|
|
|
|
description: PropTypes.string,
|
2016-07-26 08:00:02 +00:00
|
|
|
};
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
state = {description: (null: ?string)};
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2015-02-20 04:10:52 +00:00
|
|
|
var description;
|
|
|
|
if (this.props.description) {
|
|
|
|
description =
|
|
|
|
<Text style={styles.descriptionText}>
|
|
|
|
{this.props.description}
|
|
|
|
</Text>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<View style={styles.titleContainer}>
|
|
|
|
<Text style={styles.titleText}>
|
|
|
|
{this.props.title}
|
|
|
|
</Text>
|
|
|
|
{description}
|
|
|
|
</View>
|
|
|
|
<View style={styles.children}>
|
2016-07-26 08:00:02 +00:00
|
|
|
{
|
|
|
|
// $FlowFixMe found when converting React.createClass to ES6
|
|
|
|
this.props.children}
|
2015-02-20 04:10:52 +00:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
borderRadius: 3,
|
|
|
|
borderWidth: 0.5,
|
|
|
|
borderColor: '#d6d7da',
|
|
|
|
backgroundColor: '#ffffff',
|
|
|
|
margin: 10,
|
|
|
|
marginVertical: 5,
|
|
|
|
overflow: 'hidden',
|
|
|
|
},
|
|
|
|
titleContainer: {
|
2015-05-13 15:22:21 +00:00
|
|
|
borderBottomWidth: 0.5,
|
|
|
|
borderTopLeftRadius: 3,
|
|
|
|
borderTopRightRadius: 2.5,
|
|
|
|
borderBottomColor: '#d6d7da',
|
2015-02-20 04:10:52 +00:00
|
|
|
backgroundColor: '#f6f7f8',
|
|
|
|
paddingHorizontal: 10,
|
|
|
|
paddingVertical: 5,
|
|
|
|
},
|
|
|
|
titleText: {
|
|
|
|
fontSize: 14,
|
2015-03-25 23:22:59 +00:00
|
|
|
fontWeight: '500',
|
2015-02-20 04:10:52 +00:00
|
|
|
},
|
|
|
|
descriptionText: {
|
|
|
|
fontSize: 14,
|
|
|
|
},
|
|
|
|
disclosure: {
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
right: 0,
|
|
|
|
padding: 10,
|
|
|
|
},
|
|
|
|
disclosureIcon: {
|
|
|
|
width: 12,
|
|
|
|
height: 8,
|
|
|
|
},
|
|
|
|
children: {
|
2015-05-28 16:29:27 +00:00
|
|
|
margin: 10,
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
module.exports = RNTesterBlock;
|