2015-01-29 17:10:49 -08:00
|
|
|
/**
|
2018-09-11 15:27:47 -07:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
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
|
|
|
*
|
2018-05-11 13:32:37 -07:00
|
|
|
* @format
|
2015-03-23 15:07:33 -07:00
|
|
|
* @flow
|
2015-01-29 17:10:49 -08:00
|
|
|
*/
|
2018-05-11 13:32:37 -07:00
|
|
|
|
2015-01-29 17:10:49 -08:00
|
|
|
'use strict';
|
|
|
|
|
2018-09-25 17:04:38 -07:00
|
|
|
const React = require('react');
|
|
|
|
const {ScrollView, StyleSheet, View} = require('react-native');
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2018-09-25 17:04:38 -07:00
|
|
|
const RNTesterTitle = require('./RNTesterTitle');
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2018-09-25 17:04:38 -07:00
|
|
|
type Props = $ReadOnly<{|
|
|
|
|
children?: React.Node,
|
|
|
|
title?: ?string,
|
|
|
|
noScroll?: ?boolean,
|
|
|
|
noSpacer?: ?boolean,
|
|
|
|
|}>;
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2018-09-25 17:04:38 -07:00
|
|
|
class RNTesterPage extends React.Component<Props> {
|
2016-07-26 01:00:02 -07:00
|
|
|
render() {
|
2018-09-25 17:04:38 -07:00
|
|
|
let ContentWrapper;
|
|
|
|
let wrapperProps = {};
|
2015-01-29 17:10:49 -08:00
|
|
|
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>);
|
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-09-25 17:04:38 -07:00
|
|
|
const title = this.props.title ? (
|
2018-05-11 13:32:37 -07:00
|
|
|
<RNTesterTitle title={this.props.title} />
|
|
|
|
) : null;
|
2018-09-25 17:04:38 -07:00
|
|
|
const spacer = this.props.noSpacer ? null : <View style={styles.spacer} />;
|
2015-01-29 17:10:49 -08:00
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
{title}
|
2018-05-11 13:32:37 -07:00
|
|
|
<ContentWrapper style={styles.wrapper} {...wrapperProps}>
|
2018-09-25 17:04:38 -07:00
|
|
|
{this.props.children}
|
2018-05-11 13:32:37 -07:00
|
|
|
{spacer}
|
2015-01-29 17:10:49 -08:00
|
|
|
</ContentWrapper>
|
|
|
|
</View>
|
|
|
|
);
|
2016-07-26 01:00:02 -07:00
|
|
|
}
|
|
|
|
}
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2018-09-25 17:04:38 -07:00
|
|
|
const styles = StyleSheet.create({
|
2015-01-29 17:10:49 -08:00
|
|
|
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;
|