0.0.1 ā€¢ Published 7 years ago

react-native-global-modal v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

react-native-global-modal

Single instance Modal in Global scope

Build Status npm version license

Usage

import {Global} from "react-native-global-modal";

export class SomeRootView extends React.Component<Props, State> {
    render() {
        return (
            <!-- ... some else component -->
            <GlobalModal />
            <!-- ... some else component -->
        );
    }
}

API

GlobalModal.open(renderFunction)
GlobalModal.close()

Render Example

() => (
    <View style={styles.modalContainer}>
        <Text style={styles.modalText}>Modal 2</Text>
        <TouchableOpacity style={styles.closeButton} onPress={GlobalModal.close}>
            <Text style={styles.modalText}>āœ•</Text>
        </TouchableOpacity>
    </View>
)
...

const styles = {
    modalContainer: {
        width: 250,
        height: 200,
        justifyContent: "center",
        alignItems: "center",
        backgroundColor: "grey",
        borderRadius: 10,
    },
    modalText: {
        color: "#EEEEEE",
    },
    closeButton: {
        position: "absolute",
        top: 5,
        right: 7,
    },
}