import { Brain, Play, Zap } from 'lucide-react'; import { api } from '@/api'; import { useAppData } from '@/state/AppData'; import { findNode, findNodeOfLesson, unitColor } from '@/state/curriculum'; import { useNav } from '@/nav/Navigator'; import { useAsync } from '@/lib/useAsync'; import { SeyarMascot } from '@/mascots/SeyarMascot'; import { moodFromServer } from '@/mascots/seyar'; import { ErrorState, LoadingState, PrimaryButton, Screen, ScreenBody, ScreenHeader, Sep } from '@/components/ui'; import { toFa } from '@/lib/format'; import { MathText } from '@/lib/MathText'; import { Diagram } from '@/diagram'; /** معرفیِ درس، پیش از تمرین. */ export function LessonScreen({ lessonId, nodeId }: { lessonId: number; nodeId?: string }) { const { home, companion } = useAppData(); const nav = useNav(); const intro = useAsync(() => api.lesson.intro(lessonId), [lessonId]); const ref = findNode(home, nodeId) ?? findNodeOfLesson(home, lessonId); const color = ref ? unitColor(ref.unitIndex) : '#ED6956'; const data = intro.data; const figs = (where: 'intro' | 'example' | 'step', index?: number) => (data?.figures ?? []) .filter((f) => f.where === where && (where !== 'step' || f.index === index)) .map((f, k) => ); return ( : '…'} color={color} back mascot={{ char: companion, mood: moodFromServer(data?.mascotAnimation), size: 72 }} subtitle={ ref && ( {/* ترتیبِ lessonIds «درسِ بعدی اول» است، نه ترتیبِ کتاب؛ پس شماره‌ی درس از آن درنمی‌آید. */} {toFa(ref.node.lessonIds.length)} درس ) } /> {intro.loading ? ( ) : intro.error || !data ? ( ) : ( <>

{figs('intro')}
{data.kind === 'video' && data.videoUrl && (
); }