Day's meals with kcal and add per slot
import * as React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Glass, Icon, Image, Progress, Text } from "@lumioui/ui";
import { LumioMark, Mount, Press, World } from "../shared";
export interface Meal {
id: string;
slot: string;
name: string;
detail: string;
kcal: number;
imageUrl?: string;
}
export interface MealPlannerScreenProps {
day?: string;
/** e.g. "1,840 / 2,200 kcal" */
calories?: string;
meals?: Meal[];
onMealPress?: (id: string) => void;
onAddMeal?: (slot: string) => void;
onBack?: () => void;
}
const pic = (id: string) =>
`https://images.unsplash.com/photo-${id}?w=200&h=200&fit=crop&q=60&auto=format`;
const DEFAULT_MEALS: Meal[] = [
{ id: "m1", slot: "Breakfast", name: "Greek yogurt bowl", detail: "Granola, berries, honey", kcal: 380, imageUrl: pic("1488477181946-6428a0291777") },
{ id: "m2", slot: "Lunch", name: "Chicken grain bowl", detail: "Quinoa, greens, tahini", kcal: 620, imageUrl: pic("1546069901-ba9599a7e63c") },
{ id: "m3", slot: "Snack", name: "Almonds + apple", detail: "Handful, sliced", kcal: 210, imageUrl: pic("1560806887-1e4cd0b6cbd6") },
{ id: "m4", slot: "Dinner", name: "Salmon + greens", detail: "Roasted, lemon", kcal: 540, imageUrl: pic("1467003909585-2f8a72700288") },
];
/** Meal planner — day's meals with kcal progress + add per slot. */
export function MealPlannerScreen({
day = "Today",
calories = "1,750 / 2,200 kcal",
meals = DEFAULT_MEALS,
onMealPress,
onAddMeal,
onBack,
}: MealPlannerScreenProps) {
const insets = useSafeAreaInsets();
const slots = ["Breakfast", "Lunch", "Snack", "Dinner"];
return (
<World primary="#16A34A">
<SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
<View pointerEvents="box-none" className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }}>
<View className="flex-row items-center justify-between">
<Glass interactive effect="regular" className="h-11 w-11 items-center justify-center rounded-full">
<Press
haptic="light"
onPress={() => onBack?.()}
accessibilityRole="button"
accessibilityLabel="Go back"
className="h-9 w-9 items-center justify-center"
>
<Icon name="chevron-left" size="md" color="foreground" />
</Press>
</Glass>
<View className="h-11 w-11" />
</View>
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
<View className="h-11 flex-row items-center justify-center gap-2 rounded-full pl-3.5 pr-5">
<Glass effect="regular" className="absolute inset-0 rounded-full" />
<LumioMark size={18} />
<Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
Meals
</Text>
</View>
</View>
</View>
<Mount>
<Text variant="h2" accessibilityRole="header" className="px-6 pb-1 tracking-tight" style={{ paddingTop: insets.top + 60 }}>
{day}
</Text>
</Mount>
{/* Day + calorie budget. */}
<View className="flex-row items-end justify-between px-4 pb-3 pt-2">
<Text variant="h3">Budget</Text>
<Text className="text-sm font-medium tabular-nums">{calories}</Text>
</View>
<Progress value={83} className="mx-4 mb-4 h-2" indicatorClassName="bg-success" />
{/* Remaining budget — the number dinner decisions need. */}
<Text variant="muted" className="mx-4 -mt-3 pb-1 text-right text-xs">
450 kcal left today
</Text>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingBottom: insets.bottom + 32 }}
>
{slots.map((slot) => {
const slotMeals = meals.filter((m) => m.slot === slot);
return (
<View key={slot} className="mb-4 px-4">
<View className="flex-row items-center justify-between pb-1.5">
<Text variant="small" className="font-medium text-muted-foreground">
{slot}
</Text>
<Button
variant="ghost"
size="sm"
haptic="light"
onPress={() => onAddMeal?.(slot)}
accessibilityLabel={`Add ${slot}`}
className="h-8 px-2"
>
<Icon name="plus" size="sm" color="#16A34A" />
</Button>
</View>
{slotMeals.map((m) => (
<Press
key={m.id}
haptic="light"
onPress={() => onMealPress?.(m.id)}
accessibilityLabel={`${m.name}, ${m.kcal} calories`}
className="mb-2 overflow-hidden rounded-3xl bg-white p-3.5 dark:bg-[#1A1A20]"
>
<View className="flex-row items-center gap-3.5">
{m.imageUrl ? (
<Image
source={{ uri: m.imageUrl }}
className="h-14 w-14 rounded-2xl bg-muted"
accessibilityLabel={m.name}
/>
) : (
<View className="h-14 w-14 items-center justify-center rounded-2xl bg-muted">
<Icon name="utensils" size="sm" color="mutedForeground" />
</View>
)}
<View className="flex-1 gap-0.5">
<Text className="font-medium">{m.name}</Text>
<Text className="text-xs text-muted-foreground">
{m.detail}
</Text>
</View>
<Text className="text-sm font-medium">{m.kcal}</Text>
</View>
</Press>
))}
</View>
);
})}
{/* Macro split — the second thing a tracker shows after calories. */}
<Mount className="mx-4 mt-2 gap-4 overflow-hidden rounded-3xl bg-white p-5 dark:bg-[#1A1A20]">
<Text className="font-semibold">Macros</Text>
<View className="flex-row gap-4">
{[
{ label: "Protein", grams: "98g", fill: "w-3/4", color: "bg-[#16A34A]" },
{ label: "Carbs", grams: "210g", fill: "w-4/5", color: "bg-warning" },
{ label: "Fat", grams: "58g", fill: "w-3/5", color: "bg-chart-3" },
].map((m) => (
<View key={m.label} className="flex-1 gap-1.5">
<Text className="text-xs text-muted-foreground">{m.label}</Text>
<Text className="font-semibold tabular-nums">{m.grams}</Text>
<View className="h-1.5 overflow-hidden rounded-full bg-muted">
<View className={`h-full rounded-full ${m.color} ${m.fill}`} />
</View>
</View>
))}
</View>
</Mount>
</ScrollView>
</SafeAreaView>
</World>
);
}
MealPlannerScreen.displayName = "MealPlannerScreen";
Recreate the "Meal Planner Screen" screen in React Native using LumioUI.
Goal: Day's meals with kcal and add per slot Match the reference implementation's layout, behavior, and motion exactly — this is a production screen, not a mockup.
## Setup
Fastest path — install the screen plus its component deps:
```bash
npx lumioui add health-meal-planner
```
Or pull just the components: `npx lumioui add button icon image progress text`
Native packages:
- @lumioui/ui@latest
- react-native-safe-area-context@*
- @lumioui/core@latest
- react-native-reanimated@*
- react-native-svg@*
- nativewind@*
Stack assumptions: Expo SDK 54 / RN 0.81, Reanimated 4, NativeWind v4, TypeScript strict, Expo Go compatible.
## Components — how, where, when
### `button` — Tactile pill button with press spring, ink wash and async loading.
- `<Button>` ×1
### `icon` — Lucide icon set mapped to theme colors and sizes.
- `<Icon>` ×3
### `image` — Cached image with placeholder, fallback and aspect handling.
- `<Image>` ×1
### `progress` — Animated fill bar with indeterminate sweep mode.
- `<Progress>` ×1
### `text` — Themed type scale from caption to display.
- `<Text>` ×12
## Conventions (non-negotiable)
- Styling via NativeWind `className` with semantic tokens only: `bg-background`, `text-foreground`, `bg-card`, `text-card-foreground`, `bg-secondary`, `bg-muted`, `text-muted-foreground`, `bg-accent`, `bg-destructive`, `border-border`. Hard-coded colors only inside media overlays (`text-white`, `bg-black/N`).
- Motion via the token presets from `@lumioui/core` (`spring.press`, `spring.surface`, `spring.glide`, `timing.fast`, `timing.slow`, …) — no bespoke spring configs or durations.
- Gate transform motion behind `useReducedMotion()`; keep opacity/color feedback, drop travel and overshoot.
- Haptics via `useHaptic()`: `light` on press, `selection` on toggle/select, `warning` on invalid input. Never import expo-haptics directly.
- Press feedback via `usePressAnimation()` (~0.97 scale), not `activeOpacity` tricks.
- a11y: `accessibilityRole` + `accessibilityLabel` on every control, touch targets ≥44pt.
- Entrance choreography: staggered `Mount` wrappers (delay 0/60/120…) so regions land in sequence instead of popping in at once.
- Wrap the screen in `SafeAreaView`; keep dark mode working via the semantic tokens.
## Deliverable
One file: `screens/health/meal-planner.tsx` exporting MealPlannerScreen. Preserve the props interface — the host app wires the callbacks (navigation, submit handlers) through them.
## Reference implementation
The LumioUI source for this screen — reproduce it faithfully:
```tsx
import * as React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Glass, Icon, Image, Progress, Text } from "@lumioui/ui";
import { LumioMark, Mount, Press, World } from "../shared";
export interface Meal {
id: string;
slot: string;
name: string;
detail: string;
kcal: number;
imageUrl?: string;
}
export interface MealPlannerScreenProps {
day?: string;
/** e.g. "1,840 / 2,200 kcal" */
calories?: string;
meals?: Meal[];
onMealPress?: (id: string) => void;
onAddMeal?: (slot: string) => void;
onBack?: () => void;
}
const pic = (id: string) =>
`https://images.unsplash.com/photo-${id}?w=200&h=200&fit=crop&q=60&auto=format`;
const DEFAULT_MEALS: Meal[] = [
{ id: "m1", slot: "Breakfast", name: "Greek yogurt bowl", detail: "Granola, berries, honey", kcal: 380, imageUrl: pic("1488477181946-6428a0291777") },
{ id: "m2", slot: "Lunch", name: "Chicken grain bowl", detail: "Quinoa, greens, tahini", kcal: 620, imageUrl: pic("1546069901-ba9599a7e63c") },
{ id: "m3", slot: "Snack", name: "Almonds + apple", detail: "Handful, sliced", kcal: 210, imageUrl: pic("1560806887-1e4cd0b6cbd6") },
{ id: "m4", slot: "Dinner", name: "Salmon + greens", detail: "Roasted, lemon", kcal: 540, imageUrl: pic("1467003909585-2f8a72700288") },
];
/** Meal planner — day's meals with kcal progress + add per slot. */
export function MealPlannerScreen({
day = "Today",
calories = "1,750 / 2,200 kcal",
meals = DEFAULT_MEALS,
onMealPress,
onAddMeal,
onBack,
}: MealPlannerScreenProps) {
const insets = useSafeAreaInsets();
const slots = ["Breakfast", "Lunch", "Snack", "Dinner"];
return (
<World primary="#16A34A">
<SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
<View pointerEvents="box-none" className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }}>
<View className="flex-row items-center justify-between">
<Glass interactive effect="regular" className="h-11 w-11 items-center justify-center rounded-full">
<Press
haptic="light"
onPress={() => onBack?.()}
accessibilityRole="button"
accessibilityLabel="Go back"
className="h-9 w-9 items-center justify-center"
>
<Icon name="chevron-left" size="md" color="foreground" />
</Press>
</Glass>
<View className="h-11 w-11" />
</View>
<View pointerEvents="none" className="absolute inset-0 items-center justify-center">
<View className="h-11 flex-row items-center justify-center gap-2 rounded-full pl-3.5 pr-5">
<Glass effect="regular" className="absolute inset-0 rounded-full" />
<LumioMark size={18} />
<Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
Meals
</Text>
</View>
</View>
</View>
<Mount>
<Text variant="h2" accessibilityRole="header" className="px-6 pb-1 tracking-tight" style={{ paddingTop: insets.top + 60 }}>
{day}
</Text>
</Mount>
{/* Day + calorie budget. */}
<View className="flex-row items-end justify-between px-4 pb-3 pt-2">
<Text variant="h3">Budget</Text>
<Text className="text-sm font-medium tabular-nums">{calories}</Text>
</View>
<Progress value={83} className="mx-4 mb-4 h-2" indicatorClassName="bg-success" />
{/* Remaining budget — the number dinner decisions need. */}
<Text variant="muted" className="mx-4 -mt-3 pb-1 text-right text-xs">
450 kcal left today
</Text>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingBottom: insets.bottom + 32 }}
>
{slots.map((slot) => {
const slotMeals = meals.filter((m) => m.slot === slot);
return (
<View key={slot} className="mb-4 px-4">
<View className="flex-row items-center justify-between pb-1.5">
<Text variant="small" className="font-medium text-muted-foreground">
{slot}
</Text>
<Button
variant="ghost"
size="sm"
haptic="light"
onPress={() => onAddMeal?.(slot)}
accessibilityLabel={`Add ${slot}`}
className="h-8 px-2"
>
<Icon name="plus" size="sm" color="#16A34A" />
</Button>
</View>
{slotMeals.map((m) => (
<Press
key={m.id}
haptic="light"
onPress={() => onMealPress?.(m.id)}
accessibilityLabel={`${m.name}, ${m.kcal} calories`}
className="mb-2 overflow-hidden rounded-3xl bg-white p-3.5 dark:bg-[#1A1A20]"
>
<View className="flex-row items-center gap-3.5">
{m.imageUrl ? (
<Image
source={{ uri: m.imageUrl }}
className="h-14 w-14 rounded-2xl bg-muted"
accessibilityLabel={m.name}
/>
) : (
<View className="h-14 w-14 items-center justify-center rounded-2xl bg-muted">
<Icon name="utensils" size="sm" color="mutedForeground" />
</View>
)}
<View className="flex-1 gap-0.5">
<Text className="font-medium">{m.name}</Text>
<Text className="text-xs text-muted-foreground">
{m.detail}
</Text>
</View>
<Text className="text-sm font-medium">{m.kcal}</Text>
</View>
</Press>
))}
</View>
);
})}
{/* Macro split — the second thing a tracker shows after calories. */}
<Mount className="mx-4 mt-2 gap-4 overflow-hidden rounded-3xl bg-white p-5 dark:bg-[#1A1A20]">
<Text className="font-semibold">Macros</Text>
<View className="flex-row gap-4">
{[
{ label: "Protein", grams: "98g", fill: "w-3/4", color: "bg-[#16A34A]" },
{ label: "Carbs", grams: "210g", fill: "w-4/5", color: "bg-warning" },
{ label: "Fat", grams: "58g", fill: "w-3/5", color: "bg-chart-3" },
].map((m) => (
<View key={m.label} className="flex-1 gap-1.5">
<Text className="text-xs text-muted-foreground">{m.label}</Text>
<Text className="font-semibold tabular-nums">{m.grams}</Text>
<View className="h-1.5 overflow-hidden rounded-full bg-muted">
<View className={`h-full rounded-full ${m.color} ${m.fill}`} />
</View>
</View>
))}
</View>
</Mount>
</ScrollView>
</SafeAreaView>
</World>
);
}
MealPlannerScreen.displayName = "MealPlannerScreen";
```
Screen: https://lumioui.dev/screens/health-meal-planner