diff --git a/App.tsx b/App.tsx index 69cec35..8dca9a5 100644 --- a/App.tsx +++ b/App.tsx @@ -31,7 +31,7 @@ import RequestAccepted from './src/components/Home/Request/RequestAccepted'; import AddCloset from './src/components/Closet/AddCloset'; import ClosetMain from './src/components/Closet/ClosetMain'; import { ClosetProvider } from './src/contexts/ClosetContext'; -import Calender from './src/components/Calender/Calender'; +import CalendarWithCloset from './src/components/Calendar/CalendarWithCloset'; import { Colors } from 'react-native/Libraries/NewAppScreen'; // 네비게이터 생성 @@ -52,8 +52,7 @@ function SeekerNavigator() { - - + ); diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index bb294f8..cce6157 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,9 @@ + + + { Setter - {/* 아이디 입력 및 중복 확인 */} + { - {/* 비밀번호 입력 및 검증 */} + { /> {passwordError ? {passwordError} : null} - {/* 성별 선택 */} + setGender(itemValue)} @@ -74,7 +74,7 @@ const SetterSignup = () => { - {/* 닉네임 입력 및 중복 확인 */} + { - {/* 키와 몸무게 입력 */} + { onChangeText={setWeight} /> - {/* 경력 입력 */} + { onChangeText={setExperience} /> - {/* 추가 입력 칸 */} + { onChangeText={setAdditionalInput} /> - {/* 다음 버튼 */} 다음 diff --git a/src/components/Calendar/CalendarWithCloset.tsx b/src/components/Calendar/CalendarWithCloset.tsx new file mode 100644 index 0000000..d541dd4 --- /dev/null +++ b/src/components/Calendar/CalendarWithCloset.tsx @@ -0,0 +1,222 @@ +import React, { useState } from 'react'; +import { View, Text, StyleSheet, Alert, Image, TouchableOpacity, Modal, ScrollView, Button } from 'react-native'; +import { Calendar } from 'react-native-calendars'; +import { launchImageLibrary } from 'react-native-image-picker'; + +const CalendarWithCloset = () => { + const [selectedMonth, setSelectedMonth] = useState('2024-11'); // 기본 달 + const [dateClothes, setDateClothes] = useState({}); // 날짜별 옷 데이터를 저장하는 상태 + const [selectedDate, setSelectedDate] = useState(null); // 선택된 날짜 + const [modalVisible, setModalVisible] = useState(false); // 모달 표시 여부 + + // 날짜에 옷 추가 + const addClothesToDate = (date) => { + launchImageLibrary({ mediaType: 'photo' }, (response) => { + if (response.didCancel) { + console.log('User cancelled image picker'); + } else if (response.errorCode) { + console.error('Image Picker Error: ', response.errorMessage); + Alert.alert('Error', 'Failed to select image.'); + } else if (response.assets && response.assets.length > 0) { + const selectedImageUri = response.assets[0].uri; + + setDateClothes((prev) => ({ + ...prev, + [date]: [...(prev[date] || []), selectedImageUri], + })); + Alert.alert('Success', 'Clothes added to the date.'); + } + }); + }; + + // 날짜에 옷 삭제 + const removeClothesFromDate = (date) => { + setDateClothes((prev) => { + const updatedClothes = { ...prev }; + delete updatedClothes[date]; // 해당 날짜 데이터 삭제 + return updatedClothes; + }); + Alert.alert('Success', 'All clothes removed from the date.'); + }; + + // 날짜를 눌렀을 때 동작 + const onDayPress = (day) => { + setSelectedDate(day.dateString); // 선택된 날짜 업데이트 + setModalVisible(true); // 모달 열기 + }; + + // 달 변경 핸들러 + const onMonthChange = (month) => { + const newMonth = `${month.year}-${String(month.month).padStart(2, '0')}`; + setSelectedMonth(newMonth); + }; + + // 날짜 렌더링 + const renderDay = ({ date }) => { + const clothes = dateClothes[date.dateString] || []; + + return ( + onDayPress(date)} style={styles.dayContainer}> + {date.day} + {clothes.slice(0, 1).map((item, index) => ( + + ))} + + ); + }; + + return ( + + {selectedMonth} Calendar + renderDay(props)} + style={styles.calendar} + theme={{ + arrowColor: 'black', + monthTextColor: 'black', + textDayFontWeight: '300', + textMonthFontWeight: 'bold', + todayTextColor: 'red', + }} + /> + setModalVisible(false)}> + + Options for {selectedDate} + + {selectedDate && dateClothes[selectedDate] ? ( + <> + Current Clothes + + {dateClothes[selectedDate].map((item, index) => ( + + ))} + + addClothesToDate(selectedDate)} + > + Add More Clothes + + { + removeClothesFromDate(selectedDate); + setModalVisible(false); // 모달 닫기 + }} + > + Remove All Clothes + + + ) : ( + <> + No clothes added yet. + addClothesToDate(selectedDate)} + > + Add Clothes + + + )} + + setModalVisible(false)} + > + Close + + + + + ); +}; + +const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 10, + backgroundColor: '#fff', + }, + header: { + fontSize: 24, + fontWeight: 'bold', + textAlign: 'center', + marginBottom: 10, + }, + calendar: { + borderRadius: 10, + marginBottom: 20, + }, + dayContainer: { + alignItems: 'center', + justifyContent: 'center', + width: 50, + height: 70, + }, + dayText: { + fontSize: 14, + color: '#333', + }, + clothesImage: { + width: 30, + height: 30, + resizeMode: 'contain', + marginTop: 4, + }, + modalContainer: { + flex: 1, + backgroundColor: '#fff', + padding: 20, + }, + modalHeader: { + fontSize: 20, + fontWeight: 'bold', + marginBottom: 10, + textAlign: 'center', + }, + scrollView: { + alignItems: 'center', + paddingBottom: 20, + }, + clothesTitle: { + fontSize: 18, + fontWeight: 'bold', + marginBottom: 10, + textAlign: 'center', + }, + clothesContainer: { + flexDirection: 'row', + flexWrap: 'wrap', + justifyContent: 'center', + marginBottom: 20, + }, + modalClothesImage: { + width: 80, + height: 80, + margin: 5, + borderRadius: 5, + }, + modalButton: { + padding: 15, + borderRadius: 5, + alignItems: 'center', + marginBottom: 10, + width: '100%', + }, + modalButtonText: { + color: '#fff', + fontSize: 16, + fontWeight: 'bold', + }, + noClothesText: { + fontSize: 16, + color: '#333', + textAlign: 'center', + marginVertical: 20, + }, +}); + +export default CalendarWithCloset; diff --git a/src/components/Calender/Calender.tsx b/src/components/Calender/Calender.tsx deleted file mode 100644 index 5b13e7d..0000000 --- a/src/components/Calender/Calender.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import React, { useState } from 'react'; -import { View, Text, StyleSheet } from 'react-native'; -import { Calendar } from 'react-native-calendars'; - -const Calender = () => { - const [selectedMonth, setSelectedMonth] = useState('2023-12'); - - // Render only the day number without any images - const renderDay = (day) => { - return ( - - {day.day} - - ); - }; - - // Handle month change - const onMonthChange = (month) => { - const newMonth = `${month.year}-${String(month.month).padStart(2, '0')}`; - setSelectedMonth(newMonth); - }; - - return ( - - {selectedMonth} Calendar - - console.log('Selected day', day)} - onMonthChange={onMonthChange} - dayComponent={({ date }) => renderDay(date)} - style={styles.calendar} - theme={{ - arrowColor: 'black', - monthTextColor: 'black', - textDayFontWeight: '300', - textMonthFontWeight: 'bold', - todayTextColor: 'red', - }} - /> - - ); -}; - -const styles = StyleSheet.create({ - container: { - flex: 1, - padding: 10, - backgroundColor: '#fff', - }, - header: { - fontSize: 24, - fontWeight: 'bold', - textAlign: 'center', - marginBottom: 10, - }, - calendar: { - borderRadius: 10, - marginBottom: 20, - }, - dayContainer: { - alignItems: 'center', - justifyContent: 'center', - width: 50, - height: 50, - }, - dayText: { - fontSize: 14, - color: '#333', - }, -}); - -export default Calender; diff --git a/src/components/Home/Main/SeekerMainPage.tsx b/src/components/Home/Main/SeekerMainPage.tsx index d4d8fd4..96a171c 100644 --- a/src/components/Home/Main/SeekerMainPage.tsx +++ b/src/components/Home/Main/SeekerMainPage.tsx @@ -45,7 +45,7 @@ const SeekerMainPage = () => { navigation.navigate('Calender')} + onPress={() => navigation.navigate('CalendarWithCloset')} > 캘린더 @@ -53,15 +53,6 @@ const SeekerMainPage = () => { - - - navigation.navigate('RequestSent')} - > - REQUEST SENT - - ); }; @@ -125,20 +116,6 @@ const styles = StyleSheet.create({ color: '#333', marginLeft: 8, }, - singleButton: { - backgroundColor: '#e0e0e0', - padding: 15, - borderRadius: 10, - alignItems: 'center', // 텍스트를 버튼의 중앙에 배치 - justifyContent: 'center', // 텍스트를 버튼의 중앙에 배치 - width: '80%', // 원하는 버튼 크기 조정 - }, - singleButtonText: { - fontSize: 16, - fontWeight: 'bold', - color: '#333', - textAlign: 'center', // 텍스트 중앙 정렬 - }, }); export default SeekerMainPage; diff --git a/src/components/Home/Request/RequestPage.tsx b/src/components/Home/Request/RequestPage.tsx index f1c4d44..b9a3b89 100644 --- a/src/components/Home/Request/RequestPage.tsx +++ b/src/components/Home/Request/RequestPage.tsx @@ -34,9 +34,6 @@ useEffect(() => { Request Confirmation - - - {clothes.length > 0 && ( <> Selected Clothes @@ -188,7 +185,7 @@ useEffect(() => { - + );