Giter Site home page Giter Site logo

powerdesigninc / react-native-actionsheet Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2.15 MB

help you to using ActionSheet cross platform iOS(ActionSheetIOS) and Android(BottomSheetDialog)

License: MIT License

Kotlin 26.36% Java 21.26% JavaScript 5.14% TypeScript 11.94% Starlark 2.05% Objective-C 15.02% Ruby 18.23%

react-native-actionsheet's Introduction

React Native ActionSheet

npm version

Inspired by talut/rn-actionsheet-module.

This package will help you to using ActionSheet cross platform iOS(ActionSheetIOS) and Android(BottomSheetDialog).

Use the same way as ActionSheetIOS, simply just change ActionSheetIOS to ActionSheet.

Screenshots

Android iOS


Installation

# with npm
npm install @powerdesigninc/react-native-actionsheet
# with yarn
yarn add @powerdesigninc/react-native-actionsheet

React Native >= v0.60

you don't need to link anything. Native Modules are now Autolinked

React Native < v0.60, Manual linking

react-native link @powerdesigninc/react-native-actionsheet

Example

import ActionSheet from "@powerdesigninc/react-native-actionsheet"

const App = () => {
  return (
    <View style={styles.container}>
      <TouchableOpacity
        style={styles.button}
        onPress={() => {
          ActionSheet.showActionSheetWithOptions(
            {
              title: 'Title',
              message: 'message',
              options: ['Cancel', 'From Gallery', 'From Camera'],
              destructiveButtonIndex: 1,
              cancelButtonIndex: 0,
            },
            index => {
              switch (index) {
                case 1: 
                  Alert.alert('From Camera clicked');
                  break;
                case 2: 
                  Alert.alert('From Camera clicked');
                  break;
                case 0: 
                  Alert.alert('onCancel');
                  break;
                default: 
                  Alert.alert('Default');
                  break;
              }
            },
          );
        }}>
        <Text>Show ActionSheet</Text>
      </TouchableOpacity>
    </View>
  );
};

Options

// same as ActionSheetIOSOptions
interface ActionSheetOptions {
  title?: string;
  options: string[];
  cancelButtonIndex?: number;
  destructiveButtonIndex?: number;
  message?: string;
  anchor?: number;
  tintColor?: string;
  hideCancelButton?: boolean; // if you don't want to show cancel on Android, but no effect on iOS
}

Run Example Project

cd example
yarn install

yarn ios
yarn android

License

This project is licensed under the MIT License - see the LICENSE.md file for details

react-native-actionsheet's People

Contributors

weironghuang31 avatar

Stargazers

 avatar

Watchers

James Cloos 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.