npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

custom-action-sheet

v1.0.0

Published

Cross-platform ActionSheet component that provides a unified way to display ActionSheets on iOS and Android.

Downloads

8

Readme

custom-action-sheet

The custom-action-sheet component is a cross-platform ActionSheet component that provides a unified way to display ActionSheets on iOS and Android. It utilizes the native ActionSheetIOS component on iOS for optimal visual effects.

Note

This is an updated and enhanced version of the original "react-native-actionsheet" library. In this new version, existing issues have been addressed, and the library is now compatible with newer versions of React Native.

Note: This library includes improvements made on top of the original "beefe/react-native-actionsheet" repository.

Users can seamlessly integrate the ActionSheet component using this updated version and incorporate it into their projects with ease.

Installation

npm install custom-action-sheet --save

Usage

import ActionSheet from 'custom-action-sheet';

class Demo extends React.Component {
  showActionSheet = () => {
    this.ActionSheet.show();
  };

  render() {
    return (
      <View>
        <Text onPress={this.showActionSheet}>Open ActionSheet</Text>
        <ActionSheet
          ref={o => (this.ActionSheet = o)}
          title={'Which one do you like?'}
          options={['Apple', 'Banana', 'cancel']}
          cancelButtonIndex={2}
          destructiveButtonIndex={1}
          onPress={index => {
            /* do something */
          }}
        />
      </View>
    );
  }
}

Using ActionSheetCustom directly

You can also use the ActionSheetCustom component directly to customize the options and title.

import { ActionSheetCustom as ActionSheet } from 'custom-action-sheet';

const options = [
  'Cancel',
  'Apple',
  <Text style={{ color: 'yellow' }}>Banana</Text>,
  'Watermelon',
  <Text style={{ color: 'red' }}>Durian</Text>,
];

class Demo extends React.Component {
  showActionSheet = () => {
    this.ActionSheet.show();
  };

  render() {
    return (
      <View>
        <Text onPress={this.showActionSheet}>Open ActionSheet</Text>
        <ActionSheet
          ref={o => (this.ActionSheet = o)}
          title={<Text style={{ color: '#000', fontSize: 18 }}>Which one do you like?</Text>}
          options={options}
          cancelButtonIndex={0}
          destructiveButtonIndex={4}
          onPress={index => {
            /* do something */
          }}
        />
      </View>
    );
  }
}

Customizing Styles

You can customize the style of the ActionSheet by providing a styles prop. The default styles are defined in lib/styles.js. See the example below:

const styles = {
  titleBox: {
    background: 'pink',
  },
  titleText: {
    fontSize: 16,
    color: '#000',
  },
};

<ActionSheet
  // ...
  styles={styles}
/>

Props

  • title: PropTypes.string or PropTypes.element
  • message: PropTypes.string or PropTypes.element
  • options: PropTypes.arrayOf([PropTypes.string, PropTypes.element])
  • tintColor: PropTypes.string
  • cancelButtonIndex: PropTypes.number
  • destructiveButtonIndex: PropTypes.number
  • onPress: PropTypes.func (index) => {}
  • styles (only for ActionSheetCustom): {}

For more details on props, please refer to the options.js file.