Chat conversation

One-to-one conversation with grouped bubbles, day separators, read receipts that tick from sent to read, a photo, a link preview, a quoted reply and a voice note whose waveform fills as it plays. Press and hold a bubble to lift it over a dimmed thread with a reaction bar and an action menu, swipe right to reply, and send a message to watch the ticks progress, the typing bubble bounce and a reply arrive.

chatconversationmessagesbubblesreactionsreplyvoice noteread receiptstyping indicatorlong-pressswipecomposeranimationreanimated
Paste into Claude Code Cursor Codex Lovable RapidNative

Or let your agent fetch it: connect the gluestack MCP server, then ask for chat-conversation.

Live preview · follows the site themeOpen full screen

Details

File
components/patterns/chat-conversation.tsx
Lines
985
Stack
React Native, StyleSheet
Packages
expo-linear-gradient, lucide-react-native, react-native-reanimated, react-native-safe-area-context, react-native-svg, react-native-worklets
Platforms
iOS, Android, Web

Using gluestack-ui?

Optional. The screen is plain React Native; these components can stand in for its primitives.

components/patterns/chat-conversation.tsx
1import { useEffect, useMemo, useRef, useState, type ComponentProps, type ComponentRef, type ReactNode, type RefObject } from 'react';
2import {
3 Image,
4 KeyboardAvoidingView,
5 PanResponder,
6 Platform,
7 Pressable,
8 ScrollView,
9 StyleSheet,
10 Text,
11 TextInput,
12 View,
13 useColorScheme,
14 type LayoutChangeEvent,
15 type NativeScrollEvent,
16 type NativeSyntheticEvent,
17} from 'react-native';
18import Animated, {
19 cancelAnimation,
20 Easing,
21 FadeIn,
22 FadeInDown,
23 FadeOut,
24 interpolate,
25 LinearTransition,
26 runOnJS,
27 useAnimatedStyle,
28 useSharedValue,
29 withDelay,
30 withRepeat,
31 withSequence,
32 withSpring,
33 withTiming,
34 ZoomIn,
35 type SharedValue,
36} from 'react-native-reanimated';
37import { LinearGradient } from 'expo-linear-gradient';
38import { useSafeAreaInsets } from 'react-native-safe-area-context';
39import Svg, { Path } from 'react-native-svg';
40import {
41 ArrowUp,
42 Camera,
43 Check,
44 CheckCheck,
45 ChevronDown,
46 ChevronLeft,
47 Copy,
48 Forward,
49 Link2,
50 Lock,
51 Mic,
52 Pause,
53 Phone,
54 Play,
55 Plus,
56 Reply,
57 Smile,
58 Trash2,
59 UtensilsCrossed,
60 Video,
61 X,
62 type LucideIcon,
63} from 'lucide-react-native';
64
65// ─── Brand ──────────────────────────────────────────────────────────────────
66// The screen's accent. Every accent colour below derives from these, so changing them rebrands the screen.
67
68const ACCENT = '#1064FF';
69const ACCENT_DARK = '#4C8DFF'; // the accent as text or a glyph on dark backgrounds
70const ON_ACCENT = '#FFFFFF'; // text and icons on an accent fill
71
72/** `hex` at `alpha` opacity, as rgba(). */
73function tint(hex: string, alpha: number) {
74 const n = parseInt(hex.slice(1), 16);
75 return `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;
76}
77
78// ─── Sample data ────────────────────────────────────────────────────────────
79
80const photo = (id: string, w: number) => `https://images.unsplash.com/photo-${id}?w=${w}&q=80&fit=crop`;
81
82const CONTACT = { name: 'Sofia Martinez', first: 'Sofia', avatar: photo('1494790108377-be9c29b29330', 200) };
83
84type Receipt = 'sent' | 'delivered' | 'read';
85type Reaction = { emoji: string; count: number; mine?: boolean };
86
87type Message = {
88 id: string;
89 from: 'me' | 'them';
90 day: string;
91 time: string;
92 text?: string;
93 photo?: { uri: string; alt: string; height: number };
94 /** Length in seconds. */
95 voice?: number;
96 link?: { title: string; blurb: string; host: string };
97 replyTo?: { name: string; text: string };
98 /** Set on your own messages. */
99 receipt?: Receipt;
100 reactions?: Reaction[];
101 /** Sent or received while the screen is open, so it springs in. */
102 fresh?: boolean;
103};
104
105const MESSAGES: Message[] = [
106 { id: 'm1', from: 'them', day: 'Yesterday', time: '18:42', photo: { uri: photo('1464822759023-fed622ff2c3b', 600), alt: 'A valley of pines under snowy peaks', height: 156 } },
107 { id: 'm2', from: 'them', day: 'Yesterday', time: '18:42', text: 'Made it up Lark Ridge. My legs are done' },
108 { id: 'm3', from: 'me', day: 'Yesterday', time: '18:45', text: 'Told you the last climb was brutal', receipt: 'read' },
109 { id: 'm4', from: 'me', day: 'Yesterday', time: '18:45', text: 'Worth it though?', receipt: 'read' },
110 { id: 'm5', from: 'them', day: 'Yesterday', time: '18:47', text: 'Every step. You are coming next time', reactions: [{ emoji: '😂', count: 1, mine: true }] },
111 { id: 'm6', from: 'me', day: 'Yesterday', time: '18:50', text: 'Only if there are snacks', receipt: 'read' },
112 { id: 'm7', from: 'them', day: 'Today', time: '9:02', text: 'Brunch here at 10? My treat', link: { title: 'Alder Street Kitchen', blurb: 'All-day brunch, bakery and coffee', host: 'alderstkitchen.co' } },
113 { id: 'm8', from: 'them', day: 'Today', time: '9:03', photo: { uri: photo('1546069901-ba9599a7e63c', 600), alt: 'A grain bowl with tofu, corn and greens', height: 162 }, reactions: [{ emoji: '😍', count: 1, mine: true }] },
114 { id: 'm9', from: 'me', day: 'Today', time: '9:06', text: 'Booked. Table for two by the window', replyTo: { name: CONTACT.name, text: 'Brunch here at 10? My treat' }, receipt: 'read', reactions: [{ emoji: '🙌', count: 1 }] },
115 { id: 'm10', from: 'them', day: 'Today', time: '9:31', voice: 18 },
116 { id: 'm12', from: 'them', day: 'Today', time: '9:40', text: 'Just got off the tram' },
117 { id: 'm13', from: 'them', day: 'Today', time: '9:41', text: 'Running 5 min late, grab us a table?' },
118];
119
120// What comes back after you send something; replace with your realtime channel.
121const REPLIES = ['Perfect. See you in a few', 'Ha, on it', 'Save me the seat facing the street', 'Okay okay, walking faster'];
122const EMOJI = ['❤️', '😂', '😮', '😢', '🙏', '👍'];
123// The shape of the voice note, one value per bar.
124const WAVE = [0.3, 0.5, 0.8, 0.45, 0.65, 1, 0.7, 0.4, 0.55, 0.9, 0.6, 0.35, 0.5, 0.75, 0.95, 0.6, 0.4, 0.7, 0.85, 0.5, 0.3, 0.45, 0.7, 0.55, 0.35, 0.6, 0.4, 0.25];
125// New messages are stamped with this; replace with the real time.
126const NOW = '9:42';
127
128type Action = 'Reply' | 'Copy' | 'Forward' | 'Delete';
129const ACTIONS: { id: Action; icon: LucideIcon }[] = [
130 { id: 'Reply', icon: Reply },
131 { id: 'Copy', icon: Copy },
132 { id: 'Forward', icon: Forward },
133 { id: 'Delete', icon: Trash2 },
134];
135
136// ─── Palette ────────────────────────────────────────────────────────────────
137
138const ONLINE = '#22C55E';
139const ALERT = '#FF3B5C';
140const POP = { damping: 14, stiffness: 280, mass: 0.6 };
141const ARRIVE = { damping: 15, stiffness: 220, mass: 0.7 };
142const MOVE = LinearTransition.duration(240);
143const HEADER = 56;
144const PHOTO_W = 220;
145const SWIPE_MAX = 64;
146const SWIPE_AT = 46;
147const REACT_BAR = 48;
148const MENU_ROW = 44;
149
150function usePalette() {
151 const dark = useColorScheme() === 'dark';
152 return {
153 dark,
154 bg: dark ? '#000000' : '#FFFFFF',
155 fg: dark ? '#FAFAFA' : '#0A0A0A',
156 muted: dark ? '#8E8E93' : '#6E6E76',
157 faint: dark ? '#5C5C63' : '#A9A9B2',
158 line: dark ? '#1F1F23' : '#ECECEF',
159 chip: dark ? '#1A1A1D' : '#F1F1F3',
160 // Their bubbles, and the quote and link card set into them.
161 bubble: dark ? '#1C1C20' : '#F1F1F3',
162 inset: dark ? '#0B0B0D' : '#FFFFFF',
163 quote: dark ? '#2A2A30' : '#E4E4E9',
164 skeleton: dark ? '#141416' : '#E9E9EC',
165 shine: dark ? '#26262A' : '#DADADF',
166 // Accent as text or a glyph; filled shapes use ACCENT itself under ON_ACCENT text.
167 accent: dark ? ACCENT_DARK : ACCENT,
168 wash: dark ? tint(ACCENT_DARK, 0.17) : tint(ACCENT, 0.09),
169 // The press-and-hold layer.
170 dim: dark ? '#000000B8' : '#0A0A0A66',
171 menu: dark ? '#1E1E22' : '#FFFFFF',
172 menuLine: dark ? '#2C2C31' : '#EFEFF2',
173 };
174}
175
176type Palette = ReturnType<typeof usePalette>;
177
178// ─── Small pieces ───────────────────────────────────────────────────────────
179
180function Tap({ children, label, onPress, to = 0.88 }: { children: ReactNode; label: string; onPress?: () => void; to?: number }) {
181 const scale = useSharedValue(1);
182 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
183 return (
184 <Pressable role="button" aria-label={label} onPress={onPress} hitSlop={6} onPressIn={() => (scale.value = withSpring(to, POP))} onPressOut={() => (scale.value = withSpring(1, POP))}>
185 <Animated.View style={style}>{children}</Animated.View>
186 </Pressable>
187 );
188}
189
190/** A photo that pulses as a placeholder, then fades in once it has loaded. */
191function Photo({ uri, alt, width, height, radius }: { uri: string; alt: string; width: number; height: number; radius: number }) {
192 const c = usePalette();
193 const shown = useSharedValue(0);
194 const pulse = useSharedValue(0.4);
195 useEffect(() => {
196 pulse.value = withRepeat(withSequence(withTiming(1, { duration: 700 }), withTiming(0.4, { duration: 700 })), -1);
197 return () => cancelAnimation(pulse);
198 }, [pulse]);
199 const image = useAnimatedStyle(() => ({ opacity: shown.value }));
200 const placeholder = useAnimatedStyle(() => ({ opacity: (1 - shown.value) * pulse.value }));
201 return (
202 <View style={[styles.photo, { width, height, borderRadius: radius, backgroundColor: c.skeleton }]}>
203 <Animated.View style={[StyleSheet.absoluteFill, { backgroundColor: c.shine }, placeholder]} />
204 <Animated.View style={[styles.fill, image]}>
205 <Image
206 source={{ uri }}
207 alt={alt}
208 resizeMode="cover"
209 style={styles.photoImage}
210 onLoad={() => {
211 cancelAnimation(pulse);
212 shown.value = withTiming(1, { duration: 320 });
213 }}
214 />
215 </Animated.View>
216 </View>
217 );
218}
219
220function TypingDot({ index, color }: { index: number; color: string }) {
221 const t = useSharedValue(0);
222 useEffect(() => {
223 // Up, down, then a rest, each dot starting a beat after the one before it.
224 t.value = withDelay(
225 index * 150,
226 withRepeat(withSequence(withTiming(1, { duration: 260, easing: Easing.out(Easing.quad) }), withTiming(0, { duration: 260, easing: Easing.in(Easing.quad) }), withTiming(0, { duration: 480 })), -1)
227 );
228 return () => cancelAnimation(t);
229 }, [index, t]);
230 const style = useAnimatedStyle(() => ({ opacity: 0.45 + t.value * 0.55, transform: [{ translateY: -4 * t.value }] }));
231 return <Animated.View style={[styles.typingDot, { backgroundColor: color }, style]} />;
232}
233
234function ReceiptMark({ state }: { state: Receipt }) {
235 const c = usePalette();
236 const Icon = state === 'sent' ? Check : CheckCheck;
237 // Keyed, so each step pops in.
238 return (
239 <Animated.View key={state} entering={ZoomIn.duration(180)}>
240 <Icon size={15} color={state === 'read' ? c.accent : c.faint} strokeWidth={2.5} />
241 </Animated.View>
242 );
243}
244
245/** The tail on the last bubble of a group, drawn out of the bubble's own corner. */
246function Tail({ mine, color }: { mine: boolean; color: string }) {
247 return (
248 <Svg width={15} height={17} viewBox="0 0 15 17" style={mine ? styles.tailMine : styles.tailTheirs}>
249 <Path d="M9 0 C9 9 10.5 13.5 15 17 C8.5 17 3 14.5 0 10 Z" fill={color} />
250 </Svg>
251 );
252}
253
254const preview = (m: Message) => m.text ?? (m.photo ? 'Photo' : m.voice ? `Voice message, ${clock(m.voice)}` : '');
255const clock = (s: number) => `0:${String(Math.floor(s)).padStart(2, '0')}`;
256
257// ─── Voice note: the waveform fills and the bar under the playhead swells ────
258
259function WaveBar({ index, level, progress, on, off }: { index: number; level: number; progress: SharedValue<number>; on: string; off: string }) {
260 const style = useAnimatedStyle(() => {
261 const head = progress.value * WAVE.length;
262 const near = progress.value > 0 ? Math.max(0, 1 - Math.abs(head - index) / 2) : 0;
263 return { backgroundColor: index < head ? on : off, transform: [{ scaleY: 1 + 0.45 * near }] };
264 });
265 return <Animated.View style={[styles.waveBar, { height: 4 + level * 20 }, style]} />;
266}
267
268function VoiceNote({ seconds, mine }: { seconds: number; mine: boolean }) {
269 const c = usePalette();
270 const progress = useSharedValue(0);
271 const [playing, setPlaying] = useState(false);
272 const [elapsed, setElapsed] = useState(0);
273 useEffect(() => {
274 if (!playing) return;
275 const t = setInterval(() => setElapsed(progress.value * seconds), 200);
276 return () => clearInterval(t);
277 }, [playing, progress, seconds]);
278 useEffect(() => () => cancelAnimation(progress), [progress]);
279 const finish = () => {
280 setPlaying(false);
281 setElapsed(0);
282 };
283 // No audio here: replace the timer with your player's position.
284 const toggle = () => {
285 if (playing) {
286 cancelAnimation(progress);
287 setElapsed(progress.value * seconds);
288 setPlaying(false);
289 return;
290 }
291 const from = progress.value >= 1 ? 0 : progress.value;
292 progress.value = from;
293 progress.value = withTiming(1, { duration: (1 - from) * seconds * 1000, easing: Easing.linear }, (done) => {
294 if (!done) return;
295 progress.value = withTiming(0, { duration: 220 });
296 runOnJS(finish)();
297 });
298 setPlaying(true);
299 };
300 const Icon = playing ? Pause : Play;
301 return (
302 <View style={styles.voice}>
303 <Tap label={playing ? 'Pause voice message' : 'Play voice message'} onPress={toggle}>
304 <View style={[styles.voicePlay, mine ? styles.voicePlayMine : styles.voicePlayTheirs]}>
305 <Icon size={16} color={mine ? ACCENT : ON_ACCENT} fill={mine ? ACCENT : ON_ACCENT} strokeWidth={2} style={playing ? null : styles.playNudge} />
306 </View>
307 </Tap>
308 <View style={styles.wave}>
309 {WAVE.map((level, i) => (
310 <WaveBar key={i} index={i} level={level} progress={progress} on={mine ? ON_ACCENT : c.accent} off={mine ? tint(ON_ACCENT, 0.4) : c.faint} />
311 ))}
312 </View>
313 <Text style={[styles.voiceTime, styles.tabular, { color: mine ? tint(ON_ACCENT, 0.8) : c.muted }]}>{clock(playing || elapsed > 0 ? elapsed : seconds)}</Text>
314 </View>
315 );
316}
317
318// ─── A bubble ───────────────────────────────────────────────────────────────
319
320function Bubble({ msg, tail, joined }: { msg: Message; tail: boolean; joined: boolean }) {
321 const c = usePalette();
322 const mine = msg.from === 'me';
323 // Bubbles in a group square off the corners they share on the sender's side.
324 const corners = mine ? { borderTopRightRadius: joined ? 6 : 20, borderBottomRightRadius: tail ? 20 : 6 } : { borderTopLeftRadius: joined ? 6 : 20, borderBottomLeftRadius: tail ? 20 : 6 };
325 if (msg.photo) {
326 return (
327 <View style={[styles.photoBubble, corners]}>
328 <Photo uri={msg.photo.uri} alt={msg.photo.alt} width={PHOTO_W} height={msg.photo.height} radius={0} />
329 </View>
330 );
331 }
332 const ground = mine ? ACCENT : c.bubble;
333 return (
334 <View style={[styles.bubble, corners, { backgroundColor: ground }, msg.link ? styles.bubbleWide : null]}>
335 {tail ? <Tail mine={mine} color={ground} /> : null}
336 {msg.replyTo ? (
337 <View style={[styles.quote, { backgroundColor: mine ? tint(ON_ACCENT, 0.15) : c.quote }]}>
338 <View style={[styles.quoteBar, { backgroundColor: mine ? ON_ACCENT : c.accent }]} />
339 <View style={styles.quoteBody}>
340 <Text selectable={false} numberOfLines={1} style={[styles.quoteName, { color: mine ? ON_ACCENT : c.accent }]}>
341 {msg.replyTo.name}
342 </Text>
343 <Text selectable={false} numberOfLines={1} style={[styles.quoteText, { color: mine ? tint(ON_ACCENT, 0.85) : c.muted }]}>
344 {msg.replyTo.text}
345 </Text>
346 </View>
347 </View>
348 ) : null}
349 {msg.link ? (
350 <View role="link" aria-label={`${msg.link.title}, ${msg.link.host}`} style={[styles.link, { backgroundColor: c.inset }]}>
351 <LinearGradient colors={['#FDBA74', '#F97316']} start={{ x: 0, y: 0 }} end={{ x: 1, y: 1 }} style={styles.linkThumb}>
352 <UtensilsCrossed size={22} color="#fff" strokeWidth={2.2} />
353 </LinearGradient>
354 <View style={styles.linkBody}>
355 <Text selectable={false} numberOfLines={1} style={[styles.linkTitle, { color: c.fg }]}>
356 {msg.link.title}
357 </Text>
358 <Text selectable={false} numberOfLines={1} style={[styles.linkBlurb, { color: c.muted }]}>
359 {msg.link.blurb}
360 </Text>
361 <View style={styles.linkHost}>
362 <Link2 size={12} color={c.accent} strokeWidth={2.4} />
363 <Text selectable={false} numberOfLines={1} style={[styles.linkHostText, { color: c.accent }]}>
364 {msg.link.host}
365 </Text>
366 </View>
367 </View>
368 </View>
369 ) : null}
370 {msg.voice ? <VoiceNote seconds={msg.voice} mine={mine} /> : null}
371 {msg.text ? (
372 <Text selectable={false} style={[styles.bubbleText, { color: mine ? ON_ACCENT : c.fg }]}>
373 {msg.text}
374 </Text>
375 ) : null}
376 </View>
377 );
378}
379
380function ReactionPill({ reaction, onPress }: { reaction: Reaction; onPress: () => void }) {
381 const c = usePalette();
382 const scale = useSharedValue(0.3);
383 useEffect(() => {
384 scale.value = withSpring(1, POP);
385 }, [scale, reaction.count, reaction.mine]);
386 const style = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] }));
387 return (
388 <Animated.View style={style}>
389 <Pressable
390 role="button"
391 aria-label={`${reaction.emoji} ${reaction.count}${reaction.mine ? ', remove your reaction' : ''}`}
392 hitSlop={6}
393 onPress={onPress}
394 style={[styles.pill, { backgroundColor: reaction.mine ? c.wash : c.chip, borderColor: reaction.mine ? c.accent : c.chip }]}
395 >
396 <Text style={styles.pillEmoji}>{reaction.emoji}</Text>
397 {reaction.count > 1 ? <Text style={[styles.pillCount, styles.tabular, { color: reaction.mine ? c.accent : c.muted }]}>{reaction.count}</Text> : null}
398 </Pressable>
399 </Animated.View>
400 );
401}
402
403type Box = { x: number; y: number; w: number; h: number };
404type RowProps = {
405 msg: Message;
406 tail: boolean;
407 joined: boolean;
408 hidden: boolean;
409 onLift: (node: ComponentRef<typeof View>) => void;
410 onReply: () => void;
411 onReact: (emoji: string) => void;
412};
413
414/** One message: press and hold lifts it, a swipe to the right replies to it. */
415function MessageRow({ msg, tail, joined, hidden, onLift, onReply, onReact }: RowProps) {
416 const c = usePalette();
417 const mine = msg.from === 'me';
418 const node = useRef<ComponentRef<typeof View>>(null);
419 const x = useSharedValue(0);
420 const press = useSharedValue(1);
421 const appear = useSharedValue(msg.fresh ? 0 : 1);
422 useEffect(() => {
423 if (msg.fresh) appear.value = withSpring(1, ARRIVE);
424 }, [appear, msg.fresh]);
425 const reply = useRef(onReply);
426 reply.current = onReply;
427 const pan = useMemo(
428 () =>
429 PanResponder.create({
430 onMoveShouldSetPanResponder: (_e, g) => g.dx > 8 && Math.abs(g.dx) > Math.abs(g.dy) * 1.5,
431 onPanResponderMove: (_e, g) => {
432 x.value = Math.max(0, Math.min(SWIPE_MAX, g.dx * 0.6));
433 },
434 onPanResponderRelease: (_e, g) => {
435 if (g.dx * 0.6 >= SWIPE_AT) reply.current();
436 x.value = withSpring(0, POP);
437 },
438 onPanResponderTerminate: () => {
439 x.value = withSpring(0, POP);
440 },
441 }),
442 [x]
443 );
444 const arrive = useAnimatedStyle(() => ({
445 opacity: Math.min(1, appear.value * 1.6),
446 transform: [{ translateY: (1 - appear.value) * 22 }, { scale: 0.86 + 0.14 * appear.value }],
447 }));
448 const slide = useAnimatedStyle(() => ({ transform: [{ translateX: x.value }] }));
449 const hint = useAnimatedStyle(() => ({
450 opacity: interpolate(x.value, [6, SWIPE_AT], [0, 1], 'clamp'),
451 transform: [{ scale: interpolate(x.value, [6, SWIPE_AT, SWIPE_MAX], [0.4, 1, 1.18], 'clamp') }],
452 }));
453 const held = useAnimatedStyle(() => ({ transform: [{ scale: press.value }] }));
454 const reactions = msg.reactions ?? [];
455 const label = `${mine ? 'You' : CONTACT.first}: ${preview(msg)}, ${msg.time}${msg.receipt ? `, ${msg.receipt}` : ''}`;
456 return (
457 <Animated.View style={[styles.row, joined ? styles.rowJoined : null, arrive, { transformOrigin: mine ? 'right bottom' : 'left bottom' }]} {...pan.panHandlers}>
458 <Animated.View style={[styles.replyHint, { backgroundColor: c.chip }, hint]}>
459 <Reply size={16} color={c.accent} strokeWidth={2.4} />
460 </Animated.View>
461 <Animated.View style={[styles.column, mine ? styles.columnMine : styles.columnTheirs, slide]}>
462 <Pressable
463 aria-label={label}
464 delayLongPress={320}
465 onLongPress={() => node.current && onLift(node.current)}
466 onPressIn={() => (press.value = withTiming(0.96, { duration: 240 }))}
467 onPressOut={() => (press.value = withSpring(1, POP))}
468 >
469 {/* Measured on the outer view, which the press scale does not shrink. */}
470 <View ref={node} style={hidden ? styles.hidden : null}>
471 <Animated.View style={held}>
472 <Bubble msg={msg} tail={tail} joined={joined} />
473 </Animated.View>
474 </View>
475 </Pressable>
476 {tail || reactions.length > 0 ? (
477 <View style={[styles.footer, mine ? styles.footerMine : null]}>
478 {reactions.map((r) => (
479 <ReactionPill key={r.emoji} reaction={r} onPress={() => onReact(r.emoji)} />
480 ))}
481 {tail ? <Text style={[styles.time, styles.tabular, { color: c.muted }]}>{msg.time}</Text> : null}
482 {tail && msg.receipt ? <ReceiptMark state={msg.receipt} /> : null}
483 </View>
484 ) : null}
485 </Animated.View>
486 </Animated.View>
487 );
488}
489
490function TypingBubble() {
491 const c = usePalette();
492 return (
493 <Animated.View entering={FadeInDown.duration(220)} exiting={FadeOut.duration(100)} style={[styles.row, styles.column, styles.columnTheirs]}>
494 <View role="status" aria-label={`${CONTACT.first} is typing`} style={[styles.bubble, styles.typingBubble, { backgroundColor: c.bubble }]}>
495 <Tail mine={false} color={c.bubble} />
496 {[0, 1, 2].map((i) => (
497 <TypingDot key={i} index={i} color={c.muted} />
498 ))}
499 </View>
500 </Animated.View>
501 );
502}
503
504// ─── Press and hold: the bubble lifts over a dimmed thread ───────────────────
505
506type Lifted = Box & { msg: Message; tail: boolean; joined: boolean };
507
508function LiftLayer({ lift, frame, onClose, onReact, onAction }: { lift: Lifted; frame: { w: number; h: number }; onClose: () => void; onReact: (emoji: string) => void; onAction: (a: Action) => void }) {
509 const c = usePalette();
510 const insets = useSafeAreaInsets();
511 const mine = lift.msg.from === 'me';
512 // Slide the bubble just far enough for the bar above it and the menu below it to fit.
513 const top = lift.y - REACT_BAR - 8;
514 const bottom = lift.y + lift.h + 8 + ACTIONS.length * MENU_ROW;
515 let shift = Math.min(0, frame.h - insets.bottom - 12 - bottom);
516 if (top + shift < insets.top + 8) shift = insets.top + 8 - top;
517 const t = useSharedValue(0);
518 useEffect(() => {
519 t.value = withSpring(1, ARRIVE);
520 }, [t]);
521 const raised = useAnimatedStyle(() => ({ transform: [{ translateY: shift * t.value }, { scale: 1 + 0.03 * t.value }] }));
522 const follow = useAnimatedStyle(() => ({ opacity: Math.min(1, t.value), transform: [{ translateY: shift * t.value }, { scale: 0.9 + 0.1 * t.value }] }));
523 const side = mine ? { right: frame.w - lift.x - lift.w } : { left: lift.x };
524 const current = lift.msg.reactions?.find((r) => r.mine)?.emoji;
525 return (
526 <Animated.View exiting={FadeOut.duration(140)} style={[StyleSheet.absoluteFill, styles.liftLayer]}>
527 <Animated.View entering={FadeIn.duration(180)} style={[StyleSheet.absoluteFill, { backgroundColor: c.dim }]}>
528 <Pressable role="button" aria-label="Close message actions" onPress={onClose} style={styles.fill} />
529 </Animated.View>
530 <Animated.View style={[styles.reactBar, styles.float, side, { top, backgroundColor: c.menu, transformOrigin: mine ? 'right bottom' : 'left bottom' }, follow]}>
531 {EMOJI.map((e, i) => (
532 <Animated.View key={e} entering={ZoomIn.delay(60 + i * 30).duration(200)}>
533 <Tap label={`React with ${e}`} to={1.3} onPress={() => onReact(e)}>
534 <View style={[styles.reactButton, e === current ? { backgroundColor: c.wash } : null]}>
535 <Text style={styles.reactEmoji}>{e}</Text>
536 </View>
537 </Tap>
538 </Animated.View>
539 ))}
540 </Animated.View>
541 <Animated.View pointerEvents="none" style={[styles.lifted, { left: lift.x, top: lift.y, width: lift.w }, raised]}>
542 <Bubble msg={lift.msg} tail={lift.tail} joined={lift.joined} />
543 </Animated.View>
544 <Animated.View role="menu" style={[styles.menu, styles.float, side, { top: lift.y + lift.h + 8, backgroundColor: c.menu, transformOrigin: mine ? 'right top' : 'left top' }, follow]}>
545 {ACTIONS.map(({ id, icon: Icon }, i) => (
546 <Pressable
547 key={id}
548 role="menuitem"
549 aria-label={id}
550 onPress={() => onAction(id)}
551 style={({ pressed }) => [styles.menuRow, { borderTopColor: c.menuLine, borderTopWidth: i ? 1 : 0, backgroundColor: pressed ? c.menuLine : c.menu }]}
552 >
553 <Text style={[styles.menuLabel, { color: id === 'Delete' ? ALERT : c.fg }]}>{id}</Text>
554 <Icon size={18} color={id === 'Delete' ? ALERT : c.fg} strokeWidth={2} />
555 </Pressable>
556 ))}
557 </Animated.View>
558 </Animated.View>
559 );
560}
561
562// ─── Composer ───────────────────────────────────────────────────────────────
563
564type ComposerProps = {
565 c: Palette;
566 value: string;
567 onChange: (v: string) => void;
568 onSend: () => void;
569 replyTo: Message | null;
570 onCancelReply: () => void;
571 input: RefObject<ComponentRef<typeof TextInput> | null>;
572};
573
574function Composer({ c, value, onChange, onSend, replyTo, onCancelReply, input }: ComposerProps) {
575 const insets = useSafeAreaInsets();
576 const has = value.trim().length > 0;
577 // The field is as tall as a hidden copy of its text, from one line up to five.
578 const [height, setHeight] = useState(40);
579 const morph = useSharedValue(0);
580 useEffect(() => {
581 morph.value = withSpring(has ? 1 : 0, POP);
582 }, [has, morph]);
583 // Emoji and camera shrink away as the send button turns in, and the field takes the room.
584 const slot = useAnimatedStyle(() => ({ width: interpolate(morph.value, [0, 1], [80, 40], 'clamp') }));
585 const idle = useAnimatedStyle(() => ({ opacity: interpolate(morph.value, [0, 0.6], [1, 0], 'clamp'), transform: [{ scale: interpolate(morph.value, [0, 1], [1, 0.5], 'clamp') }] }));
586 const sendStyle = useAnimatedStyle(() => ({
587 opacity: interpolate(morph.value, [0.2, 0.8], [0, 1], 'clamp'),
588 transform: [{ scale: Math.max(0, 0.4 + 0.6 * morph.value) }, { rotate: `${(1 - morph.value) * -90}deg` }],
589 }));
590 // The event type comes from TextInput's own props, so it holds across React Native versions (0.88 renamed it).
591 const onKeyPress: NonNullable<ComponentProps<typeof TextInput>['onKeyPress']> = (e) => {
592 // On web, Enter sends and Shift+Enter breaks the line.
593 if (Platform.OS !== 'web' || e.nativeEvent.key !== 'Enter' || (e.nativeEvent as { shiftKey?: boolean }).shiftKey) return;
594 e.preventDefault();
595 onSend();
596 };
597 return (
598 <View style={[styles.composer, { backgroundColor: c.bg, borderTopColor: c.line, paddingBottom: Math.max(insets.bottom, 8) }]}>
599 {replyTo ? (
600 <Animated.View entering={FadeInDown.duration(200)} exiting={FadeOut.duration(120)} style={styles.replying}>
601 <View style={[styles.replyingBar, { backgroundColor: c.accent }]} />
602 <View style={styles.quoteBody}>
603 <Text numberOfLines={1} style={[styles.replyingName, { color: c.accent }]}>
604 Replying to {replyTo.from === 'me' ? 'yourself' : CONTACT.name}
605 </Text>
606 <Text numberOfLines={1} style={[styles.replyingText, { color: c.muted }]}>
607 {preview(replyTo)}
608 </Text>
609 </View>
610 <Tap label="Cancel reply" onPress={onCancelReply}>
611 <View style={[styles.replyingClose, { backgroundColor: c.chip }]}>
612 <X size={14} color={c.muted} strokeWidth={2.6} />
613 </View>
614 </Tap>
615 </Animated.View>
616 ) : null}
617 <View style={styles.composerRow}>
618 <Tap label="Attach">
619 <View style={[styles.round, { backgroundColor: c.chip }]}>
620 <Plus size={22} color={c.accent} strokeWidth={2.2} />
621 </View>
622 </Tap>
623 <View style={[styles.field, { backgroundColor: c.chip }]}>
624 <Text aria-hidden pointerEvents="none" onLayout={(e: LayoutChangeEvent) => setHeight(Math.max(40, Math.min(124, Math.ceil(e.nativeEvent.layout.height))))} style={[styles.input, styles.inputMirror]}>
625 {value.endsWith('\n') || !value ? `${value} ` : value}
626 </Text>
627 <TextInput
628 ref={input}
629 value={value}
630 onChangeText={onChange}
631 onKeyPress={onKeyPress}
632 placeholder="Message"
633 placeholderTextColor={c.muted}
634 selectionColor={c.accent}
635 aria-label="Message"
636 multiline
637 style={[styles.input, { color: c.fg, height }, Platform.OS === 'web' ? ({ outlineStyle: 'none' } as object) : null]}
638 />
639 </View>
640 <Animated.View style={[styles.trailing, slot]}>
641 <Animated.View pointerEvents={has ? 'none' : 'auto'} style={[styles.trailingIdle, idle]}>
642 <Tap label="Emoji">
643 <View style={styles.round}>
644 <Smile size={24} color={c.accent} strokeWidth={2} />
645 </View>
646 </Tap>
647 <Tap label="Camera">
648 <View style={styles.round}>
649 <Camera size={24} color={c.accent} strokeWidth={2} />
650 </View>
651 </Tap>
652 </Animated.View>
653 <Animated.View pointerEvents={has ? 'auto' : 'none'} style={[styles.trailingSend, sendStyle]}>
654 <Tap label="Send" onPress={onSend}>
655 <View style={[styles.round, styles.send]}>
656 <ArrowUp size={21} color={ON_ACCENT} strokeWidth={2.8} />
657 </View>
658 </Tap>
659 </Animated.View>
660 </Animated.View>
661 </View>
662 </View>
663 );
664}
665
666// ─── Screen ─────────────────────────────────────────────────────────────────
667
668export default function ChatConversationScreen() {
669 const c = usePalette();
670 const insets = useSafeAreaInsets();
671 // Replace with your conversation query and realtime channel.
672 const [messages, setMessages] = useState(MESSAGES);
673 const [text, setText] = useState('');
674 const [typing, setTyping] = useState(false);
675 const [replyTo, setReplyTo] = useState<Message | null>(null);
676 const [lifted, setLifted] = useState<Lifted | null>(null);
677 const [toast, setToast] = useState('');
678 const [away, setAway] = useState(false);
679 const [frame, setFrame] = useState({ w: 0, h: 0 });
680
681 const root = useRef<ComponentRef<typeof View>>(null);
682 const list = useRef<ComponentRef<typeof ScrollView>>(null);
683 const input = useRef<ComponentRef<typeof TextInput>>(null);
684 const following = useRef(true);
685 const settled = useRef(false);
686 const sent = useRef(0);
687 const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
688 const later = (fn: () => void, ms: number) => timers.current.push(setTimeout(fn, ms));
689 useEffect(() => {
690 later(() => (settled.current = true), 700);
691 const all = timers.current;
692 return () => all.forEach(clearTimeout);
693 }, []);
694
695 // The thread opens on the newest message and stays there while you are at the bottom.
696 const toEnd = (animated: boolean) => list.current?.scrollToEnd({ animated });
697 const follow = () => following.current && toEnd(settled.current);
698 const onScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
699 const { contentOffset, contentSize, layoutMeasurement } = e.nativeEvent;
700 const gap = contentSize.height - contentOffset.y - layoutMeasurement.height;
701 following.current = gap < 80;
702 setAway(gap > 220);
703 };
704
705 const patch = (id: string, change: (m: Message) => Message) => setMessages((all) => all.map((m) => (m.id === id ? change(m) : m)));
706
707 const send = () => {
708 const body = text.trim();
709 if (!body) return;
710 const id = `s${Date.now()}`;
711 const quoted = replyTo ? { name: replyTo.from === 'me' ? 'You' : CONTACT.name, text: preview(replyTo) } : undefined;
712 following.current = true;
713 setMessages((all) => [...all, { id, from: 'me', day: 'Today', time: NOW, text: body, replyTo: quoted, receipt: 'sent', fresh: true }]);
714 setText('');
715 setReplyTo(null);
716 // Replace these timers with delivery, read and typing events from your server.
717 later(() => patch(id, (m) => ({ ...m, receipt: 'delivered' })), 400);
718 later(() => patch(id, (m) => ({ ...m, receipt: 'read' })), 1000);
719 later(() => setTyping(true), 1500);
720 later(() => {
721 const reply = REPLIES[sent.current++ % REPLIES.length];
722 setTyping(false);
723 setMessages((all) => [...all, { id: `r${id}`, from: 'them', day: 'Today', time: NOW, text: reply, fresh: true }]);
724 }, 3600);
725 };
726
727 // One reaction each: the same emoji again takes it back, another one replaces it.
728 const react = (id: string, emoji: string) =>
729 patch(id, (m) => {
730 const had = m.reactions?.find((r) => r.mine)?.emoji;
731 let next = (m.reactions ?? []).map((r) => (r.mine ? { ...r, count: r.count - 1, mine: false } : r)).filter((r) => r.count > 0);
732 if (had !== emoji) next = next.some((r) => r.emoji === emoji) ? next.map((r) => (r.emoji === emoji ? { ...r, count: r.count + 1, mine: true } : r)) : [...next, { emoji, count: 1, mine: true }];
733 return { ...m, reactions: next };
734 });
735 const remove = (id: string) => setMessages((all) => all.filter((m) => m.id !== id));
736 const startReply = (m: Message) => {
737 setReplyTo(m);
738 input.current?.focus();
739 };
740 const say = (line: string) => {
741 setToast(line);
742 later(() => setToast(''), 1500);
743 };
744
745 // Where the bubble sits inside this screen, so its copy can rise from the same spot.
746 const lift = (m: Message, tail: boolean, joined: boolean, node: ComponentRef<typeof View>) =>
747 root.current?.measureInWindow((rx: number, ry: number) => node.measureInWindow((x: number, y: number, w: number, h: number) => setLifted({ msg: m, tail, joined, x: x - rx, y: y - ry, w: Math.ceil(w), h })));
748 const act = (a: Action) => {
749 if (!lifted) return;
750 const m = lifted.msg;
751 setLifted(null);
752 if (a === 'Reply') startReply(m);
753 // Copy and Forward stop here: write to your clipboard, open your chat picker.
754 if (a === 'Copy') say('Message copied');
755 if (a === 'Forward') say('Choose a chat to forward to');
756 if (a === 'Delete') remove(m.id);
757 };
758
759 return (
760 <KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'padding' : undefined} style={[styles.fill, { backgroundColor: c.bg }]}>
761 <View ref={root} style={styles.fill} onLayout={(e: LayoutChangeEvent) => setFrame({ w: e.nativeEvent.layout.width, h: e.nativeEvent.layout.height })}>
762 {/* Header: opaque, under the status bar */}
763 <View style={[styles.header, { paddingTop: insets.top, backgroundColor: c.bg, borderBottomColor: c.line }]}>
764 <View style={styles.bar}>
765 <Tap label="Back to messages">
766 <View style={styles.back}>
767 <ChevronLeft size={28} color={c.accent} strokeWidth={2.2} />
768 </View>
769 </Tap>
770 <Pressable role="button" aria-label={`${CONTACT.name}, ${typing ? 'typing' : 'online'}. View contact`} style={({ pressed }) => [styles.who, { opacity: pressed ? 0.6 : 1 }]}>
771 <View style={styles.avatar}>
772 <Photo uri={CONTACT.avatar} alt="" width={38} height={38} radius={19} />
773 <View style={[styles.presence, { borderColor: c.bg }]} />
774 </View>
775 <View style={styles.whoText}>
776 <Text numberOfLines={1} style={[styles.name, { color: c.fg }]}>
777 {CONTACT.name}
778 </Text>
779 <Animated.Text key={typing ? 'typing' : 'online'} entering={FadeInDown.duration(200)} numberOfLines={1} style={[styles.status, { color: typing ? c.accent : c.muted }]}>
780 {typing ? 'typing…' : 'online'}
781 </Animated.Text>
782 </View>
783 </Pressable>
784 <Tap label="Video call">
785 <View style={styles.headerButton}>
786 <Video size={24} color={c.accent} strokeWidth={2} />
787 </View>
788 </Tap>
789 <Tap label="Voice call">
790 <View style={styles.headerButton}>
791 <Phone size={21} color={c.accent} strokeWidth={2} />
792 </View>
793 </Tap>
794 </View>
795 </View>
796
797 <View style={styles.fill}>
798 <ScrollView
799 ref={list}
800 onScroll={onScroll}
801 scrollEventThrottle={32}
802 onContentSizeChange={follow}
803 onLayout={follow}
804 showsVerticalScrollIndicator={false}
805 keyboardShouldPersistTaps="handled"
806 keyboardDismissMode="interactive"
807 contentContainerStyle={styles.thread}
808 >
809 <View style={styles.note}>
810 <Lock size={11} color={c.faint} strokeWidth={2.6} />
811 <Text style={[styles.noteText, { color: c.faint }]}>Messages are end-to-end encrypted</Text>
812 </View>
813 {messages.map((m, i) => {
814 const before = messages[i - 1];
815 const after = messages[i + 1];
816 const joined = !!before && before.from === m.from && before.day === m.day;
817 const tail = !(after && after.from === m.from && after.day === m.day);
818 return (
819 <Animated.View key={m.id} layout={MOVE} exiting={FadeOut.duration(160)}>
820 {!before || before.day !== m.day ? (
821 <View style={styles.day}>
822 <Text role="heading" style={[styles.dayText, { color: c.muted, backgroundColor: c.chip }]}>
823 {m.day}
824 </Text>
825 </View>
826 ) : null}
827 <MessageRow msg={m} tail={tail} joined={joined} hidden={lifted?.msg.id === m.id} onLift={(node) => lift(m, tail, joined, node)} onReply={() => startReply(m)} onReact={(e) => react(m.id, e)} />
828 </Animated.View>
829 );
830 })}
831 {typing ? <TypingBubble /> : null}
832 </ScrollView>
833
834 {away ? (
835 <Animated.View entering={ZoomIn.duration(180)} exiting={FadeOut.duration(120)} style={styles.jump}>
836 <Tap
837 label="Jump to latest message"
838 onPress={() => {
839 following.current = true;
840 toEnd(true);
841 }}
842 >
843 <View style={[styles.jumpButton, styles.float, { backgroundColor: c.menu, borderColor: c.line }]}>
844 <ChevronDown size={22} color={c.accent} strokeWidth={2.4} />
845 </View>
846 </Tap>
847 </Animated.View>
848 ) : null}
849 {toast ? (
850 <Animated.View entering={FadeInDown.duration(200)} exiting={FadeOut.duration(160)} pointerEvents="none" style={styles.toastWrap}>
851 <Text role="status" style={[styles.toast, { color: c.bg, backgroundColor: c.fg }]}>
852 {toast}
853 </Text>
854 </Animated.View>
855 ) : null}
856 </View>
857
858 <Composer c={c} value={text} onChange={setText} onSend={send} replyTo={replyTo} onCancelReply={() => setReplyTo(null)} input={input} />
859
860 {lifted ? (
861 <LiftLayer
862 lift={lifted}
863 frame={frame}
864 onClose={() => setLifted(null)}
865 onReact={(e) => {
866 react(lifted.msg.id, e);
867 setLifted(null);
868 }}
869 onAction={act}
870 />
871 ) : null}
872 </View>
873 </KeyboardAvoidingView>
874 );
875}
876
877// ─── Styles ─────────────────────────────────────────────────────────────────
878
879const styles = StyleSheet.create({
880 fill: { flex: 1 },
881 tabular: { fontVariant: ['tabular-nums'] },
882 float: { shadowColor: '#000', shadowOpacity: 0.16, shadowRadius: 24, shadowOffset: { width: 0, height: 8 } },
883 round: { width: 36, height: 36, borderRadius: 18, alignItems: 'center', justifyContent: 'center' },
884
885 // Header
886 header: { borderBottomWidth: 1, zIndex: 2 },
887 bar: { height: HEADER, flexDirection: 'row', alignItems: 'center', paddingLeft: 4, paddingRight: 8 },
888 back: { width: 36, height: 44, alignItems: 'center', justifyContent: 'center' },
889 who: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 10, marginRight: 4 },
890 avatar: { width: 38, height: 38 },
891 presence: { position: 'absolute', right: -2, bottom: -2, width: 14, height: 14, borderRadius: 7, borderWidth: 2.5, backgroundColor: ONLINE },
892 whoText: { flex: 1, gap: 1 },
893 name: { fontSize: 16.5, fontWeight: '600', letterSpacing: -0.2 },
894 status: { fontSize: 12.5, fontWeight: '500' },
895 headerButton: { width: 42, height: 44, alignItems: 'center', justifyContent: 'center' },
896
897 // Thread
898 thread: { paddingTop: 12, paddingBottom: 12 },
899 note: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 5, paddingBottom: 4 },
900 noteText: { fontSize: 11.5, fontWeight: '500' },
901 day: { alignItems: 'center', paddingTop: 14, paddingBottom: 2 },
902 dayText: { fontSize: 12, fontWeight: '600', paddingHorizontal: 10, paddingVertical: 4, borderRadius: 11, overflow: 'hidden' },
903 row: { paddingHorizontal: 14, marginTop: 10 },
904 rowJoined: { marginTop: 2 },
905 column: { maxWidth: '80%' },
906 columnMine: { alignSelf: 'flex-end', alignItems: 'flex-end' },
907 columnTheirs: { alignSelf: 'flex-start', alignItems: 'flex-start' },
908 replyHint: { position: 'absolute', left: 12, top: '50%', marginTop: -15, width: 30, height: 30, borderRadius: 15, alignItems: 'center', justifyContent: 'center' },
909
910 // Bubbles
911 bubble: { borderRadius: 20, paddingHorizontal: 13, paddingVertical: 8, gap: 6 },
912 bubbleWide: { paddingHorizontal: 6, paddingTop: 6, minWidth: 262 },
913 bubbleText: { fontSize: 16, lineHeight: 21, letterSpacing: -0.1, paddingHorizontal: 0 },
914 tailMine: { position: 'absolute', right: -5.5, bottom: 0 },
915 tailTheirs: { position: 'absolute', left: -5.5, bottom: 0, transform: [{ scaleX: -1 }] },
916 photoBubble: { borderRadius: 20, overflow: 'hidden' },
917 photo: { overflow: 'hidden' },
918 photoImage: { width: '100%', height: '100%' },
919 quote: { flexDirection: 'row', borderRadius: 10, overflow: 'hidden', marginHorizontal: -5, marginTop: -1, minWidth: 180 },
920 quoteBar: { width: 3 },
921 quoteBody: { flex: 1, paddingHorizontal: 9, paddingVertical: 6, gap: 1 },
922 quoteName: { fontSize: 13, fontWeight: '700' },
923 quoteText: { fontSize: 13.5 },
924 link: { flexDirection: 'row', alignItems: 'center', gap: 10, borderRadius: 15, padding: 8 },
925 linkThumb: { width: 56, height: 56, borderRadius: 10, alignItems: 'center', justifyContent: 'center' },
926 linkBody: { flex: 1, gap: 2 },
927 linkTitle: { fontSize: 14.5, fontWeight: '600', letterSpacing: -0.1 },
928 linkBlurb: { fontSize: 12.5 },
929 linkHost: { flexDirection: 'row', alignItems: 'center', gap: 4, marginTop: 1 },
930 linkHostText: { fontSize: 12, fontWeight: '500' },
931 typingBubble: { flexDirection: 'row', alignItems: 'center', gap: 4, height: 37, paddingTop: 12 },
932 typingDot: { width: 7, height: 7, borderRadius: 3.5 },
933
934 // Voice note
935 voice: { flexDirection: 'row', alignItems: 'center', gap: 10, marginHorizontal: -5, paddingVertical: 1 },
936 voicePlay: { width: 36, height: 36, borderRadius: 18, alignItems: 'center', justifyContent: 'center' },
937 voicePlayMine: { backgroundColor: ON_ACCENT },
938 voicePlayTheirs: { backgroundColor: ACCENT },
939 playNudge: { marginLeft: 2 },
940 wave: { height: 30, flexDirection: 'row', alignItems: 'center', gap: 2 },
941 waveBar: { width: 3, borderRadius: 1.5 },
942 voiceTime: { fontSize: 12.5, fontWeight: '500', marginRight: 6 },
943
944 // Under a bubble
945 footer: { flexDirection: 'row', alignItems: 'center', gap: 4, marginTop: 4, minHeight: 16, paddingHorizontal: 2 },
946 footerMine: { justifyContent: 'flex-end' },
947 time: { fontSize: 11.5 },
948 pill: { height: 24, minWidth: 34, borderRadius: 12, borderWidth: 1, paddingHorizontal: 7, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 3, marginRight: 2 },
949 pillEmoji: { fontSize: 13 },
950 pillCount: { fontSize: 12, fontWeight: '600' },
951
952 // Press and hold
953 liftLayer: { zIndex: 10 },
954 lifted: { position: 'absolute' },
955 hidden: { opacity: 0 },
956 reactBar: { position: 'absolute', height: REACT_BAR, borderRadius: REACT_BAR / 2, paddingHorizontal: 6, flexDirection: 'row', alignItems: 'center', gap: 2 },
957 reactButton: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center' },
958 reactEmoji: { fontSize: 25 },
959 menu: { position: 'absolute', width: 214, borderRadius: 16, overflow: 'hidden' },
960 menuRow: { height: MENU_ROW, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 16 },
961 menuLabel: { fontSize: 16 },
962
963 // Over the thread
964 jump: { position: 'absolute', right: 14, bottom: 12 },
965 jumpButton: { width: 40, height: 40, borderRadius: 20, borderWidth: 1, alignItems: 'center', justifyContent: 'center' },
966 toastWrap: { position: 'absolute', top: 12, left: 0, right: 0, alignItems: 'center' },
967 toast: { fontSize: 13.5, fontWeight: '600', paddingHorizontal: 14, paddingVertical: 8, borderRadius: 17, overflow: 'hidden' },
968
969 // Composer
970 composer: { borderTopWidth: 1, paddingTop: 8 },
971 composerRow: { flexDirection: 'row', alignItems: 'flex-end', gap: 8, paddingLeft: 10, paddingRight: 8 },
972 field: { flex: 1, minHeight: 40, borderRadius: 20, paddingHorizontal: 14, marginBottom: -2, marginTop: -2 },
973 input: { fontSize: 16, lineHeight: 21, paddingTop: 9.5, paddingBottom: 9.5, paddingHorizontal: 0, textAlignVertical: 'top' },
974 inputMirror: { position: 'absolute', left: 14, right: 14, top: 0, opacity: 0 },
975 trailing: { height: 36 },
976 trailingIdle: { position: 'absolute', right: 0, top: 0, flexDirection: 'row', gap: 4, transformOrigin: 'right center' },
977 trailingSend: { position: 'absolute', right: 0, top: 0 },
978 send: { backgroundColor: ACCENT },
979 replying: { flexDirection: 'row', alignItems: 'center', marginHorizontal: 14, marginBottom: 8, gap: 4 },
980 replyingBar: { width: 3, alignSelf: 'stretch', borderRadius: 1.5 },
981 replyingName: { fontSize: 13, fontWeight: '600' },
982 replyingText: { fontSize: 13.5 },
983 replyingClose: { width: 26, height: 26, borderRadius: 13, alignItems: 'center', justifyContent: 'center' },
984});

More screens like this.

All AI & Chat