All Projects → ammarahm-ed → React Native Actions Sheet

ammarahm-ed / React Native Actions Sheet

Licence: mit
A Cross Platform(Android & iOS) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Native Actions Sheet

react-spring-bottom-sheet
Accessible ♿️, Delightful ✨, & Fast 🚀
Stars: ✭ 604 (+46.6%)
Mutual labels:  drawer, modal, dialog, bottom-sheet
Customalertviewdialogue
Custom AlertView Dialogue is the world's most advanced alert view library. Custom AlertView Dialogue includes simple message popups, confirmation alerts, selector popups, action sheet bottom menus, and input/feedback contact forms.
Stars: ✭ 100 (-75.73%)
Mutual labels:  action, dialog, modal
React Native Raw Bottom Sheet
Add Your Own Component To Bottom Sheet Whatever You Want (Android and iOS)
Stars: ✭ 771 (+87.14%)
Mutual labels:  picker, modal, bottom-sheet
vue-modal
A customizable, stackable, and lightweight modal component for Vue.
Stars: ✭ 96 (-76.7%)
Mutual labels:  drawer, modal, dialog
HijriDatePicker
Material (Gregorian - Hijri) Date & Time Picker
Stars: ✭ 128 (-68.93%)
Mutual labels:  dialog, picker
react-fusionui
☢️ Nuclear power-up for your UI.
Stars: ✭ 13 (-96.84%)
Mutual labels:  modal, dialog
react-native-wxui
A UI package for React Native
Stars: ✭ 21 (-94.9%)
Mutual labels:  dialog, actionsheet
react-native-navigation-drawer-extension
Drawer API built on top of wix react-native-navigation for iOS and Android (with TypeScript!)
Stars: ✭ 151 (-63.35%)
Mutual labels:  native, drawer
SheetyColors
An action sheet styled color picker for iOS.
Stars: ✭ 101 (-75.49%)
Mutual labels:  picker, actionsheet
ngx-modal
Dynamic modal dialog for Angular
Stars: ✭ 54 (-86.89%)
Mutual labels:  modal, dialog
bootstrap-modal-wrapper
Bootstrap modal factory that supports dynamic modal creations and nested stacked modal features.
Stars: ✭ 18 (-95.63%)
Mutual labels:  modal, dialog
jquery.dialog.js
A lightweight replacement for the browser's default dialog boxes.
Stars: ✭ 17 (-95.87%)
Mutual labels:  modal, dialog
flutter jd address selector
京东地址选择器
Stars: ✭ 26 (-93.69%)
Mutual labels:  dialog, picker
plain-modal
The simple library for customizable modal window.
Stars: ✭ 21 (-94.9%)
Mutual labels:  modal, dialog
svelte-accessible-dialog
An accessible dialog component for Svelte apps
Stars: ✭ 24 (-94.17%)
Mutual labels:  modal, dialog
nativescript-vue-multi-drawer
A NativeScript-Vue component for creating multiple side drawers (4 sides supported)
Stars: ✭ 45 (-89.08%)
Mutual labels:  drawer, bottom-sheet
Cupertino Pane
🎉📱Multi-functional panes and boards for next generation progressive applications
Stars: ✭ 267 (-35.19%)
Mutual labels:  modal, drawer
Vue Modal Dialogs
Promisify dialogs in Vue!
Stars: ✭ 259 (-37.14%)
Mutual labels:  dialog, modal
Md Date Time Picker
An implementation of Material Design Picker components in vanilla CSS, JS, and HTML
Stars: ✭ 272 (-33.98%)
Mutual labels:  dialog, picker
Vodal
A Vue modal with animations.
Stars: ✭ 312 (-24.27%)
Mutual labels:  dialog, modal

react-native-actions-sheet

A highly customizable cross platform ActionSheet for react native.

Screenshots

Features

  1. Cross Platform (iOS and Android)
  2. Native Animations & Performance
  3. Identical Working on Android and iOS
  4. Control ActionSheet with Gestures
  5. Raw ActionSheet - You can Add Anything
  6. Allow ActionSheet to be partially shown when opened
  7. Support TextInputs
  8. Cool bounce effect on open.
  9. Support for Tablets and iPads
  10. Support Horizontal Layout
  11. Support for Nested Scrolling or Scrollable Content.
  12. Virtualization Support

Run Example

To run the example app clone the project
git clone https://github.com/ammarahm-ed/react-native-actions-sheet.git

then run yarn or npm install in the example folder and finally to run the example app:

react-native run-android

Installation Guide

npm install react-native-actions-sheet --save

or if you use yarn:

yarn add react-native-actions-sheet

Usage Example

For complete usage, see the example project.
import ActionSheet from "react-native-actions-sheet";
import React, { createRef } from "react";

const actionSheetRef = createRef();

const App = () => {
  let actionSheet;

  return (
    <View
      style={{
        justifyContent: "center",
        flex: 1,
      }}
    >
      <TouchableOpacity
        onPress={() => {
          actionSheetRef.current?.setModalVisible();
        }}
      >
        <Text>Open ActionSheet</Text>
      </TouchableOpacity>

      <ActionSheet ref={actionSheetRef}>
        <View>
          <Text>YOUR CUSTOM COMPONENT INSIDE THE ACTIONSHEET</Text>
        </View>
      </ActionSheet>
    </View>
  );
};

export default App;

Reference

Props

ref

Assigns a ref to ActionSheet component to use methods.

Type Required
ref Yes

initialOffsetFromBottom

Use if you want to show the ActionSheet Partially on Opening. Requires gestureEnabled=true

Type Required
boolean no

Default:1

extraScroll

Normally when the ActionSheet is fully opened, a small portion from the bottom is hidden by default. Use this prop if you want the ActionSheet to hover over the bottom of screen and not hide a little behind it.

Type Required
number no

Default:0

containerStyle

Any custom styles for the container.

Type Required
Object no

delayActionSheetDraw

Delay draw of ActionSheet on open for android.

Type Required
boolean no

Default: false

delayActionSheetDrawTime

Delay draw of ActionSheet on open for android time.

Type Required
number (ms) no

Default: 50

CustomHeaderComponent

Your custom header component. Using this will hide the default indicator.

Type Required
React.Component no

headerAlwaysVisible

Keep the header always visible even when gestures are disabled.

Type Required
boolean no

Default: false

animated

Animate the opening and closing of ActionSheet.

Type Required
boolean no

Default: true

openAnimationSpeed

Speed of opening animation. Higher means the ActionSheet will open more quickly.

Type Required
number no

Default: 12

closeAnimationDuration

Duration of closing animation.

Type Required
number no

Default: 300

gestureEnabled

Enables gesture control of ActionSheet

Type Required
boolean no

Default: false

closeOnTouchBackdrop

Control closing ActionSheet by touching on backdrop.

Type Required
boolean no

Default: true

bounceOnOpen

Bounces the ActionSheet on open.

Type Required
boolean no

Default: false

bounciness

How much you want the ActionSheet to bounce when it is opened.

Type Required
number no

Default: 8

springOffset

When touch ends and user has not moved farther from the set springOffset, the ActionSheet will return to previous position.

Type Required
number no

Default: 50

elevation

Add elevation to the ActionSheet container.

Type Required
number no

Default: 0

indicatorColor

Color of the gestureEnabled Indicator.

Type Required
string no

Default: "#f0f0f0"

overlayColor

Color of the overlay/backdrop.

Type Required
string no

Default: "black"

defaultOverlayOpacity

Default opacity of the overlay/backdrop.

Type Required
number 0 - 1 no

Default: 0.3

closable

Prevent ActionSheet from closing on gesture or tapping on backdrop. Instead snap it to bottomOffset location

Type Required
boolean no

Default: true

bottomOffset

Snap ActionSheet to this location if closable is set to false. By default it will snap to the location on first open.

Type Required
number no

Default: 0

keyboardShouldPersistTaps

Setting the keyboard persistence of the ScrollView component. Should be one of "never", "always" or "handled"

Type Required
string no

Default: never

statusBarTranslucent

Determine whether the modal should go under the system statusbar.

Type Required
boolean no

Default: true

closeOnPressBack

Will the ActionSheet close on hardwareBackPress event.

Type Required
boolean no

Default: true

hideUnderlay

Hide the top underlay when ActionSheet is fullscreen.

Type Required
boolean no

Default: false

onClose

Event called when the ActionSheet closes.

Type Required
function no

onOpen

An event called when the ActionSheet Opens.

Type Required
function no

Methods

Methods require you to set a ref on ActionSheet Component.

handleChildScrollEnd()

If your component includes any child ScrollView/FlatList you must attach this method to all scroll end callbacks.

<ScrollView
            ref={scrollViewRef}
            nestedScrollEnabled={true}
            onScrollEndDrag={() =>
              actionSheetRef.current?.handleChildScrollEnd()
            }
            onScrollAnimationEnd={() =>
              actionSheetRef.current?.handleChildScrollEnd()
            }
            onMomentumScrollEnd={() =>
              actionSheetRef.current?.handleChildScrollEnd()
            }
.....


show()

Opens the ActionSheet.

import ActionSheet from "react-native-actions-sheet";
import React, { createRef } from "react";

const actionSheetRef = createRef();

// First create a ref on your <ActionSheet/> Component.
<ActionSheet ref={actionSheetRef} />;

// then later in your function to open the ActionSheet:

actionSheetRef.current?.show();

hide()

Closes the ActionSheet.

import ActionSheet from "react-native-actions-sheet";
import React, { createRef } from "react";

const actionSheetRef = createRef();

// First create a ref on your <ActionSheet/> Component.
<ActionSheet ref={actionSheetRef} />;

// then later in your function to open the ActionSheet:

actionSheetRef.current?.hide();

setModalVisible

ActionSheet can be opened or closed using its ref.

import ActionSheet from "react-native-actions-sheet";
import React, { createRef } from "react";

const actionSheetRef = createRef();

// First create a ref on your <ActionSheet/> Component.
<ActionSheet ref={actionSheetRef} />;

// then later in your function to open the ActionSheet:

actionSheetRef.current?.setModalVisible();

setModalVisible(visible)

It's also possible to explicitly either show or hide modal.

import ActionSheet from "react-native-actions-sheet";
import React, { createRef } from "react";

const actionSheetRef = createRef();
// First create a ref on your <ActionSheet/> Component.
<ActionSheet ref={actionSheetRef} />;

// then to show modal use
actionSheetRef.current?.setModalVisible(true);

// and later you may want to hide it using
actionSheetRef.current?.setModalVisible(false);

snapToOffset(offset:number)

When the ActionSheet is open, you can progammatically snap it to different offsets.

import ActionSheet from "react-native-actions-sheet";
import React, { createRef } from "react";

const actionSheetRef = createRef();
// First create a ref on your <ActionSheet/> Component.
<ActionSheet ref={actionSheetRef} />;

// snap to this location on screen
actionSheetRef.current?.snapToOffset(200);

actionSheetRef.current?.snapToOffset(150);

actionSheetRef.current?.snapToOffset(300);

Event Listeners

Listen to changes in ActionSheet State.

addHasReachedTopListener(callback)

Attach a listener to know when ActionSheet is fully opened and has reached top. Use this if you want to use a ScrollView inside the ActionSheet. Check the example for demonstration on how to use nested ScrollViews inside ActionSheet.

import ActionSheet, {
  addHasReachedTopListener,
  removeHasReachedTopListener,
} from "react-native-actions-sheet";

const App = () => {
  const scrollViewRef = useRef();
  const actionSheetRef = useRef();

  const onHasReachedTop = (hasReachedTop) => {
    if (hasReachedTop)
      scrollViewRef.current?.setNativeProps({
        scrollEnabled: hasReachedTop,
      });
  };

  useEffect(() => {
    addHasReachedTopListener(onHasReachedTop);
    return () => {
      removeHasReachedTopListener(onHasReachedTop);
    };
  }, []);

  const onClose = () => {
    scrollViewRef.current?.setNativeProps({
      scrollEnabled: false,
    });
  };

  return (
    <ActionSheet ref={actionSheetRef}>
      <ScrollView
        ref={scrollViewRef}
        nestedScrollEnabled={true}
        onScrollEndDrag={() => actionSheetRef.current?.handleChildScrollEnd()}
        onScrollAnimationEnd={() =>
          actionSheetRef.current?.handleChildScrollEnd()
        }
        onMomentumScrollEnd={() =>
          actionSheetRef.current?.handleChildScrollEnd()
        }
      />
    </ActionSheet>
  );
};

Find this library useful? ❤️

Support it by donating or joining stargazers for this repository. ⭐️ and follow me for my next creations!

MIT Licensed

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].