Socket
Book a DemoInstallSign in
Socket

react-native-bottom-sheet-picker

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-bottom-sheet-picker

A picker component that uses the bottom sheet to show the list item instead of using the dropdown.

Source
npmnpm
Version
1.1.10
Version published
Weekly downloads
1
-94.12%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-bottom-sheet-picker

React native bottom sheet picker is a picker component that uses the bottom sheet to show the list item instead of using the dropdown. This picker allows the user to play the audio of the placeholder and list items of the picker.

Support

iOS & Android

Installation

npm install react-native-bottom-sheet-picker

Installing dependencies

npm install @gorhom/bottom-sheet@^4 react-native-gesture-handler react-native-reanimated react-native-vector-icons react-native-sound
  • @gorhom/bottom-sheet
  • react-native-gesture-handler
  • react-native-reanimated
  • react-native-vector-icons
  • react-native-sound

Usage

import {BottomSheetPicker} from 'react-native-bottom-sheet-picker';

// ...
const [playingUuid, setPlayingUuid] = React.useState(null);
let selectedLocation = null;
const locations = [
  {label: 'Siem Reap', value: 1, audio: 'audio1.mp3'},
  {label: 'Phnom Penh', value: 2, audio: 'audio2.mp3'},
  {label: 'Battambang', value: 3, audio: 'audio3.mp3'}
];

<BottomSheetPicker
  title="Your location"
  placeholder="Select your location"
  bottomSheetTitle="Select you location"
  required={true}
  requiredColor='#d50000'
  primaryColor='green'
  secondaryColor='gray'
  items={locations}
  selectedItem={selectedLocation}
  snapPoints={['60%']}
  pickerContentHeight={425}
  titleStyle={{}}
  containerStyle={{}}
  pickerStyle={{}}
  placeholderStyle={{}}
  listItemStyle={{}}
  itemTextStyle={{}}
  customPicker={{}}
  customBottomSheetTitle={component}
  customIcon={component}
  customListItem={component}
  customPickerContent={component}
  onSelectItem={(item) => selectedLocation = item}
  onBottomSheetShow={() => {}}
  onDismiss={() => {}}
  pickerUuid=''
  placeholderAudio={}
  playingUuid={playingUuid}
  updatePlayingUuid={(uuid) => setPlayingUuid(uuid)}
/>

Extra step

Add GestureHandlerRootView and BottomSheetModalProvider on the App.js

import {BottomSheetPicker} from 'react-native-bottom-sheet-picker';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
...

<GestureHandlerRootView style={{flex: 1}}>
  <BottomSheetModalProvider>
    ...
  </BottomSheetModalProvider>
</GestureHandlerRootView>

Properties

Basic

PropDefaultTypeDescription
title''stringTitle on top of the picker box
placeholder''stringPlaceholder inside the picker box
bottomSheetTitle''stringTitle on the bottom sheet
requiredfalsebooleanIf true, show the * sign on the title
requiredColor'#d50000'stringThe color of the * sign
primaryColor'black'stringColor for the pressable component
secondaryColor'#b5b5b5'stringColor of the audio button while the audio is playing
items[]ArrayArray of item for selections.(Ex: [{label: 'example', value: 1}])
selectedItemnullThe selected value
snapPoints['60%']ArrayThe height of the bottom sheet
pickerContentHeight425numberThe height of the content inside the bottom sheet
pickerUuid''stringThe uuid of the picker (for play audio purpose)
placeholderAudionullaudioThe audio of the placeholder (support .mp3). If null, it will not show play audio botton on the picker box
playingUuid''stringThe uuid of the playing auido component (to prevent playing audio overlap each other)
hideListItemAudiofalsebooleanHide or show the play audio button on the list item
showCheckIconfalsebooleanHide or show the check icon on the selected item
checkIconSize24numberSize of the check icon
isOutlinedfalsebooleanIf set to true, the picker will render in outlined style
pickerFontSize16numberFont size of the label inside the picker box
indicatorLabel''stringThe label on the right side of the picker box
disabledfalsebooleanThe status to disable the picker
disabledColor'#cdccc'stringThe color of the picker when disabled
titleFontFamily''stringThe font family of the title in the bottom sheet
itemFontFamily''stringThe font family of the item in the bottom sheet
selectedFieldNamenullstringThe custom field name used to get the selected value of the item (default field name is value)
showRadioStylefalsebooleanIf true, show the radio button style (circle & round icon) on the right side of each list
showLeftCheckIconfalsebooleanIf true with showRadioStyle and showCheckIcon are false, show the radio button style (circle & check icon) on the left side of each list

Custom styles

PropDefaultTypeDescription
titleStyle{...}styleStyle of the picker title
containerStyle{...}styleStyle of the picker wrapper
pickerStyle{...}styleStyle of the picker box container
pickerBoxStyle{...}styleStyle of the picker box
placeholderStyle{...}styleStyle of the placeholder label in the picker box
bottomSheetTitleStyle{...}styleStyle of the bottom sheet title
listItemStyle{...}styleStyle of the list item on bottom sheet
itemTextStyle{...}styleStyle of the label of the list item on bottom sheet
outlinedTitleContainerStyle{...}styleStyle of the outlined label container
indicatorLabelStyle{...}styleStyle of the label on the right side of the picker box
requiredTitleStyle{...}styleStyle of the required sign "*" on the title

Custom components

PropDefaultTypeDescription
customPicker{...}compCustom component of the picker box
customBottomSheetTitle{...}compCustom component of the bottom sheet title
customIcon{...}compCustom component of the icon on the picker box
customListItem{...}compCustom component of the list item on the bottom sheet
customPickerContent{...}compCustom content inside the bottom sheet (whole content)

Events

PropDefaultTypeDescription
onSelectItem{...}eventOn selecting an item
onBottomSheetShow{...}eventOn the bottom sheet show
onDismiss{...}eventOn the bottom sheet close
updatePlayingUuid{...}eventMark the component uuid as playingUuid when playing the audio

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Made with create-react-native-library

Keywords

react-native

FAQs

Package last updated on 11 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts