few cosmetic fixes
This commit is contained in:
@@ -6,10 +6,12 @@ import {
|
||||
KeyboardAvoidingView,
|
||||
View,
|
||||
ActivityIndicator,
|
||||
Image,
|
||||
} from "react-native";
|
||||
import {TextInput, Button, Snackbar, useTheme} from "react-native-paper";
|
||||
import {TextInput, Button, Snackbar, useTheme, Text} from "react-native-paper";
|
||||
import {useLocalSearchParams, useRouter} from "expo-router";
|
||||
import useLocationStore from "@/locationStore";
|
||||
import {normalizeImageSource} from "@/api/locations";
|
||||
|
||||
export default function EditLocation() {
|
||||
const theme = useTheme();
|
||||
@@ -89,6 +91,16 @@ export default function EditLocation() {
|
||||
}
|
||||
};
|
||||
|
||||
const isBase64Image = (str) => {
|
||||
let image = normalizeImageSource(str);
|
||||
return image && (
|
||||
image.uri.startsWith('data:image/jpeg;base64,') ||
|
||||
image.uri.startsWith('data:image/png;base64,') ||
|
||||
image.uri.startsWith('data:image/gif;base64,') ||
|
||||
image.uri.startsWith('data:image/webp;base64,')
|
||||
);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<View
|
||||
@@ -99,6 +111,14 @@ export default function EditLocation() {
|
||||
);
|
||||
}
|
||||
|
||||
if (!formData) {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.text}>Brak lokalizacji - {id}</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<KeyboardAvoidingView
|
||||
style={{flex: 1}}
|
||||
@@ -112,6 +132,30 @@ export default function EditLocation() {
|
||||
>
|
||||
{message}
|
||||
</Snackbar>
|
||||
|
||||
{isBase64Image(formData.image) ? (
|
||||
<View style={styles.imageContainer}>
|
||||
<Text style={{color: theme.colors.onBackground, marginBottom: 5}}>
|
||||
Aktualne zdjęcie:
|
||||
</Text>
|
||||
<Image
|
||||
source={normalizeImageSource(formData.image)}
|
||||
style={styles.imagePreview}
|
||||
resizeMode="contain"
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
<TextInput
|
||||
mode="outlined"
|
||||
label="Link do zdjęcia"
|
||||
multiline={true}
|
||||
placeholder="Wpisz link do zdjęcia"
|
||||
style={{margin: 10, width: "100%"}}
|
||||
value={formData.image}
|
||||
onChangeText={(e) => setFormData({...formData, image: e})}
|
||||
/>
|
||||
)}
|
||||
|
||||
<TextInput
|
||||
mode="outlined"
|
||||
label="Nazwa"
|
||||
@@ -129,15 +173,6 @@ export default function EditLocation() {
|
||||
value={formData.description}
|
||||
onChangeText={(e) => setFormData({...formData, description: e})}
|
||||
/>
|
||||
<TextInput
|
||||
mode="outlined"
|
||||
label="Link do zdjęcia"
|
||||
multiline={true}
|
||||
placeholder="Wpisz link do zdjęcia"
|
||||
style={{margin: 10, width: "100%"}}
|
||||
value={formData.image}
|
||||
onChangeText={(e) => setFormData({...formData, image: e})}
|
||||
/>
|
||||
<TextInput
|
||||
mode="outlined"
|
||||
label="Powierzchnia"
|
||||
@@ -194,4 +229,15 @@ const styles = StyleSheet.create({
|
||||
alignItems: "center",
|
||||
flexGrow: 1,
|
||||
},
|
||||
imageContainer: {
|
||||
margin: 10,
|
||||
width: "100%",
|
||||
alignItems: "center",
|
||||
padding: 10,
|
||||
},
|
||||
imagePreview: {
|
||||
width: "100%",
|
||||
height: 200,
|
||||
borderRadius: 5,
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user