v0.1 public beta early access on GitHub
Home / Screens / health-water-tracker
Screen template

Water Tracker Screen

Fill-ring goal with quick-add

pro Expo Go ✓ iosandroid gestures: tap · scroll haptics: light · selection
$ npx lumioui add health-water-tracker
import { WaterTrackerScreen } from "@/screens/health/water-tracker";
Registry dependencies4
Native packages installed6
@lumioui/ui@latest@lumioui/core@latestreact-native-safe-area-context@*react-native-reanimated@*react-native-svg@*nativewind@*
health/water-tracker.tsxsource · yours to edit
import * as React from "react";
import { ScrollView, View } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Button, Glass, Icon, ProgressRing, Text } from "@lumioui/ui";
import { useHaptic } from "@lumioui/core";
import { LumioMark, MONO, Mount, Press, StickyBottomBar, World } from "../shared";

export interface WaterEntry {
  id: string;
  amount: string;
  time: string;
}

export interface WaterTrackerScreenProps {
  goalMl?: number;
  entries?: WaterEntry[];
  /** Quick-add amounts in ml. */
  quickAdd?: number[];
  onAdd?: (ml: number) => void;
  onBack?: () => void;
}

const DEFAULT_ENTRIES: WaterEntry[] = [
  { id: "w1", amount: "500 ml", time: "8:12 AM" },
  { id: "w2", amount: "250 ml", time: "10:40 AM" },
  { id: "w3", amount: "350 ml", time: "1:05 PM" },
];

const DEFAULT_QUICK = [250, 350, 500];

/** Day-letter week strip — filled dot = goal hit. */
const WEEK = [
  { d: "M", hit: true },
  { d: "T", hit: true },
  { d: "W", hit: false },
  { d: "T", hit: true },
  { d: "F", hit: true },
  { d: "S", hit: false },
  { d: "S", hit: false },
];

/** Water tracker — fill-ring hero, quick-add, day's entries. */
export function WaterTrackerScreen({
  goalMl = 2400,
  entries = DEFAULT_ENTRIES,
  quickAdd = DEFAULT_QUICK,
  onAdd,
  onBack,
}: WaterTrackerScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const totalMl = entries.reduce(
    (acc, e) => acc + parseInt(e.amount, 10),
    0
  );
  const pct = Math.min(100, Math.round((totalMl / goalMl) * 100));

  return (
    <World primary="#0891B2">
    <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">
              Water
            </Text>
          </View>
        </View>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingBottom: insets.bottom + 96 }}
      >
        {/* Fill ring — real arc, droplet + total centered in the well. */}
        <Mount className="items-center" style={{ paddingTop: insets.top + 64 }}>
          <ProgressRing value={pct} size={176} strokeWidth={14} color="chart2">
            <View className="items-center gap-0.5">
              <Icon name="droplet" size="md" color="chart2" filled />
              <Text className="pt-1 text-3xl font-light" style={{ fontFamily: MONO, fontVariant: ["tabular-nums"] }}>
                {totalMl.toLocaleString()}
              </Text>
              <Text className="text-xs text-muted-foreground">ml</Text>
            </View>
          </ProgressRing>
          <Text className="mt-3 text-sm text-muted-foreground">
            {pct}% of {goalMl.toLocaleString()} ml goal
          </Text>
          {/* Pace hint — trackers answer "am I on time". */}
          <Text variant="muted" className="mt-0.5 text-xs">
            On pace — about one glass every 2 hours
          </Text>
        </Mount>

        {/* Quick-add chips — droplet + amount pills. */}
        <Mount delay={60} className="mx-4 mt-5 flex-row justify-center gap-3">
          {quickAdd.map((ml) => (
            <Press
              key={ml}
              haptic="light"
              pressedScale={0.94}
              onPress={() => onAdd?.(ml)}
              accessibilityRole="button"
              accessibilityLabel={`Add ${ml} ml`}
              className="flex-row items-center gap-1.5 overflow-hidden rounded-full px-4 py-2.5"
            >
              <Glass interactive effect="clear" sheen={0.5} className="absolute inset-0 rounded-full" pointerEvents="none" />
              <Icon name="droplet" size="sm" color="chart2" />
              <Text variant="small" className="font-medium text-secondary-foreground">
                +{ml} ml
              </Text>
            </Press>
          ))}
        </Mount>

        {/* Entries — one grouped card, separators between rows. */}
        <Mount delay={120} className="mt-5 px-4">
          <Text variant="small" className="pb-2 text-muted-foreground">
            Today
          </Text>
          <View className="overflow-hidden rounded-3xl bg-white dark:bg-[#1A1A20]">
            {entries.map((e, i) => (
              <View
                key={e.id}
                className={`flex-row items-center gap-3 px-4 py-3 ${
                  i > 0 ? "border-t border-border/60" : ""
                }`}
              >
                <View className="h-8 w-8 items-center justify-center rounded-xl bg-chart-2/15">
                  <Icon name="droplet" size="sm" color="chart2" />
                </View>
                <Text className="flex-1 text-sm font-medium">{e.amount}</Text>
                <Text className="text-xs text-muted-foreground">{e.time}</Text>
              </View>
            ))}
          </View>
        </Mount>

        {/* Week rollup — the 7-dot consistency strip is the real metric. */}
        <Mount delay={180} className="mx-4 mt-5 gap-3 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <View className="flex-row items-center gap-3">
            <View className="h-10 w-10 items-center justify-center rounded-full bg-chart-2/15">
              <Icon name="droplet" size="sm" color="chart2" />
            </View>
            <View className="flex-1">
              <Text className="text-sm font-semibold">2.1 L daily average</Text>
              <Text className="text-xs text-muted-foreground">
                Goal hit {WEEK.filter((w) => w.hit).length} of 7 days this week
              </Text>
            </View>
          </View>
          <View className="flex-row justify-between px-1">
            {WEEK.map((w, i) => (
              <View key={i} className="items-center gap-1">
                <View
                  className={`h-2 w-2 rounded-full ${w.hit ? "bg-chart-2" : "bg-muted"}`}
                />
                <Text className="text-[10px] text-muted-foreground">{w.d}</Text>
              </View>
            ))}
          </View>
        </Mount>
      </ScrollView>

      <StickyBottomBar>
        <View className="rounded-3xl bg-white p-3 shadow-sm dark:bg-[#1A1A20]">
          <Button
            tone="inverse"
            haptic="light"
            onPress={() => {
              haptics.light();
              onAdd?.(250);
            }}
            accessibilityLabel="Log water"
            className="w-full bg-[#1B1B26]"
            icon={<Icon name="droplet" size="sm" color="#38BDF8" />}
          >
            Log water
          </Button>
        </View>
      </StickyBottomBar>
    </SafeAreaView>
    </World>
  );
}
WaterTrackerScreen.displayName = "WaterTrackerScreen";
agent prompt — paste into Claude Code, Cursor, Devin…
Recreate the "Water Tracker Screen" screen in React Native using LumioUI.

Goal: Fill-ring goal with quick-add 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-water-tracker
```

Or pull just the components: `npx lumioui add button icon progress-ring text`

Native packages:
- @lumioui/ui@latest
- @lumioui/core@latest
- react-native-safe-area-context@*
- 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>` ×6

### `progress-ring` — Circular progress ring with animated stroke arc, center slot and indeterminate spin.
- `<ProgressRing>` ×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/water-tracker.tsx` exporting WaterTrackerScreen. 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, ProgressRing, Text } from "@lumioui/ui";
import { useHaptic } from "@lumioui/core";
import { LumioMark, MONO, Mount, Press, StickyBottomBar, World } from "../shared";

export interface WaterEntry {
  id: string;
  amount: string;
  time: string;
}

export interface WaterTrackerScreenProps {
  goalMl?: number;
  entries?: WaterEntry[];
  /** Quick-add amounts in ml. */
  quickAdd?: number[];
  onAdd?: (ml: number) => void;
  onBack?: () => void;
}

const DEFAULT_ENTRIES: WaterEntry[] = [
  { id: "w1", amount: "500 ml", time: "8:12 AM" },
  { id: "w2", amount: "250 ml", time: "10:40 AM" },
  { id: "w3", amount: "350 ml", time: "1:05 PM" },
];

const DEFAULT_QUICK = [250, 350, 500];

/** Day-letter week strip — filled dot = goal hit. */
const WEEK = [
  { d: "M", hit: true },
  { d: "T", hit: true },
  { d: "W", hit: false },
  { d: "T", hit: true },
  { d: "F", hit: true },
  { d: "S", hit: false },
  { d: "S", hit: false },
];

/** Water tracker — fill-ring hero, quick-add, day's entries. */
export function WaterTrackerScreen({
  goalMl = 2400,
  entries = DEFAULT_ENTRIES,
  quickAdd = DEFAULT_QUICK,
  onAdd,
  onBack,
}: WaterTrackerScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const totalMl = entries.reduce(
    (acc, e) => acc + parseInt(e.amount, 10),
    0
  );
  const pct = Math.min(100, Math.round((totalMl / goalMl) * 100));

  return (
    <World primary="#0891B2">
    <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">
              Water
            </Text>
          </View>
        </View>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingBottom: insets.bottom + 96 }}
      >
        {/* Fill ring — real arc, droplet + total centered in the well. */}
        <Mount className="items-center" style={{ paddingTop: insets.top + 64 }}>
          <ProgressRing value={pct} size={176} strokeWidth={14} color="chart2">
            <View className="items-center gap-0.5">
              <Icon name="droplet" size="md" color="chart2" filled />
              <Text className="pt-1 text-3xl font-light" style={{ fontFamily: MONO, fontVariant: ["tabular-nums"] }}>
                {totalMl.toLocaleString()}
              </Text>
              <Text className="text-xs text-muted-foreground">ml</Text>
            </View>
          </ProgressRing>
          <Text className="mt-3 text-sm text-muted-foreground">
            {pct}% of {goalMl.toLocaleString()} ml goal
          </Text>
          {/* Pace hint — trackers answer "am I on time". */}
          <Text variant="muted" className="mt-0.5 text-xs">
            On pace — about one glass every 2 hours
          </Text>
        </Mount>

        {/* Quick-add chips — droplet + amount pills. */}
        <Mount delay={60} className="mx-4 mt-5 flex-row justify-center gap-3">
          {quickAdd.map((ml) => (
            <Press
              key={ml}
              haptic="light"
              pressedScale={0.94}
              onPress={() => onAdd?.(ml)}
              accessibilityRole="button"
              accessibilityLabel={`Add ${ml} ml`}
              className="flex-row items-center gap-1.5 overflow-hidden rounded-full px-4 py-2.5"
            >
              <Glass interactive effect="clear" sheen={0.5} className="absolute inset-0 rounded-full" pointerEvents="none" />
              <Icon name="droplet" size="sm" color="chart2" />
              <Text variant="small" className="font-medium text-secondary-foreground">
                +{ml} ml
              </Text>
            </Press>
          ))}
        </Mount>

        {/* Entries — one grouped card, separators between rows. */}
        <Mount delay={120} className="mt-5 px-4">
          <Text variant="small" className="pb-2 text-muted-foreground">
            Today
          </Text>
          <View className="overflow-hidden rounded-3xl bg-white dark:bg-[#1A1A20]">
            {entries.map((e, i) => (
              <View
                key={e.id}
                className={`flex-row items-center gap-3 px-4 py-3 ${
                  i > 0 ? "border-t border-border/60" : ""
                }`}
              >
                <View className="h-8 w-8 items-center justify-center rounded-xl bg-chart-2/15">
                  <Icon name="droplet" size="sm" color="chart2" />
                </View>
                <Text className="flex-1 text-sm font-medium">{e.amount}</Text>
                <Text className="text-xs text-muted-foreground">{e.time}</Text>
              </View>
            ))}
          </View>
        </Mount>

        {/* Week rollup — the 7-dot consistency strip is the real metric. */}
        <Mount delay={180} className="mx-4 mt-5 gap-3 overflow-hidden rounded-3xl bg-white p-4 dark:bg-[#1A1A20]">
          <View className="flex-row items-center gap-3">
            <View className="h-10 w-10 items-center justify-center rounded-full bg-chart-2/15">
              <Icon name="droplet" size="sm" color="chart2" />
            </View>
            <View className="flex-1">
              <Text className="text-sm font-semibold">2.1 L daily average</Text>
              <Text className="text-xs text-muted-foreground">
                Goal hit {WEEK.filter((w) => w.hit).length} of 7 days this week
              </Text>
            </View>
          </View>
          <View className="flex-row justify-between px-1">
            {WEEK.map((w, i) => (
              <View key={i} className="items-center gap-1">
                <View
                  className={`h-2 w-2 rounded-full ${w.hit ? "bg-chart-2" : "bg-muted"}`}
                />
                <Text className="text-[10px] text-muted-foreground">{w.d}</Text>
              </View>
            ))}
          </View>
        </Mount>
      </ScrollView>

      <StickyBottomBar>
        <View className="rounded-3xl bg-white p-3 shadow-sm dark:bg-[#1A1A20]">
          <Button
            tone="inverse"
            haptic="light"
            onPress={() => {
              haptics.light();
              onAdd?.(250);
            }}
            accessibilityLabel="Log water"
            className="w-full bg-[#1B1B26]"
            icon={<Icon name="droplet" size="sm" color="#38BDF8" />}
          >
            Log water
          </Button>
        </View>
      </StickyBottomBar>
    </SafeAreaView>
    </World>
  );
}
WaterTrackerScreen.displayName = "WaterTrackerScreen";
```

Screen: https://lumioui.dev/screens/health-water-tracker
iPhone 17 · iOS
9:41
Live preview — the real screen via Expo Web · open full ↗