init edit

This commit is contained in:
Patryk
2025-04-15 21:54:54 +02:00
parent 6e8a235ed4
commit 5e44b30a49
5 changed files with 183 additions and 14 deletions

View File

@@ -21,10 +21,11 @@ export default function TabLayout() {
headerTintColor: theme.colors.primary,
tabBarItemStyle: { flex: 1 },
}}>
<Tabs.Screen name="index" options={{ title: 'Home',tabBarIcon: ({ color, focused }) => (
<Ionicons name={focused ? 'home-sharp' : 'home-outline'} color={color} size={24} />
), }} />
<Tabs.Screen name="addLocation" options={{title: 'Create' ,tabBarIcon: ({ color, focused }) => (
<Tabs.Screen name="add" options={{title: 'Create' ,tabBarIcon: ({ color, focused }) => (
<Ionicons name={focused ? 'add-circle-sharp' : 'add-circle-outline'} color={color} size={24} />
),}} />
</Tabs>

View File

@@ -1,6 +1,6 @@
import { useState } from 'react';
import { View, StyleSheet } from 'react-native';
import { TextInput, Button } from 'react-native-paper';
import { StyleSheet, Platform, KeyboardAvoidingView, ScrollView } from 'react-native';
import { TextInput, Button, Snackbar } from 'react-native-paper';
import { locations } from '@/data/locations';
@@ -12,6 +12,8 @@ export default function FormScreen() {
area: '',
population: '',
});
const [message, setMessage] = useState('');
const [visible, setVisible] = useState(false);
const [location, setLocation] = useState(locations.sort((a, b) => b.id - a.id));
@@ -38,13 +40,27 @@ export default function FormScreen() {
area: '',
population: '',
});
setMessage('Lokalizacja została dodana!');
setVisible(true);
}else{
setMessage('Wypełnij wszystkie pola!');
setVisible(true);
}
}
return (
<View style={styles.container}>
<KeyboardAvoidingView
style={{ flex: 1 }}
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
>
<ScrollView contentContainerStyle={styles.container}>
<Snackbar
visible={visible}
onDismiss={() => setVisible(false)}
duration={3000}
>
{message}
</Snackbar>
<TextInput
mode="outlined"
label="Nazwa"
@@ -66,6 +82,7 @@ export default function FormScreen() {
<TextInput
mode="outlined"
label="Link do zdjęcia"
multiline={true}
placeholder="Wpisz link do zdjęcia"
style={{ margin: 10, width: '100%', borderRadius:10}}
value={formData.image}
@@ -94,7 +111,8 @@ export default function FormScreen() {
mode={'contained'}
onPress={addLocation}
>Dodaj</Button>
</View>
</ScrollView>
</KeyboardAvoidingView>
);
}
@@ -102,7 +120,7 @@ const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#25292e',
justifyContent: 'center',
justifyContent: 'flex-start',
alignItems: 'center',
},
text: {

View File

@@ -5,7 +5,7 @@ import { locations } from '@/data/locations';
export default function Index() {
const theme = useTheme();
console.log(locations);
locations.sort((a, b) => b.id - a.id);
return (
<View style={[styles.container, {backgroundColor: theme.colors.background}]}>
<FlatList