import { View, Text, TouchableOpacity, Image, Button, ButtonSize, } from "react-native-ui-lib"; import React, { useState } from "react"; import { Dialog, PanningProvider, Card } from "react-native-ui-lib"; import { StyleSheet } from "react-native"; import { Feather, MaterialIcons } from "@expo/vector-icons"; import * as ImagePicker from "expo-image-picker"; interface IUploadDialogProps { show: boolean; setShow: (value: boolean) => void; } const UploadImageDialog = (uploadDialogProps: IUploadDialogProps) => { const [selectedImage, setSelectedImage] = useState(null); const [imageTitle, setImageTitle] = useState(null); const handleImagePick = async () => { const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync(); if (permissionResult.granted === false) { alert("Permission to access camera roll is required!"); return; } const result = await ImagePicker.launchImageLibraryAsync({ mediaTypes: ImagePicker.MediaTypeOptions.All, allowsEditing: true, aspect: [4, 3], quality: 1, }); // Check if the user canceled the image picker if (!result.canceled) { setSelectedImage(result.assets[0].uri); setImageTitle(result.assets[0].fileName || "Untitled"); } }; return ( uploadDialogProps.setShow(false)} panDirection={PanningProvider.Directions.DOWN} center > Upload an Image {!selectedImage && ( Click here to upload an image )} {selectedImage && ( <> {imageTitle} { setSelectedImage(null); setImageTitle(""); }} > ); }; export default UploadImageDialog; const styles = StyleSheet.create({ uploadImgBox: { backgroundColor: "#ffe8f2", width: "100%", aspectRatio: 1.8, borderRadius: 20, borderWidth: 2, borderColor: "#fd1775", borderStyle: "dashed", }, selectedImage: { width: 60, aspectRatio: 1, borderRadius: 10, }, imageContainer: { alignItems: "center", width: "80%", borderWidth: 1, borderColor: "#d9d9d9", padding: 10, borderRadius: 13, }, imageInfo: { marginLeft: 10, }, imageTitle: { fontSize: 16, color: "#333", }, });