npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

amen-dialogbox

v0.6.10

Published

dialog popup for react-native

Downloads

39

Readme

npm version npm downloads Dependencies React-Native platforms

react-native-dialogbox

Greenkeeper badge

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

This is a forked distro of react-native-popup that adds support for the current versions of react-native, and adds additional features (style overrides, promise support). The originating distro can be found here

Demo

ui

NPM

Props

  • isOverlay bool - default true
  • isOverlayClickClose bool - default true
  • onDismiss function() - optional callback called when overlay dismisses dialogbox
  • style object - optional override for system styles

Methods

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

		this.dialogbox.alert(1);

		this.dialogbox.alert(1, 'two', '10 messages at most');

		this.dialogbox.alert('promise example').then(() => this.dialogbox.alert('dismissed'));
  • tip({ title: string, content: string|number|array<string|number> isRequired, btn: {title: string default 'OK', style: object, callback: function}, }) : Promise
	e.g.

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

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

		this.dialogbox.tip({
			content: ['come on!', 'go!'],
			btn: {
				text: 'OKOK',
				callback: () => {
					this.dialogbox.alert('over!');
				},
			},
		});

		this.dialogbox.tip({
			content: 'promise example',
			btn: {
				text: 'done'
			}
		}).then(() => (this.dialogbox.alert('done')));

		this.dialogbox.tip({
			content: 'style example',
			style: {
				color: 'red';
			}
		});
  • confirm({ title: string, content: string|number|array<string|number> isRequired, buttonFlow: 'auto' | 'row' | 'column' default 'auto', ok: {title: string default 'OK', style: object, callback: function}, cancel: {title: string default 'Cancel', style: object, callback: function}, }) : Promise
	e.g.

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

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

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

		this.dialogbox.confirm({
			title: 'title',
			content: ['come on!', 'go!'],
			ok: {
				text: 'Y',
				style: {
					color: 'red'
				}
			},
			cancel: {
				text: 'N',
				style: {
					color: 'blue'
				}
			},
		}).then((event) => {
			if (event.button) {
				this.dialogbox.alert(`You selected ${event.button.text}`);
			} else {
				this.dialogbox.alert('Dialog cancelled');
			}
		});
  • pop({ title: string, content: string|number|array<string|number> isRequired, buttonFlow: 'auto' | 'row' | 'column' default 'auto', btns: [{title: string default 'OK', style: object, callback: function}] }) : Promise
	e.g.

		this.dialogbox.pop({
			title: 'Animals',
			content: 'Which animal do you like?',
			btns: [
				{
					text: 'Frog',
					callback: () => {
						this.dialogbox.alert('Ribbit!');
					},
				},
				{
					text: 'Dog',
					callback: () => {
						this.dialogbox.alert('Woof!');
					},
				},
				{
					text: 'Cat',
					callback: () => {
						this.dialogbox.alert('Meow!');
					},
				}
			]
		});

		this.dialogbox.pop({
			title: 'Animals',
			content: 'Which animal do you like?',
			btns: [
				{
					text: 'Frog'
				},
				{
					text: 'Dog'
				},
				{
					text: 'Cat'
				}
			]
		}).then(event => {
			if (event.button) {
				this.dialogbox.alert([
					`You selected ${event.button.text}`, 
					`It was button index ${event.index}`
				]);
			} else {
				this.dialogbox.alert([
					'Dialog was dismissed without selection', 
					'Index for this event is always -1'
				]);
			}
		});

		this.dialogbox.pop({
			title: 'Animals with Stacked Buttons',
			content: 'Which animal do you like?',
			buttonFlow: 'column',
			btns: [
				{
					text: 'Frog'
				},
				{
					text: 'Dog'
				},
				{
					text: 'Cat'
				}
			]
		}).then(event => {
			if (event.button) {
				this.dialogbox.alert([
					`You selected ${event.button.text}`, 
					`It was button index ${event.index}`
				]);
			} else {
				this.dialogbox.alert([
					'Dialog was dismissed without selection', 
					'Index for this event is always -1'
				]);
			}
		});

Usage

Step 1 - install

	npm install react-native-dialogbox --save

Step 2 - import and use in project

import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import DialogBox from 'react-native-dialogbox';

export default class App extends Component {

	handleOnPress = () => {
		// alert
		this.dialogbox.alert(1);
	},

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

				<Text style={styles.btn} onPress={this.handleOnPress}>click me !</Text>

				{/** dialogbox component */}
				<DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>

			</View>
		);
	},

};