2017-05-06 03:50:47 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-05-06 03:50:47 +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.
|
2017-05-06 03:50:47 +00:00
|
|
|
*
|
2018-05-11 20:32:37 +00:00
|
|
|
* @format
|
2017-05-06 03:50:47 +00:00
|
|
|
*/
|
2018-05-11 20:32:37 +00:00
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const React = require('react');
|
2018-05-11 20:32:37 +00:00
|
|
|
const {Platform} = require('react-native');
|
2017-05-06 03:50:47 +00:00
|
|
|
const RNTesterBlock = require('./RNTesterBlock');
|
|
|
|
const RNTesterPage = require('./RNTesterPage');
|
|
|
|
|
|
|
|
class RNTesterExampleContainer extends React.Component {
|
|
|
|
renderExample(example, i) {
|
|
|
|
// Filter platform-specific examples
|
|
|
|
var {title, description, platform} = example;
|
|
|
|
if (platform) {
|
|
|
|
if (Platform.OS !== platform) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
title += ' (' + platform + ' only)';
|
|
|
|
}
|
|
|
|
return (
|
2018-05-11 20:32:37 +00:00
|
|
|
<RNTesterBlock key={i} title={title} description={description}>
|
2017-05-06 03:50:47 +00:00
|
|
|
{example.render()}
|
|
|
|
</RNTesterBlock>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render(): React.Element<any> {
|
|
|
|
if (!this.props.module.examples) {
|
|
|
|
return <this.props.module />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<RNTesterPage title={this.props.title}>
|
|
|
|
{this.props.module.examples.map(this.renderExample)}
|
|
|
|
</RNTesterPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = RNTesterExampleContainer;
|