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 | 3x 3x 1x | /**
* @fileoverview Home screen component
* @module HomeScreen
* @description Home screen, it is the first screen that the user sees when opening the app.
* @requires react react-native
*/
import React from 'react'
import { SafeAreaView, StyleSheet } from 'react-native'
import LoadingModal from '@components/LoadingModal'
import { colors } from '@global/colors'
import HeaderView from './Views/HeaderView'
import useHomeScreenController from './useHomeScreenController'
import CarouselView from './CarouselView/CarouselView'
import MapView from './MapView/MapView'
import NoPlacesFound from './Views/NoPlacesFound'
/**
* @function HomeScreen
* @description Component that renders the Home screen.
* @returns {React.JSX.Element} App component template
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function HomeScreen({ navigation }: any): React.JSX.Element {
const {
city,
currentPage,
displaySearchBar,
toggleSearchBar,
searchValue,
setSearchValue,
togglePage,
places,
latestPlaces,
getNearestPlaces,
getAllPlacesUsingSearch,
isLoading,
onRefresh,
isRefreshing,
isSuccessful,
goToFilterPage,
} = useHomeScreenController(navigation)
return (
<SafeAreaView style={styles.container}>
<HeaderView
city={city}
page={currentPage}
togglePage={togglePage}
displaySearchBar={displaySearchBar}
toggleSearchBar={toggleSearchBar}
searchValue={searchValue}
setSearchValue={setSearchValue}
getAllPlacesUsingSearch={getAllPlacesUsingSearch}
navigation={navigation}
goToFilterPage={goToFilterPage}
/>
{currentPage === 'carousel' && isSuccessful && places.length > 0 && (
<CarouselView
places={places}
latestPlaces={latestPlaces}
navigation={navigation}
getNearestPlaces={getNearestPlaces}
isLoading={isRefreshing}
onRefresh={onRefresh}
/>
)}
{currentPage === 'carousel' && isSuccessful && places.length === 0 && <NoPlacesFound />}
{currentPage === 'map' && (
<MapView
places={places}
navigation={navigation}
/>
)}
<LoadingModal visible={isLoading} />
</SafeAreaView>
)
}
const styles = StyleSheet.create({
container: {
backgroundColor: colors.veryLightGrey,
flex: 1,
},
})
|