Feature / search bar customization (#20)
* feat: add props (searchBarStyles, searchBarTextStyles, searchBarPlaceholderColor) * docs: update readme
This commit is contained in:
parent
8bb5ac517b
commit
c4a8ed36fc
|
@ -49,6 +49,9 @@ export default function App() {
|
||||||
| categoryPosition | 'floating' \| 'top' \| 'bottom' | 'floating' | no | Specify category container position |
|
| categoryPosition | 'floating' \| 'top' \| 'bottom' | 'floating' | no | Specify category container position |
|
||||||
| enableSearchBar | boolean | false | no | Enable search bar |
|
| enableSearchBar | boolean | false | no | Enable search bar |
|
||||||
| closeSearchColor | string | "#00000055" | no | Change button (cross) color for close/cancel search |
|
| closeSearchColor | string | "#00000055" | no | Change button (cross) color for close/cancel search |
|
||||||
|
| searchBarStyles | ViewStyle | {} | no | Override search bar container styles |
|
||||||
|
| searchBarTextStyles | ViewStyle | {} | no | Override search bar text styles |
|
||||||
|
| searchBarPlaceholderColor | string | "#00000055" | no | Override search bar placeholder color |
|
||||||
| headerStyles | TextStyle | {} | no | Override category name styles |
|
| headerStyles | TextStyle | {} | no | Override category name styles |
|
||||||
| knobStyles | ViewStyle | {} | no | Override knob styles |
|
| knobStyles | ViewStyle | {} | no | Override knob styles |
|
||||||
| containerStyles | ViewStyle | {} | no | Override container styles |
|
| containerStyles | ViewStyle | {} | no | Override container styles |
|
||||||
|
|
|
@ -20,6 +20,9 @@ export const SearchBar = ({ flatListRef }: SearchBarProps) => {
|
||||||
translation,
|
translation,
|
||||||
setActiveCategoryIndex,
|
setActiveCategoryIndex,
|
||||||
closeSearchColor,
|
closeSearchColor,
|
||||||
|
searchBarStyles,
|
||||||
|
searchBarTextStyles,
|
||||||
|
searchBarPlaceholderColor,
|
||||||
} = React.useContext(KeyboardContext);
|
} = React.useContext(KeyboardContext);
|
||||||
const inputRef = React.useRef<TextInput>(null);
|
const inputRef = React.useRef<TextInput>(null);
|
||||||
|
|
||||||
|
@ -34,13 +37,14 @@ export const SearchBar = ({ flatListRef }: SearchBarProps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={[styles.container, searchBarStyles]}>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={[styles.input, searchBarTextStyles]}
|
||||||
value={searchPhrase}
|
value={searchPhrase}
|
||||||
onChangeText={handleSearch}
|
onChangeText={handleSearch}
|
||||||
placeholder={translation.search}
|
placeholder={translation.search}
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
|
placeholderTextColor={searchBarPlaceholderColor}
|
||||||
/>
|
/>
|
||||||
{!!searchPhrase && (
|
{!!searchPhrase && (
|
||||||
<TouchableOpacity onPress={clearPhrase} style={styles.button}>
|
<TouchableOpacity onPress={clearPhrase} style={styles.button}>
|
||||||
|
|
|
@ -41,6 +41,9 @@ export type KeyboardProps = {
|
||||||
categoryPosition?: CategoryPosition;
|
categoryPosition?: CategoryPosition;
|
||||||
enableSearchBar?: boolean;
|
enableSearchBar?: boolean;
|
||||||
closeSearchColor?: string;
|
closeSearchColor?: string;
|
||||||
|
searchBarStyles?: ViewStyle;
|
||||||
|
searchBarTextStyles?: TextStyle;
|
||||||
|
searchBarPlaceholderColor?: string;
|
||||||
};
|
};
|
||||||
export type ContextValues = {
|
export type ContextValues = {
|
||||||
activeCategoryIndex: number;
|
activeCategoryIndex: number;
|
||||||
|
|
|
@ -40,6 +40,9 @@ export const defaultKeyboardContext: Required<KeyboardProps> = {
|
||||||
categoryPosition: 'floating',
|
categoryPosition: 'floating',
|
||||||
enableSearchBar: false,
|
enableSearchBar: false,
|
||||||
closeSearchColor: '#00000055',
|
closeSearchColor: '#00000055',
|
||||||
|
searchBarStyles: {},
|
||||||
|
searchBarTextStyles: {},
|
||||||
|
searchBarPlaceholderColor: '#00000055',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultKeyboardValues: ContextValues = {
|
export const defaultKeyboardValues: ContextValues = {
|
||||||
|
|
Loading…
Reference in New Issue