ReactNative弹出Modal对话框

本小妞迷上赌 提交于 2019-11-29 07:51:51
const RootStackWithModal = createStackNavigator(
    {
        Main: {
            screen: RootNavigator,
        },
        ParticipantModal: {
            screen: ParticipantModal,
        },
    },
    {
        mode: 'modal',
        headerMode: 'none',
        cardStyle: {
            backgroundColor: 'rgba(0, 0, 0, 0)',
            opacity: 1
        },
        transitionConfig: () => ({
            containerStyle: {
                backgroundColor: 'rgba(0, 0, 0, 0)'
            }
        })
    }
);
export default AppContainer = createAppContainer(RootStackWithModal);
import {Modal, Text, TouchableHighlight, View, Dimensions} from "react-native";
import React from "react";

export default class ParticipantModal extends React.Component {
    render() {
        return (
            <Modal
                transparent={true}
                onRequestClose={() => {
                    alert("Modal has been closed.");
                }}
            >
                <View style={{
                    height: Dimensions.get('window').height,
                    justifyContent: 'center',
                    alignItems: 'center',
                    backgroundColor: 'rgba(0,0,0,0.5)'
                }}>
                    <View style={{height: 250, width: 300, margin: 20, backgroundColor: 'white'}}>
                        <View style={{
                            flex: 1,
                            justifyContent: 'center',
                            alignItems: 'center',
                            borderWidth: 1,
                            borderColor: '#eee'
                        }}>
                            <Text>Hello World!</Text>
                        </View>
                        <TouchableHighlight
                            onPress={() => {
                                this.props.navigation.goBack()
                            }}
                            style={{height: 50, justifyContent: 'center', alignItems: 'center'}}
                        >
                            <Text>Hide Modal</Text>
                        </TouchableHighlight>
                    </View>
                </View>
            </Modal>);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!