Explore the learn-p5 codebase (working dir /workspaces/learn-p5) and report back, thoroughly:
The Toast component: read src/components/Toast.tsx fully. Report its props, color source (does it use Colors.light/dark tokens or hardcoded hex?), how showToast is invoked from src/app/learn/[course]/[id].tsx, and the current visual treatment (icon, color, animation).
The task completion flow in src/app/learn/[course]/[id].tsx: find the TASK_COMPLETE and EXERCISE_COMPLETE handlers (~line 442-448), the handleRun function, and any toast shown on completion. Quote the exact code blocks. Is any toast shown today on a single task completion? On exercise completion? What does the StreakToast do (read src/components/StreakToast.tsx)?
The useStreak hook (src/hooks/useStreak.ts): report its API, what it persists to AsyncStorage, what "streak" means here (consecutive days? consecutive tasks?). Quote the key functions.
The exercise state shape (ExerciseState, ExerciseAction) and how completedTasks / currentTaskIndex flow.
Existing badges/achievements: search for "badge", "achievement", "streak", "milestone" across src/. Report any existing system.
Material Design motion: is react-native-reanimated already used? Where (grep for reanimated, useSharedValue, withTiming, AnimatedFadingTransition)? Is there a theme context with motion tokens (durations, easings)? Read src/components/ThemeProvider.tsx and src/constants/Colors.ts briefly to understand the theming system.
Return: file paths with line numbers, exact code snippets for the critical blocks, and a concise summary. Do NOT edit anything — read only.
Assistant
I'll explore the codebase systematically. Let me start with parallel reads of the key files.
Assistant
Now let me read the learn page and search for the other items inparallel.
Assistant
Let me search for streak usage and motion tokens, and check Defaults.
Assistant
I have all the information needed. Here is the thorough report.
Icon color and default success color are hardcoded hex — #22C55E is the default iconColor and is re-applied by the caller for success toasts. Shadow color is hardcoded "#000" (line 109). The #22C55E does NOT come from Colors.light/dark (there is no green token defined in Colors.ts).
Visual treatment
Icon: MaterialCommunityIcons at size 20, color = iconColor (line 82), default check-circle.
Layout: top-anchored banner, full width, paddingTop: insets.top + 8, row layout with content (icon + message) and optional right-side action button.
Run is triggered by a FAB via handleRunPressIn/handleRunPressOut (long-press 2000ms opens SearchOverlay instead). It posts runSketch to the WebView; the WebView later replies with taskComplete, exerciseComplete, or validationFailed.
Toasts on completion
Single task completion (TASK_COMPLETE): NO toast is shown. It only dispatches the reducer; nothing calls showToast in the taskComplete branch.
Exercise completion: YES, a toast is shown. It is triggered by an effect watching state.completed (lines 678–708):
Note: state.completed is set true by BOTH EXERCISE_COMPLETE AND TASK_COMPLETE when !hasMoreTasks — so completing the final task fires the "✓ Exercise completed!" toast with a "Next →" action (handleToastNext, lines 663–676, loads next lesson / goes to course index). The toast's success color is the hardcoded #22C55E, not a token.
So StreakToast only shows on first visit-of-day (when useStreak found it was a new day and set the streak_toast_pending flag). It is unrelated to task/exercise completion.
3. useStreak hook (src/hooks/useStreak.ts)
API (lines 31–34, 111)
ts
export function useStreak(): StreakData & {
checkStreak: () => Promise<boolean>;
consumePendingToast: () => Promise<StreakData | null>;
};
export async function getStreakFromStorage(): Promise<{ count: number; longest: number }>;
Returned StreakData:
ts
interface StreakData {
count: number;
longest: number;
isNewDay: boolean;
currentTier: number; // 0..365 from STREAK_TIERS, or 0
nextTier: number; // next threshold in STREAK_TIERS
tierProgress: number; // count / nextTier (0..1)
}
StreakData.currentTier from reducer logic is actually the tier VALUE (e.g. 3, 7) at STREAK_TIERS[idx], or 0 (lines 58, 92).
getDateString (lines 20–22) uses date.toISOString().split("T")[0] (UTC day).
The hook auto-runs checkStreak() on mount (lines 107–109). consumePendingToast (lines 100–105) is a one-shot: returns the data only if the pending flag was set, otherwise null. There is no concept of tasks completed / exercises completed feeding into the streak.
src/app/dashboard.tsx lines 14, 40, 71, 494 (dashboard also animates the streak stat counter — streakAnim, animatedStreak, lines 46–186)
src/app/settings/index.tsx lines 10, 20–24, 110–111, 272–273, 683–801 (debug panel to set/preview streak toast — keys listed at lines 20–24 include an extra streak_last_tier that the hook does not actually use)
4. Exercise state shape (src/app/learn/[course]/[id].tsx)
completedTasks accumulates the indexes of tasks the WebView reports as passed (lines 92–93). It is currently write-only — nothing reads/renders it for UI like a checklist; only the array grows.
currentTaskIndex advances to taskIndex + 1 if there are more tasks (line 98). It is consumed in:
The HTML bundle passed to the WebView (activeTaskIndex: state.currentTaskIndex, line 178) so the in-WebView instruction panel shows the active task.
An effect that posts setActiveTask to the WebView whenever currentTaskIndex changes (lines 595–612), pushing the new task's instructionHtml.
completed becomes true either via EXERCISE_COMPLETE (line 91) or via TASK_COMPLETE when there are no further tasks (line 99). completed is what triggers the "✓ Exercise completed!" toast effect at line 678.
5. Existing badges / achievements
A grep across src/ for badge|achievement|milestone returned no files. There is no dedicated badges or achievements system in source.
What exists that is adjacent:
Streaks: useStreak (consecutive-day counter) + StreakToast milestone banners using STREAK_TIERS = [3, 7, 14, 30, 100, 365]. The "milestone" concept only lives inside StreakToast.getMilestoneText/getMilestoneTitle (lines 17–36) and isMilestone = STREAK_TIERS.includes(streakCount) (line 136) — visualized as a trophy icon ("trophy", #FFD700) vs. the normal flame icon ("fire", #FF6B35).
Completion records in AsyncStorage only:
completedLessons (array of course/id strings) — line 687 of [id].tsx
completedCourses (array of course slugs) — line 700 of [id].tsx
These have no UI surfacing as "achievements."
Dashboard (src/app/dashboard.tsx) shows streak count, longest streak, completed count, and "level" (lines 46–186, stat displayed at line 379) but no badge grid.
The settings debug panel (src/app/settings/index.tsx lines 683–801) lets the developer preview the StreakToast — there is a streak_last_tier key referenced in the debug key map (lines 20–24) that the actual hook does not write or read.
6. Material Design motion / theming
react-native-reanimated — YES, already in use
Declared as a dependency: package.json line 44 ("react-native-reanimated": "4.2.1"), also package-lock.json line 39.
Used in 3 components (none of which are Toast/StreakToast):
src/components/SideDrawer.tsx lines 4–8, 17–18, 21–67 — useSharedValue for translateX and backdropOpacity, withTiming with { duration: 200..300 }.
src/components/SplashScreen.tsx lines 4–10, 45–52, 60–61 — useSharedValue for translateY/translateX, withTiming for drop + wobble animations.
Toast.tsx and StreakToast.tsx use the legacy RN Animated API (new Animated.Value, Animated.spring, Animated.timing, Animated.parallel, Animated.sequence) — NOT Reanimated. No AnimatedFadingTransition usage was found.
colorScheme: "light" | "dark", defaults to system scheme unless a user override is persisted under key userColorScheme (line 18).
ctaColor: a user-pickable accent (default #FF69B4 from DEFAULTS.ctaColor), persisted under setting_ctaColor (line 19).
derivedColors: built by deriveColorsFromAccent(ctaColor, isDark) (src/utils/colorUtils.ts, used at lines 72–75). This is the only "derived" surface; it exposes at least primary, primaryContainer (used widely).
applyAccentIcon(ctaColor) (line 78) updates the launcher/home-screen icon tint.
There are NO motion tokens (durations, easings) in the theme context. Durations and easings are hardcoded inline per component (e.g. SideDrawer 200–300ms, onboarding 400ms, Toast 200ms in/out, StreakToast 200ms in / 150ms out / 1000ms count ramp). Animated calls do not use an Easing import; only spring tension/friction configs.
Color tokens (src/constants/Colors.ts)
Two static schemes Colors.light and Colors.dark (78 lines), a Material-3-flavored palette: primary, cta, onPrimary, primaryContainer, onPrimaryContainer, primaryFixedDim, secondary/tertiary family, surface, surfaceDim, surfaceBright, surfaceContainer{Low,High,Highest,Lowest}, onSurface, onSurfaceVariant, outline, outlineVariant, textSecondary, inverseSurface/inverseOnSurface/inversePrimary, scrim, error/errorContainer/onError/onErrorContainer. There is no success/positive token — which is why Toast.tsx, StreakToast.tsx, and the showToast wrapper all hardcode #22C55E for the success icon and #FFD700/#FF6B35 for streak icons.
Summary
Toast is a top banner with a Material icon + message + optional action. Theming is half tokenized (surface/text tokens) but success color #22C55E and shadow #000 are hardcoded. It animates with legacy Animated (spring-in, 200ms timing-out).
Task completion fires NO toast today. Only validationFailed (failure toast) and final exercise completion ("✓ Exercise completed!" + "Next →" action, hardcoded green check icon) fire the Toast. There is no per-task success feedback surface.
StreakToast is a separate, richer banner that shows a day-streak milestone (fire/trophy icon, animated count ramp 0→N over 1 s, animated progress bar to next tier, 5 s auto-dismiss). It only appears once per new calendar day, gated by consumePendingToast() — completely decoupled from task/exercise completion.
useStreak counts consecutive calendar days (UTC), persisting streak_count, streak_last_visit, streak_longest, streak_toast_pending to AsyncStorage. Tiers [3,7,14,30,100,365]. It is unrelated to task completion.
No badge/achievement/milestone system exists beyond the streak-tier concept baked into StreakToast. Lesson/course completion is only recorded to AsyncStorage (completedLessons, completedCourses) and surfaced as counts in the dashboard.
Reanimated 4.2.1 is installed and used in SideDrawer, SplashScreen, and onboarding — but NOT in the two toast components, which still use the legacy Animated API. There are no centralized motion tokens (durations/easings); each component hardcodes its own timings.