init State Mangement and add del function

This commit is contained in:
Patryk
2025-04-22 18:35:39 +02:00
parent 5e44b30a49
commit 8f5b151d87
8 changed files with 252 additions and 185 deletions

View File

@@ -1,31 +1,32 @@
import { View, StyleSheet, FlatList } from 'react-native';
import { useTheme, Card, Text, Button} from 'react-native-paper';
import { useTheme, Card, Text, Button } from 'react-native-paper';
import { Link } from 'expo-router';
import { locations } from '@/data/locations';
import useLocationStore from '@/store';
export default function Index() {
const theme = useTheme();
locations.sort((a, b) => b.id - a.id);
const theme = useTheme();
const locations = useLocationStore((state) => state.locations);
return (
<View style={[styles.container, {backgroundColor: theme.colors.background}]}>
<FlatList
<View style={[styles.container, { backgroundColor: theme.colors.background }]}>
<FlatList
data={locations}
keyExtractor={(item) => item.name}
keyExtractor={(item) => item.id.toString()}
renderItem={({ item }) => (
<Card style={{ margin: 10}}>
<Card.Cover style={{ marginBottom:10 }} source={{ uri: item.image }} />
<Card.Content style={{ marginBottom:10 }}>
<Card style={{ margin: 10 }}>
<Card.Cover style={{ marginBottom: 10 }} source={{ uri: item.image }} />
<Card.Content style={{ marginBottom: 10 }}>
<Text variant="titleLarge">{item.name}</Text>
<Text variant="bodyMedium">{item.description.split('.')[0]}...</Text>
</Card.Content>
<Card.Actions>
<Link href={`/location/${item.id}`} asChild>
<Button>Zobacz więcej</Button>
<Link href={`/location/${item.id}`} asChild>
<Button>Zobacz więcej</Button>
</Link>
</Card.Actions>
</Card>
)}>
</FlatList>
)}
/>
</View>
);
}
@@ -37,7 +38,4 @@ const styles = StyleSheet.create({
justifyContent: 'center',
alignItems: 'center',
},
text: {
color: '#fff',
},
});
});