import { View, ScrollView, StyleSheet } from "react-native";
import { useEffect } from "react";
import {useTheme, Text, Card, ActivityIndicator} from "react-native-paper";
import { useLocalSearchParams } from "expo-router";
import useLocationStore from "@/locationStore";
export default function Location() {
const theme = useTheme();
const { id } = useLocalSearchParams();
const getLocation = useLocationStore((state) => state.getLocation);
const fetchLocations = useLocationStore((state) => state.fetchLocations);
const loading = useLocationStore((state) => state.loading);
const location = getLocation(id);
useEffect(() => {
if (!location && !loading) {
fetchLocations();
}
}, [location, loading, fetchLocations]);
if (loading) {
return (
);
}
if (!location) {
return (
Brak lokalizacji - {id}
);
}
return (
{location.name}
Opis:
{location.description}
Statystyki:
Powierzchnia: {location.area} km²
Ludność: {location.population} osób
Współrzedne geograficzne: {location.latitude}, {location.longitude}
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#25292e",
justifyContent: "center",
},
text: {
color: "#fff",
},
});