Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(mobile): wire tab bar layout and app shell
Richie McIlroyb33bef2ebe42
diff --git a/apps/mobile/app/(tabs)/_layout.tsx b/apps/mobile/app/(tabs)/_layout.tsxindex 3985c71fe..17969c401 100644--- a/apps/mobile/app/(tabs)/_layout.tsx+++ b/apps/mobile/app/(tabs)/_layout.tsx@@ -1,53 +1,24 @@-import { NativeTabs } from "expo-router/unstable-native-tabs";-import { colors, fonts } from "@/theme";+import { Tabs } from "expo-router";+import { TabBar } from "@/components/TabBar";export default function TabsLayout() {return (- <NativeTabs- backgroundColor={colors.glass}- blurEffect="systemMaterialLight"- disableTransparentOnScrollEdge- iconColor={{ default: colors.gray9, selected: colors.blue9 }}- labelStyle={{- default: {- color: colors.gray9,- fontFamily: fonts.medium,- fontSize: 11,- },- selected: {- color: colors.blue9,- fontFamily: fonts.medium,- fontSize: 11,- },- }}- minimizeBehavior="automatic"- shadowColor={colors.gray4}- tintColor={colors.blue9}- >- <NativeTabs.Trigger name="index">- <NativeTabs.Trigger.Label>My Caps</NativeTabs.Trigger.Label>- <NativeTabs.Trigger.Icon- sf={{ default: "folder", selected: "folder.fill" }}- />- </NativeTabs.Trigger>- <NativeTabs.Trigger name="upload">- <NativeTabs.Trigger.Label>Import</NativeTabs.Trigger.Label>- <NativeTabs.Trigger.Icon- sf={{- default: "square.and.arrow.up",- selected: "square.and.arrow.up.fill",+ <Tabs+ screenOptions={{ headerShown: false }}+ tabBar={(props) => (+ <TabBar+ activeRouteName={+ props.state.routes[props.state.index]?.name ?? "index"+ }+ onSelect={(routeName) => {+ props.navigation.navigate(routeName);}}/>- </NativeTabs.Trigger>- <NativeTabs.Trigger name="account">- <NativeTabs.Trigger.Label>Account</NativeTabs.Trigger.Label>- <NativeTabs.Trigger.Icon- sf={{- default: "person.crop.circle",- selected: "person.crop.circle.fill",- }}- />- </NativeTabs.Trigger>- </NativeTabs>+ )}+ >+ <Tabs.Screen name="index" options={{ title: "My Caps" }} />+ <Tabs.Screen name="upload" options={{ href: null }} />+ <Tabs.Screen name="account" options={{ title: "Account" }} />+ </Tabs>);}diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsxindex dc77e8242..30e58a97d 100644--- a/apps/mobile/app/_layout.tsx+++ b/apps/mobile/app/_layout.tsx@@ -3,7 +3,6 @@ import "react-native-reanimated";import { Stack, useSegments } from "expo-router";import {- ActivityIndicator,KeyboardAvoidingView,Platform,ScrollView,@@ -16,6 +15,7 @@ import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";import { AuthProvider, useAuth } from "@/auth/AuthContext";import { SignInPanel } from "@/auth/SignInPanel";import { signInTitleForSegments } from "@/auth/signInDestination";+import { CapLoadingIndicator } from "@/components/CapLoadingIndicator";import { RecordingUploadStatus } from "@/components/recording-upload-status";import { colors } from "@/theme";import { RecordingUploadProvider } from "@/uploads/recording-upload-provider";@@ -27,7 +27,7 @@ function AppShell() {if (auth.status === "loading") {return (<View style={styles.loadingScreen}>- <ActivityIndicator color={colors.blue11} />+ <CapLoadingIndicator /></View>);}@@ -53,8 +53,11 @@ function AppShell() {return (<Stack screenOptions={{ headerShown: false }}>- <Stack.Screen name="(tabs)" />+ <Stack.Screen name="(tabs)" options={{ title: "My Caps" }} /><Stack.Screen name="caps/[id]" />+ <Stack.Screen name="analytics" />+ <Stack.Screen name="organization-settings" />+ <Stack.Screen name="loom-import" /></Stack>);}diff --git a/apps/mobile/src/components/Screen.test.tsx b/apps/mobile/src/components/Screen.test.tsxindex 9a5a0ea6f..250143ba7 100644--- a/apps/mobile/src/components/Screen.test.tsx+++ b/apps/mobile/src/components/Screen.test.tsx@@ -97,6 +97,44 @@ vi.mock("react-native-safe-area-context", async () => {};});+vi.mock("./CapLoadingIndicator", async () => {+ const React = await import("react");+ return {+ CapLoadingIndicator: (props: HostProps) =>+ React.createElement("CapLoadingIndicator", props),+ };+});++vi.mock("./CapRefreshControl", async () => {+ const React = await import("react");+ return {+ CapRefreshControl: (props: HostProps) =>+ React.createElement("CapRefreshControl", props),+ CapRefreshOverlay: (props: HostProps) =>+ React.createElement("CapRefreshOverlay", props),+ };+});++const findNodeByType = (+ node: JsonNode,+ type: string,+): ReactTestRendererJSON | null => {+ if (!node || typeof node === "string") return null;+ if (Array.isArray(node)) {+ for (const item of node) {+ const match = findNodeByType(item, type);+ if (match) return match;+ }+ return null;+ }+ if (node.type === type) return node;+ for (const child of node.children ?? []) {+ const match = findNodeByType(child, type);+ if (match) return match;+ }+ return null;+};+describe("Screen", () => {it("uses the Cap web subtitle scale", async () => {const tree = await renderTree();@@ -112,6 +150,12 @@ describe("Screen", () => {expect(hasStyle(tree, { paddingBottom: 32 })).toBe(true);});+ it("shows the animated Cap logo while loading", async () => {+ const tree = await renderTree(<Screen loading />);++ expect(findNodeByType(tree, "CapLoadingIndicator")).not.toBeNull();+ });+it("can keep focused inputs visible above the keyboard", async () => {const tree = await renderTree(<Screen automaticallyAdjustKeyboardInsets scroll />,diff --git a/apps/mobile/src/components/Screen.tsx b/apps/mobile/src/components/Screen.tsxindex 25472fd36..e9a593bf7 100644--- a/apps/mobile/src/components/Screen.tsx+++ b/apps/mobile/src/components/Screen.tsx@@ -1,14 +1,9 @@import type { ReactNode } from "react";-import {- ActivityIndicator,- ScrollView,- StyleSheet,- Text,- View,-} from "react-native";+import { ScrollView, StyleSheet, Text, View } from "react-native";import { type Edge, SafeAreaView } from "react-native-safe-area-context";import { colors, fonts } from "@/theme";-import { CapRefreshControl } from "./CapRefreshControl";+import { CapLoadingIndicator } from "./CapLoadingIndicator";+import { CapRefreshControl, CapRefreshOverlay } from "./CapRefreshControl";type ScreenProps = {children?: ReactNode;@@ -21,6 +16,8 @@ type ScreenProps = {footer?: ReactNode;safeEdges?: Edge[];automaticallyAdjustKeyboardInsets?: boolean;+ contentInsetBottom?: number;+ headerLeft?: ReactNode;};const defaultSafeEdges: Edge[] = ["top", "left", "right"];@@ -36,18 +33,23 @@ export function Screen({footer,safeEdges = defaultSafeEdges,automaticallyAdjustKeyboardInsets = false,+ contentInsetBottom,+ headerLeft,}: ScreenProps) {const content = (<>{title ? (<View style={[styles.header, subtitle && styles.headerWithSubtitle]}>+ {headerLeft ? (+ <View style={styles.headerLeft}>{headerLeft}</View>+ ) : null}<Text style={styles.title}>{title}</Text>{subtitle ? <Text style={styles.subtitle}>{subtitle}</Text> : null}</View>) : null}{loading ? (<View style={styles.loading}>- <ActivityIndicator color={colors.blue9} />+ <CapLoadingIndicator /></View>) : (children@@ -59,25 +61,44 @@ export function Screen({return (<SafeAreaView style={styles.safeArea} edges={safeEdges}>{scroll ? (- <ScrollView- automaticallyAdjustKeyboardInsets={automaticallyAdjustKeyboardInsets}- contentInsetAdjustmentBehavior="automatic"- contentContainerStyle={styles.scrollContent}- keyboardDismissMode="interactive"- keyboardShouldPersistTaps="handled"- refreshControl={- onRefresh ? (- <CapRefreshControl- refreshing={refreshing}- onRefresh={onRefresh}- />- ) : undefined- }+ <>+ <ScrollView+ automaticallyAdjustKeyboardInsets={+ automaticallyAdjustKeyboardInsets+ }+ contentInsetAdjustmentBehavior="automatic"+ contentContainerStyle={[+ styles.scrollContent,+ contentInsetBottom != null+ ? { paddingBottom: contentInsetBottom }+ : null,+ ]}+ keyboardDismissMode="interactive"+ keyboardShouldPersistTaps="handled"+ refreshControl={+ onRefresh ? (+ <CapRefreshControl+ refreshing={refreshing}+ onRefresh={onRefresh}+ />+ ) : undefined+ }+ >+ {content}+ </ScrollView>+ {onRefresh ? <CapRefreshOverlay refreshing={refreshing} /> : null}+ </>+ ) : (+ <View+ style={[+ styles.content,+ contentInsetBottom != null+ ? { paddingBottom: contentInsetBottom }+ : null,+ ]}>{content}- </ScrollView>- ) : (- <View style={styles.content}>{content}</View>+ </View>)}</SafeAreaView>);@@ -106,6 +127,9 @@ const styles = StyleSheet.create({headerWithSubtitle: {paddingBottom: 32,},+ headerLeft: {+ marginBottom: 4,+ },title: {fontFamily: fonts.medium,fontSize: 24,