Skip to content
Merged
5 changes: 5 additions & 0 deletions assets/images/add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/images/arrow_back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/app/tutoring/invite.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { InviteScreen } from '@/features/tutoring/InviteScreen';

export default function Screen() {
return <InviteScreen />;
}
6 changes: 6 additions & 0 deletions src/app/tutoring/student.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { StudentInfoScreen } from '@/features/tutoring/StudentInfoScreen';

// TODO: 앞 단계가 생기면 실제로 불러온 출처를 넘깁니다.
export default function Screen() {
return <StudentInfoScreen prefillSource="lastTutoring" />;
}
8 changes: 8 additions & 0 deletions src/app/tutoring/textbook.tsx
Original file line number Diff line number Diff line change
@@ -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 <TextbookScreen prefillSource={isPrefillSource(source) ? source : undefined} />;
}
14 changes: 11 additions & 3 deletions src/components/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -16,14 +17,16 @@ const colors = {
export type ChipProps = Omit<PressableProps, 'style' | 'children'> & {
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 (
<Pressable
{...props}
role="checkbox"
role={props.role ?? 'checkbox'}
aria-checked={selected}
accessibilityLabel={label}
style={[
Expand All @@ -34,7 +37,12 @@ export function Chip({ label, selected = false, ...props }: ChipProps) {
},
]}
>
<Text style={[s.label, { color: selected ? colors.selectedText : colors.text }]}>
<Text
style={[
s.label,
{ color: selected ? colors.selectedText : muted ? colors.mutedText : colors.text },
]}
>
{label}
</Text>
</Pressable>
Expand Down
18 changes: 13 additions & 5 deletions src/components/ProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 (
Expand All @@ -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]}
>
<View style={s.track}>
<View style={[s.track, stretch && s.trackStretch]}>
{Array.from({ length: total }, (_, i) => (
<View key={i} style={[s.segment, i < current && s.segmentFilled]} />
<View
key={i}
style={[s.segment, stretch && s.segmentStretch, i < current && s.segmentFilled]}
/>
))}
</View>
{showLabel ? (
Expand All @@ -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],
Expand Down
115 changes: 115 additions & 0 deletions src/features/tutoring/FormFields.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
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';

export const TOO_LONG_MESSAGE = '글자 수가 초과되었어요';

/** 앞뒤 공백을 뺀 글자 수가 max를 넘는지 봅니다. 넘어도 입력은 막지 않고 오류 문구만 보여 줍니다. */
export const isTooLong = (value: string, max: number) => value.trim().length > max;

type FieldLabelProps = {
label: string;
/** 별표(*) 뒤에 붙는 설명. 예: (복수 선택 가능) */
hint?: string;
required?: boolean;
/** true면 라벨을 더 진한 색(text/default/strong)으로 보여 줍니다. */
strong?: boolean;
};

function FieldLabel({ label, hint, required = true, strong = false }: FieldLabelProps) {
return (
<Text style={[s.label, strong && s.labelStrong]}>
{label}
{required ? <Text style={s.required}>*</Text> : null}
{hint ? ` ${hint}` : null}
</Text>
);
}

export type TextFieldProps = Omit<TextInputProps, 'accessibilityLabel'> & FieldLabelProps;

/** 위에 라벨이 붙은 입력칸 */
export function TextField({ label, hint, required, strong, ...inputProps }: TextFieldProps) {
return (
<View style={s.textField}>
<View style={s.textLabel}>
<FieldLabel label={label} hint={hint} required={required} strong={strong} />
</View>
<TextInput accessibilityLabel={label} returnKeyType="done" {...inputProps} />
</View>
);
}

type ChipSelectFieldProps<T extends string> = 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<T extends string>({
label,
hint,
required,
strong,
options,
isSelected,
onPress,
single = false,
other,
}: ChipSelectFieldProps<T>) {
return (
<View style={s.selectField}>
<View style={s.selectLabel}>
<FieldLabel label={label} hint={hint} required={required} strong={strong} />
</View>
<View role={single ? 'radiogroup' : 'group'} accessibilityLabel={label} style={s.chips}>
{options.map((option) => (
<Chip
key={option}
label={option}
muted
role={single ? 'radio' : 'checkbox'}
selected={isSelected(option)}
onPress={() => onPress(option)}
/>
))}
</View>
{other?.visible ? (
<View style={s.otherInput}>
<TextInput
value={other.value}
onChangeText={other.onChangeText}
placeholder="텍스트를 입력해주세요"
accessibilityLabel={`기타 ${label}`}
returnKeyType="done"
/>
</View>
) : null}
</View>
);
}

const s = StyleSheet.create({
label: {
...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] },
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] },
});
Loading
Loading