2016-02-20 00:55:07 +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
|
2016-02-20 00:55:07 +00:00
|
|
|
* @flow
|
|
|
|
*/
|
2018-05-11 20:32:37 +00:00
|
|
|
|
2016-02-20 00:55:07 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-09 03:36:40 +00:00
|
|
|
const React = require('react');
|
|
|
|
const ReactNative = require('react-native');
|
2018-05-11 20:32:37 +00:00
|
|
|
const {StyleSheet, Text, TouchableHighlight, View} = ReactNative;
|
2016-02-20 00:55:07 +00:00
|
|
|
|
2018-05-11 20:32:37 +00:00
|
|
|
class RootViewSizeFlexibilityExampleApp extends React.Component<
|
|
|
|
{toggled: boolean},
|
|
|
|
any,
|
|
|
|
> {
|
2016-02-20 00:55:07 +00:00
|
|
|
constructor(props: {toggled: boolean}) {
|
|
|
|
super(props);
|
2018-05-11 20:32:37 +00:00
|
|
|
this.state = {toggled: false};
|
2016-02-20 00:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onPressButton() {
|
2018-05-11 20:32:37 +00:00
|
|
|
this.setState({toggled: !this.state.toggled});
|
2016-02-20 00:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-05-11 20:32:37 +00:00
|
|
|
const viewStyle = this.state.toggled
|
|
|
|
? styles.bigContainer
|
|
|
|
: styles.smallContainer;
|
2016-02-20 00:55:07 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<TouchableHighlight onPress={this._onPressButton.bind(this)}>
|
|
|
|
<View style={viewStyle}>
|
|
|
|
<View style={styles.center}>
|
2018-05-11 20:32:37 +00:00
|
|
|
<Text style={styles.whiteText}>React Native Button</Text>
|
2016-02-20 00:55:07 +00:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</TouchableHighlight>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
bigContainer: {
|
|
|
|
flex: 1,
|
|
|
|
height: 60,
|
|
|
|
backgroundColor: 'gray',
|
|
|
|
},
|
|
|
|
smallContainer: {
|
|
|
|
flex: 1,
|
|
|
|
height: 40,
|
|
|
|
backgroundColor: 'gray',
|
|
|
|
},
|
|
|
|
center: {
|
|
|
|
flex: 1,
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
},
|
|
|
|
whiteText: {
|
|
|
|
color: 'white',
|
2018-05-11 20:32:37 +00:00
|
|
|
},
|
2016-02-20 00:55:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = RootViewSizeFlexibilityExampleApp;
|