Skip to content

Commit

Permalink
전체적 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
doyoom committed Nov 16, 2024
1 parent 83b4ee7 commit 33c0028
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 112 deletions.
5 changes: 2 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

// 네비게이터 생성
Expand All @@ -52,8 +52,7 @@ function SeekerNavigator() {
<Stack.Screen name="InitialLogin" component={InitialLogin} />
<Stack.Screen name="AddCloset" component={AddCloset} />
<Stack.Screen name="ClosetMain" component={ClosetMain} />
<Stack.Screen name="Calender" component={Calender} />

<Stack.Screen name="CalendarWithCloset" component={CalendarWithCloset} />
</Stack.Navigator>

);
Expand Down
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />

<application
android:name=".MainApplication"
Expand Down
15 changes: 7 additions & 8 deletions src/components/Auth/SetterSignup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const SetterSignup = () => {
<View style={styles.container}>
<Text style={styles.header}>Setter</Text>

{/* 아이디 입력 및 중복 확인 */}

<View style={styles.row}>
<TextInput
style={styles.input}
Expand All @@ -50,7 +50,7 @@ const SetterSignup = () => {
</TouchableOpacity>
</View>

{/* 비밀번호 입력 및 검증 */}

<TextInput
style={[styles.input, passwordError && styles.errorInput]}
placeholder="비밀번호 (영문, 숫자 혼합 8자 이상)"
Expand All @@ -63,7 +63,7 @@ const SetterSignup = () => {
/>
{passwordError ? <Text style={styles.errorText}>{passwordError}</Text> : null}

{/* 성별 선택 */}

<Picker
selectedValue={gender}
onValueChange={(itemValue) => setGender(itemValue)}
Expand All @@ -74,7 +74,7 @@ const SetterSignup = () => {
<Picker.Item label="선택안함" value="선택안함" />
</Picker>

{/* 닉네임 입력 및 중복 확인 */}

<View style={styles.row}>
<TextInput
style={styles.input}
Expand All @@ -87,7 +87,7 @@ const SetterSignup = () => {
</TouchableOpacity>
</View>

{/* 키와 몸무게 입력 */}

<TextInput
style={styles.input}
placeholder="키 (cm)"
Expand All @@ -103,7 +103,7 @@ const SetterSignup = () => {
onChangeText={setWeight}
/>

{/* 경력 입력 */}

<TextInput
style={styles.input}
placeholder="경력 (연수)"
Expand All @@ -112,15 +112,14 @@ const SetterSignup = () => {
onChangeText={setExperience}
/>

{/* 추가 입력 칸 */}

<TextInput
style={styles.input}
placeholder="기타 입력 (선택 사항)"
value={additionalInput}
onChangeText={setAdditionalInput}
/>

{/* 다음 버튼 */}
<TouchableOpacity style={styles.nextButton}>
<Text style={styles.nextButtonText}>다음</Text>
</TouchableOpacity>
Expand Down
222 changes: 222 additions & 0 deletions src/components/Calendar/CalendarWithCloset.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<TouchableOpacity onPress={() => onDayPress(date)} style={styles.dayContainer}>
<Text style={styles.dayText}>{date.day}</Text>
{clothes.slice(0, 1).map((item, index) => (
<Image key={index} source={{ uri: item }} style={styles.clothesImage} />
))}
</TouchableOpacity>
);
};

return (
<View style={styles.container}>
<Text style={styles.header}>{selectedMonth} Calendar</Text>
<Calendar
current={selectedMonth}
onDayPress={onDayPress}
onMonthChange={onMonthChange}
dayComponent={(props) => renderDay(props)}
style={styles.calendar}
theme={{
arrowColor: 'black',
monthTextColor: 'black',
textDayFontWeight: '300',
textMonthFontWeight: 'bold',
todayTextColor: 'red',
}}
/>
<Modal visible={modalVisible} animationType="slide" onRequestClose={() => setModalVisible(false)}>
<View style={styles.modalContainer}>
<Text style={styles.modalHeader}>Options for {selectedDate}</Text>
<ScrollView contentContainerStyle={styles.scrollView}>
{selectedDate && dateClothes[selectedDate] ? (
<>
<Text style={styles.clothesTitle}>Current Clothes</Text>
<View style={styles.clothesContainer}>
{dateClothes[selectedDate].map((item, index) => (
<Image key={index} source={{ uri: item }} style={styles.modalClothesImage} />
))}
</View>
<TouchableOpacity
style={[styles.modalButton, { backgroundColor: '#32CD32' }]}
onPress={() => addClothesToDate(selectedDate)}
>
<Text style={styles.modalButtonText}>Add More Clothes</Text>
</TouchableOpacity>
<TouchableOpacity
style={[styles.modalButton, { backgroundColor: '#FF6347' }]}
onPress={() => {
removeClothesFromDate(selectedDate);
setModalVisible(false); // 모달 닫기
}}
>
<Text style={styles.modalButtonText}>Remove All Clothes</Text>
</TouchableOpacity>
</>
) : (
<>
<Text style={styles.noClothesText}>No clothes added yet.</Text>
<TouchableOpacity
style={[styles.modalButton, { backgroundColor: '#32CD32' }]}
onPress={() => addClothesToDate(selectedDate)}
>
<Text style={styles.modalButtonText}>Add Clothes</Text>
</TouchableOpacity>
</>
)}
</ScrollView>
<TouchableOpacity
style={[styles.modalButton, { backgroundColor: '#808080' }]}
onPress={() => setModalVisible(false)}
>
<Text style={styles.modalButtonText}>Close</Text>
</TouchableOpacity>
</View>
</Modal>
</View>
);
};

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;
73 changes: 0 additions & 73 deletions src/components/Calender/Calender.tsx

This file was deleted.

Loading

0 comments on commit 33c0028

Please sign in to comment.