1.0.7 • Published 2 years ago

react-native-select-bottom-list v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Project Title

A simple, lightweight and fully customisable Select Input List component and a BottomSheet made using Modal from react-native.

Demo

first second third

Features

  • Lightweight Select Input List Component.
  • Dynamic Modal height.
  • Fully Customisable styles.
  • Included BottomSheet component for custom usage.
  • Cross platform.
  • Written in Typescript.
  • Basic Search Support.

Coming Soon Features :rocket:

  • Stable Release.
  • Custom Header Component.
  • More Custom Styles.
  • SectionList Support.
  • Better Documentation.

Installation

Using npm

npm i react-native-select-bottom-list

Using yarn

yarn add react-native-select-bottom-list

SelectList Usage

import { SelectList } from 'react-native-select-bottom-list';

Simple use case :

const YourComponent = () => {
  const [value, setValue] = useState('Select');

  return (
    <SafeAreaView>
      <SelectList
        onSelect={(item,index) => setValue(item)}
        value={value}
        data={[
          'Change the world by being yourself – T.S Eliot',
          'Every moment is a fresh beginning. – T.S Eliot',
          'When nothing goes right, go left. – Anonymous',
          'Success is the child of audacity. – Benjamin Disraeli',
          'Never regret anything that made you smile. – Mark Twain',
          'Die with memories, not dreams. – Anonymous',
        ]}
        headerTitle={'Quotes'}
      />
    </SafeAreaView>
  );
};

BottomSheet Usage

import { BottomSheet, BottomSheetRefType } from 'react-native-select-bottom-list';

Simply place any component or view inside and use reference to open and close it.

Example :

const App = () => {

  const sheetRef = useRef<BottomSheetRefType>(null);

  const onPress = () => {
    sheetRef.current?.open();
  };

  return (
    <SafeAreaView>
      <Text onPress={onPress} style={{padding: 20}}>
        Open BottoSheet
      </Text>

      <BottomSheet
        ref={sheetRef}
        presentationStyle={'overFullScreen'}
        height={'30%'}>
        <View
          style={{
            padding: 100,
          }}>
          <Text style={{fontSize: 20, textAlign: 'center'}}>
            Put Whatever you want to have here!
          </Text>
        </View>
      </BottomSheet>
    </SafeAreaView>
  );
};

Documentation

SelectList Props

NameTypeDescription
styleViewStyleOptional. Custom style for input
placeHolderstringOptional. Placeholder for input
textStyleViewStyleOptional. Custom style for input value
valuestringRequired. Selected value from list
dataObjectRequired. list of data to render in bottom list
listTypestringOptional. Not Required as of now, defaults to 'list', 'sectionlist' to be added in future
itemStyleViewStyleOptional. List Item container style
itemTextStyleTextStyleOptional. List Item text style
headerStyleTextStyleOptional. List Header Container style
headerTextStyleTextStyleOptional. List Header Text style
itemValueKeystringOptional. Used to render list item with key other than 'title','value'&'text'. itemValueKey doesn't work for nested key, use renderItem for nested key
headerTitlestringOptional. Header value of title
onSelectFunctionRequired. Function invoked on list item selection, gives back (item, index)
renderItemFunctionOptional. Custom list item, gives back ({item, index}, sheetRef). sheetRef containes close() & open() method to close & open respectively
presentationStylestringOptional. iOS only, this is similar to presentationStyle of Modal from react native
listHeightstring Or numberOptional. Height of Bottomlist
renderIconFunctionOptional. Render icon
showSearchbooleanOptional. Search Input to search items. Search only works for defualt list. Don't use renderItem in case you want to use search. For better user experience use 'listheight' prop

BottomSheet Methods

NameTypeDescription
closeFunctionOptional. To close BottomSheet, Use ref to close
openFunctionOptional. To open BottomSheet, Use ref to open

BottomSheet Props

NameTypeDescription
childrenReactNodeOptional. Content inside bottom sheet
heightstringOptional. Height of BottomSheet
presentationStyleViewStyleOptional. iOS only, this is similar to presentationStyle

Contributing

Contributions are always welcome! Feel free to open a new GitHub issue for any change or enhancement.

Feedback

Any feedback would be deeply appreciated, please feel free to reach out to me at amangautam72@gmail.com

Author

Aman Gautam

License

MIT