diff --git a/assets/images/check.png b/assets/images/check.png deleted file mode 100644 index 9c84c860..00000000 Binary files a/assets/images/check.png and /dev/null differ diff --git a/assets/images/chevron.png b/assets/images/chevron.png deleted file mode 100644 index 1a62e0c4..00000000 Binary files a/assets/images/chevron.png and /dev/null differ diff --git a/assets/images/close.png b/assets/images/close.png deleted file mode 100644 index 3c38ff31..00000000 Binary files a/assets/images/close.png and /dev/null differ diff --git a/assets/images/search.png b/assets/images/search.png deleted file mode 100644 index 3cb1c410..00000000 Binary files a/assets/images/search.png and /dev/null differ diff --git a/components/Icons.js b/components/Icons.js new file mode 100644 index 00000000..f117e0dc --- /dev/null +++ b/components/Icons.js @@ -0,0 +1,45 @@ +import React from "react"; +import AntDesign from "react-native-vector-icons/AntDesign"; +import FontAwesome from "react-native-vector-icons/FontAwesome"; +import FontAwesome5 from "react-native-vector-icons/FontAwesome5"; +import Ionicons from "react-native-vector-icons/Ionicons"; +import Feather from "react-native-vector-icons/Feather"; +import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons"; +import Entypo from "react-native-vector-icons/Entypo"; +import MaterialIcons from "react-native-vector-icons/MaterialIcons"; +import SimpleLineIcons from "react-native-vector-icons/SimpleLineIcons"; +import Octicons from "react-native-vector-icons/Octicons"; +import Foundation from "react-native-vector-icons/Foundation"; +import Fontisto from "react-native-vector-icons/Fontisto"; +export const Icons = { + MaterialCommunityIcons, + MaterialIcons, + Ionicons, + Feather, + FontAwesome, + FontAwesome5, + AntDesign, + Entypo, + SimpleLineIcons, + Octicons, + Foundation, + Fontisto, +}; +const Icon = ({ type, name, color, size = 24, style, onPress }) => { + const fontSize = 24; + const Tag = type; + return ( + <> + {type && name && ( + + )} + + ); +}; +export default Icon; diff --git a/components/SelectList.tsx b/components/SelectList.tsx index 234a7e10..688c3223 100644 --- a/components/SelectList.tsx +++ b/components/SelectList.tsx @@ -1,263 +1,281 @@ -import React from 'react'; -import { - View, - Text, - StyleSheet, - Image, - TouchableOpacity, - ScrollView, - Animated, - TextInput, - Keyboard -} from 'react-native'; - -import { SelectListProps } from '..'; - -type L1Keys = { key?: any; value?: any; disabled?: boolean | undefined } - -const SelectList: React.FC = ({ - setSelected, - placeholder, - boxStyles, - inputStyles, - dropdownStyles, - dropdownItemStyles, - dropdownTextStyles, - maxHeight, - data, - defaultOption, - searchicon = false, - arrowicon = false, - closeicon = false, - search = true, - searchPlaceholder = "search", - notFoundText = "No data found", - disabledItemStyles, - disabledTextStyles, - onSelect = () => {}, - save = 'key', - dropdownShown = false, - fontFamily - }) => { +// SelectList.tsx - const oldOption = React.useRef(null) - const [_firstRender,_setFirstRender] = React.useState(true); - const [dropdown, setDropdown] = React.useState(dropdownShown); - const [selectedval, setSelectedVal] = React.useState(""); - const [height,setHeight] = React.useState(200) - const animatedvalue = React.useRef(new Animated.Value(0)).current; - const [filtereddata,setFilteredData] = React.useState(data) +import React, { useState, useRef, useEffect } from "react"; +import { + View, + Text, + StyleSheet, + TouchableOpacity, + ScrollView, + Animated, + TextInput, + StyleProp, + TextStyle, + ViewStyle, +} from "react-native"; +import Icon, { Icons } from "./Icons"; +interface Option { + key?: string | number; + value: string; + disabled?: boolean; +} - const slidedown = () => { - setDropdown(true) - Animated.timing(animatedvalue,{ - toValue:height, - duration:500, - useNativeDriver:false, - - }).start() - } - const slideup = () => { - - Animated.timing(animatedvalue,{ - toValue:0, - duration:500, - useNativeDriver:false, - - }).start(() => setDropdown(false)) - } +interface SelectListProps { + setSelected: (value: string | number) => void; + setTyped: (value: string) => void; + placeholder?: string; + boxStyles?: StyleProp; + inputStyles?: StyleProp; + dropdownStyles?: StyleProp; + dropdownItemStyles?: StyleProp; + dropdownTextStyles?: StyleProp; + maxHeight?: number; + data: Option[]; + defaultOption?: Option; + searchIcon?: boolean; + arrowIcon?: boolean; + closeIcon?: boolean; + search?: boolean; + searchPlaceholder?: string; + notFoundText?: string; + disabledItemStyles?: StyleProp; + disabledTextStyles?: StyleProp; + onSelect?: (value: string) => void; + save?: "key" | "value"; + dropdownShown?: boolean; + fontFamily?: string; +} - React.useEffect( () => { - if(maxHeight) - setHeight(maxHeight) - },[maxHeight]) +const SelectList: React.FC = ({ + setSelected, + setTyped, + placeholder, + boxStyles, + inputStyles, + dropdownStyles, + dropdownItemStyles, + dropdownTextStyles, + maxHeight, + data, + defaultOption, + searchIcon = true, + arrowIcon = true, + closeIcon = true, + search = true, + searchPlaceholder = "Select from the list or input manually.", + notFoundText = "No data found", + disabledItemStyles, + disabledTextStyles, + onSelect = () => {}, + save = "key", + dropdownShown = false, + fontFamily, +}) => { + const oldOption = useRef