Skip to content

Commit

Permalink
old version
Browse files Browse the repository at this point in the history
  • Loading branch information
fateh999 committed Jul 20, 2024
1 parent d8f3e66 commit 5257fa6
Showing 1 changed file with 185 additions and 0 deletions.
185 changes: 185 additions & 0 deletions docs/old-version.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# react-native-paper-dropdown

[![npm version](https://img.shields.io/npm/v/react-native-paper-dropdown.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-paper-dropdown)
[![npm downloads](https://img.shields.io/npm/dm/react-native-paper-dropdown.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-paper-dropdown)
[![npm](https://img.shields.io/npm/dt/react-native-paper-dropdown.svg?style=for-the-badge)](https://www.npmjs.com/package/react-native-paper-dropdown)
[![npm](https://img.shields.io/npm/l/react-native-paper-dropdown?style=for-the-badge)](https://github.com/fateh999/react-native-paper-dropdown/blob/master/LICENSE)

Material Design Dropdown Component using React Native Paper

## Dependencies

react-native-paper

## Installation

```bash

yarn add react-native-paper-dropdown

```

or

```
npm i react-native-paper-dropdown
```

## Basic Example

```javascript
import {
Appbar,
DarkTheme,
DefaultTheme,
Provider,
Surface,
ThemeProvider,
} from 'react-native-paper';
import React, { useState } from 'react';
import { SafeAreaView, StatusBar, StyleSheet, View } from 'react-native';
import DropDown from 'react-native-paper-dropdown';

function App() {
const [nightMode, setNightmode] = useState(false);
const [showDropDown, setShowDropDown] = useState(false);
const [gender, setGender] = useState < string > '';
const [showMultiSelectDropDown, setShowMultiSelectDropDown] = useState(false);
const [colors, setColors] = useState < string > '';
const genderList = [
{
label: 'Male',
value: 'male',
},
{
label: 'Female',
value: 'female',
},
{
label: 'Others',
value: 'others',
},
];
const colorList = [
{
label: 'White',
value: 'white',
},
{
label: 'Red',
value: 'red',
},
{
label: 'Blue',
value: 'blue',
},
{
label: 'Green',
value: 'green',
},
{
label: 'Orange',
value: 'orange',
},
];

return (
<Provider theme={nightMode ? DarkTheme : DefaultTheme}>
<ThemeProvider theme={nightMode ? DarkTheme : DefaultTheme}>
<StatusBar
backgroundColor={
nightMode ? DarkTheme.colors.surface : DefaultTheme.colors.primary
}
barStyle={'light-content'}
/>
<Appbar.Header>
<Appbar.Content title="React Native Paper Dropdown" />
<Appbar.Action
icon={nightMode ? 'brightness-7' : 'brightness-3'}
onPress={() => setNightmode(!nightMode)}
/>
</Appbar.Header>
<Surface style={styles.containerStyle}>
<SafeAreaView style={styles.safeContainerStyle}>
<DropDown
label={'Gender'}
mode={'outlined'}
visible={showDropDown}
showDropDown={() => setShowDropDown(true)}
onDismiss={() => setShowDropDown(false)}
value={gender}
setValue={setGender}
list={genderList}
/>
<View style={styles.spacerStyle} />
<DropDown
label={'Colors'}
mode={'outlined'}
visible={showMultiSelectDropDown}
showDropDown={() => setShowMultiSelectDropDown(true)}
onDismiss={() => setShowMultiSelectDropDown(false)}
value={colors}
setValue={setColors}
list={colorList}
multiSelect
/>
</SafeAreaView>
</Surface>
</ThemeProvider>
</Provider>
);
}

const styles = StyleSheet.create({
containerStyle: {
flex: 1,
},
spacerStyle: {
marginBottom: 15,
},
safeContainerStyle: {
flex: 1,
margin: 20,
justifyContent: 'center',
},
});

export default App;
```

## Demo

![Demo](https://github.com/fateh999/react-native-paper-dropdown/blob/master/Demo.gif)

## Props

```typescript
{
visible: boolean;
multiSelect?: boolean;
onDismiss: () => void;
showDropDown: () => void;
value: any;
setValue: (_value: any) => void;
label?: string | undefined;
placeholder?: string | undefined;
mode?: "outlined" | "flat" | undefined;
inputProps?: TextInputPropsWithoutTheme;
list: Array<{
label: string;
value: string | number;
custom?: ReactNode;
}>;
dropDownContainerMaxHeight?: number;
dropDownContainerHeight?: number;
activeColor?: string;
theme?: Theme;
dropDownStyle?: ViewStyle;
dropDownItemSelectedTextStyle?: TextStyle;
dropDownItemSelectedStyle?: ViewStyle;
dropDownItemStyle?: ViewStyle;
dropDownItemTextStyle?: TextStyle;
}
```

0 comments on commit 5257fa6

Please sign in to comment.