v0.1 public beta early access on GitHub
Home / Screens / ecommerce-recently-viewed
Screen template

Recently viewed Screen

Product photo grid ordered by view time with clear history.

pro Expo Go ✓ iosandroid gestures: tap · scroll haptics: light · selection
$ npx lumioui add ecommerce-recently-viewed
import { RecentlyViewedScreen } from "@/screens/ecommerce/recently-viewed";
Registry dependencies5
Native packages installed6
@lumioui/ui@latest@lumioui/core@latestreact-native-safe-area-context@*react-native-reanimated@*react-native-svg@*nativewind@*
ecommerce/recently-viewed.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 { Glass, Icon, Image, Text } from "@lumioui/ui";
import { useHaptic } from "@lumioui/core";
import { LumioMark, Mount, catalogImg, type CatalogPhoto, Press } from "../shared";

export interface RecentlyViewedItem {
  id: string;
  title: string;
  price: string;
  photo: CatalogPhoto;
  /** e.g. "2h ago" */
  viewedAt: string;
}

export interface RecentlyViewedScreenProps {
  items?: RecentlyViewedItem[];
  onItemPress?: (id: string) => void;
  onClearAll?: () => void;
  onBack?: () => void;
}

const DEFAULT_ITEMS: RecentlyViewedItem[] = [
  { id: "v1", title: "Check wool blazer", price: "$240", photo: "blazer", viewedAt: "2h ago" },
  { id: "v2", title: "Leather lace-up boots", price: "$198", photo: "boots", viewedAt: "5h ago" },
  { id: "v5", title: "Camel overcoat", price: "$310", photo: "overcoat", viewedAt: "6h ago" },
  { id: "v6", title: "Court sneakers", price: "$120", photo: "sneakers", viewedAt: "8h ago" },
  { id: "v3", title: "Volt trail runner", price: "$135", photo: "runner", viewedAt: "Yesterday" },
  { id: "v4", title: "Graphic print tee", price: "$42", photo: "graphicTee", viewedAt: "Yesterday" },
  { id: "v7", title: "Denim trucker jacket", price: "$98", photo: "denimJacket", viewedAt: "Yesterday" },
  { id: "v8", title: "Oxford white tee", price: "$28", photo: "whiteTee", viewedAt: "Yesterday" },
];

/** Recently viewed — product photo grid ordered by view time. */
export function RecentlyViewedScreen({
  items = DEFAULT_ITEMS,
  onItemPress,
  onClearAll,
  onBack,
}: RecentlyViewedScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [visible, setVisible] = React.useState(items);
  React.useEffect(() => setVisible(items), [items]);

  return (
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back disc + centered title pill + Clear text pill. */}
      <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>
          <Glass interactive effect="regular" className="h-11 items-center justify-center rounded-full">
            <Press
              haptic="light"
              onPress={() => {
                setVisible([]);
                onClearAll?.();
              }}
              accessibilityRole="button"
              accessibilityLabel="Clear history"
              className="h-9 items-center justify-center px-4"
            >
              <Text className="text-xs font-semibold">Clear</Text>
            </Press>
          </Glass>
        </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">
              Recently viewed
            </Text>
          </View>
        </View>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{
          paddingTop: insets.top + 60,
          paddingBottom: insets.bottom + 32,
          paddingHorizontal: 16,
        }}
      >
        {(["Today", "Earlier"] as const).map((day) => {
          const rows = visible.filter((i) =>
            day === "Today" ? i.viewedAt.includes("ago") : !i.viewedAt.includes("ago")
          );
          if (rows.length === 0) return null;
          return (
            <View key={day} className="pb-2">
              {/* Day grouping is the point of a recency list. */}
              <Text variant="small" className="pb-2 pt-1 text-muted-foreground">
                {day}
              </Text>
              <View className="flex-row flex-wrap justify-between gap-y-4">
                {rows.map((item) => (
                  <View key={item.id} className="w-[48%]">
                    <Press
                      haptic="light"
                      onPress={() => onItemPress?.(item.id)}
                      accessibilityLabel={`${item.title}, ${item.price}`}
                      className="w-full items-start justify-start p-0"
                    >
                      <View className="w-full">
                        <Image
                          source={{ uri: catalogImg(item.photo, 400, 500) }}
                          className="aspect-[4/5] w-full rounded-2xl bg-muted"
                          accessibilityLabel={item.title}
                        />
                        {/* Dismiss sits on the photo corner — remove without
                            leaving the screen. */}
                        <View className="absolute right-2 top-2 h-7 w-7 items-center justify-center rounded-full">
                          <Glass interactive effect="regular" className="absolute inset-0 rounded-full" />
                          <Press
                            haptic="light"
                            onPress={() =>
                              setVisible((p) => p.filter((x) => x.id !== item.id))
                            }
                            accessibilityRole="button"
                            accessibilityLabel={`Remove ${item.title}`}
                            className="h-5 w-5 items-center justify-center"
                          >
                            <Icon name="x" size="sm" color="foreground" />
                          </Press>
                        </View>
                        <View className="items-start gap-0.5 px-1 pt-2">
                          <Text variant="small" numberOfLines={1}>
                            {item.title}
                          </Text>
                          <View className="flex-row items-center justify-between self-stretch">
                            <Text variant="small" className="font-semibold">
                              {item.price}
                            </Text>
                            <Press
                              onPress={() => haptics.medium()}
                              accessibilityRole="button"
                              accessibilityLabel={`Add ${item.title} to bag`}
                              className="h-7 w-7 items-center justify-center rounded-full bg-[#1B1B26]"
                              hitSlop={4}
                            >
                              <Icon name="shopping-cart" size="sm" color="#FFFFFF" />
                            </Press>
                          </View>
                        </View>
                      </View>
                    </Press>
                  </View>
                ))}
              </View>
            </View>
          );
        })}

        {visible.length === 0 ? (
          <Text variant="small" className="pt-16 text-center text-muted-foreground">
            Items you view will show up here.
          </Text>
        ) : (
          <Press
            onPress={() => haptics.light()}
            accessibilityRole="button"
            accessibilityLabel="Continue shopping"
            className="mt-6 flex-row items-center justify-center gap-2 self-center rounded-full bg-[#1B1B26] px-5 py-2.5"
          >
            <Text variant="small" className="font-medium text-white">
              Continue shopping
            </Text>
            <Icon name="arrow-right" size="sm" color="#FFFFFF" />
          </Press>
        )}
        {/* Retention note — history pages say how long things linger. */}
        <Text variant="muted" className="px-6 pt-6 text-center text-xs">
          Your browsing history clears automatically after 30 days
        </Text>
      </ScrollView>
    </SafeAreaView>
  );
}
RecentlyViewedScreen.displayName = "RecentlyViewedScreen";
agent prompt — paste into Claude Code, Cursor, Devin…
Recreate the "Recently viewed Screen" screen in React Native using LumioUI.

Goal: Product photo grid ordered by view time with clear history. 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 ecommerce-recently-viewed
```

Or pull just the components: `npx lumioui add button glass icon image 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.
- imported but not rendered directly — likely used through a sibling or as a utility

### `glass` — iOS 26 liquid-glass surface — real glass via expo-glass-effect (Expo Go) or @callstack/liquid-glass (dev builds), SVG refraction + specular rim on web, frosted fallback elsewhere; GlassContainer melts adjacent panes into one blob
- `<Glass>` ×4

### `icon` — Lucide icon set mapped to theme colors and sizes.
- `<Icon>` ×4

### `image` — Cached image with placeholder, fallback and aspect handling.
- `<Image>` ×1

### `text` — Themed type scale from caption to display.
- `<Text>` ×8

## 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/ecommerce/recently-viewed.tsx` exporting RecentlyViewedScreen. 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 { Glass, Icon, Image, Text } from "@lumioui/ui";
import { useHaptic } from "@lumioui/core";
import { LumioMark, Mount, catalogImg, type CatalogPhoto, Press } from "../shared";

export interface RecentlyViewedItem {
  id: string;
  title: string;
  price: string;
  photo: CatalogPhoto;
  /** e.g. "2h ago" */
  viewedAt: string;
}

export interface RecentlyViewedScreenProps {
  items?: RecentlyViewedItem[];
  onItemPress?: (id: string) => void;
  onClearAll?: () => void;
  onBack?: () => void;
}

const DEFAULT_ITEMS: RecentlyViewedItem[] = [
  { id: "v1", title: "Check wool blazer", price: "$240", photo: "blazer", viewedAt: "2h ago" },
  { id: "v2", title: "Leather lace-up boots", price: "$198", photo: "boots", viewedAt: "5h ago" },
  { id: "v5", title: "Camel overcoat", price: "$310", photo: "overcoat", viewedAt: "6h ago" },
  { id: "v6", title: "Court sneakers", price: "$120", photo: "sneakers", viewedAt: "8h ago" },
  { id: "v3", title: "Volt trail runner", price: "$135", photo: "runner", viewedAt: "Yesterday" },
  { id: "v4", title: "Graphic print tee", price: "$42", photo: "graphicTee", viewedAt: "Yesterday" },
  { id: "v7", title: "Denim trucker jacket", price: "$98", photo: "denimJacket", viewedAt: "Yesterday" },
  { id: "v8", title: "Oxford white tee", price: "$28", photo: "whiteTee", viewedAt: "Yesterday" },
];

/** Recently viewed — product photo grid ordered by view time. */
export function RecentlyViewedScreen({
  items = DEFAULT_ITEMS,
  onItemPress,
  onClearAll,
  onBack,
}: RecentlyViewedScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [visible, setVisible] = React.useState(items);
  React.useEffect(() => setVisible(items), [items]);

  return (
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back disc + centered title pill + Clear text pill. */}
      <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>
          <Glass interactive effect="regular" className="h-11 items-center justify-center rounded-full">
            <Press
              haptic="light"
              onPress={() => {
                setVisible([]);
                onClearAll?.();
              }}
              accessibilityRole="button"
              accessibilityLabel="Clear history"
              className="h-9 items-center justify-center px-4"
            >
              <Text className="text-xs font-semibold">Clear</Text>
            </Press>
          </Glass>
        </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">
              Recently viewed
            </Text>
          </View>
        </View>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{
          paddingTop: insets.top + 60,
          paddingBottom: insets.bottom + 32,
          paddingHorizontal: 16,
        }}
      >
        {(["Today", "Earlier"] as const).map((day) => {
          const rows = visible.filter((i) =>
            day === "Today" ? i.viewedAt.includes("ago") : !i.viewedAt.includes("ago")
          );
          if (rows.length === 0) return null;
          return (
            <View key={day} className="pb-2">
              {/* Day grouping is the point of a recency list. */}
              <Text variant="small" className="pb-2 pt-1 text-muted-foreground">
                {day}
              </Text>
              <View className="flex-row flex-wrap justify-between gap-y-4">
                {rows.map((item) => (
                  <View key={item.id} className="w-[48%]">
                    <Press
                      haptic="light"
                      onPress={() => onItemPress?.(item.id)}
                      accessibilityLabel={`${item.title}, ${item.price}`}
                      className="w-full items-start justify-start p-0"
                    >
                      <View className="w-full">
                        <Image
                          source={{ uri: catalogImg(item.photo, 400, 500) }}
                          className="aspect-[4/5] w-full rounded-2xl bg-muted"
                          accessibilityLabel={item.title}
                        />
                        {/* Dismiss sits on the photo corner — remove without
                            leaving the screen. */}
                        <View className="absolute right-2 top-2 h-7 w-7 items-center justify-center rounded-full">
                          <Glass interactive effect="regular" className="absolute inset-0 rounded-full" />
                          <Press
                            haptic="light"
                            onPress={() =>
                              setVisible((p) => p.filter((x) => x.id !== item.id))
                            }
                            accessibilityRole="button"
                            accessibilityLabel={`Remove ${item.title}`}
                            className="h-5 w-5 items-center justify-center"
                          >
                            <Icon name="x" size="sm" color="foreground" />
                          </Press>
                        </View>
                        <View className="items-start gap-0.5 px-1 pt-2">
                          <Text variant="small" numberOfLines={1}>
                            {item.title}
                          </Text>
                          <View className="flex-row items-center justify-between self-stretch">
                            <Text variant="small" className="font-semibold">
                              {item.price}
                            </Text>
                            <Press
                              onPress={() => haptics.medium()}
                              accessibilityRole="button"
                              accessibilityLabel={`Add ${item.title} to bag`}
                              className="h-7 w-7 items-center justify-center rounded-full bg-[#1B1B26]"
                              hitSlop={4}
                            >
                              <Icon name="shopping-cart" size="sm" color="#FFFFFF" />
                            </Press>
                          </View>
                        </View>
                      </View>
                    </Press>
                  </View>
                ))}
              </View>
            </View>
          );
        })}

        {visible.length === 0 ? (
          <Text variant="small" className="pt-16 text-center text-muted-foreground">
            Items you view will show up here.
          </Text>
        ) : (
          <Press
            onPress={() => haptics.light()}
            accessibilityRole="button"
            accessibilityLabel="Continue shopping"
            className="mt-6 flex-row items-center justify-center gap-2 self-center rounded-full bg-[#1B1B26] px-5 py-2.5"
          >
            <Text variant="small" className="font-medium text-white">
              Continue shopping
            </Text>
            <Icon name="arrow-right" size="sm" color="#FFFFFF" />
          </Press>
        )}
        {/* Retention note — history pages say how long things linger. */}
        <Text variant="muted" className="px-6 pt-6 text-center text-xs">
          Your browsing history clears automatically after 30 days
        </Text>
      </ScrollView>
    </SafeAreaView>
  );
}
RecentlyViewedScreen.displayName = "RecentlyViewedScreen";
```

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