1.0.0 • Published 6 years ago

react-native-popup-dialog-hendra v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Build Status npm npm

React Native Popup Dialog

React Native Popup Dialog for iOS & Android.

Another similar dialog component: react-native-dialog-component the main difference is style.

Pull request are welcomed. Please follow Airbnb JS Style Guide

How to thank me ?

Just click on ⭐️ button 😘

Try it with Exponent

           

Installation

npm install --save react-native-popup-dialog
# OR
yarn add react-native-popup-dialog

Exposed Modules

  • Dialog
  • PopupDialog
  • DialogButton
  • DialogTitle
  • Overlay
  • Animation
  • FadeAnimation
  • ScaleAnimation
  • SlideAnimation
  • PopupDialogType
  • DialogType
  • DialogButtonType
  • DialogTitleType
  • OverlayType

Examples

Example

Usage

import PopupDialog from 'react-native-popup-dialog';
import { Button } from 'react-native'

<View style={styles.container}>
  <Button
    title="Show Dialog"
    onPress={() => {
      this.popupDialog.show();
    }}
  />
  <PopupDialog
    ref={(popupDialog) => { this.popupDialog = popupDialog; }}
  >
    <View>
      <Text>Hello</Text>
    </View>
  </PopupDialog>
</View>

Usage - With Animation

import PopupDialog, { SlideAnimation } from 'react-native-popup-dialog';

const slideAnimation = new SlideAnimation({
  slideFrom: 'bottom',
});

<View style={styles.container}>
  <PopupDialog
    ref={(popupDialog) => { this.popupDialog = popupDialog; }}
    dialogAnimation={slideAnimation}
  >
    <View>
      <Text>Hello</Text>
    </View>
  </PopupDialog>
</View>

Usage - With Dialog Dialog Title

import PopupDialog, { DialogTitle } from 'react-native-popup-dialog';

<View style={styles.container}>
  <PopupDialog
    dialogTitle={<DialogTitle title="Dialog Title" />}
    ref={(popupDialog) => { this.popupDialog = popupDialog; }}
  >
    <View>
      <Text>Hello</Text>
    </View>
  </PopupDialog>
</View>

Methods

show

this.popupDialog.show(() => {
  console.log('callback - will be called immediately')
});

dismiss

this.popupDialog.dismiss(() => {
  console.log('callback - will be called immediately')
});

Props

PopupDialog

PropTypeDefaultNote
dialogTitle?React ElementYou can pass a DialogTitle component or pass a View for customizing titlebar
width?NumberYour device widthThe Width of Dialog, you can use fixed width or use percentage. For example 0.5 it means 50%
height?Number300The Height of Dialog, you can use fixed height or use percentage. For example 0.5 it means 50%
dialogAnimation?FadeAnimationanimation for dialog
dialogStyle?any
containerStyle?anynullFor example: { zIndex: 10, elevation: 10 }
animationDuration?Number200
overlayPointerEvents?StringAvailable option: auto, none
overlayBackgroundColor?String#000
overlayOpacity?Number0.5
dismissOnTouchOutside?BooltrueWhen touch overlay will dismiss dialog, but if haveOverlay? is false then the dismissOnTouchOutside won't work
dismissOnHardwareBackPress?BooltrueOnly for Android
haveOverlay?BooltrueIf false won't show overlay while dialog show
show?Boolfalse
onShown?FunctionYou can pass shown function as a callback function, will call the function when dialog shown
onDismissed?FunctionYou can pass onDismissed function as a callback function, will call the function when dialog dismissed
actions?ArrayArray of DialogButton component for example: [<DialogButton text="DISMISS" align="center" onPress={() => this.popupDialog.dismiss()}/>]

DialogTitle

PropTypeDefaultNote
titleString
titleStyle?any
titleTextStyle?any
titleAlign?StringcenterAvailable option: left, center, right
haveTitleBar?Booltrue

DialogButton

PropTypeDefaultNote
textString
align?StringcenterThe position of the button. Available option: left, center, right
onPress?Function
buttonStyle?any
textStyle?any
textContainerStyle?any
disabled?Booleanfalse
activeOpacity?Number

Animation

Params for (*)Animation

FadeAnimation

Example:
new FadeAnimation({
  toValue: 0, // optional
  animationDuration: 150, // optional
  useNativeDriver: true, // optional
})
ParamTypeDefaultNote
toValueNumber0
animationDuration?Number150
useNativeDriver?Booleantrue

ScaleAnimation

Example:
new ScaleAnimation({
  toValue: 0, // optional
  useNativeDriver: true, // optional
})
ParamTypeDefaultNote
toValueNumber0
useNativeDriverBooleantrue

SlideAnimation

Example:
new SlideAnimation({
  toValue: 0, // optional
  slideFrom: 'bottom', // optional
  useNativeDriver: true, // optional
})
ParamTypeDefaultNote
toValueNumber0
slideFromStringbottomAvailable option: top, bottom, left, right
useNativeDriverBooleantrue

Development

yarn

yarn run build