1.2.2 • Published 8 months ago

react-native-bottom-sheet-picker v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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 react-native-text-highlighter

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
leftCheckIconColor'#ffffff'stringThe color of the check icon on the left side of the list item
showSubtitlefalsebooleanIf true show the subtitle in the list item (make sure you have subtitle atribute in the items)
isSearchablefalsebooleanIf true show a search box above the list item
searchPlaceholder''stringThe placeholder of the search text input
searchIconColor''stringColor of the search icon in the search input box
clearSearchIconColor''stringColor of the clear text icon in the search box

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
subtitleStyle{...}styleStyle of the subtitle in the list item
searchInputStyle{...}styleStyle of the search text input (if isSearchable is setted to true)
searchInputContainerStyle{...}styleStyle of the container of the search text input

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

1.2.0

8 months ago

1.2.2

8 months ago

1.2.1

8 months ago

1.1.9

10 months ago

1.1.8

11 months ago

1.1.7

11 months ago

1.1.12

10 months ago

1.1.11

10 months ago

1.1.10

10 months ago

1.1.1

1 year ago

1.0.2

1 year ago

1.1.0

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago