GithubHelp home page GithubHelp logo

clip-sub / react-native-bottomsheet Goto Github PK

View Code? Open in Web Editor NEW
92.0 3.0 24.0 136 KB

True Cross-platform ActionSheet for Android and iOS

License: MIT License

Java 99.17% JavaScript 0.83%
react-native android

react-native-bottomsheet's Introduction

react-native-bottomsheet

react-native-bottomsheet is a cross-platform ActionSheet for both Android and iOS. It uses original ActionSheet on iOS and soarcn BottomSheet on Android with some minor fixes, such as title and list item margins.

Update: The library now uses a copy of original lib (source copied) so you can modify it whenever you need to.

bottomsheet

Note: On Android, message property is not available. Instead, there's a dark option to turn on Dark Mode like so:

BottomSheet.showBottomSheetWithOptions({
  options: ['Option 1', 'Option 2', 'Option 3'],
  title: 'Demo Bottom Sheet',
  dark: true,
  cancelButtonIndex: 3,
}, (value) => {
  alert(value);
});

Installation

First, install the npm package:

npm install --save react-native-bottomsheet

Then:

- If you are using React Native 0.60+

You don't have to do anything, since it will be linked automatically for you.

- If you are using React Native 0.59 and below

Then link the native module, since we are using native bottom sheet on Android:

react-native link react-native-bottomsheet

Or you can link it manually in MainApplication.java

import com.clipsub.rnbottomsheet.RNBottomSheetPackage; // Import this

....
@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
       new RNBottomSheetPackage() // Add this
  );
}

Usage

Import the package

import BottomSheet from 'react-native-bottomsheet';

Use it like how you do with ActionSheet.

BottomSheet.showBottomSheetWithOptions(options: Object, callback: Function)
BottomSheet.showShareBottomSheetWithOptions(options: Object, failureCallback: Function, successCallback: Function)

Example:

import BottomSheet from 'react-native-bottomsheet';
...
BottomSheet.showBottomSheetWithOptions({
  options: ['Option 1', 'Option 2', 'Option 3'],
  title: 'Demo Bottom Sheet',
  dark: true,
  cancelButtonIndex: 3,
}, (value) => {
  alert(value);
});
BottomSheet.showShareBottomSheetWithOptions({
  url: 'https://google.com',
  subject: 'Share',
  message: 'Simple share',
}, (value) => {
  alert(value);
}, (resultcode, path) => {
  alert(resultcode);
  alert(path);
})

react-native-bottomsheet's People

Contributors

adamsinnottssg avatar alibsg avatar doko-demo-doa avatar geweald avatar mikehardy avatar plowman avatar saghul avatar svishwakarma101 avatar usrbowe avatar vuongpsht avatar yauhenbichel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-native-bottomsheet's Issues

Is there a 'cancel' callback function?

Hi there,

For me, the callback function works fine for the 'options' but the cancel button does not seem to be working. Is this intentional or am I doing something wrong?

BottomSheet.showBottomSheetWithOptions({
            options: this.props.options,
            cancelButtonIndex: this.props.cancelButtonIndex,
            destructiveButtonIndex: this.props.destructiveButtonIndex,
            title: this.props.title,
        }, (value) => {
            console.log(value);
        });

Props being passed in (in case something is wrong there):

interface IActionSheetProps {
    options: string[];
    cancelButtonIndex: number;
    destructiveButtonIndex: number;
    title: string;
}

Broken release

The latest version in npm (1.9.1) is broken.

The app crashes as soon as you select the value in the sheet with the following error in adb logs

Illegal callback invocation from native module. This callback type only permits a single invocation from native code.

The error occurs because RN allows the action press callback to be invoked only one time, but with the latest feature, which adds a callback invocation on cancel press, the callback gets executed twice, which causes a crash.

image

For anyone stumbling across this - install version 1.8.1.

Styling title/message

Is it planned to have styling ability for the title? Or message? (buttons would be an awesome bonus too)

Thanks for this awesome module!

null is not an object (evaluating '_reactNativeBottomsheet.default.showBottomSheetWithOptions

Hi,

I keep getting this error when i call my onPress function. Error - null is not an object (evaluating '_reactNativeBottomsheet.default.showBottomSheetWithOptions.

I made sure to the package is linked.
I made sure to import import BottomSheet from 'react-native-bottomsheet';
I used the example code from the readme.
Device Info: Android Emulator - Nexus_5 API_25:5554.
Android Version - 7.1 (Nougat) - API 25
React Native Version - 0.59.10
React Version - 16.8.3

Publish to NPM

Hi,

Could you publish your package to NPM? It was last published 2 years ago and you have had lots of updates since then it would be really good to get them in the package.

If we could up the react native version to ^0.71.0 first that would be fantastic.

Thanks,
Adam

Build android failed on after install

screen shot 2017-11-03 at 12 03 00 pm

After install, I run yarn run android and receive error like image.

compileSdkVersion 25
buildToolsVersion "25.0.1"
"react-native": "^0.48.4"
compile "com.android.support:appcompat-v7:23.0.1"

I tried:
Replace android value: This solution

Change the compile "com.android.support:appcompat-v7:23.0.1" to compile "com.android.support:appcompat-v7:26.+"

All not running. :(

Reply me as Vietnamese lang if you can.

Crash when keyboard open

When I try to open bottomsheet while keyboard open app crashed. So I checked issue and solve by hide keyboard before open bottomsheet. Please review this issue and solve in library.

Android app getting crash on click of showImageMenu

We're using:
"react": "16.8.3",
"react-native": "0.59.4",
"react-native-bottomsheet": "^1.8.1"

With all above defined versions, BottomSheet was working fine but suddenly we are getting following error on click of showImageMenu(i.e three dots ...) which opens options for edit, delete etc..
Screenshot_20190807-130554

Migrating app to Androidx fails due to unability to transform bottomsheet-1.3.1 dependency

Hi there.
As of today many faced an issue with building RN apps due to major release by google.
Details are here: RN issue

The main way to fix this is to upgrade your app to Androidx.
Android studio has a way to update dependencies sort of automatically, but bottomsheet is one that can not be updated.

Here is Gradle sync error after one adds

android.useAndroidX=true android.enableJetifier=true

to gradle.properties according to manual.

Unable to resolve dependency for ':react-native-bottomsheet@debug/compileClasspath': Failed to transform file 'bottomsheet-1.3.1.aar' to match attributes {artifactType=processed-aar} using transform JetifyTransform

This prevents me from migrating project to Androidx and thus from ability to further build.

I see this references native bottomsheet library and not your wrapper directly.
Hopefully you might know the reason Jettifier can not transform this exact aar or have other thoughts on this.

soarcn BottomSheet on Android is deprecated

Google introduced official bottomsheets implementation in Support library 23.2.0,thus this library is no longer activly being developed. I will continuely fix defects been found and accept good PR but No more new feature will be developed.

Cannot build with react native 0.47.1

Cannot build with react native 0.47.1 and react-native-bottomsheet 1.5.0:

../node_modules/react-native-bottomsheet/android/src/main/java/com/clipsub/rnbottomsheet/RNBottomSheetPackage.java:28: error: method does not override or implement a method from a supertype

Insert image with Text

Hello thanks for your awesome plugin, is there anyway to insert a text with a left or right image?

kind of

BottomSheet.showBottomSheetWithOptions({
  options: [
    {image : "http:// || require(...)", title : "Option 1", position : "right"},
   {image : "http:// || require(...)", title : "Option 2", position : "left"},
   {image : "http:// || require(...)", title : "Option 3", position : "right"},
  ],
  title: 'Demo Bottom Sheet',
  dark: true,
  cancelButtonIndex: 3,
}, (value) => {
  alert(value);
});

showBottomSheetWithOptions crashes the app

Using showBottomSheetWithOptions crashes the app.
Tried the Example code:

 BottomSheet.showBottomSheetWithOptions({
          options: ['Option 1', 'Option 2', 'Option 3'],
          title: 'Demo Bottom Sheet',
          dark: true,
          cancelButtonIndex: 3,
        }, (value) => {
          alert(value);
 })

Using "react-native": "0.45.1"
"react-native-bottomsheet": "^1.4.0",

Wrong Import module

This is a very handy bottom sheet because it support both iOS and Android but when importing you using import BottomSheet from 'react-native-bottom-sheet'; instead of import BottomSheet from 'react-native-bottomsheet';

Took me a long time to figure out what the problem was.

React native 0.64.0 requirement clashes with React 18 in our project

With the release of React Native 0.69.0 a new requirement for React 18 was brought in. Our project uses React 0.71.3 which brings in React 18.

Our project then clashes with this package's React Native 0.64.0 requirement of React 17.0.2, meaning we have to install with the --legacy-peer-deps flag in npm.

Can this package be brought up to date with the latest React Native and React versions?

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.