All Projects → jacklam718 → React Native Modals

jacklam718 / React Native Modals

Licence: mit
A react native modals library. Swipeable. Highly customizable. Support multi modals & Support custom animation. For IOS & Android.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Native Modals

Vue Ydui
A mobile components Library with Vue2.js. 一只基于Vue2.x的移动端组件库。
Stars: ✭ 2,798 (+39%)
Mutual labels:  component, dialog
Ngx Ui
🚀 Style and Component Library for Angular
Stars: ✭ 534 (-73.47%)
Mutual labels:  component, dialog
React Native Dialog Component
A react native dialog component support custom animation for IOS & Android.
Stars: ✭ 81 (-95.98%)
Mutual labels:  component, dialog
Garland View Android
≡ GarlandView seamlessly transitions between multiple lists of content. Made by @Ramotion
Stars: ✭ 1,855 (-7.85%)
Mutual labels:  component
Alertifyjs
A javascript framework for developing pretty browser dialogs and notifications.
Stars: ✭ 1,922 (-4.52%)
Mutual labels:  dialog
Serializer
With the Serializer component it's possible to handle serializing data structures, including object graphs, into array structures or other formats like XML and JSON. It can also handle deserializing XML and JSON back to object graphs.
Stars: ✭ 2,021 (+0.4%)
Mutual labels:  component
Scriptui Dialog Builder Joonas
A web app for designing and building Adobe ScriptUI javascript dialogs (Illustrator, Indesign, Photoshop, After Effects, Bridge). Design your dialog using a graphical interface and export as .jsx
Stars: ✭ 161 (-92%)
Mutual labels:  dialog
React Axios
Axios Components for React with child function callback
Stars: ✭ 153 (-92.4%)
Mutual labels:  component
React Console Emulator
👨‍💻 A simple, powerful and highly customisable Unix terminal emulator for React.
Stars: ✭ 160 (-92.05%)
Mutual labels:  component
React Native Input Spinner
An extensible input number spinner component for react-native highly customizable. This component enhance a text input for entering numeric values, with increase and decrease buttons.
Stars: ✭ 155 (-92.3%)
Mutual labels:  component
Mag.js
MagJS - Modular Application Glue
Stars: ✭ 157 (-92.2%)
Mutual labels:  component
Alerttoast
Create Apple-like alerts & toasts using SwiftUI
Stars: ✭ 151 (-92.5%)
Mutual labels:  dialog
Vue3 Draggable Resizable
[Vue3 组件] 用于拖拽调整位置和大小的的组件,同时支持冲突检测,元素吸附对齐,实时参考线。
Stars: ✭ 159 (-92.1%)
Mutual labels:  component
React Qr Code
A QR code generator for React and React Native.
Stars: ✭ 153 (-92.4%)
Mutual labels:  component
Vue Info Card
Simple and beautiful card component with an elegant spark line, for VueJS.
Stars: ✭ 159 (-92.1%)
Mutual labels:  component
React Native Animated Linear Gradient
Animated linear gradient as background animation or something else.
Stars: ✭ 153 (-92.4%)
Mutual labels:  component
Dcoaboutwindow
👋 A replacement for the standard Mac app About dialog.
Stars: ✭ 159 (-92.1%)
Mutual labels:  component
Polyfill Php73
This component provides functions unavailable in releases prior to PHP 7.3.
Stars: ✭ 2,121 (+5.37%)
Mutual labels:  component
React Render In Browser
React library to render browser specific content
Stars: ✭ 157 (-92.2%)
Mutual labels:  component
Vue Facebook Login
💅 A renderless Vue.js component for composing Facebook Login
Stars: ✭ 158 (-92.15%)
Mutual labels:  component

Build Status npm npm

React Native Modals

React Native Modals Library for iOS & Android.

How to thank me ?

Just click on ⭐️ button 😘

Try it with Exponent



     

BREAKING CHANGE

A lot of backward incompatible changes in v0.22.0. Please, Read the Docs before upgrading to v0.22.0

Installation

npm install --save react-native-modals
# OR
yarn add react-native-modals

Exposed Modules

  • Modal
  • ButtomModal
  • ModalPortal
  • Backdrop
  • ModalButton
  • ModalContent
  • ModalTitle
  • ModalFooter
  • Animation
  • FadeAnimation
  • ScaleAnimation
  • SlideAnimation
  • DragEvent,
  • SwipeDirection,
  • ModalProps
  • ModalFooterProps
  • ModalButtonProps
  • ModalTitleProps
  • ModalContentProps
  • BackdropProps

Examples

Example

Setup - this is essential step

The Component can not be used until ModalPortal is mounted. You should register in your app root. For example:

import { ModalPortal } from 'react-native-modals';
import { Provider } from 'react-redux';

const Root = () => {
  return (
    <Provider store={store}>
      <App />
      <ModalPortal />
    </Provider>
  );
}

Basic Usage

import { Modal, ModalContent } from 'react-native-modals';
import { Button } from 'react-native'

<View style={styles.container}>
  <Button
    title="Show Modal"
    onPress={() => {
      this.setState({ visible: true });
    }}
  />
  <Modal
    visible={this.state.visible}
    onTouchOutside={() => {
      this.setState({ visible: false });
    }}
  >
    <ModalContent>
      {...}
    </ModalContent>
  </Modal>
</View>

Usage - Imperative APIs

show

import { ModalPortal } from 'react-native-modals';

const id = ModalPortal.show((
  <View>
    {...}
  </View>
));

update

ModalPortal.update(id, {
  children: (
    <View>
      <Text>Updated</Text>
    </View>
  ),
});

dismiss

ModalPortal.dismiss(id);

dismissAll

ModalPortal.dismissAll(id);

Usage - Animation

import { Modal, SlideAnimation, ModalContent } from 'react-native-modals';

<View style={styles.container}>
  <Modal
    visible={this.state.visible}
    modalAnimation={new SlideAnimation({
      slideFrom: 'bottom',
    })}
  >
    <ModalContent>
      {...}
    </ModalContent>
  </Modal>
</View>

Usage - Swipe

import { Modal, ModalContent } from 'react-native-modals';
import { Button } from 'react-native'

<View style={styles.container}>
  <Modal
    visible={this.state.visible}
    swipeDirection={['up', 'down']} // can be string or an array
    swipeThreshold={200} // default 100
    onSwipeOut={(event) => {
      this.setState({ visible: false });
    }}
  >
    <ModalContent>
      {...}
    </ModalContent>
  </Modal>
</View>

Usage - Modal Title

import { Modal, ModalTitle, ModalContent } from 'react-native-modals';

<View style={styles.container}>
  <Modal
    visible={this.state.visible}
    modalTitle={<ModalTitle title="Modal Title" />}
  >
    <ModalContent>
      {...}
    </ModalContent>
  </Modal>
</View>

Usage - Modal Action

import { Modal, ModalFooter, ModalButton, ModalContent } from 'react-native-modals';

<View style={styles.container}>
  <Modal
    visible={this.state.visible}
    footer={
      <ModalFooter>
        <ModalButton
          text="CANCEL"
          onPress={() => {}}
        />
        <ModalButton
          text="OK"
          onPress={() => {}}
        />
      </ModalFooter>
    }
  >
    <ModalContent>
      {...}
    </ModalContent>
  </Modal>
</View>

Props

Modal

Prop Type Default Note
visible boolean false
rounded boolean true
useNativeDriver boolean true
children any
modalTitle? React Element You can pass a modalTitle component or pass a View for customizing titlebar
width? Number Your device width The Width of modal, you can use fixed width or use percentage. For example 0.5 it means 50%
height? Number 300 The Height of modal, you can use fixed height or use percentage. For example 0.5 it means 50%
modalAnimation? FadeAnimation animation for modal
modalStyle? any
containerStyle? any null For example: { zIndex: 10, elevation: 10 }
animationDuration? Number 200
overlayPointerEvents? String Available option: auto, none
overlayBackgroundColor? String #000
overlayOpacity? Number 0.5
hasOverlay? Boolean true
onShow? Function You can pass shown function as a callback function, will call the function when modal shown
onDismiss? Function You can pass onDismiss function as a callback function, will call the function when modal dismissed
onTouchOutside? Function () => {}
onHardwareBackPress? Function () => true Handle hardware button presses
onMove? Function () => {}
onSwiping? Function () => {}
onSwipeRelease? Function () => {}
onSwipingOut? Function () => {}
onSwipeOut? Function
swipeDirection? string or Array<string> [] Available option: up, down, left, right
swipeThreshold? number 100
footer? React Element null for example: <View><Button text="DISMISS" align="center" onPress={() => {}}/></View>

ModalTitle

Prop Type Default Note
title String
style? any null
textStyle? any null
align? String center Available option: left, center, right
hasTitleBar? Bool true

ModalContent

Prop Type Default Note
children any
style? any null

ModalFooter

Prop Type Default Note
children ModalButton
bordered? Boolean true
style? any null

ModalButton

Prop Type Default Note
text String
onPress Function
align? String center Available option: left, center, right
style? any null
textStyle? any null
activeOpacity? Number 0.6
disabled? Boolean false
bordered? Boolean false

Backdrop

Prop Type Default Note
visible Boolean
opacity Number 0.5
onPress? Function
backgroundColor? string #000
animationDuration? Number 200
pointerEvents? String null Available option: auto, none
useNativeDriver? Boolean true

Animation

Params for (*)Animation

FadeAnimation

Preview:

Example:
new FadeAnimation({
  initialValue: 0, // optional
  animationDuration: 150, // optional
  useNativeDriver: true, // optional
})
Param Type Default Note
initialValue Number 0
animationDuration? Number 150
useNativeDriver? Boolean true

ScaleAnimation

Preview:

Example:
new ScaleAnimation({
  initialValue: 0, // optional
  useNativeDriver: true, // optional
})
Param Type Default Note
initialValue Number 0
useNativeDriver Boolean true

SlideAnimation

Preview:

Example:
new SlideAnimation({
  initialValue: 0, // optional
  slideFrom: 'bottom', // optional
  useNativeDriver: true, // optional
})
Param Type Default Note
initialValue Number 0
slideFrom String bottom Available option: top, bottom, left, right
useNativeDriver Boolean true

Create your custom animation

Example:
import { Animated } from 'react-native';
import { Animation } from 'react-native-modals';

class CustomAnimation extends Animation {
  in(onFinished) {
    Animated.spring(this.animate, {
      toValue: 1,
      useNativeDriver: this.useNativeDriver,
    }).start(onFinished);
  }

  out(onFinished) {
    Animated.spring(this.animate, {
      toValue: 0,
      useNativeDriver: this.useNativeDriver,
    }).start(onFinished);
  }

  getAnimations() {
    return {
      transform: [{
        translateY: this.animate.interpolate({
          inputRange: [0, 1],
          outputRange: [800, 1],
        }),
      }],
    };
  }
}

Development

yarn

yarn run build

yarn test

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].