Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | 2x 2x 2x 1x | /** * @fileoverview Header View of the homescreen * @module HeaderView * @description Header view, it contains the logo, the city name, the search bar and the settings button. * @requires react react-native */ import React from 'react' import { View, Image, Text, StyleSheet, TouchableOpacity, TextInput } from 'react-native' import images from '@global/images' import colors from '@global/colors' interface HeaderViewProps { city: string page: 'map' | 'carousel' displaySearchBar: boolean toggleSearchBar: () => void togglePage: () => void searchValue: string setSearchValue: (value: string) => void getAllPlacesUsingSearch: () => void // eslint-disable-next-line @typescript-eslint/no-explicit-any navigation: any goToFilterPage: () => void } /** * @function HeaderView * @description Component that renders the header view. * @param city The city of the user * @param page The current page of the screen * @param displaySearchBar The display state of the search bar * @param toggleSearchBar The function to toggle the search bar * @param togglePage The function to toggle the current page of the screen * @param searchValue The value of the search bar * @param setSearchValue The function to set the value of the search bar * @param navigation Navigation object * @returns {React.JSX.Element} */ export default function HeaderView({ city, page, displaySearchBar, toggleSearchBar, togglePage, searchValue, setSearchValue, getAllPlacesUsingSearch, navigation, goToFilterPage, }: HeaderViewProps): React.JSX.Element { const updateText = (val: string) => { setSearchValue(val) } /** * @function defaultView * @description The default view of the header * @returns {React.JSX.Element} The default view of the header */ function defaultView(): React.JSX.Element { return ( <> <View style={styles.defaultViewContainer}> <TouchableOpacity onPress={togglePage}> <Image source={page === 'map' ? images.icons.outline.carousel() : images.icons.outline.mapArrow()} style={styles.icon} /> </TouchableOpacity> <Text style={styles.cityText}>{city.length > 8 ? `${city.substring(0, 5)}...` : city}</Text> </View> <Image source={images.logos.nolosay()} style={styles.logo} /> <View style={{ flexDirection: 'row' }}> <TouchableOpacity onPress={toggleSearchBar}> <Image source={images.icons.outline.magnifier()} style={[styles.icon, { marginRight: 20 }]} /> </TouchableOpacity> <TouchableOpacity onPress={() => navigation.navigate('SettingsModal')}> <Image source={images.icons.outline.menu()} style={styles.icon} /> </TouchableOpacity> </View> </> ) } /** * @function searchView * @description The search view of the header * @returns {React.JSX.Element} */ function searchView(): React.JSX.Element { return ( <View style={styles.searchContainer}> <TouchableOpacity onPress={goToFilterPage}> <Image source={images.icons.outline.filter()} style={[styles.icon, { marginLeft: -2, marginRight: 6, marginTop: 8 }]} /> </TouchableOpacity> <TextInput style={styles.input} placeholder='Rechercher' value={searchValue} onChangeText={updateText} placeholderTextColor={colors.lightGrey} enterKeyHint='search' onSubmitEditing={getAllPlacesUsingSearch} /> <TouchableOpacity onPress={getAllPlacesUsingSearch} style={styles.submitButton} activeOpacity={0.5} > <Text style={styles.submitText}>Envoyer</Text> </TouchableOpacity> <TouchableOpacity onPress={toggleSearchBar} style={styles.cancelButton} activeOpacity={0.5} > <Text style={styles.cancelText}>Annuler</Text> </TouchableOpacity> </View> ) } return ( <View style={styles.headerView}> {!displaySearchBar && defaultView()} {displaySearchBar && searchView()} </View> ) } const styles = StyleSheet.create({ defaultViewContainer: { flexDirection: 'row', }, searchContainer: { flexDirection: 'row', marginBottom: 8, }, cancelText: { color: colors.system.cancelBlue, fontSize: 14, }, submitText: { color: colors.white, fontSize: 14, }, logo: { width: '40%', aspectRatio: 2.46, }, icon: { height: 24, width: 24, tintColor: colors.black, }, headerView: { flexDirection: 'row', paddingHorizontal: 24, marginBottom: 16, justifyContent: 'space-between', alignContent: 'center', alignItems: 'center', }, cityText: { fontSize: 16, fontFamily: 'Poppins', fontWeight: '700', color: colors.black, marginLeft: 8, }, input: { height: 40, padding: 8, backgroundColor: colors.white, borderRadius: 8, marginRight: 8, width: '56%', }, cancelButton: { width: '15%', justifyContent: 'center', alignContent: 'center', textAlign: 'center', color: colors.system.cancelBlue, }, submitButton: { paddingHorizontal: 2, width: '20%', justifyContent: 'center', alignContent: 'center', alignItems: 'center', textAlign: 'center', textAlignVertical: 'center', color: colors.white, backgroundColor: colors.system.cancelBlue, borderRadius: 8, marginRight: 4, }, }) |