A social activity feed grouped into New, Today and This week, under a large title that collapses into a pinned bar with sliding All, Mentions and Requests tabs. Tapping a row scales its unread dot out and fades its tint, Follow back morphs into Following, follow requests fold into a confirmation on Accept or slide away on Decline, and Mark all read clears every row in a quick stagger along with the tab bar badge.

Details
1import { useEffect, useRef, useState, type ReactNode } from 'react';2import { Image, Pressable, StyleSheet, Text, View, useColorScheme, useWindowDimensions, type LayoutChangeEvent } from 'react-native';3import Animated, {4 cancelAnimation,5 Easing,6 FadeIn,7 FadeInDown,8 FadeOut,9 interpolate,10 interpolateColor,11 LinearTransition,12 useAnimatedScrollHandler,13 useAnimatedStyle,14 useSharedValue,15 withDelay,16 withRepeat,17 withSequence,18 withSpring,19 withTiming,20 ZoomIn,21} from 'react-native-reanimated';22import { LinearGradient } from 'expo-linear-gradient';23import { useSafeAreaInsets } from 'react-native-safe-area-context';24import {25 AtSign,26 Bell,27 Check,28 CheckCheck,29 ChevronRight,30 Compass,31 Heart,32 House,33 MessageCircle,34 Plus,35 Settings,36 ShieldCheck,37 Sparkles,38 UserCheck,39 UserPlus,40 type LucideIcon,41} from 'lucide-react-native';4243// ─── Brand ──────────────────────────────────────────────────────────────────44// The screen's accent. Every accent colour below derives from these, so changing them rebrands the screen.4546const ACCENT = '#1064FF';47const ACCENT_DARK = '#4C8DFF'; // the accent on dark backgrounds48const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill4950/** `hex` at `alpha` opacity, as rgba(). */51function tint(hex: string, alpha: number) {52 const n = parseInt(hex.slice(1), 16);53 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;54}5556/** `hex` mixed toward black (amount > 0) or white (amount < 0); amount from -1 to 1. */57function shade(hex: string, amount: number) {58 const n = parseInt(hex.slice(1), 16);59 const target = amount < 0 ? 255 : 0;60 const p = Math.abs(amount);61 const c = (v: number) => Math.round(v + (target - v) * p).toString(16).padStart(2, '0');62 return `#${c((n >> 16) & 255)}${c((n >> 8) & 255)}${c(n & 255)}`.toUpperCase();63}6465// ─── Sample data ────────────────────────────────────────────────────────────6667const photo = (id: string, w = 200) => `https://images.unsplash.com/photo-${id}?w=${w}&q=80&fit=crop`;6869const ME = photo('1534528741775-53994a69daeb');7071type Person = { name: string; first: string; avatar: string };7273const SOFIA: Person = { name: 'Sofia Martinez', first: 'Sofia', avatar: photo('1494790108377-be9c29b29330') };74const JAMES: Person = { name: 'James Carter', first: 'James', avatar: photo('1500648767791-00dcc994a43e') };75const PRIYA: Person = { name: 'Priya Nair', first: 'Priya', avatar: photo('1438761681033-6461ffad8d80') };76const DANIEL: Person = { name: 'Daniel Okafor', first: 'Daniel', avatar: photo('1507003211169-0a1dd7228f2d') };77const ELENA: Person = { name: 'Elena Rossi', first: 'Elena', avatar: photo('1544005313-94ddf0286df2') };78const OMAR: Person = { name: 'Omar Haddad', first: 'Omar', avatar: photo('1506794778202-cad84cf45f1d') };79const HANNAH: Person = { name: 'Hannah Weiss', first: 'Hannah', avatar: photo('1517841905240-472988babdf9') };80const LEO: Person = { name: 'Leo Brandt', first: 'Leo', avatar: photo('1539571696357-5a69c17a67c6') };8182const POST = {83 ridge: photo('1464822759023-fed622ff2c3b'),84 sunrise: photo('1506905925346-21bda4d32df4'),85 lake: photo('1501785888041-af3ef285b470'),86 bowl: photo('1546069901-ba9599a7e63c'),87 stars: photo('1519681393784-d120267933ba'),88 valley: photo('1470071459604-3b5ec3a7fe05'),89};9091const GROUPS = ['New', 'Today', 'This week'] as const;92type Group = (typeof GROUPS)[number];9394const FILTERS = ['All', 'Mentions', 'Requests'] as const;95type Filter = (typeof FILTERS)[number];9697type Kind = 'like' | 'comment' | 'mention' | 'follow' | 'request' | 'system';9899type Notice = {100 id: string;101 kind: Kind;102 group: Group;103 time: string;104 read: boolean;105 /** One person, or the first two of a grouped like. Empty for a system row. */106 who: Person[];107 others?: number;108 /** What they did, or the body of a system row. */109 text: string;110 /** A system row's headline. */111 title?: string;112 tile?: 'recap' | 'security';113 quote?: string;114 thumb?: string;115 /** Follower rows: whether you follow them back. */116 following?: boolean;117 /** Follow requests. */118 status?: 'pending' | 'accepted' | 'declined';119 /** Set by "Mark all read" so the rows clear one after another. */120 readDelay?: number;121};122123const NOTICES: Notice[] = [124 { id: 'n1', kind: 'like', group: 'New', time: '2m', read: false, who: [SOFIA, LEO], others: 12, text: 'liked your photo.', thumb: POST.ridge },125 { id: 'n2', kind: 'request', group: 'New', time: '14m', read: false, who: [PRIYA], text: 'wants to follow you.', status: 'pending' },126 { id: 'n3', kind: 'comment', group: 'New', time: '31m', read: false, who: [JAMES], text: 'commented.', quote: 'This light is unreal. Which trail is it?', thumb: POST.sunrise },127 { id: 'n4', kind: 'mention', group: 'New', time: '1h', read: false, who: [ELENA], text: 'mentioned you.', quote: '@maya.chen you in for May?', thumb: POST.lake },128 { id: 't1', kind: 'follow', group: 'Today', time: '3h', read: false, who: [DANIEL], text: 'started following you.', following: false },129 { id: 't2', kind: 'system', group: 'Today', time: '6h', read: true, who: [], title: 'Your weekly recap is ready', text: '4,812 people saw your posts, up 18% on last week.', tile: 'recap' },130 { id: 't3', kind: 'request', group: 'Today', time: '8h', read: false, who: [OMAR], text: 'wants to follow you.', status: 'pending' },131 { id: 't4', kind: 'like', group: 'Today', time: '11h', read: true, who: [ELENA, JAMES], others: 5, text: 'liked your photo.', thumb: POST.bowl },132 { id: 'w1', kind: 'mention', group: 'This week', time: 'Mon', read: true, who: [LEO], text: 'mentioned you.', quote: 'Night two with @maya.chen, zero sleep, zero regrets', thumb: POST.stars },133 { id: 'w2', kind: 'follow', group: 'This week', time: 'Sun', read: true, who: [SOFIA], text: 'started following you.', following: true },134 { id: 'w3', kind: 'request', group: 'This week', time: 'Sun', read: true, who: [HANNAH], text: 'wants to follow you.', status: 'pending' },135 { id: 'w4', kind: 'comment', group: 'This week', time: 'Sat', read: true, who: [DANIEL], text: 'replied to you.', quote: 'Count me in for the next one', thumb: POST.valley },136 { id: 'w5', kind: 'system', group: 'This week', time: 'Fri', read: true, who: [], title: 'New sign-in to your account', text: 'A phone near Lisbon, Portugal. Tap to review.', tile: 'security' },137];138139// ─── Palette ────────────────────────────────────────────────────────────────140141const LOVE = '#FF3B5C';142const TEAL = '#14B8A6';143const AMBER = '#F59E0B';144const GREEN = '#22C55E';145const POP = { damping: 14, stiffness: 280, mass: 0.6 };146const TABULAR = { fontVariant: ['tabular-nums' as const] };147const MOVE = LinearTransition.duration(260);148149const BAR = 44;150const TITLE_H = 50;151const TABS_H = 46;152const TAB_BAR = 54;153const GUTTER = 20;154const AVATAR = 46;155const ACTIONS_H = 44;156const FOLLOW_W = 104;157const FOLLOWING_W = 92;158159function usePalette() {160 const dark = useColorScheme() === 'dark';161 return {162 dark,163 bg: dark ? '#000000' : '#FFFFFF',164 fg: dark ? '#FAFAFA' : '#0A0A0A',165 muted: dark ? '#8E8E93' : '#6E6E76',166 faint: dark ? '#5C5C63' : '#A9A9B2',167 line: dark ? '#232327' : '#E8E8EB',168 chip: dark ? '#1C1C1F' : '#F1F1F3',169 press: dark ? '#FFFFFF10' : '#0000000A',170 skeleton: dark ? '#141416' : '#F1F1F3',171 shine: dark ? '#26262A' : '#E2E2E6',172 // Accent as text or a glyph; filled shapes use ACCENT itself under white text.173 accent: dark ? ACCENT_DARK : ACCENT,174 wash: dark ? tint(ACCENT_DARK, 0.17) : tint(ACCENT, 0.09),175 // An unread row: the accent laid over the background, kept solid so avatar rings can match it.176 tint: dark ? shade(ACCENT_DARK, 0.85) : shade(ACCENT, -0.93),177 };178}179180// ─── Small pieces ───────────────────────────────────────────────────────────181182function Tap({ children, label, onPress, to = 0.9 }: { children: ReactNode; label: string; onPress?: () => void; to?: number }) {183 const scale = useSharedValue(1);184 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));185 return (186 <Pressable187 role="button"188 aria-label={label}189 onPress={onPress}190 hitSlop={6}191 onPressIn={() => (scale.value = withSpring(to, POP))}192 onPressOut={() => (scale.value = withSpring(1, POP))}193 >194 <Animated.View style={style}>{children}</Animated.View>195 </Pressable>196 );197}198199/** A photo that pulses as a placeholder, then fades in once it has loaded. */200function Photo({ uri, alt, size, radius }: { uri: string; alt: string; size: number; radius: number }) {201 const c = usePalette();202 const shown = useSharedValue(0);203 const pulse = useSharedValue(0.4);204 useEffect(() => {205 pulse.value = withRepeat(withSequence(withTiming(1, { duration: 700 }), withTiming(0.4, { duration: 700 })), -1);206 return () => cancelAnimation(pulse);207 }, [pulse]);208 const image = useAnimatedStyle(() => ({ opacity: shown.value }));209 const placeholder = useAnimatedStyle(() => ({ opacity: (1 - shown.value) * pulse.value }));210 return (211 <View style={[styles.photo, { width: size, height: size, borderRadius: radius, backgroundColor: c.skeleton }]}>212 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: c.shine }, placeholder]} />213 <Animated.View style={[styles.flex, image]}>214 <Image215 source={{ uri }}216 alt={alt}217 resizeMode="cover"218 style={styles.photoImage}219 onLoad={() => {220 cancelAnimation(pulse);221 shown.value = withTiming(1, { duration: 320 });222 }}223 />224 </Animated.View>225 </View>226 );227}228229const Face = ({ uri, size, alt = '' }: { uri: string; size: number; alt?: string }) => <Photo uri={uri} alt={alt} size={size} radius={size / 2} />;230231/** Stays mounted after the count reaches zero, so it can scale out. */232function CountBadge({ count }: { count: number }) {233 const c = usePalette();234 const last = useRef(count);235 if (count > 0) last.current = count;236 const p = useSharedValue(count > 0 ? 1 : 0);237 useEffect(() => {238 p.value = count > 0 ? withTiming(1, { duration: 220, easing: Easing.out(Easing.back(2)) }) : withDelay(180, withTiming(0, { duration: 240, easing: Easing.in(Easing.back(1.6)) }));239 }, [count, p]);240 const style = useAnimatedStyle(() => ({ opacity: Math.max(0, Math.min(1, p.value * 2)), transform: [{ scale: Math.max(0, p.value) }] }));241 return (242 <Animated.View243 style={[styles.countBadge, { borderColor: c.bg }, style]}244 >245 <Animated.Text key={last.current} entering={FadeInDown.duration(220)} style={[styles.countBadgeText, TABULAR]}>246 {last.current}247 </Animated.Text>248 </Animated.View>249 );250}251252// ─── Filter tabs: one underline slides and resizes to the selected label ────253254function TabLabel({ label, selected }: { label: string; selected: boolean }) {255 const c = usePalette();256 const on = useSharedValue(selected ? 1 : 0);257 useEffect(() => {258 on.value = withTiming(selected ? 1 : 0, { duration: 220 });259 }, [selected, on]);260 const style = useAnimatedStyle(() => ({ color: interpolateColor(on.value, [0, 1], [c.muted, c.fg]) }));261 return <Animated.Text style={[styles.tabLabel, style]}>{label}</Animated.Text>;262}263264function Tabs({ value, onChange, requests }: { value: Filter; onChange: (f: Filter) => void; requests: number }) {265 const c = usePalette();266 const { width } = useWindowDimensions();267 const slot = width / FILTERS.length;268 // Label widths are measured, so the underline hugs the label and follows the Requests count as it changes.269 const [widths, setWidths] = useState<Partial<Record<Filter, number>>>({});270 const index = FILTERS.indexOf(value);271 const w = widths[value];272 const placed = useRef(false);273 const x = useSharedValue(0);274 const span = useSharedValue(0);275 useEffect(() => {276 if (w === undefined) return;277 // The first measurement places the underline; after that it travels.278 const move = placed.current ? (v: number) => withTiming(v, { duration: 300, easing: Easing.out(Easing.cubic) }) : (v: number) => v;279 x.value = move(index * slot + (slot - w) / 2 - 8);280 span.value = move(w + 16);281 placed.current = true;282 }, [index, slot, w, x, span]);283 const underline = useAnimatedStyle(() => ({ width: span.value, transform: [{ translateX: x.value }] }));284 return (285 <View role="tablist" aria-label="Filter activity" style={[styles.tabs, { borderBottomColor: c.line }]}>286 {FILTERS.map((f) => {287 const count = f === 'Requests' ? requests : 0;288 return (289 <Pressable key={f} role="tab" aria-selected={f === value} aria-label={count ? `${f}, ${count}` : f} onPress={() => onChange(f)} style={styles.tab}>290 <View291 onLayout={(e: LayoutChangeEvent) => {292 const next = e.nativeEvent.layout.width;293 setWidths((all) => (all[f] === next ? all : { ...all, [f]: next }));294 }}295 style={styles.tabInner}296 >297 <TabLabel label={f} selected={f === value} />298 {count ? (299 <View style={[styles.tabCount, { backgroundColor: c.wash }]}>300 <Animated.Text key={count} entering={FadeInDown.duration(220)} style={[styles.tabCountText, { color: c.accent }, TABULAR]}>301 {count}302 </Animated.Text>303 </View>304 ) : null}305 </View>306 </Pressable>307 );308 })}309 {w !== undefined ? <Animated.View style={[styles.underline, { backgroundColor: c.accent }, underline]} /> : null}310 </View>311 );312}313314// ─── Row pieces ─────────────────────────────────────────────────────────────315316const BADGE: Record<Exclude<Kind, 'system'> | 'accepted', { icon: LucideIcon; color: string; on?: string; fill?: boolean }> = {317 like: { icon: Heart, color: LOVE, fill: true },318 comment: { icon: MessageCircle, color: ACCENT, on: ON_ACCENT, fill: true },319 mention: { icon: AtSign, color: AMBER },320 follow: { icon: UserPlus, color: TEAL },321 request: { icon: UserPlus, color: TEAL },322 accepted: { icon: Check, color: GREEN },323};324325const TILE: Record<NonNullable<Notice['tile']>, { icon: LucideIcon; colors: readonly [string, string] }> = {326 recap: { icon: Sparkles, colors: ['#3B82F6', '#06B6D4'] },327 security: { icon: ShieldCheck, colors: ['#34D399', '#059669'] },328};329330type RingStyle = ReturnType<typeof useAnimatedStyle>;331332/** The avatar (or two, for grouped likes) with the coloured type badge on its corner. `ring` tracks the row's background. */333function Lead({ n, ring }: { n: Notice; ring: RingStyle }) {334 if (n.kind === 'system') {335 const tile = TILE[n.tile ?? 'recap'];336 const Icon = tile.icon;337 return (338 <LinearGradient colors={tile.colors} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={styles.tile}>339 <Icon size={22} color="#fff" strokeWidth={2.2} />340 </LinearGradient>341 );342 }343 const type = n.status === 'accepted' ? 'accepted' : n.kind;344 const badge = BADGE[type];345 const Icon = badge.icon;346 return (347 <View style={styles.lead}>348 {n.who.length > 1 ? (349 <>350 <View style={styles.leadBack}>351 <Face uri={n.who[1].avatar} size={31} />352 </View>353 <Animated.View style={[styles.leadFront, ring]}>354 <Face uri={n.who[0].avatar} size={32} />355 </Animated.View>356 </>357 ) : (358 <Face uri={n.who[0].avatar} size={AVATAR} />359 )}360 {/* Keyed by type, so accepting a request pops the tick in. */}361 <Animated.View key={type} entering={ZoomIn.duration(240)} style={styles.kindSlot}>362 <Animated.View style={[styles.kind, { backgroundColor: badge.color }, ring]}>363 <Icon size={11} color={badge.on ?? '#fff'} fill={badge.fill ? (badge.on ?? '#fff') : 'none'} strokeWidth={badge.fill ? 2 : 3} />364 </Animated.View>365 </Animated.View>366 </View>367 );368}369370/** A quoted comment, with any @handle picked out in the accent. */371function Quote({ text }: { text: string }) {372 const c = usePalette();373 return (374 <Text numberOfLines={2} style={[styles.body, { color: c.muted }]}>375 {text.split(/(@[\w.]+)/).map((part, i) =>376 part.startsWith('@') ? (377 <Text key={i} style={[styles.handle, { color: c.accent }]}>378 {part}379 </Text>380 ) : (381 part382 )383 )}384 </Text>385 );386}387388/** "Follow back" morphs into "Following": the width, the fill and the label all travel together. */389function FollowButton({ name, following, onPress }: { name: string; following: boolean; onPress: () => void }) {390 const c = usePalette();391 const p = useSharedValue(following ? 1 : 0);392 const scale = useSharedValue(1);393 useEffect(() => {394 p.value = withTiming(following ? 1 : 0, { duration: 280, easing: Easing.out(Easing.cubic) });395 }, [following, p]);396 const box = useAnimatedStyle(() => ({397 width: interpolate(p.value, [0, 1], [FOLLOW_W, FOLLOWING_W]),398 backgroundColor: interpolateColor(p.value, [0, 1], [ACCENT, c.chip]),399 transform: [{ scale: scale.value }],400 }));401 const off = useAnimatedStyle(() => ({ opacity: 1 - p.value, transform: [{ translateY: -10 * p.value }] }));402 const on = useAnimatedStyle(() => ({ opacity: p.value, transform: [{ translateY: 10 * (1 - p.value) }] }));403 const center = [StyleSheet.absoluteFill, styles.center];404 return (405 <Pressable406 role="button"407 aria-label={following ? `Following ${name}. Tap to unfollow.` : `Follow ${name} back`}408 onPress={onPress}409 hitSlop={6}410 onPressIn={() => (scale.value = withSpring(0.94, POP))}411 onPressOut={() => (scale.value = withSpring(1, POP))}412 >413 <Animated.View style={[styles.follow, box]}>414 <Animated.View style={[center, off]}>415 <Text numberOfLines={1} style={[styles.buttonLabel, styles.onAccent]}>416 Follow back417 </Text>418 </Animated.View>419 <Animated.View style={[center, on]}>420 <Text numberOfLines={1} style={[styles.buttonLabel, { color: c.fg }]}>421 Following422 </Text>423 </Animated.View>424 </Animated.View>425 </Pressable>426 );427}428429function ActionButton({ label, text, primary, onPress }: { label: string; text: string; primary?: boolean; onPress: () => void }) {430 const c = usePalette();431 return (432 <Tap label={label} onPress={onPress} to={0.95}>433 <View style={[styles.action, { backgroundColor: primary ? ACCENT : c.chip }]}>434 <Text style={[styles.buttonLabel, { color: primary ? ON_ACCENT : c.fg }]}>{text}</Text>435 </View>436 </Tap>437 );438}439440// ─── A notification row ─────────────────────────────────────────────────────441442type RowProps = { n: Notice; onOpen: () => void; onFollow: () => void; onAccept: () => void; onDecline: () => void };443444function Row({ n, onOpen, onFollow, onAccept, onDecline }: RowProps) {445 const c = usePalette();446 const person = n.who[0];447 const pending = n.status === 'pending';448 const accepted = n.status === 'accepted';449 const declined = n.status === 'declined';450451 // 1 while unread. Reading scales the dot out first, then lets the tint fade.452 const u = useSharedValue(n.read ? 0 : 1);453 useEffect(() => {454 u.value = n.read ? withDelay(n.readDelay ?? 0, withTiming(0, { duration: 360, easing: Easing.out(Easing.cubic) })) : withTiming(1, { duration: 200 });455 }, [n.read, n.readDelay, u]);456 const ground = useAnimatedStyle(() => ({ backgroundColor: interpolateColor(u.value, [0, 1], [c.bg, c.tint]) }));457 const ring = useAnimatedStyle(() => ({ borderColor: interpolateColor(u.value, [0, 1], [c.bg, c.tint]) }));458 const dot = useAnimatedStyle(() => {459 const k = interpolate(u.value, [0.45, 1], [0, 1], 'clamp');460 return { opacity: k, transform: [{ scale: k }] };461 });462463 // Accept and Decline fold away once the request is answered.464 const [actions, setActions] = useState(pending);465 const shut = useSharedValue(pending ? 0 : 1);466 useEffect(() => {467 if (pending || !actions) return;468 shut.value = withTiming(1, { duration: 280, easing: Easing.inOut(Easing.cubic) });469 const t = setTimeout(() => setActions(false), 320);470 return () => clearTimeout(t);471 }, [pending, actions, shut]);472 const actionStyle = useAnimatedStyle(() => ({ height: ACTIONS_H * (1 - shut.value), opacity: 1 - shut.value }));473474 // A declined request slides away, then the row closes up behind it.475 const natural = useSharedValue(0);476 const away = useSharedValue(declined ? 1 : 0);477 const fold = useSharedValue(declined ? 1 : 0);478 useEffect(() => {479 if (!declined) return;480 away.value = withTiming(1, { duration: 200, easing: Easing.in(Easing.cubic) });481 fold.value = withDelay(140, withTiming(1, { duration: 260, easing: Easing.inOut(Easing.cubic) }));482 }, [declined, away, fold]);483 const foldStyle = useAnimatedStyle(() => ({ maxHeight: fold.value === 0 ? 9999 : natural.value * (1 - fold.value) }));484 const awayStyle = useAnimatedStyle(() => ({ opacity: 1 - away.value, transform: [{ translateX: -36 * away.value }] }));485486 const bold = styles.bold;487 const time = <Text style={{ color: c.muted }}> {n.time}</Text>;488 const line = [styles.line, { color: c.fg }];489 let headline: ReactNode;490 let spoken: string;491 if (n.kind === 'system') {492 spoken = `${n.title}. ${n.text}`;493 headline = (494 <Text style={line}>495 <Text style={bold}>{n.title}</Text>496 {time}497 </Text>498 );499 } else if (accepted) {500 spoken = `You and ${person.first} now follow each other`;501 headline = (502 <Text style={line}>503 You and <Text style={bold}>{person.first}</Text> now follow each other.{time}504 </Text>505 );506 } else if (n.others) {507 spoken = `${n.who.map((p) => p.first).join(', ')} and ${n.others} others ${n.text}`;508 headline = (509 <Text style={line}>510 <Text style={bold}>{n.who[0].first}</Text>, <Text style={bold}>{n.who[1].first}</Text> and <Text style={bold}>{n.others} others</Text> {n.text}511 {time}512 </Text>513 );514 } else {515 spoken = `${person.name} ${n.text}${n.quote ? ` ${n.quote}` : ''}`;516 headline = (517 <Text style={line}>518 <Text style={bold}>{person.name}</Text> {n.text}519 {time}520 </Text>521 );522 }523 const label = `${spoken} ${n.time}${n.read ? '' : ', unread'}`;524525 return (526 <Animated.View style={[styles.clip, foldStyle]}>527 <Animated.View onLayout={(e: LayoutChangeEvent) => (natural.value = e.nativeEvent.layout.height)} style={[ground, awayStyle]}>528 {/* The row itself is one button under its content; the buttons inside it sit on top. */}529 <Pressable role="button" aria-label={label} onPress={onOpen} style={({ pressed }) => [StyleSheet.absoluteFill, { backgroundColor: pressed ? c.press : 'transparent' }]} />530 <Animated.View pointerEvents="none" style={[styles.unreadDot, { backgroundColor: c.accent }, dot]} />531 <View pointerEvents="box-none" style={styles.row}>532 <View pointerEvents="none">533 <Lead n={n} ring={ring} />534 </View>535 <View pointerEvents="box-none" style={styles.rowText}>536 <Animated.View key={accepted ? 'accepted' : 'text'} entering={FadeIn.duration(280)} pointerEvents="none">537 {headline}538 {n.kind === 'system' ? <Text style={[styles.body, { color: c.muted }]}>{n.text}</Text> : null}539 {n.quote ? <Quote text={n.quote} /> : null}540 </Animated.View>541 {actions ? (542 <Animated.View pointerEvents={pending ? 'auto' : 'none'} style={[styles.clip, actionStyle]}>543 <View style={styles.actions}>544 <ActionButton primary text="Accept" label={`Accept ${person.name}’s request`} onPress={onAccept} />545 <ActionButton text="Decline" label={`Decline ${person.name}’s request`} onPress={onDecline} />546 </View>547 </Animated.View>548 ) : null}549 </View>550 {n.kind === 'follow' ? (551 <View style={styles.trail}>552 <FollowButton name={person.name} following={!!n.following} onPress={onFollow} />553 </View>554 ) : n.thumb ? (555 <View pointerEvents="none">556 <Photo uri={n.thumb} alt="Your post" size={AVATAR} radius={10} />557 </View>558 ) : n.kind === 'system' ? (559 <View pointerEvents="none" style={styles.trail}>560 <ChevronRight size={18} color={c.faint} strokeWidth={2.4} />561 </View>562 ) : null}563 </View>564 </Animated.View>565 </Animated.View>566 );567}568569// ─── Empty states ───────────────────────────────────────────────────────────570571const EMPTY: Record<Filter, { icon: LucideIcon; title: string; body: string }> = {572 All: { icon: Bell, title: 'No activity yet', body: 'Likes, comments and new followers will show up here.' },573 Mentions: { icon: AtSign, title: 'No mentions yet', body: 'When someone tags you in a post or a comment, you will see it here.' },574 Requests: { icon: UserCheck, title: 'No follow requests', body: 'You are all caught up. New requests will wait for you here.' },575};576577function Empty({ filter }: { filter: Filter }) {578 const c = usePalette();579 const { icon: Icon, title, body } = EMPTY[filter];580 return (581 <View style={styles.empty}>582 <View style={[styles.emptyRing, { borderColor: c.line }]}>583 <View style={[styles.emptyIcon, { backgroundColor: c.chip }]}>584 <Icon size={30} color={c.muted} strokeWidth={1.9} />585 </View>586 <View style={[styles.emptyDot, { backgroundColor: c.accent, borderColor: c.bg }]} />587 </View>588 <Text style={[styles.emptyTitle, { color: c.fg }]}>{title}</Text>589 <Text style={[styles.emptyText, { color: c.muted }]}>{body}</Text>590 </View>591 );592}593594// ─── Tab bar ────────────────────────────────────────────────────────────────595596function TabBar({ unread }: { unread: number }) {597 const c = usePalette();598 const insets = useSafeAreaInsets();599 // Replace with your navigator's tab bar.600 const [tab, setTab] = useState('Activity');601 const item = (label: string, icon: ReactNode, badge?: ReactNode) => (602 <Pressable key={label} role="tab" aria-label={label === 'Activity' && unread ? `Activity, ${unread} unread` : label} aria-selected={tab === label} onPress={() => setTab(label)} style={styles.navItem}>603 <View>604 {icon}605 {badge}606 </View>607 </Pressable>608 );609 const tint = (label: string) => (tab === label ? c.fg : c.muted);610 const weight = (label: string) => (tab === label ? 2.5 : 2);611 return (612 <View role="tablist" style={[styles.nav, { paddingBottom: insets.bottom, backgroundColor: c.bg, borderTopColor: c.line }]}>613 {item('Home', <House size={25} color={tint('Home')} strokeWidth={weight('Home')} />)}614 {item('Explore', <Compass size={25} color={tint('Explore')} strokeWidth={weight('Explore')} />)}615 <View style={styles.navCompose}>616 <Tap label="New post">617 <View style={styles.compose}>618 <Plus size={22} color={ON_ACCENT} strokeWidth={2.6} />619 </View>620 </Tap>621 </View>622 {item('Activity', <Bell size={25} color={tint('Activity')} fill={tab === 'Activity' ? c.fg : 'none'} strokeWidth={weight('Activity')} />, <CountBadge count={unread} />)}623 {item(624 'Profile',625 <View style={[styles.navMe, { borderColor: tab === 'Profile' ? c.fg : 'transparent' }]}>626 <Face uri={ME} size={26} />627 </View>628 )}629 </View>630 );631}632633// ─── Screen ─────────────────────────────────────────────────────────────────634635export default function NotificationsListScreen() {636 const c = usePalette();637 const insets = useSafeAreaInsets();638 // Replace with your notifications query, newest first.639 const [items, setItems] = useState(NOTICES);640 const [filter, setFilter] = useState<Filter>('All');641 // Rows stagger in once; after that, rows a filter brings back simply fade in.642 const [intro, setIntro] = useState(true);643 const timers = useRef<ReturnType<typeof setTimeout>[]>([]);644 useEffect(() => {645 const t = setTimeout(() => setIntro(false), 1200);646 const pending = timers.current;647 return () => {648 clearTimeout(t);649 pending.forEach(clearTimeout);650 };651 }, []);652653 const unread = items.filter((n) => !n.read).length;654 const requests = items.filter((n) => n.status === 'pending').length;655 const visible = items.filter((n) => filter === 'All' || (filter === 'Mentions' && n.kind === 'mention') || (filter === 'Requests' && n.kind === 'request'));656657 const patch = (id: string, change: Partial<Notice>) => setItems((all) => all.map((n) => (n.id === id ? { ...n, ...change, read: true, readDelay: 0 } : n)));658 // Opening a row marks it read. Push the post, profile or recap screen from here too.659 const open = (id: string) => patch(id, {});660 const follow = (n: Notice) => patch(n.id, { following: !n.following });661 const accept = (id: string) => patch(id, { status: 'accepted' });662 const decline = (id: string) => {663 patch(id, { status: 'declined' });664 // The row animates itself out; it leaves the list once it has closed up.665 timers.current.push(setTimeout(() => setItems((all) => all.filter((n) => n.id !== id)), 460));666 };667 // Each unread row clears a beat after the one above it.668 const readAll = () => {669 let k = 0;670 setItems((all) => all.map((n) => (n.read ? n : { ...n, read: true, readDelay: k++ * 55 })));671 };672673 const scrollY = useSharedValue(0);674 const onScroll = useAnimatedScrollHandler((e) => {675 scrollY.value = e.contentOffset.y;676 });677 // The large title and the filter tabs ride up under the bar; the tabs stay pinned below it.678 const sheet = useAnimatedStyle(() => ({ transform: [{ translateY: -interpolate(scrollY.value, [0, TITLE_H], [0, TITLE_H], 'clamp') }] }));679 const largeTitle = useAnimatedStyle(() => ({ opacity: interpolate(scrollY.value, [0, TITLE_H * 0.7], [1, 0], 'clamp') }));680 const barTitle = useAnimatedStyle(() => ({681 opacity: interpolate(scrollY.value, [TITLE_H * 0.5, TITLE_H], [0, 1], 'clamp'),682 transform: [{ translateY: interpolate(scrollY.value, [TITLE_H * 0.5, TITLE_H], [6, 0], 'clamp') }],683 }));684685 let order = 0;686 const rowIn = () => (intro ? FadeInDown.delay(160 + Math.min(order++, 8) * 45).duration(380) : FadeIn.duration(240));687688 return (689 <View style={[styles.flex, { backgroundColor: c.bg }]}>690 <Animated.ScrollView691 onScroll={onScroll}692 scrollEventThrottle={16}693 showsVerticalScrollIndicator={false}694 contentContainerStyle={{ paddingTop: insets.top + BAR + TITLE_H + TABS_H, paddingBottom: insets.bottom + TAB_BAR + 24 }}695 >696 {GROUPS.map((group) => {697 const rows = visible.filter((n) => n.group === group);698 if (rows.length === 0) return null;699 return [700 <Animated.View key={`title-${group}`} layout={MOVE} entering={rowIn()} exiting={FadeOut.duration(120)}>701 <Text role="heading" style={[styles.groupTitle, { color: c.fg }]}>702 {group}703 </Text>704 </Animated.View>,705 ...rows.map((n) => (706 <Animated.View key={n.id} layout={MOVE} entering={rowIn()} exiting={FadeOut.duration(140)}>707 <Row n={n} onOpen={() => open(n.id)} onFollow={() => follow(n)} onAccept={() => accept(n.id)} onDecline={() => decline(n.id)} />708 </Animated.View>709 )),710 ];711 })}712 {visible.length === 0 ? (713 <Animated.View key="empty" entering={FadeIn.delay(140).duration(280)} exiting={FadeOut.duration(100)}>714 <Empty filter={filter} />715 </Animated.View>716 ) : null}717 </Animated.ScrollView>718719 {/* Large title and filter tabs: opaque, sliding up under the bar as the list scrolls */}720 <Animated.View style={[styles.sheet, { top: insets.top + BAR, backgroundColor: c.bg }, sheet]}>721 <Animated.Text722 role="heading"723 entering={FadeIn.duration(400)}724 style={[styles.largeTitle, { color: c.fg }, largeTitle]}725 >726 Activity727 </Animated.Text>728 <Tabs value={filter} onChange={setFilter} requests={requests} />729 </Animated.View>730731 {/* Bar: opaque, over everything and under the status bar */}732 <View style={[styles.header, { paddingTop: insets.top, backgroundColor: c.bg }]}>733 <View style={styles.bar}>734 <Animated.Text numberOfLines={1} style={[styles.barTitle, { color: c.fg }, barTitle]}>735 Activity736 </Animated.Text>737 {unread > 0 ? (738 <Animated.View entering={FadeIn.duration(220)} exiting={FadeOut.duration(180)}>739 <Pressable role="button" aria-label="Mark all read" hitSlop={8} onPress={readAll} style={({ pressed }) => [styles.readAll, { opacity: pressed ? 0.5 : 1 }]}>740 <CheckCheck size={16} color={c.accent} strokeWidth={2.4} />741 <Text style={[styles.readAllLabel, { color: c.accent }]}>Mark all read</Text>742 </Pressable>743 </Animated.View>744 ) : null}745 <Tap label="Notification settings">746 <View style={[styles.settings, { backgroundColor: c.chip }]}>747 <Settings size={18} color={c.fg} strokeWidth={2.1} />748 </View>749 </Tap>750 </View>751 </View>752753 <TabBar unread={unread} />754 </View>755 );756}757758// ─── Styles ─────────────────────────────────────────────────────────────────759760const styles = StyleSheet.create({761 flex: { flex: 1 },762 clip: { overflow: 'hidden' },763 center: { alignItems: 'center', justifyContent: 'center' },764765 photo: { overflow: 'hidden' },766 photoImage: { width: '100%', height: '100%' },767768 // Header, title and filter tabs769 header: { position: 'absolute', top: 0, left: 0, right: 0 },770 bar: { height: BAR, flexDirection: 'row', alignItems: 'center', paddingLeft: GUTTER, paddingRight: 16, gap: 14 },771 barTitle: { flex: 1, fontSize: 17, fontWeight: '700', letterSpacing: -0.2 },772 readAll: { height: 36, flexDirection: 'row', alignItems: 'center', gap: 5 },773 readAllLabel: { fontSize: 14.5, fontWeight: '600' },774 settings: { width: 36, height: 36, borderRadius: 18, alignItems: 'center', justifyContent: 'center' },775 sheet: { position: 'absolute', left: 0, right: 0 },776 largeTitle: { height: TITLE_H, paddingHorizontal: GUTTER, fontSize: 34, lineHeight: 42, fontWeight: '800', letterSpacing: -1 },777 tabs: { height: TABS_H, flexDirection: 'row', borderBottomWidth: 1 },778 tab: { flex: 1, alignItems: 'center', justifyContent: 'center' },779 tabInner: { flexDirection: 'row', alignItems: 'center', gap: 6 },780 tabLabel: { fontSize: 15, fontWeight: '600', letterSpacing: -0.1 },781 tabCount: { minWidth: 20, height: 20, borderRadius: 10, paddingHorizontal: 6, alignItems: 'center', justifyContent: 'center' },782 tabCountText: { fontSize: 12, fontWeight: '700' },783 underline: { position: 'absolute', left: 0, bottom: -1, height: 3, borderRadius: 1.5 },784 groupTitle: { paddingHorizontal: GUTTER, paddingTop: 18, paddingBottom: 8, fontSize: 16, fontWeight: '700', letterSpacing: -0.2 },785786 // Row787 row: { flexDirection: 'row', alignItems: 'flex-start', gap: 12, paddingLeft: GUTTER, paddingRight: 16, paddingVertical: 11 },788 rowText: { flex: 1, minHeight: AVATAR, justifyContent: 'center' },789 unreadDot: { position: 'absolute', left: 6, top: 11 + AVATAR / 2 - 4, width: 8, height: 8, borderRadius: 4 },790 line: { fontSize: 15, lineHeight: 20 },791 bold: { fontWeight: '700' },792 body: { marginTop: 2, fontSize: 14.5, lineHeight: 20 },793 handle: { fontWeight: '600' },794 trail: { height: AVATAR, justifyContent: 'center' },795 tile: { width: AVATAR, height: AVATAR, borderRadius: 14, alignItems: 'center', justifyContent: 'center' },796 lead: { width: AVATAR, height: AVATAR },797 leadBack: { position: 'absolute', top: 0, right: 0 },798 leadFront: { position: 'absolute', left: -2, bottom: -2, borderRadius: 20, borderWidth: 2.5 },799 kindSlot: { position: 'absolute', right: -4, bottom: -4 },800 kind: { width: 22, height: 22, borderRadius: 11, borderWidth: 2, alignItems: 'center', justifyContent: 'center' },801 actions: { height: ACTIONS_H, flexDirection: 'row', alignItems: 'flex-end', gap: 8 },802 action: { width: 104, height: 34, borderRadius: 10, alignItems: 'center', justifyContent: 'center' },803 follow: { height: 34, borderRadius: 10, overflow: 'hidden' },804 buttonLabel: { fontSize: 13.5, fontWeight: '700' },805 onAccent: { color: ON_ACCENT },806807 // Empty state808 empty: { alignItems: 'center', paddingTop: 56, paddingHorizontal: 44 },809 emptyRing: { width: 116, height: 116, borderRadius: 58, borderWidth: 1, alignItems: 'center', justifyContent: 'center' },810 emptyIcon: { width: 80, height: 80, borderRadius: 40, alignItems: 'center', justifyContent: 'center' },811 emptyDot: { position: 'absolute', top: 10, right: 12, width: 12, height: 12, borderRadius: 6, borderWidth: 2.5 },812 emptyTitle: { marginTop: 20, fontSize: 19, fontWeight: '700', letterSpacing: -0.3 },813 emptyText: { marginTop: 6, fontSize: 15, lineHeight: 21, textAlign: 'center' },814815 // Tab bar816 nav: { position: 'absolute', left: 0, right: 0, bottom: 0, borderTopWidth: 1, flexDirection: 'row', alignItems: 'center' },817 navItem: { flex: 1, height: TAB_BAR, alignItems: 'center', justifyContent: 'center' },818 navCompose: { flex: 1, alignItems: 'center' },819 compose: { width: 46, height: 36, borderRadius: 12, backgroundColor: ACCENT, alignItems: 'center', justifyContent: 'center' },820 navMe: { borderRadius: 15, borderWidth: 2 },821 countBadge: {822 position: 'absolute',823 top: -6,824 left: 12,825 minWidth: 18,826 height: 18,827 borderRadius: 9,828 paddingHorizontal: 4,829 backgroundColor: LOVE,830 borderWidth: 2,831 alignItems: 'center',832 justifyContent: 'center',833 },834 countBadgeText: { color: '#fff', fontSize: 10, fontWeight: '800' },835});