Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#91 (#91) #94

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
273 changes: 273 additions & 0 deletions app/child/training/choice.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
import React, { useState } from 'react';
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { globalStyles } from '../../../styles/global';
import { useRouter } from 'expo-router';

const Button = ({ title, onPress, disabled }) => (
<View style={styles.buttonContainer}>
<TouchableOpacity
onPress={onPress}
style={[styles.button, disabled && styles.buttonDisabled]}
disabled={disabled}
>
<Text style={styles.buttonText}>
{title}
</Text>
</TouchableOpacity>
</View>
);

const LearningMethod = () => {
const [currentQuestion, setCurrentQuestion] = useState(0);
const [selectedOption, setSelectedOption] = useState(null);
const router = useRouter();

const questions = [
{
question: "μ² μˆ˜μ™€ μ˜ν¬κ°€ λ‚΄ μ•žμ— μžˆλ‹€.\n인사λ₯Ό ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: 인사해야 ν•œλ‹€.",
"μ˜΅μ…˜ 2: μΈμ‚¬ν•˜μ§€ μ•Šμ•„λ„ λœλ‹€.",
"μ˜΅μ…˜ 3: 상황에 따라 λ‹€λ₯΄λ‹€.",
"μ˜΅μ…˜ 4: 더 생각해봐야 ν•œλ‹€.",
],
},
{
question: "곡곡μž₯μ†Œμ—μ„œλŠ” \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: 떠듀지 μ•ŠλŠ”λ‹€.",
"μ˜΅μ…˜ 2: μŒμ•…μ„ 크게 λ“£λŠ”λ‹€.",
"μ˜΅μ…˜ 3: μΉœκ΅¬μ™€ μž₯λ‚œμΉœλ‹€.",
"μ˜΅μ…˜ 4: 전화톡화λ₯Ό ν•œλ‹€.",
],
},
{
question: "λ™λ£Œκ°€ μ‹€μˆ˜λ₯Ό ν–ˆλ‹€λ©΄ \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: λΉ„λ‚œν•œλ‹€.",
"μ˜΅μ…˜ 2: ν•¨κ»˜ ν•΄κ²°ν•œλ‹€.",
"μ˜΅μ…˜ 3: λ¬΄μ‹œν•œλ‹€.",
"μ˜΅μ…˜ 4: μƒμ‚¬μ—κ²Œ λ°”λ‘œ λ³΄κ³ ν•œλ‹€.",
],
},
{
question: "λ²„μŠ€μ—μ„œ μžλ¦¬κ°€ μ—†λ‹€λ©΄ \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: μ„œμ„œ κ°„λ‹€.",
"μ˜΅μ…˜ 2: μ–΅μ§€λ‘œ 자리λ₯Ό λ§Œλ“ λ‹€.",
"μ˜΅μ…˜ 3: λ‹€λ₯Έ μ‚¬λžŒμ—κ²Œ 자리λ₯Ό μ–‘λ³΄ν•œλ‹€.",
"μ˜΅μ…˜ 4: κΈ°μ‚¬λ‹˜κ»˜ ν•­μ˜ν•œλ‹€.",
],
},
{
question: "μΉœκ΅¬κ°€ μŠ¬νΌν•˜κ³  μžˆλ‹€λ©΄ \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: λ¬΄κ΄€μ‹¬ν•˜κ²Œ λ³Έλ‹€.",
"μ˜΅μ…˜ 2: μœ„λ‘œν•΄μ€€λ‹€.",
"μ˜΅μ…˜ 3: ν•¨κ»˜ μšΈμ–΄μ€€λ‹€.",
"μ˜΅μ…˜ 4: λͺ¨λ₯Έ μ²™ν•œλ‹€.",
],
},
{
question: "μ‹œν—˜ μ€€λΉ„λ₯Ό \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: 미리 κ³„νšμ„ μ„Έμš΄λ‹€.",
"μ˜΅μ…˜ 2: 벼락치기 곡뢀λ₯Ό ν•œλ‹€.",
"μ˜΅μ…˜ 3: κ³΅λΆ€ν•˜μ§€ μ•ŠλŠ”λ‹€.",
"μ˜΅μ…˜ 4: μΉœκ΅¬μ—κ²Œ 맑긴닀.",
],
},
{
question: "길을 μžƒμ—ˆμ„ λ•ŒλŠ” \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: κ²½μ°°μ—κ²Œ 도움을 μš”μ²­ν•œλ‹€.",
"μ˜΅μ…˜ 2: 계속 κ±Έμ–΄λ‹€λ‹Œλ‹€.",
"μ˜΅μ…˜ 3: ν°μ†Œλ¦¬λ‘œ μ™ΈμΉœλ‹€.",
"μ˜΅μ…˜ 4: 울고만 μžˆλŠ”λ‹€.",
],
},
{
question: "동생이 잘λͺ»μ„ ν–ˆλ‹€λ©΄ \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: ν˜Όμ„ λ‚Έλ‹€.",
"μ˜΅μ…˜ 2: 이유λ₯Ό λ¬Όμ–΄λ³Έλ‹€.",
"μ˜΅μ…˜ 3: κ·Έλƒ₯ λ„˜μ–΄κ°„λ‹€.",
"μ˜΅μ…˜ 4: λΆ€λͺ¨λ‹˜κ»˜ λ§ν•œλ‹€.",
],
},
{
question: "μΉœκ΅¬κ°€ 거짓말을 ν•˜λ©΄ \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: μ™œ 거짓말을 ν–ˆλŠ”μ§€ λ¬»λŠ”λ‹€.",
"μ˜΅μ…˜ 2: ν™”λ₯Ό λ‚Έλ‹€.",
"μ˜΅μ…˜ 3: 관계λ₯Ό λŠλŠ”λ‹€.",
"μ˜΅μ…˜ 4: μš©μ„œν•œλ‹€.",
],
},
{
question: "λ‹€λ₯Έ μ‚¬λžŒμ΄ 도움을 μš”μ²­ν•˜λ©΄ \nμ–΄λ–»κ²Œ ν•΄μ•Ό ν• κΉŒ?",
options: [
"μ˜΅μ…˜ 1: 도와쀀닀.",
"μ˜΅μ…˜ 2: λͺ¨λ₯Έ μ²™ν•œλ‹€.",
"μ˜΅μ…˜ 3: 쑰건을 건닀.",
"μ˜΅μ…˜ 4: κ³ λ―Όν•œλ‹€.",
],
},
];

const handleOptionSelect = (index) => {
setSelectedOption(index);
console.log(`Option ${index + 1} selected: ${questions[currentQuestion].options[index]}`);
};

const handleNextClick = () => {
if (currentQuestion < questions.length - 1) {
setCurrentQuestion((prev) => prev + 1);
setSelectedOption(null);
} else {
router.push('/child/training/choicecontent');
}
};

return (
<View style={[globalStyles.container, { flex: 1 }]}>
<View style={styles.progressBarContainer}>
<View style={styles.progressBar}>
<View
style={[
styles.progress,
{ width: `${((currentQuestion + 1) / questions.length) * 100}%` },
]}
/>
</View>
</View>

<View style={[globalStyles.container, { backgroundColor: '#F3F4F6', flex: 1 }]}>
<View style={styles.header}>
<Text style={[globalStyles.subtitle, styles.pretendardFont]}>
{currentQuestion + 1}/{questions.length}
</Text>
<Text style={[globalStyles.description, styles.pretendardFont]}>
{currentQuestion + 1}번 λ¬Έν•­μ΄μ—μš”.
</Text>
</View>

<Text style={[styles.question, styles.pretendardFont]}>
{questions[currentQuestion].question}
</Text>

{questions[currentQuestion].options.map((option, index) => (
<TouchableOpacity
key={index}
style={[
styles.choiceBox,
selectedOption === index && styles.choiceBoxSelected,
]}
onPress={() => handleOptionSelect(index)}
>
<Text
style={[
styles.choiceText,
styles.pretendardFont,
selectedOption === index && styles.choiceTextSelected,
]}
>
{option}
</Text>
</TouchableOpacity>
))}

<View style={styles.buttonContainer}>
<Button
title="λ‹€μŒμœΌλ‘œ"
onPress={handleNextClick}
disabled={selectedOption === null} // μ˜΅μ…˜μ„ μ„ νƒν•˜μ§€ μ•Šμ•˜μ„ λ•Œ λΉ„ν™œμ„±ν™”
/>
</View>
</View>
</View>
);
};

const styles = StyleSheet.create({
progressBarContainer: {
alignItems: 'center',
marginTop: 50,
},
progressBar: {
width: 330,
height: 10,
backgroundColor: '#E0E0E0',
borderRadius: 5,
},
progress: {
height: '100%',
backgroundColor: '#5772FF',
borderRadius: 5,
},
header: {
marginTop: -40,
marginLeft: 15,
},
question: {
fontSize: 24,
textAlign: 'center',
marginBottom: 80,
marginTop: 140,
fontWeight: '700',
fontFamily: 'Pretendard',
},
choiceBox: {
borderWidth: 3,
borderColor: '#5772FF',
backgroundColor: '#FFFFFF',
padding: 19,
borderRadius: 10,
marginVertical: 5,
width: 320,
height: 56,
alignSelf: 'center',
justifyContent: 'center',
},
choiceBoxSelected: {
backgroundColor: '#5772FF',
},
choiceText: {
color: '#5772FF',
textAlign: 'center',
fontSize: 15,
fontFamily: 'Pretendard',
},
choiceTextSelected: {
color: '#FFFFFF',
},
buttonContainer: {
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
},
button: {
width: 310,
height: 50,
backgroundColor: '#5772FF',
borderRadius: 8,
justifyContent: 'center',
alignItems: 'center',
marginBottom: -180,
},
buttonDisabled: {
backgroundColor: '#B0B0B0',
},
buttonText: {
color: '#FFFFFF',
fontSize: 18,
fontFamily: 'Pretendard',
fontWeight: '600',
},
pretendardFont: {
fontFamily: 'Pretendard',
},
});

export default LearningMethod;