Better search bar UX 🎨

Tests
Lucas Delanier 2 years ago
parent f0154a514c
commit 6340ff89e8

@ -18,6 +18,8 @@ export default function FavoriteScreen({navigation}: RootTabScreenProps<'Favorit
const [filteredDataSource, setFilteredDataSource] = useState<Movie[]>([]); const [filteredDataSource, setFilteredDataSource] = useState<Movie[]>([]);
const [borderwidth, setBorderWidth] = useState(0);
const [masterDataSource] = useState([]); const [masterDataSource] = useState([]);
const insets = useSafeAreaInsets(); const insets = useSafeAreaInsets();
@ -48,15 +50,19 @@ export default function FavoriteScreen({navigation}: RootTabScreenProps<'Favorit
searchSection: { searchSection: {
height: 40, height: 40,
width: 400, width: 400,
backgroundColor: "grey", backgroundColor: "#323232",
borderRadius: 20, borderRadius: 20,
marginVertical: 10, marginVertical: 10,
alignSelf: "center" alignSelf: "center",
borderWidth: borderwidth,
borderColor: "rgba(255,255,255,0.22)"
}, },
searchBar: { searchBar: {
width: '100%', width: '100%',
height: 40, height: 40,
marginHorizontal: 20 marginHorizontal: 20,
color: "white"
}, },
titlePage: { titlePage: {
height: 50, height: 50,
@ -111,6 +117,14 @@ export default function FavoriteScreen({navigation}: RootTabScreenProps<'Favorit
} }
}; };
const ToggleSearchBar = () => {
if (borderwidth === 0)
setBorderWidth(2)
else
setBorderWidth(0)
};
return ( return (
<SafeAreaView style={styles.container}> <SafeAreaView style={styles.container}>
<View style={styles.titlePage}> <View style={styles.titlePage}>
@ -124,6 +138,10 @@ export default function FavoriteScreen({navigation}: RootTabScreenProps<'Favorit
<View style={styles.searchSection}> <View style={styles.searchSection}>
<TextInput style={styles.searchBar} onChangeText={(text) => searchFilterFunction(text)} <TextInput style={styles.searchBar} onChangeText={(text) => searchFilterFunction(text)}
value={search} value={search}
placeholder="Rechercher ici..."
placeholderTextColor={"white"}
onFocus={ToggleSearchBar}
onBlur={ToggleSearchBar}
></TextInput> ></TextInput>
</View> </View>
<FlatList <FlatList

@ -14,6 +14,8 @@ export default function WatchLaterScreen({navigation}: RootTabScreenProps<'Watch
const [search, setSearch] = useState(''); const [search, setSearch] = useState('');
const [borderwidth, setBorderWidth] = useState(0);
const [filteredDataSource, setFilteredDataSource] = useState<Movie[]>([]); const [filteredDataSource, setFilteredDataSource] = useState<Movie[]>([]);
const [masterDataSource] = useState([]); const [masterDataSource] = useState([]);
@ -66,15 +68,18 @@ export default function WatchLaterScreen({navigation}: RootTabScreenProps<'Watch
searchSection: { searchSection: {
height: 40, height: 40,
width: 400, width: 400,
backgroundColor: "grey", backgroundColor: "#323232",
borderRadius: 20, borderRadius: 20,
marginVertical: 10, marginVertical: 10,
alignSelf: "center" alignSelf: "center",
borderWidth: borderwidth,
borderColor: "rgba(255,255,255,0.22)"
}, },
searchBar: { searchBar: {
width: '100%', width: '100%',
height: 40, height: 40,
marginHorizontal: 20 marginHorizontal: 20,
color: "white"
}, },
titlePage: { titlePage: {
height: 50, height: 50,
@ -108,6 +113,14 @@ export default function WatchLaterScreen({navigation}: RootTabScreenProps<'Watch
loadWatchLater(); loadWatchLater();
}, [dispatch]); }, [dispatch]);
const ToggleSearchBar = () => {
if (borderwidth === 0)
setBorderWidth(2)
else
setBorderWidth(0)
};
return ( return (
<SafeAreaView style={styles.container}> <SafeAreaView style={styles.container}>
@ -122,6 +135,10 @@ export default function WatchLaterScreen({navigation}: RootTabScreenProps<'Watch
<View style={styles.searchSection}> <View style={styles.searchSection}>
<TextInput style={styles.searchBar} onChangeText={(text) => searchFilterFunction(text)} <TextInput style={styles.searchBar} onChangeText={(text) => searchFilterFunction(text)}
value={search} value={search}
placeholder="Rechercher ici..."
placeholderTextColor={"white"}
onFocus={ToggleSearchBar}
onBlur={ToggleSearchBar}
></TextInput> ></TextInput>
</View> </View>
<FlatList <FlatList

Loading…
Cancel
Save