/** * Copyright (c) 2013-present, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * The examples provided by Facebook are for non-commercial testing and * evaluation purposes only. * * Facebook reserves all rights not expressly granted. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * @flow * @providesModule ModalExample */ 'use strict'; var React = require('react'); var ReactNative = require('react-native'); var { Modal, Picker, StyleSheet, Switch, Text, TouchableHighlight, View, } = ReactNative; const Item = Picker.Item; exports.displayName = (undefined: ?string); exports.framework = 'React'; exports.title = ''; exports.description = 'Component for presenting modal views.'; class Button extends React.Component { state = { active: false, }; _onHighlight = () => { this.setState({active: true}); }; _onUnhighlight = () => { this.setState({active: false}); }; render() { var colorStyle = { color: this.state.active ? '#fff' : '#000', }; return ( {this.props.children} ); } } const supportedOrientationsPickerValues = [ ['portrait'], ['landscape'], ['landscape-left'], ['portrait', 'landscape-right'], ['portrait', 'landscape'], [], ]; class ModalExample extends React.Component { state = { animationType: 'none', modalVisible: false, transparent: false, selectedSupportedOrientation: 0, currentOrientation: 'unknown', }; _setModalVisible = (visible) => { this.setState({modalVisible: visible}); }; _setAnimationType = (type) => { this.setState({animationType: type}); }; _toggleTransparent = () => { this.setState({transparent: !this.state.transparent}); }; render() { var modalBackgroundStyle = { backgroundColor: this.state.transparent ? 'rgba(0, 0, 0, 0.5)' : '#f5fcff', }; var innerContainerTransparentStyle = this.state.transparent ? {backgroundColor: '#fff', padding: 20} : null; var activeButtonStyle = { backgroundColor: '#ddd' }; return ( this._setModalVisible(false)} supportedOrientations={supportedOrientationsPickerValues[this.state.selectedSupportedOrientation]} onOrientationChange={evt => this.setState({currentOrientation: evt.nativeEvent.orientation})} > This modal was presented {this.state.animationType === 'none' ? 'without' : 'with'} animation. It is currently displayed in {this.state.currentOrientation} mode. Animation Type Transparent Supported orientations this.setState({selectedSupportedOrientation: i})} itemStyle={styles.pickerItem} > ); } } exports.examples = [ { title: 'Modal Presentation', description: 'Modals can be presented with or without animation', render: () => , }, ]; var styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', padding: 20, }, innerContainer: { borderRadius: 10, alignItems: 'center', }, row: { alignItems: 'center', flex: 1, flexDirection: 'row', marginBottom: 20, }, rowTitle: { flex: 1, fontWeight: 'bold', }, button: { borderRadius: 5, flexGrow: 1, height: 44, alignSelf: 'stretch', justifyContent: 'center', overflow: 'hidden', }, buttonText: { fontSize: 18, margin: 5, textAlign: 'center', }, modalButton: { marginTop: 10, }, pickerItem: { fontSize: 16, }, });