Git Product home page Git Product logo

react-native-popup's Introduction

react-native-popup

npm version

This is a custom component for React Native, a simple popup, compatible with ios and android.

###Demo ui

###Props

  • isOverlay bool - default true
  • isOverlayClickClose bool - default true

###static Methods

  • alert(message: string|number, [...])
	e.g.

		this.popup.alert(1);

		this.popup.alert(1, 'two', '10 messages at most');
  • tip({ title: string, content: string|number|array<string|number> isRequired, btn: {title: string default 'OK', callback: function}, })
	e.g.

		this.popup.tip({
			content: 'come on!',
		});

		this.popup.tip({
			title: 'TipTip',
			content: 'come on!',
		});

		this.popup.tip({
			content: ['come on!', 'go!'],
			btn: {
				text: 'OKOK',
				style: {
					color: 'red'
				},
				callback: () => {
					this.popup.alert('over!');
				},
			},
		});
  • confirm({ title: string, content: string|number|array<string|number> isRequired, ok: {title: string default 'OK', callback: function}, cancel: {title: string default 'Cancel', callback: function}, })
	e.g.

		this.popup.confirm({
			content: 'Are you ready?',
		});

		this.popup.confirm({
			content: 'Are you ready?',
			ok: {
				callback: () => {
					this.popup.alert('Very good!');
				},
			},
		});

		this.popup.confirm({
			title: 'title',
			content: ['come on!', 'go!'],
			ok: {
				text: 'Y',
				style: {
					color: 'red'
				},
				callback: () => {
					this.popup.alert('Good!');
				},
			},
			cancel: {
				text: 'N',
				style: {
					color: 'blue'
				},
				callback: () => {
					this.popup.alert('Hurry up!');
				},
			},
		});

###Usage ####Step 1 - install

	npm install react-native-popup --save

####Step 2 - import and use in project

import Popup from 'react-native-popup';

class App extends React.Component{

	onPressHandle() {
		// alert
		this.popup.alert(1);
	},

	render() {
		return (
			<View style={styles.container}>

				<Text style={styles.btn} onPress={this.onPressHandle.bind(this)}>click me !</Text>

				{/** Popup component */}
				<Popup ref={popup => this.popup = popup }/>
				{/** or <Popup ref={popup => this.popup = popup } isOverlay={false} isOverlayClickClose={false}/> */}

			</View>
		);
	},
	
};

react-native-popup's People

Contributors

chunyanzhu avatar lhioui avatar lwhiteley avatar maitreyabuddha avatar skyren avatar xwenliang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.