v0.1 public beta early access on GitHub
Home / Screens / core-invite-friends
Screen template

Invite Friends Screen

Referral card with tappable copy-code pill and share CTA over a contacts list whose Invite buttons latch to an invited state

pro Expo Go ✓ iosandroid gestures: tap · scroll haptics: light · medium · selection
$ npx lumioui add core-invite-friends
import { InviteFriendsScreen } from "@/screens/core/invite-friends";
Registry dependencies5
Native packages installed6
@lumioui/ui@latest@lumioui/core@latestreact-native-safe-area-context@*react-native-reanimated@*react-native-svg@*nativewind@*
core/invite-friends.tsxsource · yours to edit
import * as React from "react";
import { useState } from "react";
import { View, ScrollView, Pressable } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Avatar, Button, Glass, Icon, Separator, Text } from "@lumioui/ui";
import { AnimatedPressable, useHaptic, usePressAnimation } from "@lumioui/core";

import { BLOCK_STAGGER, Mount, ROW_STAGGER, ROW_STAGGER_CAP } from "../shared";
export interface InviteContact {
  id: string;
  name: string;
  /** Secondary line — handle, phone, or mutual context. */
  detail?: string;
  avatarUrl?: string;
  /** Already invited — renders the check state and disables the button. */
  invited?: boolean;
}

export interface InviteFriendsScreenProps {
  referralCode?: string;
  /** Reward headline copy — e.g. "a free month of Lumio Pro". */
  reward?: string;
  contacts?: InviteContact[];
  onCopyCode?: (code: string) => void;
  onShare?: () => void;
  onInvite?: (contact: InviteContact) => void;
  onBack?: () => void;
}

const face = (n: number) => `https://i.pravatar.cc/150?img=${n}`;

const DEFAULT_CONTACTS: InviteContact[] = [
  { id: "c1", name: "Tom Reed", detail: "@tomreed · Berlin", avatarUrl: face(12) },
  { id: "c2", name: "Priya Nair", detail: "@priyanair · Toronto", avatarUrl: face(32) },
  { id: "c3", name: "Diego Ruiz", detail: "@diegoruiz · Lisbon", avatarUrl: face(53) },
  { id: "c4", name: "Maya Chen", detail: "@mayachen · Seoul", avatarUrl: face(47), invited: true },
  { id: "c5", name: "Nina Petrova", detail: "@ninapetrova · Vienna", avatarUrl: face(20) },
];

function ContactRow({
  contact,
  invited,
  onInvite,
}: {
  contact: InviteContact;
  invited: boolean;
  onInvite?: (contact: InviteContact) => void;
}) {
  const haptics = useHaptic();
  const press = usePressAnimation({ fast: true });
  return (
    <View className="flex-row items-center gap-3 py-2.5">
      <Avatar
        size="md"
        source={contact.avatarUrl ? { uri: contact.avatarUrl } : undefined}
        fallback={contact.name}
        alt={`${contact.name}'s avatar`}
      />
      <View className="flex-1 gap-0.5">
        <Text variant="small" className="font-semibold" numberOfLines={1}>
          {contact.name}
        </Text>
        {contact.detail ? (
          <Text variant="muted" className="text-xs" numberOfLines={1}>
            {contact.detail}
          </Text>
        ) : null}
      </View>
      {invited ? (
        <View
          className="h-8 flex-row items-center gap-1.5 px-2"
          accessibilityLabel={`Invite sent to ${contact.name}`}
        >
          <Icon name="check" size="sm" color="success" />
          <Text variant="small" className="font-medium text-muted-foreground">
            Invited
          </Text>
        </View>
      ) : (
        <AnimatedPressable
          onPress={() => {
            haptics.selection();
            onInvite?.(contact);
          }}
          onPressIn={press.onPressIn}
          onPressOut={press.onPressOut}
          style={press.animatedStyle}
          accessibilityRole="button"
          accessibilityLabel={`Invite ${contact.name}`}
          className="h-8 items-center justify-center rounded-full bg-[#BEF04C] px-4"
        >
          <Text variant="small" className="font-semibold text-[#1B1B26]">
            Invite
          </Text>
        </AnimatedPressable>
      )}
    </View>
  );
}
ContactRow.displayName = "ContactRow";

/** Invite friends — referral card with copy/share code over a contact list
 *  of per-row Invite buttons that latch to "Invited". */
export function InviteFriendsScreen({
  referralCode = "AMARA-4821",
  reward = "a free month of Lumio Pro",
  contacts = DEFAULT_CONTACTS,
  onCopyCode,
  onShare,
  onInvite,
  onBack,
}: InviteFriendsScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [copied, setCopied] = useState(false);
  // Local mirror of invited state so rows latch even without a wired host.
  const [invitedIds, setInvitedIds] = useState<Set<string>>(
    () => new Set(contacts.filter((c) => c.invited).map((c) => c.id))
  );

  const invite = (contact: InviteContact) => {
    setInvitedIds((prev) => new Set(prev).add(contact.id));
    onInvite?.(contact);
  };

  const copy = () => {
    haptics.selection();
    setCopied(true);
    onCopyCode?.(referralCode);
    // Re-arm after a beat — the check state shouldn't outlive the moment.
    setTimeout(() => setCopied(false), 1600);
  };

  return (
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back pill + hug-label title pill. */}
      <View className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }} pointerEvents="box-none">
        <View className="flex-row items-center gap-2">
          <Glass
            effect="regular"
            className="h-11 w-11 items-center justify-center rounded-full"
          >
            <Button
              variant="ghost"
              size="icon"
              haptic="light"
              onPress={() => onBack?.()}
              accessibilityLabel="Go back"
              className="h-9 w-9"
            >
              <Icon name="chevron-left" size="md" color="foreground" />
            </Button>
          </Glass>
        </View>
        <View pointerEvents="none" className="absolute inset-0 items-center justify-center">
          <Glass
            effect="regular"
            className="h-11 flex-row items-center justify-center rounded-full px-5"
          >
            <Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
              Invite friends
            </Text>
          </Glass>
        </View>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingTop: insets.top + 60, paddingBottom: insets.bottom + 32 }}
      >
        {/* Referral card — the pitch + the code worth copying. */}
        <Mount className="px-6 pt-2">
          <View className="gap-4 rounded-3xl bg-[#1B1B26] p-5">
            <View className="flex-row items-center gap-3">
              <View className="h-11 w-11 items-center justify-center rounded-2xl bg-[#BEF04C]">
                <Icon name="user-plus" size="md" color="#1B1B26" />
              </View>
              <View className="flex-1">
                <Text variant="large" className="text-white">
                  Give a month, get a month
                </Text>
                <Text className="text-sm text-white/60">
                  Friends who join with your code both get {reward}.
                </Text>
              </View>
            </View>

            {/* Social proof — faces already inside make the ask feel warm. */}
            <View className="flex-row items-center gap-2.5">
              <View className="flex-row">
                {contacts.slice(0, 4).map((c, i) => (
                  <View
                    key={c.id}
                    className="overflow-hidden rounded-full border-2 border-[#1B1B26]"
                    style={{ marginLeft: i === 0 ? 0 : -10 }}
                  >
                    <Avatar
                      size="sm"
                      source={c.avatarUrl ? { uri: c.avatarUrl } : undefined}
                      fallback={c.name}
                      alt={c.name}
                    />
                  </View>
                ))}
                <View className="-ml-2 h-6 min-w-6 items-center justify-center rounded-full border-2 border-[#1B1B26] bg-[#BEF04C] px-1.5">
                  <Text className="text-[10px] font-bold text-[#1B1B26]">214</Text>
                </View>
              </View>
              <Text className="text-xs text-white/55">friends already here</Text>
            </View>

            {/* Link row — the URL itself, since friends tap links, not codes. */}
            <View className="mb-2 flex-row items-center gap-2 rounded-xl bg-white/10 px-4 py-2.5">
              <Icon name="link" size="sm" color="#BEF04C" />
              <Text className="flex-1 font-mono text-sm text-white/80" numberOfLines={1}>
                lumio.app/r/{referralCode.toLowerCase()}
              </Text>
            </View>

            {/* Code pill — the whole strip is the copy target. */}
            <Pressable
              onPress={copy}
              accessibilityRole="button"
              accessibilityLabel={`Referral code ${referralCode}, tap to copy`}
              className="min-h-11 flex-row items-center justify-between rounded-xl bg-white/10 px-4"
            >
              <Text
                variant="large"
                className="font-bold tracking-widest text-white"
              >
                {referralCode}
              </Text>
              <View className="flex-row items-center gap-1.5">
                <Icon
                  name={copied ? "check" : "copy"}
                  size="sm"
                  color="#BEF04C"
                />
                <Text variant="small" className="font-semibold text-[#BEF04C]">
                  {copied ? "Copied" : "Copy"}
                </Text>
              </View>
            </Pressable>

            <Button
              variant="secondary"
              haptic="medium"
              icon={<Icon name="share" size="sm" color="#1B1B26" />}
              onPress={onShare}
              accessibilityLabel="Share your referral link"
              className="bg-[#BEF04C]"
              textClassName="text-[#1B1B26]"
            >
              Share invite link
            </Button>
          </View>
        </Mount>

        {/* Contacts — label lands with the section, rows stagger under it. */}
        <View className="px-6 pt-7">
          <Mount delay={BLOCK_STAGGER}>
            <Text
              variant="muted"
              accessibilityRole="header"
              className="pb-1 text-xs font-semibold uppercase tracking-wider"
            >
              From your contacts
            </Text>
          </Mount>
          {/* Grouped white card — rows breathe inside one surface. */}
          <View className="overflow-hidden rounded-3xl bg-white px-4 py-1.5 dark:bg-[#1A1A20]">
            {contacts.map((contact, i) => (
              <View key={contact.id}>
                <Mount delay={BLOCK_STAGGER + Math.min((i + 1) * ROW_STAGGER, ROW_STAGGER_CAP)}>
                  <ContactRow
                    contact={contact}
                    invited={invitedIds.has(contact.id)}
                    onInvite={invite}
                  />
                </Mount>
                {i < contacts.length - 1 ? <Separator className="ml-[60px]" /> : null}
              </View>
            ))}
          </View>
        </View>

        {/* Footnote — honest terms, muted. */}
        <Mount delay={BLOCK_STAGGER * 3}>
          <Text variant="muted" className="px-6 pt-6 text-center text-xs leading-5">
            Rewards land when your friend finishes onboarding. Up to 10 per year.
          </Text>
        </Mount>
      </ScrollView>
    </SafeAreaView>
  );
}
InviteFriendsScreen.displayName = "InviteFriendsScreen";
agent prompt — paste into Claude Code, Cursor, Devin…
Recreate the "Invite Friends Screen" screen in React Native using LumioUI.

Goal: Referral card with tappable copy-code pill and share CTA over a contacts list whose Invite buttons latch to an invited state 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 core-invite-friends
```

Or pull just the components: `npx lumioui add avatar button icon separator 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

### `avatar` — Circular user image with fallback initials and status dot.
- `<Avatar>` ×2

### `button` — Tactile pill button with press spring, ink wash and async loading.
- `<Button>` ×2

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

### `separator` — Hairline rule with orientation and spacing control.
- `<Separator>` ×1

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

## 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/core/invite-friends.tsx` exporting InviteFriendsScreen. 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 { useState } from "react";
import { View, ScrollView, Pressable } from "react-native";
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
import { Avatar, Button, Glass, Icon, Separator, Text } from "@lumioui/ui";
import { AnimatedPressable, useHaptic, usePressAnimation } from "@lumioui/core";

import { BLOCK_STAGGER, Mount, ROW_STAGGER, ROW_STAGGER_CAP } from "../shared";
export interface InviteContact {
  id: string;
  name: string;
  /** Secondary line — handle, phone, or mutual context. */
  detail?: string;
  avatarUrl?: string;
  /** Already invited — renders the check state and disables the button. */
  invited?: boolean;
}

export interface InviteFriendsScreenProps {
  referralCode?: string;
  /** Reward headline copy — e.g. "a free month of Lumio Pro". */
  reward?: string;
  contacts?: InviteContact[];
  onCopyCode?: (code: string) => void;
  onShare?: () => void;
  onInvite?: (contact: InviteContact) => void;
  onBack?: () => void;
}

const face = (n: number) => `https://i.pravatar.cc/150?img=${n}`;

const DEFAULT_CONTACTS: InviteContact[] = [
  { id: "c1", name: "Tom Reed", detail: "@tomreed · Berlin", avatarUrl: face(12) },
  { id: "c2", name: "Priya Nair", detail: "@priyanair · Toronto", avatarUrl: face(32) },
  { id: "c3", name: "Diego Ruiz", detail: "@diegoruiz · Lisbon", avatarUrl: face(53) },
  { id: "c4", name: "Maya Chen", detail: "@mayachen · Seoul", avatarUrl: face(47), invited: true },
  { id: "c5", name: "Nina Petrova", detail: "@ninapetrova · Vienna", avatarUrl: face(20) },
];

function ContactRow({
  contact,
  invited,
  onInvite,
}: {
  contact: InviteContact;
  invited: boolean;
  onInvite?: (contact: InviteContact) => void;
}) {
  const haptics = useHaptic();
  const press = usePressAnimation({ fast: true });
  return (
    <View className="flex-row items-center gap-3 py-2.5">
      <Avatar
        size="md"
        source={contact.avatarUrl ? { uri: contact.avatarUrl } : undefined}
        fallback={contact.name}
        alt={`${contact.name}'s avatar`}
      />
      <View className="flex-1 gap-0.5">
        <Text variant="small" className="font-semibold" numberOfLines={1}>
          {contact.name}
        </Text>
        {contact.detail ? (
          <Text variant="muted" className="text-xs" numberOfLines={1}>
            {contact.detail}
          </Text>
        ) : null}
      </View>
      {invited ? (
        <View
          className="h-8 flex-row items-center gap-1.5 px-2"
          accessibilityLabel={`Invite sent to ${contact.name}`}
        >
          <Icon name="check" size="sm" color="success" />
          <Text variant="small" className="font-medium text-muted-foreground">
            Invited
          </Text>
        </View>
      ) : (
        <AnimatedPressable
          onPress={() => {
            haptics.selection();
            onInvite?.(contact);
          }}
          onPressIn={press.onPressIn}
          onPressOut={press.onPressOut}
          style={press.animatedStyle}
          accessibilityRole="button"
          accessibilityLabel={`Invite ${contact.name}`}
          className="h-8 items-center justify-center rounded-full bg-[#BEF04C] px-4"
        >
          <Text variant="small" className="font-semibold text-[#1B1B26]">
            Invite
          </Text>
        </AnimatedPressable>
      )}
    </View>
  );
}
ContactRow.displayName = "ContactRow";

/** Invite friends — referral card with copy/share code over a contact list
 *  of per-row Invite buttons that latch to "Invited". */
export function InviteFriendsScreen({
  referralCode = "AMARA-4821",
  reward = "a free month of Lumio Pro",
  contacts = DEFAULT_CONTACTS,
  onCopyCode,
  onShare,
  onInvite,
  onBack,
}: InviteFriendsScreenProps) {
  const haptics = useHaptic();
  const insets = useSafeAreaInsets();
  const [copied, setCopied] = useState(false);
  // Local mirror of invited state so rows latch even without a wired host.
  const [invitedIds, setInvitedIds] = useState<Set<string>>(
    () => new Set(contacts.filter((c) => c.invited).map((c) => c.id))
  );

  const invite = (contact: InviteContact) => {
    setInvitedIds((prev) => new Set(prev).add(contact.id));
    onInvite?.(contact);
  };

  const copy = () => {
    haptics.selection();
    setCopied(true);
    onCopyCode?.(referralCode);
    // Re-arm after a beat — the check state shouldn't outlive the moment.
    setTimeout(() => setCopied(false), 1600);
  };

  return (
    <SafeAreaView className="flex-1 bg-[#F4F5F9] dark:bg-[#111114]" edges={["top"]}>
      {/* Floating chrome — back pill + hug-label title pill. */}
      <View className="absolute inset-x-4 z-10" style={{ top: insets.top + 8 }} pointerEvents="box-none">
        <View className="flex-row items-center gap-2">
          <Glass
            effect="regular"
            className="h-11 w-11 items-center justify-center rounded-full"
          >
            <Button
              variant="ghost"
              size="icon"
              haptic="light"
              onPress={() => onBack?.()}
              accessibilityLabel="Go back"
              className="h-9 w-9"
            >
              <Icon name="chevron-left" size="md" color="foreground" />
            </Button>
          </Glass>
        </View>
        <View pointerEvents="none" className="absolute inset-0 items-center justify-center">
          <Glass
            effect="regular"
            className="h-11 flex-row items-center justify-center rounded-full px-5"
          >
            <Text accessibilityRole="header" className="text-sm font-bold tracking-tight">
              Invite friends
            </Text>
          </Glass>
        </View>
      </View>

      <ScrollView
        showsVerticalScrollIndicator={false}
        contentContainerStyle={{ paddingTop: insets.top + 60, paddingBottom: insets.bottom + 32 }}
      >
        {/* Referral card — the pitch + the code worth copying. */}
        <Mount className="px-6 pt-2">
          <View className="gap-4 rounded-3xl bg-[#1B1B26] p-5">
            <View className="flex-row items-center gap-3">
              <View className="h-11 w-11 items-center justify-center rounded-2xl bg-[#BEF04C]">
                <Icon name="user-plus" size="md" color="#1B1B26" />
              </View>
              <View className="flex-1">
                <Text variant="large" className="text-white">
                  Give a month, get a month
                </Text>
                <Text className="text-sm text-white/60">
                  Friends who join with your code both get {reward}.
                </Text>
              </View>
            </View>

            {/* Social proof — faces already inside make the ask feel warm. */}
            <View className="flex-row items-center gap-2.5">
              <View className="flex-row">
                {contacts.slice(0, 4).map((c, i) => (
                  <View
                    key={c.id}
                    className="overflow-hidden rounded-full border-2 border-[#1B1B26]"
                    style={{ marginLeft: i === 0 ? 0 : -10 }}
                  >
                    <Avatar
                      size="sm"
                      source={c.avatarUrl ? { uri: c.avatarUrl } : undefined}
                      fallback={c.name}
                      alt={c.name}
                    />
                  </View>
                ))}
                <View className="-ml-2 h-6 min-w-6 items-center justify-center rounded-full border-2 border-[#1B1B26] bg-[#BEF04C] px-1.5">
                  <Text className="text-[10px] font-bold text-[#1B1B26]">214</Text>
                </View>
              </View>
              <Text className="text-xs text-white/55">friends already here</Text>
            </View>

            {/* Link row — the URL itself, since friends tap links, not codes. */}
            <View className="mb-2 flex-row items-center gap-2 rounded-xl bg-white/10 px-4 py-2.5">
              <Icon name="link" size="sm" color="#BEF04C" />
              <Text className="flex-1 font-mono text-sm text-white/80" numberOfLines={1}>
                lumio.app/r/{referralCode.toLowerCase()}
              </Text>
            </View>

            {/* Code pill — the whole strip is the copy target. */}
            <Pressable
              onPress={copy}
              accessibilityRole="button"
              accessibilityLabel={`Referral code ${referralCode}, tap to copy`}
              className="min-h-11 flex-row items-center justify-between rounded-xl bg-white/10 px-4"
            >
              <Text
                variant="large"
                className="font-bold tracking-widest text-white"
              >
                {referralCode}
              </Text>
              <View className="flex-row items-center gap-1.5">
                <Icon
                  name={copied ? "check" : "copy"}
                  size="sm"
                  color="#BEF04C"
                />
                <Text variant="small" className="font-semibold text-[#BEF04C]">
                  {copied ? "Copied" : "Copy"}
                </Text>
              </View>
            </Pressable>

            <Button
              variant="secondary"
              haptic="medium"
              icon={<Icon name="share" size="sm" color="#1B1B26" />}
              onPress={onShare}
              accessibilityLabel="Share your referral link"
              className="bg-[#BEF04C]"
              textClassName="text-[#1B1B26]"
            >
              Share invite link
            </Button>
          </View>
        </Mount>

        {/* Contacts — label lands with the section, rows stagger under it. */}
        <View className="px-6 pt-7">
          <Mount delay={BLOCK_STAGGER}>
            <Text
              variant="muted"
              accessibilityRole="header"
              className="pb-1 text-xs font-semibold uppercase tracking-wider"
            >
              From your contacts
            </Text>
          </Mount>
          {/* Grouped white card — rows breathe inside one surface. */}
          <View className="overflow-hidden rounded-3xl bg-white px-4 py-1.5 dark:bg-[#1A1A20]">
            {contacts.map((contact, i) => (
              <View key={contact.id}>
                <Mount delay={BLOCK_STAGGER + Math.min((i + 1) * ROW_STAGGER, ROW_STAGGER_CAP)}>
                  <ContactRow
                    contact={contact}
                    invited={invitedIds.has(contact.id)}
                    onInvite={invite}
                  />
                </Mount>
                {i < contacts.length - 1 ? <Separator className="ml-[60px]" /> : null}
              </View>
            ))}
          </View>
        </View>

        {/* Footnote — honest terms, muted. */}
        <Mount delay={BLOCK_STAGGER * 3}>
          <Text variant="muted" className="px-6 pt-6 text-center text-xs leading-5">
            Rewards land when your friend finishes onboarding. Up to 10 per year.
          </Text>
        </Mount>
      </ScrollView>
    </SafeAreaView>
  );
}
InviteFriendsScreen.displayName = "InviteFriendsScreen";
```

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