{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "profile",
  "type": "registry:block",
  "title": "Profile",
  "description": "A profile and settings screen: a turning avatar ring, stats that count up and grouped rows with switches.",
  "categories": [
    "screen"
  ],
  "dependencies": [
    "react-native-reanimated",
    "react-native-safe-area-context",
    "react-native-worklets"
  ],
  "registryDependencies": [
    "https://kinetik-ui.dev/r/kinetik-tokens.json",
    "https://kinetik-ui.dev/r/kinetik-motion.json",
    "https://kinetik-ui.dev/r/kinetik-count.json",
    "https://kinetik-ui.dev/r/press-jelly.json",
    "https://kinetik-ui.dev/r/pulse-toggle.json"
  ],
  "files": [
    {
      "path": "src/components/kinetik/screens/profile.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/screens/profile.tsx",
      "content": "import { useEffect, type ReactNode } from 'react';\nimport {\n  Image,\n  Pressable,\n  ScrollView,\n  StyleSheet,\n  Text,\n  View,\n  type ImageSourcePropType,\n} from 'react-native';\nimport Animated, {\n  FadeInDown,\n  useAnimatedStyle,\n  useSharedValue,\n  withRepeat,\n  withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport { PressJelly } from '../press-jelly';\nimport { PulseToggle } from '../pulse-toggle';\nimport { durations, easings, timing } from '../../../lib/kinetik/motion/motion';\nimport { useCountUp } from '../../../lib/kinetik/hooks/use-count-up';\nimport { useReduceMotion } from '../../../lib/kinetik/hooks/use-reduce-motion';\nimport { gradient } from '../../../lib/kinetik/tokens/gradient';\nimport { useKinetikTheme } from '../../../lib/kinetik/tokens/theme';\nimport { minTouchTarget } from '../../../lib/kinetik/tokens/tokens';\n\nexport type ProfileUser = {\n  name: string;\n  /** Line under the name, e.g. \"@ada\" or an email. */\n  handle?: string;\n  avatar?: ImageSourcePropType;\n};\n\nexport type ProfileStat = { label: string; value: number };\n\nexport type ProfileRow = {\n  key: string;\n  label: string;\n  /** Icon in the rounded tile at the start of the row. */\n  icon?: ReactNode;\n  /** Quiet text before the chevron, e.g. \"English\". */\n  detail?: string;\n  onPress?: () => void;\n  /** Makes the row a switch instead of a link. */\n  toggle?: { value: boolean; onValueChange: (value: boolean) => void };\n};\n\nexport type ProfileSection = { title?: string; rows: readonly ProfileRow[] };\n\nexport type ProfileProps = {\n  user: ProfileUser;\n  stats?: readonly ProfileStat[];\n  /** A highlighted card under the stats, e.g. the current subscription. */\n  plan?: { title: string; detail?: string; onPress?: () => void };\n  sections?: readonly ProfileSection[];\n  onEdit?: () => void;\n  /** Adds a Sign out row at the end. */\n  onSignOut?: () => void;\n};\n\nconst DEFAULT_SECTIONS: ProfileSection[] = [\n  {\n    title: 'Account',\n    rows: [\n      { key: 'info', label: 'Personal info' },\n      { key: 'security', label: 'Password and security' },\n    ],\n  },\n  {\n    title: 'Support',\n    rows: [\n      { key: 'help', label: 'Help center' },\n      { key: 'privacy', label: 'Privacy' },\n    ],\n  },\n];\n\n/** 1,234 stays as is; larger counts shorten to 12.4k and 1.2M. */\nexport function compactCount(n: number): string {\n  if (n < 10_000) return Math.round(n).toLocaleString('en-US');\n  if (n < 1_000_000) return `${(n / 1000).toFixed(n < 100_000 ? 1 : 0).replace(/\\.0$/, '')}k`;\n  return `${(n / 1_000_000).toFixed(1).replace(/\\.0$/, '')}M`;\n}\n\n/**\n * A profile and settings screen: an avatar inside a slowly turning ring,\n * stats that count up, an optional plan card and grouped rows with links and\n * switches, all settling in from the top.\n */\nexport function Profile({\n  user,\n  stats = [],\n  plan,\n  sections = DEFAULT_SECTIONS,\n  onEdit,\n  onSignOut,\n}: ProfileProps) {\n  const { colors, space, font, radius } = useKinetikTheme();\n  const insets = useSafeAreaInsets();\n  const reduced = useReduceMotion();\n\n  const enter = (step: number) =>\n    reduced\n      ? undefined\n      : FadeInDown.delay(80 + step * 70)\n          .duration(durations.slow)\n          .easing(easings.standard);\n\n  const all: ProfileSection[] = onSignOut\n    ? [...sections, { rows: [{ key: 'sign-out', label: 'Sign out', onPress: onSignOut }] }]\n    : [...sections];\n\n  return (\n    <ScrollView\n      style={[styles.fill, { backgroundColor: colors.background }]}\n      contentContainerStyle={{\n        paddingTop: insets.top + space[8],\n        paddingBottom: insets.bottom + space[8],\n        paddingHorizontal: space[5],\n        gap: space[6],\n      }}\n      showsVerticalScrollIndicator={false}\n    >\n      <Animated.View entering={enter(0)} style={[styles.head, { gap: space[3] }]}>\n        <Avatar user={user} />\n        <View style={{ alignItems: 'center', gap: 2 }}>\n          <Text\n            accessibilityRole=\"header\"\n            style={{\n              color: colors.text,\n              fontSize: font.size.xl,\n              fontWeight: font.weight.bold,\n              letterSpacing: font.tracking.tight,\n            }}\n          >\n            {user.name}\n          </Text>\n          {user.handle ? (\n            <Text style={{ color: colors.textMuted, fontSize: font.size.sm }}>{user.handle}</Text>\n          ) : null}\n        </View>\n        {onEdit ? (\n          <PressJelly variant=\"surface\" onPress={onEdit} style={styles.center}>\n            Edit profile\n          </PressJelly>\n        ) : null}\n      </Animated.View>\n\n      {stats.length > 0 ? (\n        <Animated.View\n          entering={enter(1)}\n          style={[\n            styles.stats,\n            {\n              backgroundColor: colors.surface,\n              borderColor: colors.border,\n              borderRadius: radius.lg,\n              paddingVertical: space[4],\n            },\n          ]}\n        >\n          {stats.map((s, i) => (\n            <View key={s.label} style={styles.statSlot}>\n              {i > 0 ? (\n                <View style={[styles.statRule, { backgroundColor: colors.border }]} />\n              ) : null}\n              <Stat stat={s} />\n            </View>\n          ))}\n        </Animated.View>\n      ) : null}\n\n      {plan ? (\n        <Animated.View entering={enter(2)}>\n          <Pressable\n            accessibilityRole={plan.onPress ? 'button' : undefined}\n            accessibilityLabel={[plan.title, plan.detail].filter(Boolean).join(', ')}\n            onPress={plan.onPress}\n            disabled={!plan.onPress}\n            style={[\n              styles.plan,\n              { borderRadius: radius.lg, padding: space[4], gap: space[3] },\n              gradient(`linear-gradient(120deg, ${colors.azure} 0%, ${colors.sky} 100%)`),\n            ]}\n          >\n            <View style={styles.fill}>\n              <Text\n                style={{\n                  color: colors.onAzure,\n                  fontSize: font.size.md,\n                  fontWeight: font.weight.bold,\n                }}\n              >\n                {plan.title}\n              </Text>\n              {plan.detail ? (\n                <Text style={{ color: colors.onAzure, fontSize: font.size.sm, opacity: 0.85 }}>\n                  {plan.detail}\n                </Text>\n              ) : null}\n            </View>\n            {plan.onPress ? <Chevron color={colors.onAzure} /> : null}\n          </Pressable>\n        </Animated.View>\n      ) : null}\n\n      {all.map((section, i) => (\n        <Animated.View\n          key={section.title ?? `section-${i}`}\n          entering={enter(3 + i)}\n          style={{ gap: space[2] }}\n        >\n          {section.title ? (\n            <Text\n              accessibilityRole=\"header\"\n              style={{\n                color: colors.textSubtle,\n                fontSize: font.size.xs,\n                fontWeight: font.weight.semibold,\n                letterSpacing: font.tracking.wide,\n                marginLeft: space[1],\n              }}\n            >\n              {section.title.toUpperCase()}\n            </Text>\n          ) : null}\n          <View\n            style={[\n              styles.group,\n              {\n                backgroundColor: colors.surface,\n                borderColor: colors.border,\n                borderRadius: radius.lg,\n              },\n            ]}\n          >\n            {section.rows.map((row, j) => (\n              <Row key={row.key} row={row} first={j === 0} danger={row.key === 'sign-out'} />\n            ))}\n          </View>\n        </Animated.View>\n      ))}\n    </ScrollView>\n  );\n}\n\n/** The photo or initials inside a ring of colour that turns slowly. */\nfunction Avatar({ user }: { user: ProfileUser }) {\n  const { colors, font } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const turn = useSharedValue(0);\n\n  useEffect(() => {\n    turn.set(\n      reduced\n        ? 0\n        : withRepeat(withTiming(1, { ...timing('slow', false, 'linear'), duration: 8000 }), -1),\n    );\n  }, [reduced, turn]);\n\n  const spin = useAnimatedStyle(() => ({ transform: [{ rotate: `${turn.get() * 360}deg` }] }));\n  const initials = user.name\n    .split(/\\s+/)\n    .filter(Boolean)\n    .slice(0, 2)\n    .map((w) => w[0]?.toUpperCase())\n    .join('');\n\n  return (\n    <View style={styles.avatarSlot} aria-hidden>\n      <View style={styles.ring}>\n        <Animated.View\n          style={[\n            styles.ringFill,\n            gradient(\n              `linear-gradient(135deg, ${colors.azure} 0%, ${colors.sky} 35%, ${colors.success} 70%, ${colors.warning} 100%)`,\n            ),\n            spin,\n          ]}\n        />\n      </View>\n      <View\n        style={[\n          styles.avatar,\n          { backgroundColor: colors.surfaceRaised, borderColor: colors.background },\n        ]}\n      >\n        {user.avatar ? (\n          <Image source={user.avatar} style={styles.photo} />\n        ) : (\n          <Text\n            style={{ color: colors.text, fontSize: font.size.xl, fontWeight: font.weight.bold }}\n          >\n            {initials}\n          </Text>\n        )}\n      </View>\n    </View>\n  );\n}\n\nfunction Stat({ stat }: { stat: ProfileStat }) {\n  const { colors, font } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const shown = useCountUp(stat.value, { instant: reduced, duration: 1100 });\n  return (\n    <View\n      accessible\n      accessibilityLabel={`${compactCount(stat.value)} ${stat.label}`}\n      style={styles.stat}\n    >\n      <Text\n        style={{\n          color: colors.text,\n          fontSize: font.size.lg,\n          fontWeight: font.weight.bold,\n          fontVariant: ['tabular-nums'],\n        }}\n      >\n        {compactCount(shown)}\n      </Text>\n      <Text style={{ color: colors.textMuted, fontSize: font.size.xs }}>{stat.label}</Text>\n    </View>\n  );\n}\n\nfunction Row({ row, first, danger }: { row: ProfileRow; first: boolean; danger: boolean }) {\n  const { colors, space, font, radius } = useKinetikTheme();\n  const ink = danger ? colors.danger : colors.text;\n\n  const content = (\n    <>\n      {row.icon ? (\n        <View\n          style={[styles.tile, { backgroundColor: colors.surfaceRaised, borderRadius: radius.sm }]}\n        >\n          {row.icon}\n        </View>\n      ) : null}\n      <Text style={[styles.fill, { color: ink, fontSize: font.size.md }]}>{row.label}</Text>\n      {row.detail ? (\n        <Text style={{ color: colors.textSubtle, fontSize: font.size.sm }}>{row.detail}</Text>\n      ) : null}\n    </>\n  );\n\n  const frame = [\n    styles.row,\n    {\n      gap: space[3],\n      paddingHorizontal: space[4],\n      borderTopColor: colors.border,\n      borderTopWidth: first ? 0 : StyleSheet.hairlineWidth,\n    },\n  ];\n\n  if (row.toggle) {\n    return (\n      <View style={frame}>\n        {content}\n        <PulseToggle\n          size=\"sm\"\n          value={row.toggle.value}\n          onValueChange={row.toggle.onValueChange}\n          accessibilityLabel={row.label}\n          style={styles.center}\n        />\n      </View>\n    );\n  }\n  return (\n    <Pressable\n      accessibilityRole=\"button\"\n      accessibilityHint={row.detail}\n      onPress={row.onPress}\n      disabled={!row.onPress}\n      style={({ pressed }) => [...frame, pressed && { backgroundColor: colors.surfaceSunken }]}\n    >\n      {content}\n      {danger ? null : <Chevron color={colors.textSubtle} />}\n    </Pressable>\n  );\n}\n\n/** A right-pointing chevron drawn with two borders. */\nfunction Chevron({ color }: { color: string }) {\n  return <View style={[styles.chevron, { borderColor: color }]} />;\n}\n\nconst styles = StyleSheet.create({\n  fill: { flex: 1 },\n  head: { alignItems: 'center' },\n  center: { alignSelf: 'center' },\n  avatarSlot: { width: 104, height: 104, alignItems: 'center', justifyContent: 'center' },\n  ring: { ...StyleSheet.absoluteFill, borderRadius: 52, overflow: 'hidden' },\n  ringFill: { position: 'absolute', top: -12, right: -12, bottom: -12, left: -12 },\n  avatar: {\n    width: 96,\n    height: 96,\n    borderRadius: 48,\n    borderWidth: 4,\n    alignItems: 'center',\n    justifyContent: 'center',\n    overflow: 'hidden',\n  },\n  photo: { width: '100%', height: '100%' },\n  stats: { flexDirection: 'row', borderWidth: StyleSheet.hairlineWidth },\n  statSlot: { flex: 1, flexDirection: 'row' },\n  statRule: { width: StyleSheet.hairlineWidth, alignSelf: 'stretch' },\n  stat: { flex: 1, alignItems: 'center', gap: 2 },\n  plan: { flexDirection: 'row', alignItems: 'center', minHeight: minTouchTarget },\n  group: { borderWidth: StyleSheet.hairlineWidth, overflow: 'hidden' },\n  row: { flexDirection: 'row', alignItems: 'center', minHeight: 56 },\n  tile: { width: 34, height: 34, alignItems: 'center', justifyContent: 'center' },\n  chevron: {\n    width: 9,\n    height: 9,\n    borderTopWidth: 2,\n    borderRightWidth: 2,\n    transform: [{ rotate: '45deg' }],\n    marginRight: 4,\n  },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "template",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "screen",
    "web": "live",
    "perf": {
      "budget": "The avatar ring turns on the UI thread. Stats count up for about a second after the screen opens (re-rendering on animation frames), then the screen is static.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-14",
          "build": "release",
          "frameMs": 21,
          "p90Ms": 23,
          "baselineMs": 17,
          "jankyPercent": 0,
          "atRest": "animating",
          "memoryMb": 151,
          "notes": "Animating at rest: the avatar ring keeps turning while the screen is open."
        }
      ]
    },
    "a11y": {
      "reducedMotion": "The ring holds still, stats show their final values and blocks appear without settling in.",
      "screenReader": "The name and section titles are headers. Each stat reads as one value (\"24.8k Followers\"); rows are buttons with their detail as a hint, and switches are named after their row.",
      "touchTarget": "Rows are 56 pt tall; buttons and switches are at least 44 pt."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { Profile } from '@/components/kinetik/screens/profile';\n\n<Profile\n  user={{ name: user.name, handle: user.email, avatar: { uri: user.photoUrl } }}\n  stats={[\n    { label: 'Posts', value: 128 },\n    { label: 'Followers', value: 24817 },\n    { label: 'Following', value: 312 },\n  ]}\n  plan={{ title: 'Pro', detail: 'Renews on 3 March', onPress: () => router.push('/plan') }}\n  sections={[\n    {\n      title: 'Account',\n      rows: [\n        { key: 'info', label: 'Personal info', icon: <UserIcon />, onPress: openInfo },\n        { key: 'payment', label: 'Payment methods', detail: 'Visa •• 42', onPress: openCards },\n      ],\n    },\n    {\n      title: 'Preferences',\n      rows: [\n        {\n          key: 'notifications',\n          label: 'Notifications',\n          toggle: { value: notify, onValueChange: setNotify },\n        },\n      ],\n    },\n  ]}\n  onEdit={() => router.push('/profile/edit')}\n  onSignOut={signOut}\n/>;\n```\n\n## When to use\n\n- The account tab of an app: who you are, a few numbers and the settings that belong to you.\n\n## When not to use\n\n- A public profile other people visit: it needs follow and message actions, not settings.\n- Long settings trees: link to a separate settings screen from one row instead.\n\n## Notes\n\n- Without `avatar` the initials of `name` are shown. Counts above 9,999 shorten to 12.4k and 1.2M.\n- A row with `toggle` becomes a switch; any other row is a button with a chevron. `onSignOut` adds a red Sign out row at the end.\n- Row icons are yours to pass, so they match the rest of your app.\n"
  },
  "docs": "Prefer `npx kinetik-ui add profile`: it installs dependencies with expo install, so versions match your Expo SDK."
}
