From ba5fafe7e2be1108d4abba7e37f85b599df3633e Mon Sep 17 00:00:00 2001 From: bae129 Date: Sat, 14 Nov 2026 13:03:15 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20Chip=20muted=20=EC=98=B5=EC=85=98?= =?UTF-8?q?=EA=B3=BC=20ProgressBar=20stretch=20=EC=98=B5=EC=85=98=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Chip.tsx | 14 +++++++++++--- src/components/ProgressBar.tsx | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/components/Chip.tsx b/src/components/Chip.tsx index f395787..5f53128 100644 --- a/src/components/Chip.tsx +++ b/src/components/Chip.tsx @@ -8,6 +8,7 @@ const colors = { background: semantic.surface.default, border: semantic.border.default, text: semantic.text.default.normal, + mutedText: semantic.text.default.weak, selectedBackground: semantic.action.default, selectedBorder: semantic.border.focused, selectedText: semantic.text.default.inverse, @@ -16,14 +17,16 @@ const colors = { export type ChipProps = Omit & { label: string; selected?: boolean; + /** true면 선택되지 않았을 때 글자를 연한 색(text/default/weak)으로 보여 줍니다. */ + muted?: boolean; }; /** 둥근 선택 칩. 너비는 글자 길이에 맞춰집니다. */ -export function Chip({ label, selected = false, ...props }: ChipProps) { +export function Chip({ label, selected = false, muted = false, ...props }: ChipProps) { return ( - + {label} diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx index ccf0b78..74dc5c7 100644 --- a/src/components/ProgressBar.tsx +++ b/src/components/ProgressBar.tsx @@ -1,6 +1,6 @@ import { StyleSheet, Text, View } from 'react-native'; import { semantic } from '@/styles/colors'; -import { gap, radius } from '@/styles/measurement'; +import { gap, padding, radius } from '@/styles/measurement'; import { fontSize, fontWeight, letterSpacing, lineHeight } from '@/styles/typography'; const SEGMENT_WIDTH = 54; @@ -13,9 +13,11 @@ export type ProgressBarProps = { total: number; /** 막대 아래 `step/total` 표시 여부 */ showLabel?: boolean; + /** true면 막대가 부모 너비를 꽉 채우고 칸 너비를 나눠 가집니다. */ + stretch?: boolean; }; -export function ProgressBar({ step, total, showLabel = true }: ProgressBarProps) { +export function ProgressBar({ step, total, showLabel = true, stretch = false }: ProgressBarProps) { const current = Math.min(Math.max(step, 0), total); return ( @@ -25,11 +27,14 @@ export function ProgressBar({ step, total, showLabel = true }: ProgressBarProps) aria-valuemax={total} aria-valuenow={current} aria-valuetext={`${current}/${total}`} - style={s.root} + style={[s.root, stretch && s.rootStretch]} > - + {Array.from({ length: total }, (_, i) => ( - + ))} {showLabel ? ( @@ -43,13 +48,16 @@ export function ProgressBar({ step, total, showLabel = true }: ProgressBarProps) const s = StyleSheet.create({ root: { alignItems: 'center', gap: gap[12] }, + rootStretch: { alignSelf: 'stretch', paddingVertical: padding[4] }, track: { flexDirection: 'row', gap: gap[2] }, + trackStretch: { alignSelf: 'stretch', paddingHorizontal: padding[4] }, segment: { width: SEGMENT_WIDTH, height: SEGMENT_HEIGHT, borderRadius: radius.small, backgroundColor: semantic.surface.disabled, }, + segmentStretch: { flex: 1, width: undefined }, segmentFilled: { backgroundColor: semantic.icon.brand }, label: { fontSize: fontSize[12], From 634e7e7c6e720344f940b108c345d9b5eae47341 Mon Sep 17 00:00:00 2001 From: bae129 Date: Sat, 14 Nov 2026 13:03:24 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=EA=B3=BC=EC=99=B8=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20=ED=95=99=EC=83=9D=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EA=B5=AC=ED=98=84=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/images/arrow_back.svg | 5 + src/app/tutoring/student.tsx | 5 + src/features/tutoring/StudentInfoScreen.tsx | 178 ++++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 assets/images/arrow_back.svg create mode 100644 src/app/tutoring/student.tsx create mode 100644 src/features/tutoring/StudentInfoScreen.tsx diff --git a/assets/images/arrow_back.svg b/assets/images/arrow_back.svg new file mode 100644 index 0000000..d183be3 --- /dev/null +++ b/assets/images/arrow_back.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/app/tutoring/student.tsx b/src/app/tutoring/student.tsx new file mode 100644 index 0000000..47d1873 --- /dev/null +++ b/src/app/tutoring/student.tsx @@ -0,0 +1,5 @@ +import { StudentInfoScreen } from '@/features/tutoring/StudentInfoScreen'; + +export default function Screen() { + return ; +} diff --git a/src/features/tutoring/StudentInfoScreen.tsx b/src/features/tutoring/StudentInfoScreen.tsx new file mode 100644 index 0000000..b2a1b97 --- /dev/null +++ b/src/features/tutoring/StudentInfoScreen.tsx @@ -0,0 +1,178 @@ +import arrowBackImage from '../../../assets/images/arrow_back.svg'; +import { useState } from 'react'; +import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'; +import { Image } from 'expo-image'; +import { router } from 'expo-router'; +import { SafeAreaView } from 'react-native-safe-area-context'; +import { ActionButton } from '@/components/ActionButton'; +import { Chip } from '@/components/Chip'; +import { ProgressBar } from '@/components/ProgressBar'; +import { TextInput } from '@/components/TextInput'; +import { semantic } from '@/styles/colors'; +import { gap, padding, radius } from '@/styles/measurement'; +import { typography } from '@/styles/typography'; + +const GRADES = ['초6', '중1', '중2', '중3', '고1', '고2', '고3', '기타'] as const; +const SUBJECTS = ['국어', '영어', '수학', '과학', '사회', '기타'] as const; + +type Grade = (typeof GRADES)[number]; +type Subject = (typeof SUBJECTS)[number]; + +const STEP = 2; +const TOTAL_STEPS = 5; + +function FieldLabel({ label, hint }: { label: string; hint?: string }) { + return ( + + {label} + * + {hint ? ` ${hint}` : null} + + ); +} + +/** T-05 과외 만들기 · 학생 정보 (2/5 단계) */ +export function StudentInfoScreen() { + const [name, setName] = useState(''); + const [grade, setGrade] = useState(null); + const [subjects, setSubjects] = useState([]); + + const toggleSubject = (subject: Subject) => + setSubjects((prev) => + prev.includes(subject) ? prev.filter((v) => v !== subject) : [...prev, subject], + ); + + const canProceed = name.trim().length > 0 && grade !== null && subjects.length > 0; + + const back = () => { + if (router.canGoBack()) router.back(); + else router.replace('/home'); + }; + + return ( + + + + + + + 과외 만들기 + + + + + + + + + 지난 과외 계좌를 불러왔어요. + + + + + + + + + + + + + + + + {GRADES.map((g) => ( + setGrade(g)} + /> + ))} + + + + + + + + + {SUBJECTS.map((subject) => ( + toggleSubject(subject)} + /> + ))} + + + + + + + + + + ); +} + +const s = StyleSheet.create({ + safe: { flex: 1, backgroundColor: semantic.surface.input }, + navBar: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + paddingHorizontal: padding[24], + paddingVertical: padding[12], + }, + icon: { width: 24, height: 24 }, + title: { + ...typography.body[1].bold, + textAlign: 'center', + color: semantic.text.default.strong, + }, + content: { + paddingHorizontal: padding[24], + gap: gap[8], + }, + inlineMessage: { + flexDirection: 'row', + alignItems: 'center', + gap: gap[4], + paddingHorizontal: padding[12], + paddingVertical: padding[8], + borderRadius: radius.small, + backgroundColor: semantic.surface.focused, + }, + inlineMessageText: { + ...typography.caption[1].medium, + color: semantic.text.brand.assistive, + }, + form: { paddingVertical: padding[12], gap: gap[20] }, + nameField: { gap: gap[8] }, + nameLabel: { paddingHorizontal: padding[8] }, + selectField: { paddingVertical: padding[8], gap: gap[8] }, + selectLabel: { paddingHorizontal: gap[4] }, + fieldLabel: { + ...typography.body[5].semiBold, + color: semantic.text.default.neutral, + }, + required: { color: semantic.text.brand.assistive }, + chips: { flexDirection: 'row', flexWrap: 'wrap', gap: gap[8] }, + cta: { + paddingHorizontal: padding[24], + paddingTop: padding[20], + paddingBottom: padding[20], + backgroundColor: semantic.surface.input, + }, +}); From a2b911334b39ad3cb88c69e86c59081183711b25 Mon Sep 17 00:00:00 2001 From: bae129 Date: Sat, 14 Nov 2026 13:05:22 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=ED=95=99=EC=83=9D=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=ED=99=94=EB=A9=B4=20=EB=AA=A8=EB=B0=94=EC=9D=BC=20?= =?UTF-8?q?=ED=8F=AD(390)=20=EB=A0=88=EC=9D=B4=EC=95=84=EC=9B=83=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/tutoring/StudentInfoScreen.tsx | 128 ++++++++++---------- 1 file changed, 66 insertions(+), 62 deletions(-) diff --git a/src/features/tutoring/StudentInfoScreen.tsx b/src/features/tutoring/StudentInfoScreen.tsx index b2a1b97..4edd475 100644 --- a/src/features/tutoring/StudentInfoScreen.tsx +++ b/src/features/tutoring/StudentInfoScreen.tsx @@ -1,6 +1,6 @@ import arrowBackImage from '../../../assets/images/arrow_back.svg'; import { useState } from 'react'; -import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'; +import { Platform, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'; import { Image } from 'expo-image'; import { router } from 'expo-router'; import { SafeAreaView } from 'react-native-safe-area-context'; @@ -51,83 +51,87 @@ export function StudentInfoScreen() { return ( - - - - - - 과외 만들기 - - - - - - - - - 지난 과외 계좌를 불러왔어요. + + + + + + + 과외 만들기 + + - - - - - - + + + + + 지난 과외 계좌를 불러왔어요. - - - + + + + + + - - {GRADES.map((g) => ( - setGrade(g)} - /> - ))} - - - - - + + + + + + {GRADES.map((g) => ( + setGrade(g)} + /> + ))} + - - {SUBJECTS.map((subject) => ( - toggleSubject(subject)} - /> - ))} + + + + + + + {SUBJECTS.map((subject) => ( + toggleSubject(subject)} + /> + ))} + - - + - - + + + ); } const s = StyleSheet.create({ - safe: { flex: 1, backgroundColor: semantic.surface.input }, + safe: { flex: 1, alignItems: 'center', backgroundColor: semantic.surface.input }, + // 웹에서는 휴대폰 너비(390)로 가운데 정렬하고, 상태바 높이만큼 위를 띄웁니다. + phone: { flex: 1, width: '100%', maxWidth: 390, paddingTop: Platform.OS === 'web' ? 44 : 0 }, navBar: { flexDirection: 'row', alignItems: 'center', From ea8bd4474580740d3b0a01f0456f784b987287d3 Mon Sep 17 00:00:00 2001 From: bae129 Date: Sat, 14 Nov 2026 14:06:32 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat:=20=ED=95=99=EC=83=9D=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=ED=99=94=EB=A9=B4=20=EA=B8=B0=ED=83=80=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5,=20=EB=A1=9C=EB=94=A9,=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EA=B8=80=EC=9E=90=20=EC=88=98=20=EC=98=A4=EB=A5=98=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EC=B6=94=EA=B0=80=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/tutoring/student.tsx | 3 +- src/features/tutoring/StudentInfoScreen.tsx | 85 +++++++++++++++++++-- 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/src/app/tutoring/student.tsx b/src/app/tutoring/student.tsx index 47d1873..df84984 100644 --- a/src/app/tutoring/student.tsx +++ b/src/app/tutoring/student.tsx @@ -1,5 +1,6 @@ import { StudentInfoScreen } from '@/features/tutoring/StudentInfoScreen'; +// TODO: 앞 단계가 생기면 실제로 불러온 출처를 넘깁니다. export default function Screen() { - return ; + return ; } diff --git a/src/features/tutoring/StudentInfoScreen.tsx b/src/features/tutoring/StudentInfoScreen.tsx index 4edd475..65f0a07 100644 --- a/src/features/tutoring/StudentInfoScreen.tsx +++ b/src/features/tutoring/StudentInfoScreen.tsx @@ -6,10 +6,11 @@ import { router } from 'expo-router'; import { SafeAreaView } from 'react-native-safe-area-context'; import { ActionButton } from '@/components/ActionButton'; import { Chip } from '@/components/Chip'; +import { Loading } from '@/components/Loading'; import { ProgressBar } from '@/components/ProgressBar'; import { TextInput } from '@/components/TextInput'; import { semantic } from '@/styles/colors'; -import { gap, padding, radius } from '@/styles/measurement'; +import { gap, padding, radius, unit } from '@/styles/measurement'; import { typography } from '@/styles/typography'; const GRADES = ['초6', '중1', '중2', '중3', '고1', '고2', '고3', '기타'] as const; @@ -18,6 +19,20 @@ const SUBJECTS = ['국어', '영어', '수학', '과학', '사회', '기타'] as type Grade = (typeof GRADES)[number]; type Subject = (typeof SUBJECTS)[number]; +// TODO: 저장 API가 생기면 실제 요청으로 바꿉니다. 지금은 로딩 화면만 보여 줍니다. +const SUBMIT_PREVIEW_MS = 1500; + +/** 앞 단계에서 미리 채워 둔 정보의 출처. 출처에 따라 안내 문구가 달라집니다. */ +export type PrefillSource = 'lastTutoring' | 'curriculum'; + +const PREFILL_NOTICE: Record = { + lastTutoring: '지난 과외 계좌를 불러왔어요.', + curriculum: '커리큘럼에서 학생 정보, 교재, 요일을 채워두었어요', +}; + +// 프로필 이름과 같은 기준입니다. 넘치면 입력은 막지 않고 오류 문구를 보여 줍니다. +const NAME_MAX_LENGTH = 10; + const STEP = 2; const TOTAL_STEPS = 5; @@ -32,17 +47,45 @@ function FieldLabel({ label, hint }: { label: string; hint?: string }) { } /** T-05 과외 만들기 · 학생 정보 (2/5 단계) */ -export function StudentInfoScreen() { +export type StudentInfoScreenProps = { + /** 없으면 안내 메시지를 보여 주지 않습니다. */ + prefillSource?: PrefillSource; +}; + +export function StudentInfoScreen({ prefillSource }: StudentInfoScreenProps) { const [name, setName] = useState(''); const [grade, setGrade] = useState(null); + const [otherGrade, setOtherGrade] = useState(''); const [subjects, setSubjects] = useState([]); + const [otherSubject, setOtherSubject] = useState(''); const toggleSubject = (subject: Subject) => setSubjects((prev) => prev.includes(subject) ? prev.filter((v) => v !== subject) : [...prev, subject], ); - const canProceed = name.trim().length > 0 && grade !== null && subjects.length > 0; + const otherSelected = subjects.includes('기타'); + const nameTooLong = name.trim().length > NAME_MAX_LENGTH; + const canProceed = + name.trim().length > 0 && + !nameTooLong && + grade !== null && + (grade !== '기타' || otherGrade.trim().length > 0) && + subjects.length > 0 && + (!otherSelected || otherSubject.trim().length > 0); + + const [submitting, setSubmitting] = useState(false); + + const submit = async () => { + if (!canProceed || submitting) return; + setSubmitting(true); + try { + await new Promise((resolve) => setTimeout(resolve, SUBMIT_PREVIEW_MS)); + // TODO: 3단계 화면이 생기면 이동합니다. + } finally { + setSubmitting(false); + } + }; const back = () => { if (router.canGoBack()) router.back(); @@ -65,9 +108,11 @@ export function StudentInfoScreen() { - - 지난 과외 계좌를 불러왔어요. - + {prefillSource ? ( + + {PREFILL_NOTICE[prefillSource]} + + ) : null} @@ -77,6 +122,7 @@ export function StudentInfoScreen() { ))} + {grade === '기타' ? ( + + + + ) : null} @@ -116,14 +173,26 @@ export function StudentInfoScreen() { /> ))} + {otherSelected ? ( + + + + ) : null} - + + ); } @@ -173,6 +242,8 @@ const s = StyleSheet.create({ }, required: { color: semantic.text.brand.assistive }, chips: { flexDirection: 'row', flexWrap: 'wrap', gap: gap[8] }, + // 디자인에서 칩 묶음과 입력칸 사이가 10px입니다 (gap 8 + 2). + otherInput: { marginTop: unit[2] }, cta: { paddingHorizontal: padding[24], paddingTop: padding[20], From a6893ed25c4b6bd3f37f7b07911370961778cadd Mon Sep 17 00:00:00 2001 From: bae129 Date: Sat, 14 Nov 2026 14:11:05 +0900 Subject: [PATCH 5/8] =?UTF-8?q?refactor:=20=EA=B3=BC=EC=99=B8=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20=EA=B3=B5=ED=86=B5=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=95=84=EC=9B=83=EA=B3=BC=20=EC=9E=85=EB=A0=A5=20=EB=B6=80?= =?UTF-8?q?=ED=92=88=20=EB=B6=84=EB=A6=AC=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/tutoring/FormFields.tsx | 106 ++++++++ src/features/tutoring/StudentInfoScreen.tsx | 262 ++++--------------- src/features/tutoring/TutoringFormLayout.tsx | 155 +++++++++++ 3 files changed, 310 insertions(+), 213 deletions(-) create mode 100644 src/features/tutoring/FormFields.tsx create mode 100644 src/features/tutoring/TutoringFormLayout.tsx diff --git a/src/features/tutoring/FormFields.tsx b/src/features/tutoring/FormFields.tsx new file mode 100644 index 0000000..58cec49 --- /dev/null +++ b/src/features/tutoring/FormFields.tsx @@ -0,0 +1,106 @@ +import { StyleSheet, Text, View } from 'react-native'; +import { Chip } from '@/components/Chip'; +import { TextInput } from '@/components/TextInput'; +import type { TextInputProps } from '@/components/TextInput'; +import { semantic } from '@/styles/colors'; +import { gap, padding, unit } from '@/styles/measurement'; +import { typography } from '@/styles/typography'; + +type FieldLabelProps = { + label: string; + /** 별표(*) 뒤에 붙는 설명. 예: (복수 선택 가능) */ + hint?: string; + required?: boolean; +}; + +function FieldLabel({ label, hint, required = true }: FieldLabelProps) { + return ( + + {label} + {required ? * : null} + {hint ? ` ${hint}` : null} + + ); +} + +export type TextFieldProps = Omit & FieldLabelProps; + +/** 위에 라벨이 붙은 입력칸 */ +export function TextField({ label, hint, required, ...inputProps }: TextFieldProps) { + return ( + + + + + + + ); +} + +type ChipSelectFieldProps = FieldLabelProps & { + options: readonly T[]; + isSelected: (option: T) => boolean; + onPress: (option: T) => void; + /** true면 하나만 고르는 라디오, false면 여러 개 고르는 체크박스로 읽힙니다. */ + single?: boolean; + /** '기타'를 골랐을 때 칩 아래에 보여 줄 입력칸 */ + other?: { visible: boolean; value: string; onChangeText: (text: string) => void }; +}; + +/** 라벨 + 칩 묶음. '기타'를 고르면 아래에 직접 입력칸이 나타납니다. */ +export function ChipSelectField({ + label, + hint, + required, + options, + isSelected, + onPress, + single = false, + other, +}: ChipSelectFieldProps) { + return ( + + + + + + {options.map((option) => ( + onPress(option)} + /> + ))} + + {other?.visible ? ( + + + + ) : null} + + ); +} + +const s = StyleSheet.create({ + label: { + ...typography.body[5].semiBold, + color: semantic.text.default.neutral, + }, + required: { color: semantic.text.brand.assistive }, + textField: { gap: gap[8] }, + textLabel: { paddingHorizontal: padding[8] }, + selectField: { paddingVertical: padding[8], gap: gap[8] }, + selectLabel: { paddingHorizontal: gap[4] }, + chips: { flexDirection: 'row', flexWrap: 'wrap', gap: gap[8] }, + // 디자인에서 칩 묶음과 입력칸 사이가 10px입니다 (gap 8 + 2). + otherInput: { marginTop: unit[2] }, +}); diff --git a/src/features/tutoring/StudentInfoScreen.tsx b/src/features/tutoring/StudentInfoScreen.tsx index 65f0a07..ceeee78 100644 --- a/src/features/tutoring/StudentInfoScreen.tsx +++ b/src/features/tutoring/StudentInfoScreen.tsx @@ -1,17 +1,8 @@ -import arrowBackImage from '../../../assets/images/arrow_back.svg'; import { useState } from 'react'; -import { Platform, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'; -import { Image } from 'expo-image'; import { router } from 'expo-router'; -import { SafeAreaView } from 'react-native-safe-area-context'; -import { ActionButton } from '@/components/ActionButton'; -import { Chip } from '@/components/Chip'; -import { Loading } from '@/components/Loading'; -import { ProgressBar } from '@/components/ProgressBar'; -import { TextInput } from '@/components/TextInput'; -import { semantic } from '@/styles/colors'; -import { gap, padding, radius, unit } from '@/styles/measurement'; -import { typography } from '@/styles/typography'; +import { ChipSelectField, TextField } from './FormFields'; +import { TutoringFormLayout, useSubmit } from './TutoringFormLayout'; +import type { PrefillSource } from './TutoringFormLayout'; const GRADES = ['초6', '중1', '중2', '중3', '고1', '고2', '고3', '기타'] as const; const SUBJECTS = ['국어', '영어', '수학', '과학', '사회', '기타'] as const; @@ -19,39 +10,15 @@ const SUBJECTS = ['국어', '영어', '수학', '과학', '사회', '기타'] as type Grade = (typeof GRADES)[number]; type Subject = (typeof SUBJECTS)[number]; -// TODO: 저장 API가 생기면 실제 요청으로 바꿉니다. 지금은 로딩 화면만 보여 줍니다. -const SUBMIT_PREVIEW_MS = 1500; - -/** 앞 단계에서 미리 채워 둔 정보의 출처. 출처에 따라 안내 문구가 달라집니다. */ -export type PrefillSource = 'lastTutoring' | 'curriculum'; - -const PREFILL_NOTICE: Record = { - lastTutoring: '지난 과외 계좌를 불러왔어요.', - curriculum: '커리큘럼에서 학생 정보, 교재, 요일을 채워두었어요', -}; - // 프로필 이름과 같은 기준입니다. 넘치면 입력은 막지 않고 오류 문구를 보여 줍니다. const NAME_MAX_LENGTH = 10; -const STEP = 2; -const TOTAL_STEPS = 5; - -function FieldLabel({ label, hint }: { label: string; hint?: string }) { - return ( - - {label} - * - {hint ? ` ${hint}` : null} - - ); -} - -/** T-05 과외 만들기 · 학생 정보 (2/5 단계) */ export type StudentInfoScreenProps = { /** 없으면 안내 메시지를 보여 주지 않습니다. */ prefillSource?: PrefillSource; }; +/** T-05 과외 만들기 · 학생 정보 (2/5 단계) */ export function StudentInfoScreen({ prefillSource }: StudentInfoScreenProps) { const [name, setName] = useState(''); const [grade, setGrade] = useState(null); @@ -64,7 +31,7 @@ export function StudentInfoScreen({ prefillSource }: StudentInfoScreenProps) { prev.includes(subject) ? prev.filter((v) => v !== subject) : [...prev, subject], ); - const otherSelected = subjects.includes('기타'); + const otherSubjectSelected = subjects.includes('기타'); const nameTooLong = name.trim().length > NAME_MAX_LENGTH; const canProceed = name.trim().length > 0 && @@ -72,182 +39,51 @@ export function StudentInfoScreen({ prefillSource }: StudentInfoScreenProps) { grade !== null && (grade !== '기타' || otherGrade.trim().length > 0) && subjects.length > 0 && - (!otherSelected || otherSubject.trim().length > 0); - - const [submitting, setSubmitting] = useState(false); - - const submit = async () => { - if (!canProceed || submitting) return; - setSubmitting(true); - try { - await new Promise((resolve) => setTimeout(resolve, SUBMIT_PREVIEW_MS)); - // TODO: 3단계 화면이 생기면 이동합니다. - } finally { - setSubmitting(false); - } - }; - - const back = () => { - if (router.canGoBack()) router.back(); - else router.replace('/home'); - }; + (!otherSubjectSelected || otherSubject.trim().length > 0); + + // TODO: 입력한 학생 정보를 다음 단계로 넘기거나 저장합니다. + const { submitting, submit } = useSubmit(() => + router.push({ + pathname: '/tutoring/textbook', + params: prefillSource ? { source: prefillSource } : {}, + }), + ); return ( - - - - - - - - 과외 만들기 - - - - - - - - {prefillSource ? ( - - {PREFILL_NOTICE[prefillSource]} - - ) : null} - - - - - - - - - - - - - - - {GRADES.map((g) => ( - setGrade(g)} - /> - ))} - - {grade === '기타' ? ( - - - - ) : null} - - - - - - - - {SUBJECTS.map((subject) => ( - toggleSubject(subject)} - /> - ))} - - {otherSelected ? ( - - - - ) : null} - - - - - - - - - - + + + grade === g} + onPress={setGrade} + other={{ visible: grade === '기타', value: otherGrade, onChangeText: setOtherGrade }} + /> + subjects.includes(subject)} + onPress={toggleSubject} + other={{ + visible: otherSubjectSelected, + value: otherSubject, + onChangeText: setOtherSubject, + }} + /> + ); } - -const s = StyleSheet.create({ - safe: { flex: 1, alignItems: 'center', backgroundColor: semantic.surface.input }, - // 웹에서는 휴대폰 너비(390)로 가운데 정렬하고, 상태바 높이만큼 위를 띄웁니다. - phone: { flex: 1, width: '100%', maxWidth: 390, paddingTop: Platform.OS === 'web' ? 44 : 0 }, - navBar: { - flexDirection: 'row', - alignItems: 'center', - justifyContent: 'space-between', - paddingHorizontal: padding[24], - paddingVertical: padding[12], - }, - icon: { width: 24, height: 24 }, - title: { - ...typography.body[1].bold, - textAlign: 'center', - color: semantic.text.default.strong, - }, - content: { - paddingHorizontal: padding[24], - gap: gap[8], - }, - inlineMessage: { - flexDirection: 'row', - alignItems: 'center', - gap: gap[4], - paddingHorizontal: padding[12], - paddingVertical: padding[8], - borderRadius: radius.small, - backgroundColor: semantic.surface.focused, - }, - inlineMessageText: { - ...typography.caption[1].medium, - color: semantic.text.brand.assistive, - }, - form: { paddingVertical: padding[12], gap: gap[20] }, - nameField: { gap: gap[8] }, - nameLabel: { paddingHorizontal: padding[8] }, - selectField: { paddingVertical: padding[8], gap: gap[8] }, - selectLabel: { paddingHorizontal: gap[4] }, - fieldLabel: { - ...typography.body[5].semiBold, - color: semantic.text.default.neutral, - }, - required: { color: semantic.text.brand.assistive }, - chips: { flexDirection: 'row', flexWrap: 'wrap', gap: gap[8] }, - // 디자인에서 칩 묶음과 입력칸 사이가 10px입니다 (gap 8 + 2). - otherInput: { marginTop: unit[2] }, - cta: { - paddingHorizontal: padding[24], - paddingTop: padding[20], - paddingBottom: padding[20], - backgroundColor: semantic.surface.input, - }, -}); diff --git a/src/features/tutoring/TutoringFormLayout.tsx b/src/features/tutoring/TutoringFormLayout.tsx new file mode 100644 index 0000000..87aa744 --- /dev/null +++ b/src/features/tutoring/TutoringFormLayout.tsx @@ -0,0 +1,155 @@ +import arrowBackImage from '../../../assets/images/arrow_back.svg'; +import { useState } from 'react'; +import type { ReactNode } from 'react'; +import { Platform, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'; +import { Image } from 'expo-image'; +import { router } from 'expo-router'; +import { SafeAreaView } from 'react-native-safe-area-context'; +import { ActionButton } from '@/components/ActionButton'; +import { Loading } from '@/components/Loading'; +import { ProgressBar } from '@/components/ProgressBar'; +import { semantic } from '@/styles/colors'; +import { gap, padding, radius } from '@/styles/measurement'; +import { typography } from '@/styles/typography'; + +export const TOTAL_STEPS = 5; + +/** 앞 단계에서 미리 채워 둔 정보의 출처. 출처에 따라 안내 문구가 달라집니다. */ +export type PrefillSource = 'lastTutoring' | 'curriculum'; + +const PREFILL_NOTICE: Record = { + lastTutoring: '지난 과외 계좌를 불러왔어요.', + curriculum: '커리큘럼에서 학생 정보, 교재, 요일을 채워두었어요', +}; + +export const isPrefillSource = (value: unknown): value is PrefillSource => + value === 'lastTutoring' || value === 'curriculum'; + +// TODO: 저장 API가 생기면 실제 요청으로 바꿉니다. 지금은 로딩 화면만 보여 줍니다. +const SUBMIT_PREVIEW_MS = 1500; + +/** "다음"을 누르면 로딩을 보여 주고, 끝나면 onDone을 부릅니다. */ +export function useSubmit(onDone: () => void) { + const [submitting, setSubmitting] = useState(false); + + const submit = async () => { + if (submitting) return; + setSubmitting(true); + try { + await new Promise((resolve) => setTimeout(resolve, SUBMIT_PREVIEW_MS)); + } finally { + setSubmitting(false); + } + onDone(); + }; + + return { submitting, submit }; +} + +export type TutoringFormLayoutProps = { + step: number; + /** 없으면 안내 메시지를 보여 주지 않습니다. */ + prefillSource?: PrefillSource; + canProceed: boolean; + submitting: boolean; + onNext: () => void; + children: ReactNode; +}; + +/** 과외 만들기 단계 화면의 공통 틀 (헤더, 진행 막대, 안내 메시지, 다음 버튼, 로딩) */ +export function TutoringFormLayout({ + step, + prefillSource, + canProceed, + submitting, + onNext, + children, +}: TutoringFormLayoutProps) { + const back = () => { + if (router.canGoBack()) router.back(); + else router.replace('/home'); + }; + + return ( + + + + + + + + 과외 만들기 + + + + + + + + {prefillSource ? ( + + {PREFILL_NOTICE[prefillSource]} + + ) : null} + + {children} + + + + { + if (canProceed) onNext(); + }} + /> + + + + + ); +} + +const s = StyleSheet.create({ + safe: { flex: 1, alignItems: 'center', backgroundColor: semantic.surface.input }, + // 웹에서는 휴대폰 너비(390)로 가운데 정렬하고, 상태바 높이만큼 위를 띄웁니다. + phone: { flex: 1, width: '100%', maxWidth: 390, paddingTop: Platform.OS === 'web' ? 44 : 0 }, + navBar: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + paddingHorizontal: padding[24], + paddingVertical: padding[12], + }, + icon: { width: 24, height: 24 }, + title: { + ...typography.body[1].bold, + textAlign: 'center', + color: semantic.text.default.strong, + }, + content: { + paddingHorizontal: padding[24], + gap: gap[8], + }, + inlineMessage: { + flexDirection: 'row', + alignItems: 'center', + gap: gap[4], + paddingHorizontal: padding[12], + paddingVertical: padding[8], + borderRadius: radius.small, + backgroundColor: semantic.surface.focused, + }, + inlineMessageText: { + ...typography.caption[1].medium, + color: semantic.text.brand.assistive, + }, + form: { paddingVertical: padding[12], gap: gap[20] }, + cta: { + paddingHorizontal: padding[24], + paddingTop: padding[20], + paddingBottom: padding[20], + backgroundColor: semantic.surface.input, + }, +}); From 5f1c019590fb26912960b4353ecb2b9e8907f9ec Mon Sep 17 00:00:00 2001 From: bae129 Date: Sat, 14 Nov 2026 14:11:13 +0900 Subject: [PATCH 6/8] =?UTF-8?q?feat:=20=EA=B3=BC=EC=99=B8=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20=EA=B5=90=EC=9E=AC=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/tutoring/textbook.tsx | 8 +++ src/features/tutoring/TextbookScreen.tsx | 62 ++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/app/tutoring/textbook.tsx create mode 100644 src/features/tutoring/TextbookScreen.tsx diff --git a/src/app/tutoring/textbook.tsx b/src/app/tutoring/textbook.tsx new file mode 100644 index 0000000..977912c --- /dev/null +++ b/src/app/tutoring/textbook.tsx @@ -0,0 +1,8 @@ +import { useLocalSearchParams } from 'expo-router'; +import { TextbookScreen } from '@/features/tutoring/TextbookScreen'; +import { isPrefillSource } from '@/features/tutoring/TutoringFormLayout'; + +export default function Screen() { + const { source } = useLocalSearchParams<{ source?: string }>(); + return ; +} diff --git a/src/features/tutoring/TextbookScreen.tsx b/src/features/tutoring/TextbookScreen.tsx new file mode 100644 index 0000000..7f617e3 --- /dev/null +++ b/src/features/tutoring/TextbookScreen.tsx @@ -0,0 +1,62 @@ +import { useState } from 'react'; +import { ChipSelectField, TextField } from './FormFields'; +import { TutoringFormLayout, useSubmit } from './TutoringFormLayout'; +import type { PrefillSource } from './TutoringFormLayout'; + +const PROGRESS_UNITS = ['Unit', '단원', 'Chapter', 'Page', '회', '기타'] as const; + +type ProgressUnit = (typeof PROGRESS_UNITS)[number]; + +export type TextbookScreenProps = { + /** 없으면 안내 메시지를 보여 주지 않습니다. */ + prefillSource?: PrefillSource; +}; + +/** T-05 과외 만들기 · 교재 (3/5 단계) */ +export function TextbookScreen({ prefillSource }: TextbookScreenProps) { + // TODO: 디자인 라벨은 "학생당 1~5권"이지만, 여러 권을 추가하는 화면이 아직 없어 한 권만 받습니다. + const [title, setTitle] = useState(''); + const [unit, setUnit] = useState(null); + const [otherUnit, setOtherUnit] = useState(''); + const [currentProgress, setCurrentProgress] = useState(''); + + const canProceed = + title.trim().length > 0 && unit !== null && (unit !== '기타' || otherUnit.trim().length > 0); + + // TODO: 4단계 화면이 생기면 이동합니다. + const { submitting, submit } = useSubmit(() => {}); + + return ( + + + unit === u} + onPress={setUnit} + other={{ visible: unit === '기타', value: otherUnit, onChangeText: setOtherUnit }} + /> + setCurrentProgress(text.replace(/[^0-9]/g, ''))} + keyboardType="number-pad" + placeholder="숫자로 입력해 주세요" + helperText="교재 내용은 저장하지 않고, 이름과 진도 단위만 써요." + /> + + ); +} From 1e138752f46aeebae4e685b44f8a9092037b7947 Mon Sep 17 00:00:00 2001 From: bae129 Date: Sat, 14 Nov 2026 14:15:19 +0900 Subject: [PATCH 7/8] =?UTF-8?q?feat:=20=EA=B5=90=EC=9E=AC=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EA=B8=80=EC=9E=90=20=EC=88=98=20=EC=B4=88=EA=B3=BC?= =?UTF-8?q?=20=EC=98=A4=EB=A5=98=20=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/tutoring/FormFields.tsx | 5 +++++ src/features/tutoring/StudentInfoScreen.tsx | 8 ++++---- src/features/tutoring/TextbookScreen.tsx | 14 +++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/features/tutoring/FormFields.tsx b/src/features/tutoring/FormFields.tsx index 58cec49..4b6be49 100644 --- a/src/features/tutoring/FormFields.tsx +++ b/src/features/tutoring/FormFields.tsx @@ -6,6 +6,11 @@ import { semantic } from '@/styles/colors'; import { gap, padding, unit } from '@/styles/measurement'; import { typography } from '@/styles/typography'; +export const TOO_LONG_MESSAGE = '글자 수가 초과되었어요'; + +/** 앞뒤 공백을 뺀 글자 수가 max를 넘는지 봅니다. 넘어도 입력은 막지 않고 오류 문구만 보여 줍니다. */ +export const isTooLong = (value: string, max: number) => value.trim().length > max; + type FieldLabelProps = { label: string; /** 별표(*) 뒤에 붙는 설명. 예: (복수 선택 가능) */ diff --git a/src/features/tutoring/StudentInfoScreen.tsx b/src/features/tutoring/StudentInfoScreen.tsx index ceeee78..eaa84a6 100644 --- a/src/features/tutoring/StudentInfoScreen.tsx +++ b/src/features/tutoring/StudentInfoScreen.tsx @@ -1,6 +1,6 @@ import { useState } from 'react'; import { router } from 'expo-router'; -import { ChipSelectField, TextField } from './FormFields'; +import { ChipSelectField, TOO_LONG_MESSAGE, TextField, isTooLong } from './FormFields'; import { TutoringFormLayout, useSubmit } from './TutoringFormLayout'; import type { PrefillSource } from './TutoringFormLayout'; @@ -10,7 +10,7 @@ const SUBJECTS = ['국어', '영어', '수학', '과학', '사회', '기타'] as type Grade = (typeof GRADES)[number]; type Subject = (typeof SUBJECTS)[number]; -// 프로필 이름과 같은 기준입니다. 넘치면 입력은 막지 않고 오류 문구를 보여 줍니다. +// 프로필 이름과 같은 기준입니다. const NAME_MAX_LENGTH = 10; export type StudentInfoScreenProps = { @@ -32,7 +32,7 @@ export function StudentInfoScreen({ prefillSource }: StudentInfoScreenProps) { ); const otherSubjectSelected = subjects.includes('기타'); - const nameTooLong = name.trim().length > NAME_MAX_LENGTH; + const nameTooLong = isTooLong(name, NAME_MAX_LENGTH); const canProceed = name.trim().length > 0 && !nameTooLong && @@ -61,7 +61,7 @@ export function StudentInfoScreen({ prefillSource }: StudentInfoScreenProps) { label="학생 이름" value={name} onChangeText={setName} - errorMessage={nameTooLong ? '글자 수가 초과되었어요' : undefined} + errorMessage={nameTooLong ? TOO_LONG_MESSAGE : undefined} placeholder="학생 이름을 입력해 주세요" /> 0 && unit !== null && (unit !== '기타' || otherUnit.trim().length > 0); + title.trim().length > 0 && + !titleTooLong && + unit !== null && + (unit !== '기타' || otherUnit.trim().length > 0); // TODO: 4단계 화면이 생기면 이동합니다. const { submitting, submit } = useSubmit(() => {}); @@ -38,6 +45,7 @@ export function TextbookScreen({ prefillSource }: TextbookScreenProps) { label="교재 (학생당 1~5권)" value={title} onChangeText={setTitle} + errorMessage={titleTooLong ? TOO_LONG_MESSAGE : undefined} placeholder="교재 이름을 입력해 주세요" /> setCurrentProgress(text.replace(/[^0-9]/g, ''))} keyboardType="number-pad" - placeholder="숫자로 입력해 주세요" + placeholder="지금 진도" helperText="교재 내용은 저장하지 않고, 이름과 진도 단위만 써요." /> From 10c183949ea45bb22b4ac5cd526a66adc261feb3 Mon Sep 17 00:00:00 2001 From: bae129 Date: Sat, 14 Nov 2026 14:27:39 +0900 Subject: [PATCH 8/8] =?UTF-8?q?feat:=20=EA=B3=BC=EC=99=B8=20=EB=A7=8C?= =?UTF-8?q?=EB=93=A4=EA=B8=B0=20=EC=B4=88=EB=8C=80=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20(=EB=A1=9C=EB=94=A9,=20=EB=B2=88=ED=98=B8?= =?UTF-8?q?=20=EC=98=A4=EB=A5=98,=20=EC=A0=84=EC=86=A1=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=20=ED=86=A0=EC=8A=A4=ED=8A=B8)=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/images/add.svg | 5 + src/app/tutoring/invite.tsx | 5 + src/features/tutoring/FormFields.tsx | 14 +- src/features/tutoring/InviteScreen.tsx | 201 +++++++++++++++++++ src/features/tutoring/TutoringFormLayout.tsx | 59 +++++- src/utils/phone.ts | 14 ++ 6 files changed, 286 insertions(+), 12 deletions(-) create mode 100644 assets/images/add.svg create mode 100644 src/app/tutoring/invite.tsx create mode 100644 src/features/tutoring/InviteScreen.tsx create mode 100644 src/utils/phone.ts diff --git a/assets/images/add.svg b/assets/images/add.svg new file mode 100644 index 0000000..b8e4137 --- /dev/null +++ b/assets/images/add.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/app/tutoring/invite.tsx b/src/app/tutoring/invite.tsx new file mode 100644 index 0000000..6716815 --- /dev/null +++ b/src/app/tutoring/invite.tsx @@ -0,0 +1,5 @@ +import { InviteScreen } from '@/features/tutoring/InviteScreen'; + +export default function Screen() { + return ; +} diff --git a/src/features/tutoring/FormFields.tsx b/src/features/tutoring/FormFields.tsx index 4b6be49..d25feaa 100644 --- a/src/features/tutoring/FormFields.tsx +++ b/src/features/tutoring/FormFields.tsx @@ -16,11 +16,13 @@ type FieldLabelProps = { /** 별표(*) 뒤에 붙는 설명. 예: (복수 선택 가능) */ hint?: string; required?: boolean; + /** true면 라벨을 더 진한 색(text/default/strong)으로 보여 줍니다. */ + strong?: boolean; }; -function FieldLabel({ label, hint, required = true }: FieldLabelProps) { +function FieldLabel({ label, hint, required = true, strong = false }: FieldLabelProps) { return ( - + {label} {required ? * : null} {hint ? ` ${hint}` : null} @@ -31,11 +33,11 @@ function FieldLabel({ label, hint, required = true }: FieldLabelProps) { export type TextFieldProps = Omit & FieldLabelProps; /** 위에 라벨이 붙은 입력칸 */ -export function TextField({ label, hint, required, ...inputProps }: TextFieldProps) { +export function TextField({ label, hint, required, strong, ...inputProps }: TextFieldProps) { return ( - + @@ -57,6 +59,7 @@ export function ChipSelectField({ label, hint, required, + strong, options, isSelected, onPress, @@ -66,7 +69,7 @@ export function ChipSelectField({ return ( - + {options.map((option) => ( @@ -100,6 +103,7 @@ const s = StyleSheet.create({ ...typography.body[5].semiBold, color: semantic.text.default.neutral, }, + labelStrong: { color: semantic.text.default.strong }, required: { color: semantic.text.brand.assistive }, textField: { gap: gap[8] }, textLabel: { paddingHorizontal: padding[8] }, diff --git a/src/features/tutoring/InviteScreen.tsx b/src/features/tutoring/InviteScreen.tsx new file mode 100644 index 0000000..f6e6f4f --- /dev/null +++ b/src/features/tutoring/InviteScreen.tsx @@ -0,0 +1,201 @@ +import addImage from '../../../assets/images/add.svg'; +import { Fragment, useState } from 'react'; +import { Pressable, StyleSheet, Text, View } from 'react-native'; +import { Image } from 'expo-image'; +import { ChipSelectField, TextField } from './FormFields'; +import type { TextFieldProps } from './FormFields'; +import { TutoringFormLayout, useSubmit } from './TutoringFormLayout'; +import { semantic } from '@/styles/colors'; +import { gap, lineWeight, padding, radius, unit } from '@/styles/measurement'; +import { typography } from '@/styles/typography'; +import { INVALID_PHONE_MESSAGE, formatPhone, isValidPhone } from '@/utils/phone'; + +const TITLES = ['어머님', '아버님', '보호자님'] as const; +const MAX_PARENTS = 2; + +type ParentTitle = (typeof TITLES)[number]; +type Parent = { phone: string; title: ParentTitle | null }; + +// TODO: 학부모 번호 입력 여부에 따라 문구가 바뀌는지 기획 확인이 필요합니다. 지금은 디자인 문구 그대로입니다. +const INVITE_SUMMARY = [ + { label: '학부모', value: '초대 링크 / 근황 보내지 않음' }, + { label: '학생', value: '초대 링크' }, + { label: '함께 보내요', value: '수업 계획서' }, +]; + +const emptyParent = (): Parent => ({ phone: '', title: null }); + +type PhoneFieldProps = Omit & { + value: string; + onChangeText: (value: string) => void; +}; + +/** 하이픈을 자동으로 넣고, 입력칸을 벗어났을 때 번호가 틀리면 오류 문구를 보여 주는 입력칸 */ +function PhoneField({ value, onChangeText, onBlur, ...props }: PhoneFieldProps) { + const [touched, setTouched] = useState(false); + const invalid = touched && value.length > 0 && !isValidPhone(value); + + return ( + onChangeText(formatPhone(text))} + onBlur={(e) => { + setTouched(true); + onBlur?.(e); + }} + errorMessage={invalid ? INVALID_PHONE_MESSAGE : undefined} + keyboardType="phone-pad" + placeholder="전화번호" + /> + ); +} + +/** T-05 과외 만들기 · 초대 (5/5 단계) */ +export function InviteScreen() { + const [parents, setParents] = useState([emptyParent()]); + const [studentPhone, setStudentPhone] = useState(''); + + const updateParent = (index: number, patch: Partial) => + setParents((prev) => prev.map((p, i) => (i === index ? { ...p, ...patch } : p))); + + // 첫 번째 학부모 번호는 필수, 나머지 번호는 입력했다면 올바른 형식이어야 합니다. + const optionalOk = (phone: string) => phone.length === 0 || isValidPhone(phone); + const canProceed = + isValidPhone(parents[0].phone) && + parents.slice(1).every((p) => optionalOk(p.phone)) && + optionalOk(studentPhone); + + // TODO: 저장·초대 링크 전송 API를 useSubmit 두 번째 인자로 넘기고, 성공하면 완료 화면으로 이동합니다. + const { submitting, failed, submit } = useSubmit(() => {}); + + return ( + + {parents.map((parent, index) => ( + + updateParent(index, { phone })} + /> + + parent.title === title} + onPress={(title) => updateParent(index, { title })} + /> + {index === parents.length - 1 && parents.length < MAX_PARENTS ? ( + setParents((prev) => [...prev, emptyParent()])} + style={({ pressed }) => [s.addButton, pressed && s.addButtonPressed]} + > + + 학부모 추가 (최대 2명) + + ) : null} + + + ))} + + + + + 이렇게 초대해요 + + {INVITE_SUMMARY.map((row, i) => ( + + {i > 0 ? : null} + + {row.label} + {row.value} + + + ))} + + {/* 전송 실패 토스트가 떠 있는 동안에는 디자인대로 안내 상자를 숨기고 그 자리에 토스트를 보여 줍니다. */} + {failed ? null : ( + + + { + '링크로 볼지 앱을 깔지는 각자 고르고, 초대를 수락하기 전에는\n아무것도 보내지 않아요.' + } + + + )} + + + ); +} + +const s = StyleSheet.create({ + addButton: { + height: 54, + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + gap: gap[8], + // 칩 묶음과 버튼 사이가 12px입니다 (칩 영역 아래 여백 8 + 4). + marginTop: unit[4], + paddingHorizontal: padding[12], + paddingVertical: padding[8], + borderRadius: radius.medium, + borderWidth: lineWeight.regular, + borderColor: semantic.border.default, + backgroundColor: semantic.surface.default, + }, + addButtonPressed: { backgroundColor: semantic.surface.disabled }, + addIcon: { width: 16, height: 16 }, + addLabel: { + ...typography.body[3].medium, + textAlign: 'center', + color: semantic.text.default.weak, + }, + inviteSection: { paddingVertical: padding[12], gap: gap[12] }, + sectionLabel: { + ...typography.body[5].semiBold, + paddingHorizontal: padding[4], + color: semantic.text.default.neutral, + }, + summary: { + gap: gap[12], + paddingHorizontal: padding[16], + paddingVertical: padding[12], + borderRadius: radius.medium, + backgroundColor: semantic.surface.subtle, + }, + summaryRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' }, + summaryLabel: { ...typography.body[4].semiBold, color: semantic.text.default.neutral }, + summaryValue: { ...typography.body[4].medium, color: semantic.text.default.weak }, + divider: { + height: lineWeight.subtle, + borderRadius: radius.small, + backgroundColor: semantic.border.default, + }, + notice: { + paddingHorizontal: padding[12], + paddingVertical: padding[8], + borderRadius: radius.small, + backgroundColor: semantic.surface.focused, + }, + noticeText: { ...typography.caption[1].medium, color: semantic.text.brand.assistive }, +}); diff --git a/src/features/tutoring/TutoringFormLayout.tsx b/src/features/tutoring/TutoringFormLayout.tsx index 87aa744..034d4d3 100644 --- a/src/features/tutoring/TutoringFormLayout.tsx +++ b/src/features/tutoring/TutoringFormLayout.tsx @@ -1,5 +1,5 @@ import arrowBackImage from '../../../assets/images/arrow_back.svg'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import type { ReactNode } from 'react'; import { Platform, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'; import { Image } from 'expo-image'; @@ -27,23 +27,40 @@ export const isPrefillSource = (value: unknown): value is PrefillSource => // TODO: 저장 API가 생기면 실제 요청으로 바꿉니다. 지금은 로딩 화면만 보여 줍니다. const SUBMIT_PREVIEW_MS = 1500; +const ERROR_TOAST_MS = 3000; -/** "다음"을 누르면 로딩을 보여 주고, 끝나면 onDone을 부릅니다. */ -export function useSubmit(onDone: () => void) { +const previewRequest = () => new Promise((resolve) => setTimeout(resolve, SUBMIT_PREVIEW_MS)); + +/** + * "다음"을 누르면 request를 기다리는 동안 로딩을 보여 주고, 성공하면 onDone을 부릅니다. + * 실패하면 failed가 3초 동안 true가 됩니다. + */ +export function useSubmit(onDone: () => void, request: () => Promise = previewRequest) { const [submitting, setSubmitting] = useState(false); + const [failed, setFailed] = useState(false); + + useEffect(() => { + if (!failed) return; + const timer = setTimeout(() => setFailed(false), ERROR_TOAST_MS); + return () => clearTimeout(timer); + }, [failed]); const submit = async () => { if (submitting) return; + setFailed(false); setSubmitting(true); try { - await new Promise((resolve) => setTimeout(resolve, SUBMIT_PREVIEW_MS)); + await request(); + } catch { + setFailed(true); + return; } finally { setSubmitting(false); } onDone(); }; - return { submitting, submit }; + return { submitting, failed, submit }; } export type TutoringFormLayoutProps = { @@ -53,6 +70,12 @@ export type TutoringFormLayoutProps = { canProceed: boolean; submitting: boolean; onNext: () => void; + /** 하단 버튼 글자. 기본값은 "다음" */ + ctaLabel?: string; + /** false면 로딩 중에 가운데 로딩 카드 없이 버튼만 로딩으로 바뀝니다. */ + loadingOverlay?: boolean; + /** 값이 있으면 하단 버튼 위에 토스트로 보여 줍니다. */ + toast?: string; children: ReactNode; }; @@ -63,6 +86,9 @@ export function TutoringFormLayout({ canProceed, submitting, onNext, + ctaLabel = '다음', + loadingOverlay = true, + toast, children, }: TutoringFormLayoutProps) { const back = () => { @@ -96,8 +122,15 @@ export function TutoringFormLayout({ + {toast ? ( + + + {toast} + + + ) : null} { @@ -106,7 +139,7 @@ export function TutoringFormLayout({ /> - + ); } @@ -146,6 +179,18 @@ const s = StyleSheet.create({ color: semantic.text.brand.assistive, }, form: { paddingVertical: padding[12], gap: gap[20] }, + // 토스트 아래쪽이 버튼 위쪽에서 12px 떨어지도록 CTA 위로 띄웁니다. (토스트 32 + 12 - CTA 위 여백 20) + toastSlot: { position: 'absolute', top: -24, left: 0, right: 0, alignItems: 'center' }, + toast: { + backgroundColor: semantic.surface.inverse, + borderRadius: radius.full, + paddingHorizontal: padding[12], + paddingVertical: padding[8], + // PushBanner와 같은 그림자입니다. + boxShadow: '0px 4px 8px rgba(0, 0, 0, 0.18)', + elevation: 6, + }, + toastText: { ...typography.caption[1].regular, color: semantic.text.default.inverse }, cta: { paddingHorizontal: padding[24], paddingTop: padding[20], diff --git a/src/utils/phone.ts b/src/utils/phone.ts new file mode 100644 index 0000000..52cfc13 --- /dev/null +++ b/src/utils/phone.ts @@ -0,0 +1,14 @@ +/** 숫자만 남기고 010-1234-5678 꼴(3-4-4)로 하이픈을 넣습니다. 11자리를 넘는 숫자는 버립니다. */ +export function formatPhone(input: string): string { + const digits = input.replace(/\D/g, '').slice(0, 11); + if (digits.length <= 3) return digits; + if (digits.length <= 7) return `${digits.slice(0, 3)}-${digits.slice(3)}`; + return `${digits.slice(0, 3)}-${digits.slice(3, 7)}-${digits.slice(7)}`; +} + +/** 01X 뒤에 8자리가 붙은 11자리 휴대폰 번호인지 봅니다. */ +export function isValidPhone(input: string): boolean { + return /^01\d{9}$/.test(input.replace(/\D/g, '')); +} + +export const INVALID_PHONE_MESSAGE = '휴대폰 번호는 8자리로 입력해주세요';