import React, { useEffect, useState } from 'react'; import { View, Text, TouchableOpacity, Platform, KeyboardAvoidingView, ScrollView, Image } from 'react-native'; import { Button, Input, Modal, FlatList as List } from 'src/components'; import RangeCalendar from 'src/components/Calendars/RangeCalendar'; import { ButtonVariants } from 'src/types/components'; import { AllRegions, PhotosData } from '../utils/types'; import { getImageUri } from '../utils'; import { styles } from './styles'; import ChevronIcon from '../../../../../assets/icons/travels-screens/chevron-bottom.svg'; import CalendarSvg from '../../../../../assets/icons/calendar.svg'; export const PhotoEditModal = ({ isVisible, onClose, photo, allRegions, handleUpdate, description, setDescription, selectedDate, setSelectedDate, selectedRegion, setSelectedRegion }: { isVisible: boolean; onClose: () => void; photo: PhotosData; allRegions: AllRegions[]; handleUpdate: () => void; description: string | null; setDescription: (text: string) => void; selectedDate: string | null; setSelectedDate: (date: string) => void; selectedRegion: AllRegions | null; setSelectedRegion: (region: any) => void; }) => { const [imgAspectRatio, setImgAspectRatio] = useState(0); const [isRegionsModalVisible, setIsRegionsModalVisible] = useState(false); const [calendarVisible, setCalendarVisible] = useState(false); useEffect(() => { if (photo) { const uri = getImageUri(photo.url_mid); Image.getSize( uri, (width, height) => { const aspectRatio = width / height; setImgAspectRatio(aspectRatio); }, (error) => { console.error(`Couldn't get the image size: ${error}`); } ); } }, [photo]); return ( setDescription(text)} value={description ?? photo?.title} /> setIsRegionsModalVisible(true)} > {selectedRegion?.country ?? allRegions.find((region: AllRegions) => region.id === photo?.region)?.country} setCalendarVisible(true)} > {selectedDate ?? photo?.date} { date && setSelectedDate(date.toISOString().split('T')[0]); setCalendarVisible(false); }} allowRangeSelection={false} />