2015-01-29 17:10:49 -08:00
|
|
|
/**
|
2017-05-05 20:50:47 -07:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
2016-07-12 05:51:57 -07:00
|
|
|
*
|
2018-02-16 18:24:55 -08: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 05:51:57 -07:00
|
|
|
*
|
2017-05-05 20:50:47 -07:00
|
|
|
* @providesModule RNTesterPage
|
2015-03-23 15:07:33 -07:00
|
|
|
* @flow
|
2015-01-29 17:10:49 -08:00
|
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
|
2017-04-12 16:09:48 -07:00
|
|
|
var PropTypes = require('prop-types');
|
2017-06-21 12:23:58 -07:00
|
|
|
var React = require('react');
|
2016-04-07 21:13:12 -07:00
|
|
|
var ReactNative = require('react-native');
|
2015-01-29 17:10:49 -08:00
|
|
|
var {
|
|
|
|
ScrollView,
|
|
|
|
StyleSheet,
|
|
|
|
View,
|
2016-04-07 21:13:12 -07:00
|
|
|
} = ReactNative;
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2017-05-05 20:50:47 -07:00
|
|
|
var RNTesterTitle = require('./RNTesterTitle');
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2017-08-17 18:36:54 -07:00
|
|
|
class RNTesterPage extends React.Component<{
|
|
|
|
noScroll?: boolean,
|
|
|
|
noSpacer?: boolean,
|
|
|
|
}> {
|
2016-07-26 01:00:02 -07:00
|
|
|
static propTypes = {
|
2017-04-12 16:09:48 -07:00
|
|
|
noScroll: PropTypes.bool,
|
|
|
|
noSpacer: PropTypes.bool,
|
2016-07-26 01:00:02 -07:00
|
|
|
};
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2016-07-26 01:00:02 -07:00
|
|
|
render() {
|
2015-01-29 17:10:49 -08:00
|
|
|
var ContentWrapper;
|
|
|
|
var wrapperProps = {};
|
|
|
|
if (this.props.noScroll) {
|
2017-08-17 18:36:54 -07:00
|
|
|
ContentWrapper = ((View: any): React.ComponentType<any>);
|
2015-01-29 17:10:49 -08:00
|
|
|
} else {
|
2017-08-17 18:36:54 -07:00
|
|
|
ContentWrapper = (ScrollView: React.ComponentType<any>);
|
2016-07-26 01:00:02 -07:00
|
|
|
// $FlowFixMe found when converting React.createClass to ES6
|
2015-07-03 02:03:08 -07:00
|
|
|
wrapperProps.automaticallyAdjustContentInsets = !this.props.title;
|
2016-12-07 21:39:54 -08:00
|
|
|
wrapperProps.keyboardShouldPersistTaps = 'handled';
|
2015-03-04 08:05:38 -08:00
|
|
|
wrapperProps.keyboardDismissMode = 'interactive';
|
2015-01-29 17:10:49 -08:00
|
|
|
}
|
2018-03-19 18:24:11 -07: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. */
|
2015-01-29 17:10:49 -08:00
|
|
|
var title = this.props.title ?
|
2017-05-05 20:50:47 -07:00
|
|
|
<RNTesterTitle title={this.props.title} /> :
|
2015-01-29 17:10:49 -08:00
|
|
|
null;
|
|
|
|
var spacer = this.props.noSpacer ? null : <View style={styles.spacer} />;
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
{title}
|
|
|
|
<ContentWrapper
|
|
|
|
style={styles.wrapper}
|
|
|
|
{...wrapperProps}>
|
2016-07-26 01:00:02 -07:00
|
|
|
{
|
|
|
|
// $FlowFixMe found when converting React.createClass to ES6
|
|
|
|
this.props.children}
|
2015-01-29 17:10:49 -08:00
|
|
|
{spacer}
|
|
|
|
</ContentWrapper>
|
|
|
|
</View>
|
|
|
|
);
|
2016-07-26 01:00:02 -07:00
|
|
|
}
|
|
|
|
}
|
2015-01-29 17:10:49 -08:00
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
backgroundColor: '#e9eaed',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
spacer: {
|
|
|
|
height: 270,
|
|
|
|
},
|
|
|
|
wrapper: {
|
|
|
|
flex: 1,
|
2015-07-03 02:03:08 -07:00
|
|
|
paddingTop: 10,
|
2015-01-29 17:10:49 -08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-05-05 20:50:47 -07:00
|
|
|
module.exports = RNTesterPage;
|