Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(mobile): add shared mobile UI components

Richie McIlroy6fc60a456d6d
diff --git a/apps/mobile/src/components/Avatar.tsx b/apps/mobile/src/components/Avatar.tsx
new file mode 100644
index 000000000..b54bdba4f
--- /dev/null
+++ b/apps/mobile/src/components/Avatar.tsx
@@ -0,0 +1,93 @@
+import { Image } from "expo-image";
+import { StyleSheet, Text, View } from "react-native";
+import { fonts, squircle } from "@/theme";
+
+type AvatarTone = {
+ background: string;
+ foreground: string;
+};
+
+const tones: AvatarTone[] = [
+ { background: "#e6f4fe", foreground: "#0d74ce" },
+ { background: "#e9f7ee", foreground: "#218358" },
+ { background: "#fdeef3", foreground: "#c2298a" },
+ { background: "#fff1e7", foreground: "#cc4e00" },
+ { background: "#f3effc", foreground: "#7c4dcc" },
+ { background: "#fff8e1", foreground: "#9e6c00" },
+ { background: "#eaf3ff", foreground: "#3358d4" },
+ { background: "#e7f6f4", foreground: "#0d8b7a" },
+];
+
+const hashString = (value: string) => {
+ let hash = 0;
+ for (let index = 0; index < value.length; index += 1) {
+ hash = (hash * 31 + value.charCodeAt(index)) | 0;
+ }
+ return Math.abs(hash);
+};
+
+export const avatarInitials = (name: string | null) => {
+ const trimmed = name?.trim();
+ if (!trimmed) return "?";
+ const words = trimmed.split(/\s+/).filter(Boolean);
+ if (words.length === 1) return words[0].slice(0, 2).toUpperCase();
+ return `${words[0][0] ?? ""}${words[words.length - 1][0] ?? ""}`.toUpperCase();
+};
+
+export const avatarTone = (name: string | null): AvatarTone =>
+ tones[hashString(name?.trim() || "cap") % tones.length];
+
+type AvatarProps = {
+ name: string | null;
+ size?: number;
+ imageUrl?: string | null;
+};
+
+export function Avatar({ name, size = 36, imageUrl }: AvatarProps) {
+ const tone = avatarTone(name);
+
+ return (
+ <View
+ style={[
+ styles.base,
+ {
+ width: size,
+ height: size,
+ borderRadius: size / 2,
+ backgroundColor: tone.background,
+ },
+ ]}
+ >
+ {imageUrl ? (
+ <Image
+ cachePolicy="memory-disk"
+ contentFit="cover"
+ source={{ uri: imageUrl }}
+ style={{ width: size, height: size }}
+ />
+ ) : (
+ <Text
+ allowFontScaling={false}
+ style={[
+ styles.initials,
+ { color: tone.foreground, fontSize: Math.round(size * 0.38) },
+ ]}
+ >
+ {avatarInitials(name)}
+ </Text>
+ )}
+ </View>
+ );
+}
+
+const styles = StyleSheet.create({
+ base: {
+ alignItems: "center",
+ justifyContent: "center",
+ overflow: "hidden",
+ ...squircle,
+ },
+ initials: {
+ fontFamily: fonts.medium,
+ },
+});
diff --git a/apps/mobile/src/components/CapLoadingIndicator.tsx b/apps/mobile/src/components/CapLoadingIndicator.tsx
new file mode 100644
index 000000000..e78fdd031
--- /dev/null
+++ b/apps/mobile/src/components/CapLoadingIndicator.tsx
@@ -0,0 +1,167 @@
+import { useEffect, useMemo } from "react";
+import { StyleSheet, View, type ViewStyle } from "react-native";
+import Animated, {
+ cancelAnimation,
+ Easing,
+ useAnimatedStyle,
+ useReducedMotion,
+ useSharedValue,
+ withRepeat,
+ withSequence,
+ withTiming,
+} from "react-native-reanimated";
+import { colors } from "@/theme";
+
+const LOGO_BLUE = "#4785FF";
+const LOGO_LIGHT_BLUE = "#ADC9FF";
+// Ring proportions from assets/splash-icon.svg (circle radii 248/202/156).
+const MIDDLE_RATIO = 202 / 248;
+const INNER_RATIO = 156 / 248;
+
+const TILT_MAX_DEG = 16;
+const ROCK_OUT_MS = 130;
+const ROCK_BACK_MS = 180;
+const ROCK_BEAT_MS = 210;
+const TREMBLE_STEP_MS = 45;
+const REST_MS = 650;
+// Both loops must span the exact same total or they drift apart over repeats:
+// tilt = 2×(130+180+210) + 8×45 + 650 = 2050
+// swell = 1040 + 360 + 90 + 160 + 400 = 2050
+
+function rockAndTremble() {
+ const out = { duration: ROCK_OUT_MS, easing: Easing.out(Easing.quad) };
+ const back = { duration: ROCK_BACK_MS, easing: Easing.inOut(Easing.quad) };
+ const step = { duration: TREMBLE_STEP_MS };
+ return withRepeat(
+ withSequence(
+ withTiming(-TILT_MAX_DEG, out),
+ withTiming(0, back),
+ withTiming(0, { duration: ROCK_BEAT_MS }),
+ withTiming(TILT_MAX_DEG, out),
+ withTiming(0, back),
+ withTiming(0, { duration: ROCK_BEAT_MS }),
+ withTiming(-4, step),
+ withTiming(4.5, step),
+ withTiming(-5.5, step),
+ withTiming(6, step),
+ withTiming(-6.5, step),
+ withTiming(7, step),
+ withTiming(-5, step),
+ withTiming(0, step),
+ withTiming(0, { duration: REST_MS }),
+ ),
+ -1,
+ );
+}
+
+function swellAndPop() {
+ return withRepeat(
+ withSequence(
+ withTiming(1, { duration: 1040 }),
+ withTiming(1.07, { duration: 360, easing: Easing.in(Easing.quad) }),
+ withTiming(0.96, { duration: 90, easing: Easing.out(Easing.quad) }),
+ withTiming(1, { duration: 160, easing: Easing.out(Easing.quad) }),
+ withTiming(1, { duration: 400 }),
+ ),
+ -1,
+ );
+}
+
+type CapLoadingIndicatorProps = {
+ size?: number;
+};
+
+export function CapLoadingIndicator({ size = 56 }: CapLoadingIndicatorProps) {
+ const reduceMotion = useReducedMotion();
+ const tilt = useSharedValue(0);
+ const swell = useSharedValue(1);
+ const pulse = useSharedValue(0);
+
+ useEffect(() => {
+ if (reduceMotion) {
+ pulse.value = 0;
+ pulse.value = withRepeat(
+ withTiming(1, { duration: 1600, easing: Easing.linear }),
+ -1,
+ );
+ return () => {
+ cancelAnimation(pulse);
+ };
+ }
+ tilt.value = 0;
+ tilt.value = rockAndTremble();
+ swell.value = 1;
+ swell.value = swellAndPop();
+ return () => {
+ cancelAnimation(tilt);
+ cancelAnimation(swell);
+ };
+ }, [reduceMotion, tilt, swell, pulse]);
+
+ // Reduce Motion swaps the wobble for a gentle opacity pulse: a loading
+ // state must keep signalling progress, it just shouldn't move.
+ const ballStyle = useAnimatedStyle(() => {
+ if (reduceMotion) {
+ return {
+ opacity: 0.7 + 0.3 * (0.5 + 0.5 * Math.sin(2 * Math.PI * pulse.value)),
+ transform: [],
+ };
+ }
+ return {
+ opacity: 1,
+ transform: [
+ // translateY sandwich moves the pivot to the ball's bottom edge so
+ // it rocks like a ball on the ground instead of spinning in place.
+ { translateY: size / 2 },
+ { rotate: `${tilt.value}deg` },
+ { translateY: -size / 2 },
+ { scale: swell.value },
+ ],
+ };
+ });
+
+ const layers = useMemo(() => {
+ const circle = (diameter: number, backgroundColor: string): ViewStyle => ({
+ backgroundColor,
+ borderRadius: diameter / 2,
+ height: diameter,
+ left: (size - diameter) / 2,
+ position: "absolute",
+ top: (size - diameter) / 2,
+ width: diameter,
+ });
+ return {
+ ball: { height: size, width: size } satisfies ViewStyle,
+ inner: circle(size * INNER_RATIO, colors.white),
+ middle: circle(size * MIDDLE_RATIO, LOGO_LIGHT_BLUE),
+ outer: {
+ ...circle(size, LOGO_BLUE),
+ boxShadow: `0px ${Math.round(size * 0.06)}px ${Math.round(size * 0.25)}px rgba(71, 133, 255, 0.3)`,
+ } satisfies ViewStyle,
+ };
+ }, [size]);
+
+ return (
+ <View
+ accessible
+ accessibilityLabel="Loading"
+ accessibilityRole="progressbar"
+ style={[styles.wrapper, layers.ball]}
+ testID="cap-loading-indicator"
+ >
+ <Animated.View style={[layers.ball, ballStyle]} testID="cap-loading-ball">
+ <View style={layers.outer} testID="cap-loading-circle-outer" />
+ <View style={layers.middle} testID="cap-loading-circle-middle" />
+ <View style={layers.inner} testID="cap-loading-circle-inner" />
+ </Animated.View>
+ </View>
+ );
+}
+
+const styles = StyleSheet.create({
+ wrapper: {
+ alignItems: "center",
+ justifyContent: "center",
+ pointerEvents: "none",
+ },
+});
diff --git a/apps/mobile/src/components/CircleIconButton.tsx b/apps/mobile/src/components/CircleIconButton.tsx
new file mode 100644
index 000000000..6e317f092
--- /dev/null
+++ b/apps/mobile/src/components/CircleIconButton.tsx
@@ -0,0 +1,168 @@
+import { type SFSymbol, SymbolView } from "expo-symbols";
+import {
+ type AccessibilityValue,
+ ActivityIndicator,
+ Pressable,
+ StyleSheet,
+ Text,
+ View,
+} from "react-native";
+import Animated, {
+ useAnimatedStyle,
+ useSharedValue,
+ withSpring,
+} from "react-native-reanimated";
+import { colors, fonts, squircle } from "@/theme";
+import { GlassSurface } from "./GlassSurface";
+
+const pressSpring = { damping: 18, stiffness: 320, mass: 0.7 };
+
+type CircleIconButtonProps = {
+ symbol: SFSymbol;
+ accessibilityLabel: string;
+ accessibilityHint?: string;
+ accessibilityValue?: AccessibilityValue;
+ onPress: () => void;
+ caption?: string;
+ disabled?: boolean;
+ loading?: boolean;
+ active?: boolean;
+ tone?: "neutral" | "accent";
+ size?: number;
+};
+
+export function CircleIconButton({
+ symbol,
+ accessibilityLabel,
+ accessibilityHint,
+ accessibilityValue,
+ onPress,
+ caption,
+ disabled = false,
+ loading = false,
+ active = false,
+ tone = "neutral",
+ size = 54,
+}: CircleIconButtonProps) {
+ const isDisabled = disabled || loading;
+ const scale = useSharedValue(1);
+
+ const circleStyle = useAnimatedStyle(() => ({
+ transform: [{ scale: scale.value }],
+ }));
+
+ const iconColor = active
+ ? colors.green9
+ : tone === "accent"
+ ? colors.blue11
+ : colors.gray12;
+
+ return (
+ <View style={styles.wrapper}>
+ <Pressable
+ accessibilityRole="button"
+ accessibilityLabel={accessibilityLabel}
+ accessibilityHint={accessibilityHint}
+ accessibilityValue={accessibilityValue}
+ accessibilityState={{ busy: loading, disabled: isDisabled }}
+ disabled={isDisabled}
+ hitSlop={8}
+ onPress={onPress}
+ onPressIn={() => {
+ scale.value = withSpring(0.94, pressSpring);
+ }}
+ onPressOut={() => {
+ scale.value = withSpring(1, pressSpring);
+ }}
+ >
+ <Animated.View
+ style={[
+ styles.circle,
+ { width: size, height: size, borderRadius: size / 2 },
+ active ? styles.circleActive : null,
+ isDisabled ? styles.circleDisabled : null,
+ circleStyle,
+ ]}
+ >
+ <GlassSurface
+ fallbackStyle={styles.glassFallback}
+ glassEffectStyle="clear"
+ isInteractive
+ style={styles.glass}
+ tintColor={active ? colors.green9 : colors.glass}
+ >
+ {loading ? (
+ <ActivityIndicator color={iconColor} />
+ ) : (
+ <SymbolView
+ name={active ? "checkmark" : symbol}
+ size={Math.round(size * 0.4)}
+ tintColor={isDisabled ? colors.gray8 : iconColor}
+ type="monochrome"
+ weight="semibold"
+ />
+ )}
+ </GlassSurface>
+ </Animated.View>
+ </Pressable>
+ {caption ? (
+ <Text
+ allowFontScaling={false}
+ numberOfLines={1}
+ style={[
+ styles.caption,
+ active ? styles.captionActive : null,
+ isDisabled ? styles.captionDisabled : null,
+ ]}
+ >
+ {caption}
+ </Text>
+ ) : null}
+ </View>
+ );
+}
+
+const styles = StyleSheet.create({
+ wrapper: {
+ alignItems: "center",
+ gap: 8,
+ },
+ circle: {
+ alignItems: "center",
+ justifyContent: "center",
+ borderWidth: StyleSheet.hairlineWidth,
+ borderColor: colors.gray4,
+ backgroundColor: colors.gray2,
+ overflow: "hidden",
+ ...squircle,
+ },
+ circleActive: {
+ borderColor: colors.green9,
+ backgroundColor: "#e9f7ee",
+ },
+ circleDisabled: {
+ backgroundColor: colors.gray3,
+ borderColor: colors.gray4,
+ },
+ glass: {
+ flex: 1,
+ alignSelf: "stretch",
+ alignItems: "center",
+ justifyContent: "center",
+ },
+ glassFallback: {
+ backgroundColor: "transparent",
+ },
+ caption: {
+ fontFamily: fonts.medium,
+ fontSize: 12,
+ lineHeight: 15,
+ color: colors.gray11,
+ },
+ captionActive: {
+ color: colors.green9,
+ },
+ captionDisabled: {
+ color: colors.gray9,
+ },
+});
diff --git a/apps/mobile/src/components/ReactionBar.tsx b/apps/mobile/src/components/ReactionBar.tsx
new file mode 100644
index 000000000..2574aa42f
--- /dev/null
+++ b/apps/mobile/src/components/ReactionBar.tsx
@@ -0,0 +1,343 @@
+import * as Haptics from "expo-haptics";
+import { useCallback, useEffect, useRef, useState } from "react";
+import {
+ type LayoutChangeEvent,
+ Pressable,
+ StyleSheet,
+ Text,
+ View,
+} from "react-native";
+import Animated, {
+ FadeIn,
+ runOnJS,
+ useAnimatedStyle,
+ useSharedValue,
+ withSequence,
+ withSpring,
+ withTiming,
+} from "react-native-reanimated";
+import { colors, fonts, radius, squircle } from "@/theme";
+import { GlassSurface } from "./GlassSurface";
+
+export type ReactionCount = {
+ emoji: string;
+ count: number;
+};
+
+type FloatingReaction = {
+ id: number;
+ emoji: string;
+ x: number;
+ drift: number;
+ rotate: number;
+};
+
+const bumpSpring = { damping: 9, stiffness: 260, mass: 0.6 };
+const floatDistance = 184;
+const floatDuration = 1200;
+
+type CountPillProps = {
+ emoji: string;
+ count: number;
+};
+
+function CountPill({ emoji, count }: CountPillProps) {
+ const scale = useSharedValue(1);
+ const previous = useRef(count);
+
+ useEffect(() => {
+ if (count > previous.current) {
+ scale.value = withSequence(
+ withSpring(1.32, bumpSpring),
+ withSpring(1, bumpSpring),
+ );
+ }
+ previous.current = count;
+ }, [count, scale]);
+
+ const animatedStyle = useAnimatedStyle(() => ({
+ transform: [{ scale: scale.value }],
+ }));
+
+ return (
+ <Animated.View
+ entering={FadeIn.duration(180)}
+ style={[styles.countPill, animatedStyle]}
+ >
+ <Text allowFontScaling={false} style={styles.countPillEmoji}>
+ {emoji}
+ </Text>
+ <Text allowFontScaling={false} style={styles.countPillValue}>
+ {count}
+ </Text>
+ </Animated.View>
+ );
+}
+
+type ReactionOptionProps = {
+ emoji: string;
+ disabled: boolean;
+ onPress: (emoji: string, centerX: number) => void;
+};
+
+function ReactionOption({ emoji, disabled, onPress }: ReactionOptionProps) {
+ const scale = useSharedValue(1);
+ const center = useRef(0);
+
+ const animatedStyle = useAnimatedStyle(() => ({
+ transform: [{ scale: scale.value }],
+ }));
+
+ const onLayout = (event: LayoutChangeEvent) => {
+ const { x, width } = event.nativeEvent.layout;
+ center.current = x + width / 2;
+ };
+
+ return (
+ <Pressable
+ accessibilityRole="button"
+ accessibilityLabel={`React with ${emoji}`}
+ accessibilityHint="Adds this reaction"
+ accessibilityState={{ disabled }}
+ disabled={disabled}
+ hitSlop={6}
+ onLayout={onLayout}
+ onPress={() => {
+ scale.value = withSequence(
+ withSpring(1.36, bumpSpring),
+ withSpring(1, bumpSpring),
+ );
+ onPress(emoji, center.current);
+ }}
+ style={styles.option}
+ >
+ <Animated.View style={animatedStyle}>
+ <Text allowFontScaling={false} style={styles.optionEmoji}>
+ {emoji}
+ </Text>
+ </Animated.View>
+ </Pressable>
+ );
+}
+
+type FloatingEmojiProps = {
+ reaction: FloatingReaction;
+ onDone: (id: number) => void;
+};
+
+function FloatingEmoji({ reaction, onDone }: FloatingEmojiProps) {
+ const progress = useSharedValue(0);
+
+ useEffect(() => {
+ progress.value = withTiming(1, { duration: floatDuration }, (finished) => {
+ if (finished) runOnJS(onDone)(reaction.id);
+ });
+ }, [progress, onDone, reaction.id]);
+
+ const animatedStyle = useAnimatedStyle(() => ({
+ opacity: 1 - progress.value,
+ transform: [
+ { translateY: -floatDistance * progress.value },
+ { translateX: reaction.drift * progress.value },
+ { rotate: `${reaction.rotate * progress.value}deg` },
+ { scale: 1 + progress.value * 0.4 },
+ ],
+ }));
+
+ return (
+ <Animated.View
+ pointerEvents="none"
+ style={[styles.floating, { left: reaction.x - 14 }, animatedStyle]}
+ >
+ <Text allowFontScaling={false} style={styles.floatingEmoji}>
+ {reaction.emoji}
+ </Text>
+ </Animated.View>
+ );
+}
+
+type ReactionBarProps = {
+ options: readonly string[];
+ counts: ReactionCount[];
+ total: number;
+ onReact: (emoji: string) => void;
+ disabled?: boolean;
+};
+
+export function ReactionBar({
+ options,
+ counts,
+ total,
+ onReact,
+ disabled = false,
+}: ReactionBarProps) {
+ const [floats, setFloats] = useState<FloatingReaction[]>([]);
+ const nextId = useRef(0);
+
+ const removeFloat = useCallback((id: number) => {
+ setFloats((current) => current.filter((item) => item.id !== id));
+ }, []);
+
+ const spawnFloats = (emoji: string, centerX: number) => {
+ const burst = 3 + Math.floor(Math.random() * 3);
+ const additions: FloatingReaction[] = [];
+ for (let index = 0; index < burst; index += 1) {
+ nextId.current += 1;
+ additions.push({
+ id: nextId.current,
+ emoji,
+ x: centerX,
+ drift: (Math.random() - 0.5) * 84,
+ rotate: (Math.random() - 0.5) * 44,
+ });
+ }
+ setFloats((current) => [...current, ...additions]);
+ };
+
+ const handlePress = (emoji: string, centerX: number) => {
+ void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
+ spawnFloats(emoji, centerX);
+ onReact(emoji);
+ };
+
+ return (
+ <View style={styles.container}>
+ <View style={styles.header}>
+ <Text style={styles.title}>Reactions</Text>
+ <Text style={styles.count}>{total}</Text>
+ </View>
+ {counts.length > 0 ? (
+ <View style={styles.countRow}>
+ {counts.map((item) => (
+ <CountPill count={item.count} emoji={item.emoji} key={item.emoji} />
+ ))}
+ </View>
+ ) : (
+ <Text style={styles.emptyText}>Be the first to react.</Text>
+ )}
+ <View style={styles.optionsWrapper}>
+ <View pointerEvents="none" style={styles.floatLayer}>
+ {floats.map((item) => (
+ <FloatingEmoji key={item.id} onDone={removeFloat} reaction={item} />
+ ))}
+ </View>
+ <GlassSurface
+ fallbackStyle={styles.optionsFallback}
+ isInteractive
+ style={styles.options}
+ tintColor={colors.gray1}
+ >
+ {options.map((emoji) => (
+ <ReactionOption
+ disabled={disabled}
+ emoji={emoji}
+ key={emoji}
+ onPress={handlePress}
+ />
+ ))}
+ </GlassSurface>
+ </View>
+ </View>
+ );
+}
+
+const styles = StyleSheet.create({
+ container: {
+ borderRadius: radius.md,
+ borderWidth: StyleSheet.hairlineWidth,
+ borderColor: colors.gray3,
+ backgroundColor: colors.gray1,
+ gap: 12,
+ padding: 16,
+ ...squircle,
+ },
+ header: {
+ flexDirection: "row",
+ alignItems: "center",
+ gap: 8,
+ },
+ title: {
+ fontFamily: fonts.medium,
+ fontSize: 18,
+ lineHeight: 23,
+ color: colors.gray12,
+ },
+ count: {
+ fontFamily: fonts.medium,
+ fontSize: 14,
+ color: colors.gray10,
+ },
+ emptyText: {
+ fontFamily: fonts.regular,
+ fontSize: 14,
+ color: colors.gray10,
+ },
+ countRow: {
+ flexDirection: "row",
+ flexWrap: "wrap",
+ gap: 8,
+ },
+ countPill: {
+ flexDirection: "row",
+ alignItems: "center",
+ gap: 6,
+ minHeight: 32,
+ borderRadius: radius.full,
+ borderWidth: StyleSheet.hairlineWidth,
+ borderColor: colors.gray4,
+ backgroundColor: colors.gray2,
+ paddingHorizontal: 11,
+ ...squircle,
+ },
+ countPillEmoji: {
+ fontSize: 15,
+ },
+ countPillValue: {
+ fontFamily: fonts.medium,
+ fontSize: 14,
+ color: colors.gray12,
+ },
+ optionsWrapper: {
+ position: "relative",
+ },
+ floatLayer: {
+ position: "absolute",
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ zIndex: 4,
+ },
+ floating: {
+ position: "absolute",
+ top: 4,
+ width: 28,
+ alignItems: "center",
+ },
+ floatingEmoji: {
+ fontSize: 24,
+ },
+ options: {
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "space-between",
+ borderRadius: radius.full,
+ borderWidth: StyleSheet.hairlineWidth,
+ borderColor: colors.gray4,
+ paddingHorizontal: 6,
+ paddingVertical: 6,
+ ...squircle,
+ },
+ optionsFallback: {
+ backgroundColor: colors.gray2,
+ },
+ option: {
+ flex: 1,
+ alignItems: "center",
+ justifyContent: "center",
+ paddingVertical: 8,
+ },
+ optionEmoji: {
+ fontSize: 24,
+ },
+});
diff --git a/apps/mobile/src/components/TabBar.tsx b/apps/mobile/src/components/TabBar.tsx
new file mode 100644
index 000000000..a9d71464a
--- /dev/null
+++ b/apps/mobile/src/components/TabBar.tsx
@@ -0,0 +1,312 @@
+import {
+ GlassView,
+ isGlassEffectAPIAvailable,
+ isLiquidGlassAvailable,
+} from "expo-glass-effect";
+import * as Haptics from "expo-haptics";
+import { router, useSegments } from "expo-router";
+import { type SFSymbol, SymbolView } from "expo-symbols";
+import { useEffect } from "react";
+import {
+ Platform,
+ Pressable,
+ StyleSheet,
+ Text,
+ useWindowDimensions,
+ View,
+} from "react-native";
+import Animated, {
+ cancelAnimation,
+ Easing,
+ useAnimatedStyle,
+ useSharedValue,
+ withRepeat,
+ withSpring,
+ withTiming,
+} from "react-native-reanimated";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { colors, fonts } from "@/theme";
+
+const BAR_HEIGHT = 62;
+const BAR_MARGIN = 12;
+const RECORD_HEIGHT = 48;
+const OVERLAY_SIZE = 96;
+
+const pressSpring = { damping: 18, stiffness: 320, mass: 0.7 } as const;
+
+const glassAvailable = (() => {
+ if (Platform.OS !== "ios") return false;
+ try {
+ return isGlassEffectAPIAvailable() && isLiquidGlassAvailable();
+ } catch {
+ return false;
+ }
+})();
+
+type TabDefinition = {
+ name: string;
+ label: string;
+ icon: SFSymbol;
+ iconActive: SFSymbol;
+};
+
+const leftTab: TabDefinition = {
+ name: "index",
+ label: "My Caps",
+ icon: "folder",
+ iconActive: "folder.fill",
+};
+
+const rightTab: TabDefinition = {
+ name: "account",
+ label: "Account",
+ icon: "person.crop.circle",
+ iconActive: "person.crop.circle.fill",
+};
+
+type TabBarProps = {
+ activeRouteName: string;
+ onSelect: (routeName: string) => void;
+};
+
+function TabSlot({
+ tab,
+ active,
+ onSelect,
+}: {
+ tab: TabDefinition;
+ active: boolean;
+ onSelect: (routeName: string) => void;
+}) {
+ const scale = useSharedValue(1);
+ const animatedStyle = useAnimatedStyle(() => ({
+ transform: [{ scale: scale.value }],
+ }));
+ const tint = active ? colors.blue9 : colors.gray11;
+ return (
+ <Pressable
+ accessibilityRole="button"
+ accessibilityState={{ selected: active }}
+ accessibilityLabel={tab.label}
+ onPressIn={() => {
+ scale.value = withSpring(0.92, pressSpring);
+ }}
+ onPressOut={() => {
+ scale.value = withSpring(1, pressSpring);
+ }}
+ onPress={() => {
+ void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
+ onSelect(tab.name);
+ }}
+ style={styles.tabSlot}
+ >
+ <Animated.View style={[styles.tabSlotInner, animatedStyle]}>
+ <SymbolView
+ name={active ? tab.iconActive : tab.icon}
+ size={22}
+ tintColor={tint}
+ weight="medium"
+ />
+ <Text style={[styles.tabLabel, { color: tint }]}>{tab.label}</Text>
+ </Animated.View>
+ </Pressable>
+ );
+}
+
+export function TabBar({ activeRouteName, onSelect }: TabBarProps) {
+ const insets = useSafeAreaInsets();
+ const { width, height } = useWindowDimensions();
+ const segments = useSegments();
+ const occluded = segments[0] === "record";
+ const breathe = useSharedValue(1);
+ const pressScale = useSharedValue(1);
+ const overlayScale = useSharedValue(0);
+ const overlayOpacity = useSharedValue(0);
+
+ useEffect(() => {
+ if (occluded) {
+ cancelAnimation(breathe);
+ breathe.value = 1;
+ return;
+ }
+ breathe.value = withRepeat(
+ withTiming(1.025, { duration: 2200, easing: Easing.inOut(Easing.ease) }),
+ -1,
+ true,
+ );
+ return () => {
+ cancelAnimation(breathe);
+ };
+ }, [breathe, occluded]);
+
+ const recordStyle = useAnimatedStyle(() => ({
+ transform: [{ scale: pressScale.value * breathe.value }],
+ }));
+ const overlayStyle = useAnimatedStyle(() => ({
+ opacity: overlayOpacity.value,
+ transform: [{ scale: overlayScale.value }],
+ }));
+
+ const overlayTarget = Math.ceil(
+ (Math.hypot(width, height) * 2.2) / OVERLAY_SIZE,
+ );
+
+ const launchRecorder = () => {
+ void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
+ overlayOpacity.value = 1;
+ overlayScale.value = 0;
+ overlayScale.value = withTiming(overlayTarget, {
+ duration: 280,
+ easing: Easing.out(Easing.cubic),
+ });
+ setTimeout(() => {
+ router.push("/record");
+ }, 220);
+ setTimeout(() => {
+ overlayOpacity.value = withTiming(0, { duration: 240 }, (finished) => {
+ if (finished) {
+ overlayScale.value = 0;
+ }
+ });
+ }, 420);
+ };
+
+ return (
+ <View
+ pointerEvents="box-none"
+ style={[styles.wrapper, { paddingBottom: insets.bottom + 8 }]}
+ >
+ <View pointerEvents="box-none" style={styles.stage}>
+ <GlassView
+ colorScheme="light"
+ glassEffectStyle="regular"
+ isInteractive
+ style={[styles.bar, glassAvailable ? null : styles.barFallback]}
+ tintColor="rgba(252, 252, 252, 0.4)"
+ >
+ <TabSlot
+ tab={leftTab}
+ active={activeRouteName === leftTab.name}
+ onSelect={onSelect}
+ />
+ <Animated.View style={[styles.recordGlow, recordStyle]}>
+ <Pressable
+ accessibilityRole="button"
+ accessibilityLabel="Record"
+ accessibilityHint="Opens the camera recorder"
+ hitSlop={10}
+ onPressIn={() => {
+ void Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
+ pressScale.value = withSpring(0.94, pressSpring);
+ }}
+ onPressOut={() => {
+ pressScale.value = withSpring(1, pressSpring);
+ }}
+ onPress={launchRecorder}
+ style={styles.record}
+ >
+ <SymbolView
+ name="video.fill"
+ size={20}
+ tintColor={colors.white}
+ weight="medium"
+ />
+ <Text style={styles.recordLabel}>Record</Text>
+ </Pressable>
+ </Animated.View>
+ <TabSlot
+ tab={rightTab}
+ active={activeRouteName === rightTab.name}
+ onSelect={onSelect}
+ />
+ </GlassView>
+ <Animated.View
+ pointerEvents="none"
+ style={[styles.overlay, overlayStyle]}
+ />
+ </View>
+ </View>
+ );
+}
+
+const styles = StyleSheet.create({
+ wrapper: {
+ position: "absolute",
+ left: 0,
+ right: 0,
+ bottom: 0,
+ },
+ stage: {
+ marginHorizontal: BAR_MARGIN,
+ alignItems: "center",
+ justifyContent: "center",
+ },
+ bar: {
+ alignSelf: "stretch",
+ height: BAR_HEIGHT,
+ borderRadius: BAR_HEIGHT / 2,
+ borderCurve: "continuous",
+ overflow: "hidden",
+ flexDirection: "row",
+ alignItems: "center",
+ paddingHorizontal: 10,
+ gap: 6,
+ },
+ barFallback: {
+ backgroundColor: "rgba(252, 252, 252, 0.94)",
+ borderWidth: StyleSheet.hairlineWidth,
+ borderColor: "rgba(0, 0, 0, 0.08)",
+ },
+ tabSlot: {
+ flex: 1,
+ height: "100%",
+ alignItems: "center",
+ justifyContent: "center",
+ },
+ tabSlotInner: {
+ alignItems: "center",
+ justifyContent: "center",
+ gap: 2,
+ },
+ tabLabel: {
+ fontFamily: fonts.medium,
+ fontSize: 11,
+ lineHeight: 13,
+ },
+ recordGlow: {
+ shadowColor: "#ff3b30",
+ shadowOffset: { width: 0, height: 4 },
+ shadowOpacity: 0.32,
+ shadowRadius: 10,
+ elevation: 10,
+ },
+ record: {
+ height: RECORD_HEIGHT,
+ minWidth: 118,
+ borderRadius: RECORD_HEIGHT / 2,
+ borderCurve: "continuous",
+ paddingHorizontal: 22,
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "center",
+ gap: 7,
+ backgroundColor: "#ff3b30",
+ },
+ recordLabel: {
+ fontFamily: fonts.medium,
+ fontSize: 14,
+ lineHeight: 18,
+ color: colors.white,
+ },
+ overlay: {
+ position: "absolute",
+ left: "50%",
+ top: "50%",
+ marginLeft: -OVERLAY_SIZE / 2,
+ marginTop: -OVERLAY_SIZE / 2,
+ width: OVERLAY_SIZE,
+ height: OVERLAY_SIZE,
+ borderRadius: OVERLAY_SIZE / 2,
+ backgroundColor: "#050505",
+ },
+});
diff --git a/apps/mobile/src/components/recording-upload-card.tsx b/apps/mobile/src/components/recording-upload-card.tsx
new file mode 100644
index 000000000..dc5e15784
--- /dev/null
+++ b/apps/mobile/src/components/recording-upload-card.tsx
@@ -0,0 +1,391 @@
+import {
+ GlassView,
+ isGlassEffectAPIAvailable,
+ isLiquidGlassAvailable,
+} from "expo-glass-effect";
+import { type SFSymbol, SymbolView } from "expo-symbols";
+import { useEffect } from "react";
+import {
+ Dimensions,
+ Platform,
+ Pressable,
+ StyleSheet,
+ Text,
+ View,
+} from "react-native";
+import { Gesture, GestureDetector } from "react-native-gesture-handler";
+import Animated, {
+ Extrapolation,
+ FadeOut,
+ interpolate,
+ runOnJS,
+ type SharedValue,
+ SlideInDown,
+ useAnimatedStyle,
+ useSharedValue,
+ withSpring,
+ withTiming,
+} from "react-native-reanimated";
+import { colors, fonts, radius, squircle } from "@/theme";
+import {
+ type RecordingUploadJob,
+ recordingUploadProgress,
+} from "@/uploads/recording-upload-queue";
+
+export const UPLOAD_CARD_HEIGHT = 64;
+const CARD_GAP = 10;
+const PEEK_OFFSET = 8;
+const SCALE_STEP = 0.05;
+const STACK_DEPTH = 2;
+const SCREEN_WIDTH = Dimensions.get("window").width;
+const DISMISS_THRESHOLD = SCREEN_WIDTH * 0.32;
+const DARK_TINT = "rgba(18,18,20,0.55)";
+const STACK_SPRING = { damping: 20, mass: 0.7, stiffness: 220 };
+const PROGRESS_SPRING = { damping: 22, mass: 0.6, stiffness: 140 };
+
+const glassAvailable = (() => {
+ if (Platform.OS !== "ios") return false;
+ try {
+ return isGlassEffectAPIAvailable() && isLiquidGlassAvailable();
+ } catch {
+ return false;
+ }
+})();
+
+type UploadCardKind =
+ | "recording"
+ | "uploading"
+ | "processing"
+ | "complete"
+ | "retryable"
+ | "unrecoverable";
+
+type UploadCardDescriptor = {
+ kind: UploadCardKind;
+ title: string;
+ symbol: SFSymbol;
+ symbolColor: string;
+ barColor: string;
+};
+
+const describeJob = (job: RecordingUploadJob): UploadCardDescriptor => {
+ if (job.status === "recording" && job.uploadOwner === "external") {
+ return {
+ kind: "recording",
+ title: "Screen recording in progress",
+ symbol: "rectangle.fill.on.rectangle.fill",
+ symbolColor: colors.red9,
+ barColor: colors.red9,
+ };
+ }
+ if (job.status === "complete") {
+ return {
+ kind: "complete",
+ title: "Recording ready · Tap to view",
+ symbol: "checkmark.icloud.fill",
+ symbolColor: colors.green9,
+ barColor: colors.green9,
+ };
+ }
+ if (job.status === "failed") {
+ if (job.durationSeconds !== null && job.uploadOwner === "app") {
+ return {
+ kind: "retryable",
+ title: "Upload paused · Tap to retry",
+ symbol: "exclamationmark.icloud.fill",
+ symbolColor: colors.yellow9,
+ barColor: colors.yellow9,
+ };
+ }
+ return {
+ kind: "unrecoverable",
+ title: "Recording could not be recovered",
+ symbol: "exclamationmark.icloud.fill",
+ symbolColor: colors.red9,
+ barColor: colors.red9,
+ };
+ }
+ if (job.status === "processing") {
+ const title =
+ job.processingMessage ??
+ (job.serverPhase === "generating_thumbnail" ||
+ job.serverPhase === "complete"
+ ? "Finishing up"
+ : job.serverPhase === "processing"
+ ? "Processing"
+ : "Finishing your recording");
+ return {
+ kind: "processing",
+ title,
+ symbol: "icloud.and.arrow.up.fill",
+ symbolColor: colors.white,
+ barColor: colors.blue9,
+ };
+ }
+ const percent = Math.round(recordingUploadProgress(job) * 100);
+ return {
+ kind: "uploading",
+ title: `Uploading · ${percent}%`,
+ symbol: "icloud.and.arrow.up.fill",
+ symbolColor: colors.white,
+ barColor: colors.blue9,
+ };
+};
+
+type UploadStackCardProps = {
+ job: RecordingUploadJob;
+ index: number;
+ total: number;
+ expanded: boolean;
+ expandProgress: SharedValue<number>;
+ onRequestExpand: () => void;
+ onOpen: (id: string) => void;
+ onRetry: (id: string) => void;
+ onDiscard: (id: string) => void;
+ onDismiss: (id: string) => void;
+};
+
+export function UploadStackCard({
+ job,
+ index,
+ total,
+ expanded,
+ expandProgress,
+ onRequestExpand,
+ onOpen,
+ onRetry,
+ onDiscard,
+ onDismiss,
+}: UploadStackCardProps) {
+ const descriptor = describeJob(job);
+ const fraction =
+ descriptor.kind === "complete" || descriptor.kind === "recording"
+ ? 1
+ : recordingUploadProgress(job);
+ const interactive = expanded || index === 0;
+ const canSwipe = interactive && descriptor.kind === "complete";
+ const translateX = useSharedValue(0);
+ const indexValue = useSharedValue(index);
+ const progress = useSharedValue(fraction);
+
+ useEffect(() => {
+ indexValue.value = withSpring(index, STACK_SPRING);
+ }, [index, indexValue]);
+
+ useEffect(() => {
+ progress.value = withSpring(fraction, PROGRESS_SPRING);
+ }, [fraction, progress]);
+
+ const cardStyle = useAnimatedStyle(() => {
+ const idx = indexValue.value;
+ const openness = expandProgress.value;
+ const collapsedY = interpolate(
+ idx,
+ [0, STACK_DEPTH],
+ [0, STACK_DEPTH * PEEK_OFFSET],
+ Extrapolation.CLAMP,
+ );
+ const collapsedScale = interpolate(
+ idx,
+ [0, STACK_DEPTH],
+ [1, 1 - STACK_DEPTH * SCALE_STEP],
+ Extrapolation.CLAMP,
+ );
+ const collapsedOpacity = interpolate(
+ idx,
+ [0, 1, 2, 3],
+ [1, 0.6, 0.42, 0],
+ Extrapolation.CLAMP,
+ );
+ const expandedY = -idx * (UPLOAD_CARD_HEIGHT + CARD_GAP);
+ const translateY = collapsedY + (expandedY - collapsedY) * openness;
+ const scale = collapsedScale + (1 - collapsedScale) * openness;
+ const opacity = collapsedOpacity + (1 - collapsedOpacity) * openness;
+ const swipeFade =
+ 1 - Math.min(1, Math.abs(translateX.value) / SCREEN_WIDTH);
+ return {
+ opacity: opacity * swipeFade,
+ transform: [{ translateY }, { translateX: translateX.value }, { scale }],
+ };
+ });
+
+ const barStyle = useAnimatedStyle(() => ({
+ transform: [{ scaleX: Math.max(0.0001, progress.value) }],
+ }));
+
+ const handlePress = () => {
+ if (!expanded && total > 1) {
+ onRequestExpand();
+ return;
+ }
+ if (descriptor.kind === "complete") onOpen(job.id);
+ else if (descriptor.kind === "retryable") onRetry(job.id);
+ };
+
+ const pan = Gesture.Pan()
+ .enabled(canSwipe)
+ .activeOffsetX([-14, 14])
+ .failOffsetY([-12, 12])
+ .onUpdate((event) => {
+ translateX.value = event.translationX;
+ })
+ .onEnd((event) => {
+ if (Math.abs(event.translationX) > DISMISS_THRESHOLD) {
+ translateX.value = withTiming(
+ Math.sign(event.translationX) * SCREEN_WIDTH,
+ { duration: 180 },
+ (finished) => {
+ if (finished) runOnJS(onDismiss)(job.id);
+ },
+ );
+ return;
+ }
+ translateX.value = withSpring(0, STACK_SPRING);
+ });
+
+ return (
+ <Animated.View
+ entering={SlideInDown.springify().damping(20).mass(0.7)}
+ exiting={FadeOut.duration(180)}
+ pointerEvents="box-none"
+ style={[styles.slot, { zIndex: total - index }]}
+ >
+ <GestureDetector gesture={pan}>
+ <Animated.View
+ pointerEvents={interactive ? "auto" : "none"}
+ style={[styles.card, cardStyle]}
+ >
+ <Pressable
+ accessibilityLabel={descriptor.title}
+ accessibilityRole="button"
+ onPress={handlePress}
+ style={styles.pressable}
+ >
+ {glassAvailable ? (
+ <GlassView
+ colorScheme="dark"
+ glassEffectStyle="regular"
+ style={StyleSheet.absoluteFill}
+ tintColor={DARK_TINT}
+ />
+ ) : (
+ <View style={[StyleSheet.absoluteFill, styles.fallback]} />
+ )}
+ <View pointerEvents="none" style={styles.border} />
+ <View style={styles.content}>
+ <View style={styles.row}>
+ <SymbolView
+ name={descriptor.symbol}
+ size={20}
+ tintColor={descriptor.symbolColor}
+ />
+ <Text numberOfLines={1} style={styles.title}>
+ {descriptor.title}
+ </Text>
+ {descriptor.kind === "unrecoverable" && interactive ? (
+ <Pressable
+ accessibilityLabel="Discard recording"
+ accessibilityRole="button"
+ hitSlop={10}
+ onPress={() => onDiscard(job.id)}
+ style={styles.discard}
+ >
+ <SymbolView
+ name="xmark"
+ size={12}
+ tintColor={colors.white}
+ weight="bold"
+ />
+ </Pressable>
+ ) : null}
+ </View>
+ <View style={styles.track}>
+ <Animated.View
+ style={[
+ styles.bar,
+ { backgroundColor: descriptor.barColor },
+ barStyle,
+ ]}
+ />
+ </View>
+ </View>
+ </Pressable>
+ </Animated.View>
+ </GestureDetector>
+ </Animated.View>
+ );
+}
+
+const styles = StyleSheet.create({
+ slot: {
+ position: "absolute",
+ left: 0,
+ right: 0,
+ top: 0,
+ height: UPLOAD_CARD_HEIGHT,
+ },
+ card: {
+ height: UPLOAD_CARD_HEIGHT,
+ borderRadius: radius.lg,
+ boxShadow: "0 12px 30px rgba(0,0,0,0.32)",
+ ...squircle,
+ },
+ pressable: {
+ flex: 1,
+ borderRadius: radius.lg,
+ overflow: "hidden",
+ ...squircle,
+ },
+ fallback: {
+ backgroundColor: "rgba(18,18,20,0.92)",
+ },
+ border: {
+ ...StyleSheet.absoluteFillObject,
+ borderRadius: radius.lg,
+ borderWidth: StyleSheet.hairlineWidth,
+ borderColor: "rgba(255,255,255,0.14)",
+ ...squircle,
+ },
+ content: {
+ flex: 1,
+ paddingHorizontal: 14,
+ paddingVertical: 11,
+ justifyContent: "center",
+ gap: 9,
+ },
+ row: {
+ flexDirection: "row",
+ alignItems: "center",
+ gap: 10,
+ },
+ title: {
+ flex: 1,
+ color: colors.white,
+ fontFamily: fonts.medium,
+ fontSize: 14.5,
+ fontVariant: ["tabular-nums"],
+ },
+ discard: {
+ width: 22,
+ height: 22,
+ borderRadius: radius.full,
+ alignItems: "center",
+ justifyContent: "center",
+ backgroundColor: "rgba(255,255,255,0.12)",
+ },
+ track: {
+ height: 3,
+ borderRadius: radius.full,
+ backgroundColor: "rgba(255,255,255,0.16)",
+ overflow: "hidden",
+ },
+ bar: {
+ position: "absolute",
+ left: 0,
+ top: 0,
+ bottom: 0,
+ width: "100%",
+ borderRadius: radius.full,
+ transformOrigin: "left",
+ },
+});