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 22:07:33 +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';
|
|
|
|
|
2017-04-12 23:09:48 +00:00
|
|
|
var PropTypes = require('prop-types');
|
2017-06-21 19:23:58 +00:00
|
|
|
var React = require('react');
|
2016-04-08 04:13:12 +00:00
|
|
|
var ReactNative = require('react-native');
|
2018-05-11 20:32:37 +00:00
|
|
|
var {ScrollView, StyleSheet, View} = ReactNative;
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
var RNTesterTitle = require('./RNTesterTitle');
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class RNTesterPage extends React.Component<{
|
|
|
|
noScroll?: boolean,
|
|
|
|
noSpacer?: boolean,
|
|
|
|
}> {
|
2016-07-26 08:00:02 +00:00
|
|
|
static propTypes = {
|
2017-04-12 23:09:48 +00:00
|
|
|
noScroll: PropTypes.bool,
|
|
|
|
noSpacer: PropTypes.bool,
|
2016-07-26 08:00:02 +00:00
|
|
|
};
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2016-07-26 08:00:02 +00:00
|
|
|
render() {
|
2015-01-30 01:10:49 +00:00
|
|
|
var ContentWrapper;
|
|
|
|
var wrapperProps = {};
|
|
|
|
if (this.props.noScroll) {
|
2017-08-18 01:36:54 +00:00
|
|
|
ContentWrapper = ((View: any): React.ComponentType<any>);
|
2015-01-30 01:10:49 +00:00
|
|
|
} else {
|
2017-08-18 01:36:54 +00:00
|
|
|
ContentWrapper = (ScrollView: React.ComponentType<any>);
|
2016-07-26 08:00:02 +00:00
|
|
|
// $FlowFixMe found when converting React.createClass to ES6
|
2015-07-03 09:03:08 +00:00
|
|
|
wrapperProps.automaticallyAdjustContentInsets = !this.props.title;
|
2016-12-08 05:39:54 +00:00
|
|
|
wrapperProps.keyboardShouldPersistTaps = 'handled';
|
2015-03-04 16:05:38 +00:00
|
|
|
wrapperProps.keyboardDismissMode = 'interactive';
|
2015-01-30 01:10:49 +00:00
|
|
|
}
|
2018-03-20 01:24:11 +00:00
|
|
|
/* $FlowFixMe(>=0.68.0 site=react_native_fb) This comment suppresses an
|
|
|
|
* error found when Flow v0.68 was deployed. To see the error delete this
|
|
|
|
* comment and run Flow. */
|
2018-05-11 20:32:37 +00:00
|
|
|
var title = this.props.title ? (
|
|
|
|
<RNTesterTitle title={this.props.title} />
|
|
|
|
) : null;
|
2015-01-30 01:10:49 +00:00
|
|
|
var spacer = this.props.noSpacer ? null : <View style={styles.spacer} />;
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
{title}
|
2018-05-11 20:32:37 +00:00
|
|
|
<ContentWrapper style={styles.wrapper} {...wrapperProps}>
|
|
|
|
{
|
|
|
|
// $FlowFixMe found when converting React.createClass to ES6
|
|
|
|
this.props.children
|
|
|
|
}
|
|
|
|
{spacer}
|
2015-01-30 01:10:49 +00:00
|
|
|
</ContentWrapper>
|
|
|
|
</View>
|
|
|
|
);
|
2016-07-26 08:00:02 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
backgroundColor: '#e9eaed',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
spacer: {
|
|
|
|
height: 270,
|
|
|
|
},
|
|
|
|
wrapper: {
|
|
|
|
flex: 1,
|
2015-07-03 09:03:08 +00:00
|
|
|
paddingTop: 10,
|
2015-01-30 01:10:49 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-05-06 03:50:47 +00:00
|
|
|
module.exports = RNTesterPage;
|