1.0.1 • Published 4 years ago

react-native-actionsheet-cstm v1.0.1

Weekly downloads
58
License
MIT
Repository
github
Last release
4 years ago

react-native-actionsheet-cstm

npm version

Getting started

$ npm install react-native-actionsheet-cstm --save

Demo

A basic Setup

import React, {useState} from 'react';
import {SafeAreaView, Text, ScrollView, TouchableOpacity} from 'react-native';

import {ActionSheet} from 'react-native-actionsheet-cstm';

const App = () => {
  const [showActionSheet, setShowActionSheet] = useState<boolean>(false);

  const onShowActionSheet = () => {
    setShowActionSheet(true);
  };
  const onCloseActionSheet = () => {
    setShowActionSheet(false);
  };

  return (
    <SafeAreaView style={{flex: 1}}>
      <Text style={{textAlign: 'center'}}>Components</Text>
      <ScrollView style={{flex: 1, marginTop: 50}}>
        <TouchableOpacity
          style={{
            flex: 1,
            height: 40,
            justifyContent: 'center',
            alignItems: 'center',
            backgroundColor: '#3880ff',
          }}
          onPress={onShowActionSheet}>
          <Text style={{color: '#fff'}}>Show Action Sheet</Text>
        </TouchableOpacity>

        <ActionSheet
          visible={showActionSheet}
          onClose={onCloseActionSheet}
          actionItems={[
            {
              text: 'Save',
              onPress: () => {
                console.log('Save');
              },
            },
            {
              text: 'Update',
              onPress: () => {
                console.log('Update');
              },
            },
            {
              text: 'Delete',
              textStyle: [{color: 'red'}],
              onPress: () => {
                console.log('Delete');
              },
            },
          ]}
        />
      </ScrollView>
    </SafeAreaView>
  );
};

export default App;

Options

ActionSheetProps

NameTypeDefaultDescription
visiblebooleanfalseShow the Action sheet
onClosefunctionnullTrigger a function asking to close the Action sheet.
actionItemsArraynull(array of ActionItem) - a list of button
onShow?functionnullThe onShow prop allows passing a function that will be called once the Action sheet has been shown.
onDismiss?functionnullThe onDismiss prop allows passing a function that will be called once the Action sheet has been dismissed.
backdropStyle?StylePropnullBack drop style
containerStyle?StylePropnullContainer style
titleContainerStyle?StylePropnullContainer title style
title?stringnullAction sheet title (Not required)
titleTextStyle?StylePropnullAction sheet title style
cancelButtonStyle?StylePropnullAction sheet cancel button style
cancelText?string'Cancel'Action sheet cancel button title
cancelTextStyle?StylePropnullAction sheet cancel button text style
hideCancelbooleanfalseHidde the Action sheet Cancel button

ActionItem

NameTypeDefaultDescription
textstringnullbutton title
onPressfunctionnullbutton action
textStyle?StylePropnullbutton style