Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(mobile): add root layout and tab navigation

Richie McIlroyc586c5834d52
diff --git a/apps/mobile/app/(tabs)/_layout.tsx b/apps/mobile/app/(tabs)/_layout.tsx
new file mode 100644
index 000000000..3985c71fe
--- /dev/null
+++ b/apps/mobile/app/(tabs)/_layout.tsx
@@ -0,0 +1,53 @@
+import { NativeTabs } from "expo-router/unstable-native-tabs";
+import { colors, fonts } from "@/theme";
+
+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",
+ }}
+ />
+ </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>
+ );
+}
diff --git a/apps/mobile/app/_layout.tsx b/apps/mobile/app/_layout.tsx
new file mode 100644
index 000000000..b5794d72f
--- /dev/null
+++ b/apps/mobile/app/_layout.tsx
@@ -0,0 +1,110 @@
+import "react-native-gesture-handler";
+import "react-native-reanimated";
+
+import { useFonts } from "expo-font";
+import { Stack, useSegments } from "expo-router";
+import {
+ ActivityIndicator,
+ KeyboardAvoidingView,
+ Platform,
+ ScrollView,
+ StatusBar,
+ StyleSheet,
+ View,
+} from "react-native";
+import { GestureHandlerRootView } from "react-native-gesture-handler";
+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 { colors } from "@/theme";
+
+function AppShell() {
+ const auth = useAuth();
+ const segments = useSegments();
+
+ if (auth.status === "loading") {
+ return (
+ <View style={styles.loadingScreen}>
+ <ActivityIndicator color={colors.blue11} />
+ </View>
+ );
+ }
+
+ if (auth.status === "signedOut") {
+ return (
+ <SafeAreaView style={styles.authScreen}>
+ <KeyboardAvoidingView
+ behavior={Platform.OS === "ios" ? "padding" : undefined}
+ style={styles.authKeyboard}
+ >
+ <ScrollView
+ keyboardShouldPersistTaps="handled"
+ contentContainerStyle={styles.authContent}
+ style={styles.authScroll}
+ >
+ <SignInPanel title={signInTitleForSegments(segments)} />
+ </ScrollView>
+ </KeyboardAvoidingView>
+ </SafeAreaView>
+ );
+ }
+
+ return (
+ <Stack screenOptions={{ headerShown: false }}>
+ <Stack.Screen name="(tabs)" />
+ <Stack.Screen name="caps/[id]" />
+ </Stack>
+ );
+}
+
+export default function RootLayout() {
+ const [fontsLoaded] = useFonts({
+ "NeueMontreal-Regular": require("../../web/public/fonts/NeueMontreal-Regular.otf"),
+ "NeueMontreal-Medium": require("../../web/public/fonts/NeueMontreal-Medium.otf"),
+ "NeueMontreal-Bold": require("../../web/public/fonts/NeueMontreal-Bold.otf"),
+ });
+
+ if (!fontsLoaded) return null;
+
+ return (
+ <GestureHandlerRootView
+ style={{ flex: 1, backgroundColor: colors.appBackground }}
+ >
+ <SafeAreaProvider>
+ <AuthProvider>
+ <StatusBar
+ backgroundColor={colors.appBackground}
+ barStyle="dark-content"
+ />
+ <AppShell />
+ </AuthProvider>
+ </SafeAreaProvider>
+ </GestureHandlerRootView>
+ );
+}
+
+const styles = StyleSheet.create({
+ loadingScreen: {
+ flex: 1,
+ alignItems: "center",
+ justifyContent: "center",
+ backgroundColor: colors.appBackground,
+ },
+ authScreen: {
+ flex: 1,
+ backgroundColor: colors.appBackground,
+ },
+ authKeyboard: {
+ flex: 1,
+ },
+ authScroll: {
+ flex: 1,
+ },
+ authContent: {
+ flexGrow: 1,
+ justifyContent: "center",
+ paddingHorizontal: 20,
+ paddingVertical: 28,
+ },
+});