Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions components/MultipleSelectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
Animated,
TextInput,
ViewStyle,
Pressable} from 'react-native';
Pressable,
Keyboard} from 'react-native';

import { MultipleSelectListProps } from '..';

Expand Down Expand Up @@ -42,20 +43,22 @@ const MultipleSelectList: React.FC<MultipleSelectListProps> = ({
badgeTextStyles,
checkBoxStyles,
save = 'key',
dropdownShown = false
dropdownShown = false,
defaultSelected = [],
}) => {

const oldOption = React.useRef(null)
const [_firstRender,_setFirstRender] = React.useState<boolean>(true);
const [dropdown, setDropdown] = React.useState<boolean>(dropdownShown);
const [selectedval, setSelectedVal] = React.useState<any>([]);
const [selectedval, setSelectedVal] = React.useState<any>(defaultSelected);
const [height,setHeight] = React.useState<number>(350)
const animatedvalue = React.useRef(new Animated.Value(0)).current;
const [filtereddata,setFilteredData] = React.useState(data);


const slidedown = () => {
setDropdown(true)
Keyboard.dismiss();

Animated.timing(animatedvalue,{
toValue:height,
Expand Down Expand Up @@ -105,7 +108,10 @@ const MultipleSelectList: React.FC<MultipleSelectListProps> = ({

},[dropdownShown])


React.useEffect(() => {
setSelected(defaultSelected);
}, []);




Expand Down Expand Up @@ -184,7 +190,7 @@ const MultipleSelectList: React.FC<MultipleSelectListProps> = ({
</View>
</TouchableOpacity>
:
<TouchableOpacity style={[styles.wrapper,boxStyles]} onPress={() => { if(!dropdown){ slidedown() }else{ slideup() } }}>
<TouchableOpacity style={[styles.wrapper,boxStyles]} onPress={() => { if(!dropdown){ slidedown() }else{ slideup() } }} >
<Text style={[{fontFamily},inputStyles]}>{ (selectedval == "") ? (placeholder) ? placeholder : 'Select option' : selectedval }</Text>
{
(!arrowicon)
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export interface MultipleSelectListProps {
* Additional styles for label
*/
labelStyles?: TextStyle,
defaultSelected?: any[];
}

declare class MultipleSelectList extends React.Component<MultipleSelectListProps> {}
Expand Down