merge
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { Chantier } from '@/class/class';
|
||||
import { ThemedView } from '@/components/theme/themed-view';
|
||||
import React, { use, useState } from 'react';
|
||||
import { TouchableOpacity, StyleProp, StyleSheet, View, ViewStyle,Text, TextInput } from 'react-native';
|
||||
import { TouchableOpacity, StyleProp, StyleSheet, View, Image, ViewStyle,Text, TextInput } from 'react-native';
|
||||
import { ThemedText } from './theme/themed-text';
|
||||
import { deleteAnomalie, addAnomalie, getChantiers } from '@/services/ressourcesService';
|
||||
import { useChantier } from '@/app/ContextChantier';
|
||||
import * as ImagePicker from 'expo-image-picker';
|
||||
|
||||
type Props = {
|
||||
data: {
|
||||
@@ -16,6 +17,7 @@ type Props = {
|
||||
export default function Anomaly({data,style}: Props) {
|
||||
|
||||
const{syncChantier }= useChantier();
|
||||
const [imageUri, setImageUri] = useState<string | null>(null);
|
||||
|
||||
const handleDelete = async (anomaly: string) => {
|
||||
await deleteAnomalie(data.chantier!.id, anomaly);
|
||||
@@ -31,6 +33,22 @@ export default function Anomaly({data,style}: Props) {
|
||||
await syncChantier();
|
||||
};
|
||||
|
||||
// Image picker function (not used currently)
|
||||
const selectImage = async () => {
|
||||
let result = await ImagePicker.launchImageLibraryAsync({
|
||||
mediaTypes: ['images'],
|
||||
allowsEditing: true,
|
||||
quality: 1,
|
||||
});
|
||||
|
||||
if (!result.canceled) {
|
||||
console.log(result);
|
||||
} else {
|
||||
alert('You did not select any image.');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const [newAnomaly, setNewAnomaly] = useState("");
|
||||
|
||||
return(
|
||||
@@ -56,6 +74,12 @@ export default function Anomaly({data,style}: Props) {
|
||||
<TouchableOpacity style={styles.addButton} onPress={handleAdd}>
|
||||
<Text style={styles.addButtonText}>Ajouter</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity onPress={selectImage} style={styles.addButton}>
|
||||
<Text style={styles.addButton}>Choisir une image</Text>
|
||||
</TouchableOpacity>
|
||||
{imageUri && (
|
||||
<Image source={{ uri: imageUri }} style={styles.image} />
|
||||
)}
|
||||
</View>
|
||||
</ThemedView>
|
||||
): null}
|
||||
@@ -120,5 +144,6 @@ const styles = StyleSheet.create({
|
||||
addButtonText: {
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}
|
||||
},
|
||||
image: { width: 200, height: 200, borderRadius: 10 }
|
||||
})
|
||||
Reference in New Issue
Block a user