From 97a784bb5cb992b922356e98cab9252482e1faf7 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 6 Feb 2026 21:40:13 -0800 Subject: [PATCH 1/9] WIP --- .../app/(authenticated)/(drawer)/_layout.tsx | 15 + .../(authenticated)/(drawer)/tasks/index.tsx | 3 + .../(drawer)/workspaces/index.tsx | 3 + apps/mobile/app/(authenticated)/_layout.tsx | 13 +- apps/mobile/app/(authenticated)/demo.tsx | 3 - apps/mobile/app/(authenticated)/index.tsx | 6 +- apps/mobile/app/(authenticated)/settings.tsx | 3 + .../mobile/app/(authenticated)/tasks/[id].tsx | 3 + .../app/(authenticated)/workspaces/[id].tsx | 3 + apps/mobile/assets/social/github.svg | 1 + apps/mobile/assets/social/google.svg | 1 + .../OrganizationSwitcher.tsx | 90 -- .../components/OrganizationSwitcher/index.ts | 1 - apps/mobile/global.d.ts | 5 + apps/mobile/hooks/useSignOut/index.ts | 1 + apps/mobile/hooks/useSignOut/useSignOut.ts | 25 + apps/mobile/package.json | 4 + .../screens/(auth)/sign-in/SignInScreen.tsx | 124 +-- .../components/SocialButton/SocialButton.tsx | 78 ++ .../sign-in/components/SocialButton/index.ts | 1 + .../(drawer)/tasks/TasksScreen.tsx | 30 + .../(authenticated)/(drawer)/tasks/index.ts | 1 + .../(drawer)/workspaces/WorkspacesScreen.tsx | 30 + .../(drawer)/workspaces/index.ts | 1 + .../DrawerContent/DrawerContent.tsx | 65 ++ .../components/OrgDropdown/OrgDropdown.tsx | 107 ++ .../components/OrgDropdown/index.ts | 1 + .../components/DrawerContent/index.ts | 1 + .../DrawerToggleButton/DrawerToggleButton.tsx | 19 + .../components/DrawerToggleButton/index.ts | 1 + .../(authenticated)/demo/DemoScreen.tsx | 924 ------------------ .../screens/(authenticated)/demo/index.ts | 1 - .../(authenticated)/index/HomeScreen.tsx | 248 ----- .../screens/(authenticated)/index/index.ts | 1 - .../CollectionsProvider.tsx | 0 .../providers/CollectionsProvider/index.ts | 0 .../settings/SettingsScreen.tsx | 61 ++ .../screens/(authenticated)/settings/index.ts | 1 + .../tasks/[id]/TaskDetailScreen.tsx | 36 + .../(authenticated)/tasks/[id]/index.ts | 1 + .../workspaces/[id]/WorkspaceDetailScreen.tsx | 64 ++ .../(authenticated)/workspaces/[id]/index.ts | 1 + apps/mobile/screens/RootLayout/RootLayout.tsx | 10 +- bun.lock | 22 +- 44 files changed, 669 insertions(+), 1340 deletions(-) create mode 100644 apps/mobile/app/(authenticated)/(drawer)/_layout.tsx create mode 100644 apps/mobile/app/(authenticated)/(drawer)/tasks/index.tsx create mode 100644 apps/mobile/app/(authenticated)/(drawer)/workspaces/index.tsx delete mode 100644 apps/mobile/app/(authenticated)/demo.tsx create mode 100644 apps/mobile/app/(authenticated)/settings.tsx create mode 100644 apps/mobile/app/(authenticated)/tasks/[id].tsx create mode 100644 apps/mobile/app/(authenticated)/workspaces/[id].tsx create mode 100644 apps/mobile/assets/social/github.svg create mode 100644 apps/mobile/assets/social/google.svg delete mode 100644 apps/mobile/components/OrganizationSwitcher/OrganizationSwitcher.tsx delete mode 100644 apps/mobile/components/OrganizationSwitcher/index.ts create mode 100644 apps/mobile/global.d.ts create mode 100644 apps/mobile/hooks/useSignOut/index.ts create mode 100644 apps/mobile/hooks/useSignOut/useSignOut.ts create mode 100644 apps/mobile/screens/(auth)/sign-in/components/SocialButton/SocialButton.tsx create mode 100644 apps/mobile/screens/(auth)/sign-in/components/SocialButton/index.ts create mode 100644 apps/mobile/screens/(authenticated)/(drawer)/tasks/TasksScreen.tsx create mode 100644 apps/mobile/screens/(authenticated)/(drawer)/tasks/index.ts create mode 100644 apps/mobile/screens/(authenticated)/(drawer)/workspaces/WorkspacesScreen.tsx create mode 100644 apps/mobile/screens/(authenticated)/(drawer)/workspaces/index.ts create mode 100644 apps/mobile/screens/(authenticated)/components/DrawerContent/DrawerContent.tsx create mode 100644 apps/mobile/screens/(authenticated)/components/DrawerContent/components/OrgDropdown/OrgDropdown.tsx create mode 100644 apps/mobile/screens/(authenticated)/components/DrawerContent/components/OrgDropdown/index.ts create mode 100644 apps/mobile/screens/(authenticated)/components/DrawerContent/index.ts create mode 100644 apps/mobile/screens/(authenticated)/components/DrawerToggleButton/DrawerToggleButton.tsx create mode 100644 apps/mobile/screens/(authenticated)/components/DrawerToggleButton/index.ts delete mode 100644 apps/mobile/screens/(authenticated)/demo/DemoScreen.tsx delete mode 100644 apps/mobile/screens/(authenticated)/demo/index.ts delete mode 100644 apps/mobile/screens/(authenticated)/index/HomeScreen.tsx delete mode 100644 apps/mobile/screens/(authenticated)/index/index.ts rename apps/mobile/{ => screens/(authenticated)}/providers/CollectionsProvider/CollectionsProvider.tsx (100%) rename apps/mobile/{ => screens/(authenticated)}/providers/CollectionsProvider/index.ts (100%) create mode 100644 apps/mobile/screens/(authenticated)/settings/SettingsScreen.tsx create mode 100644 apps/mobile/screens/(authenticated)/settings/index.ts create mode 100644 apps/mobile/screens/(authenticated)/tasks/[id]/TaskDetailScreen.tsx create mode 100644 apps/mobile/screens/(authenticated)/tasks/[id]/index.ts create mode 100644 apps/mobile/screens/(authenticated)/workspaces/[id]/WorkspaceDetailScreen.tsx create mode 100644 apps/mobile/screens/(authenticated)/workspaces/[id]/index.ts diff --git a/apps/mobile/app/(authenticated)/(drawer)/_layout.tsx b/apps/mobile/app/(authenticated)/(drawer)/_layout.tsx new file mode 100644 index 00000000000..9cd495b952f --- /dev/null +++ b/apps/mobile/app/(authenticated)/(drawer)/_layout.tsx @@ -0,0 +1,15 @@ +import { Stack } from "expo-router"; +import { DrawerToggleButton } from "@/screens/(authenticated)/components/DrawerToggleButton"; + +export default function DrawerGroupLayout() { + return ( + , + }} + > + + + + ); +} diff --git a/apps/mobile/app/(authenticated)/(drawer)/tasks/index.tsx b/apps/mobile/app/(authenticated)/(drawer)/tasks/index.tsx new file mode 100644 index 00000000000..e5d769f3d72 --- /dev/null +++ b/apps/mobile/app/(authenticated)/(drawer)/tasks/index.tsx @@ -0,0 +1,3 @@ +import { TasksScreen } from "@/screens/(authenticated)/(drawer)/tasks"; + +export default TasksScreen; diff --git a/apps/mobile/app/(authenticated)/(drawer)/workspaces/index.tsx b/apps/mobile/app/(authenticated)/(drawer)/workspaces/index.tsx new file mode 100644 index 00000000000..36848f3dd5f --- /dev/null +++ b/apps/mobile/app/(authenticated)/(drawer)/workspaces/index.tsx @@ -0,0 +1,3 @@ +import { WorkspacesScreen } from "@/screens/(authenticated)/(drawer)/workspaces"; + +export default WorkspacesScreen; diff --git a/apps/mobile/app/(authenticated)/_layout.tsx b/apps/mobile/app/(authenticated)/_layout.tsx index 30806acfeb3..eb80b38d345 100644 --- a/apps/mobile/app/(authenticated)/_layout.tsx +++ b/apps/mobile/app/(authenticated)/_layout.tsx @@ -1,13 +1,20 @@ -import { Stack } from "expo-router"; +import type { DrawerContentComponentProps } from "@react-navigation/drawer"; +import { Drawer } from "expo-router/drawer"; import { useDevicePresence } from "@/hooks/useDevicePresence"; -import { CollectionsProvider } from "@/providers/CollectionsProvider"; +import { DrawerContent } from "@/screens/(authenticated)/components/DrawerContent"; +import { CollectionsProvider } from "@/screens/(authenticated)/providers/CollectionsProvider"; export default function AuthenticatedLayout() { useDevicePresence(); return ( - + ( + + )} + screenOptions={{ headerShown: false }} + /> ); } diff --git a/apps/mobile/app/(authenticated)/demo.tsx b/apps/mobile/app/(authenticated)/demo.tsx deleted file mode 100644 index dfb88551d19..00000000000 --- a/apps/mobile/app/(authenticated)/demo.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import { DemoScreen } from "@/screens/(authenticated)/demo"; - -export default DemoScreen; diff --git a/apps/mobile/app/(authenticated)/index.tsx b/apps/mobile/app/(authenticated)/index.tsx index b75369e1edc..dabd20bad43 100644 --- a/apps/mobile/app/(authenticated)/index.tsx +++ b/apps/mobile/app/(authenticated)/index.tsx @@ -1,3 +1,5 @@ -import { HomeScreen } from "@/screens/(authenticated)/index"; +import { Redirect } from "expo-router"; -export default HomeScreen; +export default function AuthenticatedIndex() { + return ; +} diff --git a/apps/mobile/app/(authenticated)/settings.tsx b/apps/mobile/app/(authenticated)/settings.tsx new file mode 100644 index 00000000000..af1c7925892 --- /dev/null +++ b/apps/mobile/app/(authenticated)/settings.tsx @@ -0,0 +1,3 @@ +import { SettingsScreen } from "@/screens/(authenticated)/settings"; + +export default SettingsScreen; diff --git a/apps/mobile/app/(authenticated)/tasks/[id].tsx b/apps/mobile/app/(authenticated)/tasks/[id].tsx new file mode 100644 index 00000000000..8a395863763 --- /dev/null +++ b/apps/mobile/app/(authenticated)/tasks/[id].tsx @@ -0,0 +1,3 @@ +import { TaskDetailScreen } from "@/screens/(authenticated)/tasks/[id]"; + +export default TaskDetailScreen; diff --git a/apps/mobile/app/(authenticated)/workspaces/[id].tsx b/apps/mobile/app/(authenticated)/workspaces/[id].tsx new file mode 100644 index 00000000000..f6fcec899b6 --- /dev/null +++ b/apps/mobile/app/(authenticated)/workspaces/[id].tsx @@ -0,0 +1,3 @@ +import { WorkspaceDetailScreen } from "@/screens/(authenticated)/workspaces/[id]"; + +export default WorkspaceDetailScreen; diff --git a/apps/mobile/assets/social/github.svg b/apps/mobile/assets/social/github.svg new file mode 100644 index 00000000000..c1ef8e53e03 --- /dev/null +++ b/apps/mobile/assets/social/github.svg @@ -0,0 +1 @@ + diff --git a/apps/mobile/assets/social/google.svg b/apps/mobile/assets/social/google.svg new file mode 100644 index 00000000000..b372f3248e8 --- /dev/null +++ b/apps/mobile/assets/social/google.svg @@ -0,0 +1 @@ + diff --git a/apps/mobile/components/OrganizationSwitcher/OrganizationSwitcher.tsx b/apps/mobile/components/OrganizationSwitcher/OrganizationSwitcher.tsx deleted file mode 100644 index 63c15653f82..00000000000 --- a/apps/mobile/components/OrganizationSwitcher/OrganizationSwitcher.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import { useLiveQuery } from "@tanstack/react-db"; -import { useState } from "react"; -import { View } from "react-native"; -import { authClient } from "@/lib/auth/client"; -import { useCollections } from "@/providers/CollectionsProvider"; -import { Button } from "../ui/button"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "../ui/card"; -import { Text } from "../ui/text"; - -export function OrganizationSwitcher() { - const collections = useCollections(); - const [switching, setSwitching] = useState(false); - - // Get all organizations - const { data: orgs } = useLiveQuery( - (q) => q.from({ organizations: collections.organizations }), - [collections], - ); - - // Get current session to know active org - const session = authClient.useSession(); - const activeOrgId = session.data?.session?.activeOrganizationId; - - const handleSwitchOrg = async (orgId: string) => { - if (orgId === activeOrgId) return; - - setSwitching(true); - try { - await authClient.organization.setActive({ - organizationId: orgId, - }); - // Refresh the page to reload collections - // Note: In React Native, we might need to handle this differently - } catch (error) { - console.error("Failed to switch organization:", error); - } finally { - setSwitching(false); - } - }; - - return ( - - - Organizations - - {orgs?.length || 0} organization(s) available - - - - {orgs?.map((org) => { - const isActive = org.id === activeOrgId; - return ( - - - - {org.name} - {org.slug && ( - - @{org.slug} - - )} - - {isActive ? ( - - Active - - ) : ( - - )} - - - ); - })} - - - ); -} diff --git a/apps/mobile/components/OrganizationSwitcher/index.ts b/apps/mobile/components/OrganizationSwitcher/index.ts deleted file mode 100644 index 05deafcfd8b..00000000000 --- a/apps/mobile/components/OrganizationSwitcher/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { OrganizationSwitcher } from "./OrganizationSwitcher"; diff --git a/apps/mobile/global.d.ts b/apps/mobile/global.d.ts new file mode 100644 index 00000000000..99185e10286 --- /dev/null +++ b/apps/mobile/global.d.ts @@ -0,0 +1,5 @@ +declare module "*.svg" { + import type { ImageSourcePropType } from "react-native"; + const value: ImageSourcePropType; + export default value; +} diff --git a/apps/mobile/hooks/useSignOut/index.ts b/apps/mobile/hooks/useSignOut/index.ts new file mode 100644 index 00000000000..a1a52d54189 --- /dev/null +++ b/apps/mobile/hooks/useSignOut/index.ts @@ -0,0 +1 @@ +export { useSignOut } from "./useSignOut"; diff --git a/apps/mobile/hooks/useSignOut/useSignOut.ts b/apps/mobile/hooks/useSignOut/useSignOut.ts new file mode 100644 index 00000000000..199e3347bf8 --- /dev/null +++ b/apps/mobile/hooks/useSignOut/useSignOut.ts @@ -0,0 +1,25 @@ +import { useQueryClient } from "@tanstack/react-query"; +import { useRouter } from "expo-router"; +import { useCallback, useState } from "react"; +import { signOut } from "@/lib/auth/client"; + +export function useSignOut() { + const router = useRouter(); + const queryClient = useQueryClient(); + const [isSigningOut, setIsSigningOut] = useState(false); + + const handleSignOut = useCallback(async () => { + setIsSigningOut(true); + try { + await signOut(); + queryClient.clear(); + router.replace("/(auth)/sign-in"); + } catch (error) { + console.error("[auth/signOut] Failed to sign out:", error); + } finally { + setIsSigningOut(false); + } + }, [router, queryClient]); + + return { signOut: handleSignOut, isSigningOut }; +} diff --git a/apps/mobile/package.json b/apps/mobile/package.json index cc0d87a4e6b..81d268d2e61 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -14,7 +14,9 @@ "dependencies": { "@better-auth/expo": "1.4.18", "@electric-sql/client": "https://pkg.pr.new/@electric-sql/client@3724", + "@expo/vector-icons": "^15.0.3", "@react-native-async-storage/async-storage": "2.2.0", + "@react-navigation/drawer": "^7.3.14", "@react-navigation/native": "^7.1.28", "@rn-primitives/accordion": "^1.2.0", "@rn-primitives/alert-dialog": "^1.2.0", @@ -59,6 +61,7 @@ "expo-dev-client": "~6.0.20", "expo-device": "~8.0.10", "expo-file-system": "~19.0.21", + "expo-image": "~3.0.11", "expo-linking": "~8.0.11", "expo-localization": "~17.0.8", "expo-network": "~8.0.8", @@ -71,6 +74,7 @@ "posthog-react-native": "^4.23.0", "react": "19.1.0", "react-native": "0.81.5", + "react-native-gesture-handler": "~2.24.0", "react-native-get-random-values": "^1.11.0", "react-native-reanimated": "~4.1.1", "react-native-safe-area-context": "~5.6.0", diff --git a/apps/mobile/screens/(auth)/sign-in/SignInScreen.tsx b/apps/mobile/screens/(auth)/sign-in/SignInScreen.tsx index 6e0d18e005b..bdeb3528dc1 100644 --- a/apps/mobile/screens/(auth)/sign-in/SignInScreen.tsx +++ b/apps/mobile/screens/(auth)/sign-in/SignInScreen.tsx @@ -1,79 +1,81 @@ import { useState } from "react"; -import { ActivityIndicator, Alert, View } from "react-native"; -import { Button } from "@/components/ui/button"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; +import { Image, Linking, View } from "react-native"; import { Text } from "@/components/ui/text"; import { signIn } from "@/lib/auth/client"; +import type { SocialProvider } from "./components/SocialButton"; +import { SocialButton } from "./components/SocialButton"; + +const TERMS_URL = "https://superset.sh/terms"; +const PRIVACY_URL = "https://superset.sh/privacy"; + export function SignInScreen() { - const [loading, setLoading] = useState<"github" | "google" | null>(null); + const [error, setError] = useState(null); - const handleSignIn = async (provider: "github" | "google") => { - console.log("[sign-in] Button clicked:", provider); + const handleSignIn = async (provider: SocialProvider) => { + setError(null); try { - setLoading(provider); - console.log("[sign-in] Calling signIn.social..."); - const result = await signIn.social({ + await signIn.social({ provider, callbackURL: "/", }); - console.log("[sign-in] signIn.social result:", result); - } catch (error) { - console.error("[sign-in] Error caught:", error); - console.error("[sign-in] Error details:", JSON.stringify(error, null, 2)); - Alert.alert( - "Sign In Failed", - error instanceof Error ? error.message : JSON.stringify(error), - ); - } finally { - setLoading(null); + } catch (err) { + const message = + err instanceof Error ? err.message : "Something went wrong"; + console.error("[sign-in] Error:", err); + setError(message); } }; return ( - - - - Welcome to Superset - Sign in to continue - - - + + + + + + Welcome to Superset + + + Sign in to get started + + + + + handleSignIn("github")} + className="w-4/5" + /> + handleSignIn("google")} + className="w-4/5" + /> + + + {error && ( + {error} + )} - - - + + By signing in, you agree to our{"\n"} + Linking.openURL(TERMS_URL)} + > + Terms of Service + {" "} + and{" "} + Linking.openURL(PRIVACY_URL)} + > + Privacy Policy + + ); } diff --git a/apps/mobile/screens/(auth)/sign-in/components/SocialButton/SocialButton.tsx b/apps/mobile/screens/(auth)/sign-in/components/SocialButton/SocialButton.tsx new file mode 100644 index 00000000000..a6d559054e8 --- /dev/null +++ b/apps/mobile/screens/(auth)/sign-in/components/SocialButton/SocialButton.tsx @@ -0,0 +1,78 @@ +import { useColorScheme } from "react-native"; +import Svg, { Path } from "react-native-svg"; +import type { ButtonProps } from "@/components/ui/button"; +import { Button } from "@/components/ui/button"; +import { Text } from "@/components/ui/text"; +import { cn } from "@/lib/utils"; + +export type SocialProvider = "github" | "google"; + +export interface SocialButtonProps extends Omit { + provider: SocialProvider; +} + +function GithubIcon({ color }: { color: string }) { + return ( + + + + ); +} + +function GoogleIcon() { + return ( + + + + + + + ); +} + +const PROVIDER_NAME: Record = { + github: "GitHub", + google: "Google", +}; + +export function SocialButton({ + provider, + className, + ...props +}: SocialButtonProps) { + const colorScheme = useColorScheme(); + const iconColor = colorScheme === "dark" ? "white" : "black"; + + return ( + + ); +} diff --git a/apps/mobile/screens/(auth)/sign-in/components/SocialButton/index.ts b/apps/mobile/screens/(auth)/sign-in/components/SocialButton/index.ts new file mode 100644 index 00000000000..717835727eb --- /dev/null +++ b/apps/mobile/screens/(auth)/sign-in/components/SocialButton/index.ts @@ -0,0 +1 @@ +export { SocialButton, type SocialProvider } from "./SocialButton"; diff --git a/apps/mobile/screens/(authenticated)/(drawer)/tasks/TasksScreen.tsx b/apps/mobile/screens/(authenticated)/(drawer)/tasks/TasksScreen.tsx new file mode 100644 index 00000000000..27efda58021 --- /dev/null +++ b/apps/mobile/screens/(authenticated)/(drawer)/tasks/TasksScreen.tsx @@ -0,0 +1,30 @@ +import { useCallback, useState } from "react"; +import { RefreshControl, ScrollView, View } from "react-native"; +import { Text } from "@/components/ui/text"; + +export function TasksScreen() { + const [refreshing, setRefreshing] = useState(false); + + const onRefresh = useCallback(async () => { + setRefreshing(true); + // TODO: refresh task data + setRefreshing(false); + }, []); + + return ( + + } + > + + + + Tasks synced via Electric will appear here + + + + + ); +} diff --git a/apps/mobile/screens/(authenticated)/(drawer)/tasks/index.ts b/apps/mobile/screens/(authenticated)/(drawer)/tasks/index.ts new file mode 100644 index 00000000000..7c9a351cd92 --- /dev/null +++ b/apps/mobile/screens/(authenticated)/(drawer)/tasks/index.ts @@ -0,0 +1 @@ +export { TasksScreen } from "./TasksScreen"; diff --git a/apps/mobile/screens/(authenticated)/(drawer)/workspaces/WorkspacesScreen.tsx b/apps/mobile/screens/(authenticated)/(drawer)/workspaces/WorkspacesScreen.tsx new file mode 100644 index 00000000000..c6785f001ce --- /dev/null +++ b/apps/mobile/screens/(authenticated)/(drawer)/workspaces/WorkspacesScreen.tsx @@ -0,0 +1,30 @@ +import { useCallback, useState } from "react"; +import { RefreshControl, ScrollView, View } from "react-native"; +import { Text } from "@/components/ui/text"; + +export function WorkspacesScreen() { + const [refreshing, setRefreshing] = useState(false); + + const onRefresh = useCallback(async () => { + setRefreshing(true); + // TODO: refresh workspace data + setRefreshing(false); + }, []); + + return ( + + } + > + + + + Workspaces grouped by project will appear here + + + + + ); +} diff --git a/apps/mobile/screens/(authenticated)/(drawer)/workspaces/index.ts b/apps/mobile/screens/(authenticated)/(drawer)/workspaces/index.ts new file mode 100644 index 00000000000..bf11998e5e7 --- /dev/null +++ b/apps/mobile/screens/(authenticated)/(drawer)/workspaces/index.ts @@ -0,0 +1 @@ +export { WorkspacesScreen } from "./WorkspacesScreen"; diff --git a/apps/mobile/screens/(authenticated)/components/DrawerContent/DrawerContent.tsx b/apps/mobile/screens/(authenticated)/components/DrawerContent/DrawerContent.tsx new file mode 100644 index 00000000000..38614f1d1b5 --- /dev/null +++ b/apps/mobile/screens/(authenticated)/components/DrawerContent/DrawerContent.tsx @@ -0,0 +1,65 @@ +import type { DrawerContentComponentProps } from "@react-navigation/drawer"; +import { usePathname, useRouter } from "expo-router"; +import { CheckSquare, LayoutGrid } from "lucide-react-native"; +import { Pressable, View } from "react-native"; +import { useSafeAreaInsets } from "react-native-safe-area-context"; +import { Icon } from "@/components/ui/icon"; +import { Separator } from "@/components/ui/separator"; +import { Text } from "@/components/ui/text"; +import { OrgDropdown } from "./components/OrgDropdown"; + +const NAV_ITEMS = [ + { + label: "Workspaces", + icon: LayoutGrid, + href: "/(authenticated)/(drawer)/workspaces" as const, + matchPath: "/workspaces", + }, + { + label: "Tasks", + icon: CheckSquare, + href: "/(authenticated)/(drawer)/tasks" as const, + matchPath: "/tasks", + }, +]; + +export function DrawerContent(_props: DrawerContentComponentProps) { + const router = useRouter(); + const pathname = usePathname(); + const insets = useSafeAreaInsets(); + + return ( + + + + + {NAV_ITEMS.map((item) => { + const isActive = pathname.includes(item.matchPath); + return ( + router.replace(item.href)} + className={`flex-row items-center gap-3 rounded-lg px-3 py-2.5 ${ + isActive ? "bg-accent" : "" + }`} + > + + + {item.label} + + + ); + })} + + + ); +} diff --git a/apps/mobile/screens/(authenticated)/components/DrawerContent/components/OrgDropdown/OrgDropdown.tsx b/apps/mobile/screens/(authenticated)/components/DrawerContent/components/OrgDropdown/OrgDropdown.tsx new file mode 100644 index 00000000000..b81659dce3f --- /dev/null +++ b/apps/mobile/screens/(authenticated)/components/DrawerContent/components/OrgDropdown/OrgDropdown.tsx @@ -0,0 +1,107 @@ +import { useLiveQuery } from "@tanstack/react-db"; +import { useRouter } from "expo-router"; +import { + ArrowLeftRight, + ChevronDown, + LogOut, + Settings, + UserPlus, +} from "lucide-react-native"; +import { useState } from "react"; +import { View } from "react-native"; +import { Avatar, AvatarFallback } from "@/components/ui/avatar"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { Icon } from "@/components/ui/icon"; +import { Text } from "@/components/ui/text"; +import { useSignOut } from "@/hooks/useSignOut"; +import { authClient } from "@/lib/auth/client"; +import { useCollections } from "@/screens/(authenticated)/providers/CollectionsProvider"; + +export function OrgDropdown() { + const router = useRouter(); + const { signOut } = useSignOut(); + const collections = useCollections(); + const [switching, setSwitching] = useState(false); + + const session = authClient.useSession(); + const activeOrgId = session.data?.session?.activeOrganizationId; + + const { data: orgs } = useLiveQuery( + (q) => q.from({ organizations: collections.organizations }), + [collections], + ); + + const activeOrg = orgs?.find((org) => org.id === activeOrgId); + const orgInitial = activeOrg?.name?.charAt(0).toUpperCase() ?? "?"; + + const handleSwitchOrg = async (orgId: string) => { + if (orgId === activeOrgId) return; + setSwitching(true); + try { + await authClient.organization.setActive({ organizationId: orgId }); + router.replace("/(authenticated)/(drawer)/workspaces"); + } catch (error) { + console.error("[org/switch] Failed to switch organization:", error); + } finally { + setSwitching(false); + } + }; + + return ( + + + + + + {orgInitial} + + + + + {activeOrg?.name ?? "Select Organization"} + + + + + + + router.push("/(authenticated)/settings")} + > + + Settings + + + + Invite members + + + {orgs + ?.filter((org) => org.id !== activeOrgId) + .map((org) => ( + handleSwitchOrg(org.id)} + disabled={switching} + > + + Switch to {org.name} + + ))} + {orgs && orgs.filter((org) => org.id !== activeOrgId).length > 0 && ( + + )} + + + Log out + + + + ); +} diff --git a/apps/mobile/screens/(authenticated)/components/DrawerContent/components/OrgDropdown/index.ts b/apps/mobile/screens/(authenticated)/components/DrawerContent/components/OrgDropdown/index.ts new file mode 100644 index 00000000000..19c7757cef8 --- /dev/null +++ b/apps/mobile/screens/(authenticated)/components/DrawerContent/components/OrgDropdown/index.ts @@ -0,0 +1 @@ +export { OrgDropdown } from "./OrgDropdown"; diff --git a/apps/mobile/screens/(authenticated)/components/DrawerContent/index.ts b/apps/mobile/screens/(authenticated)/components/DrawerContent/index.ts new file mode 100644 index 00000000000..36d06f1ed69 --- /dev/null +++ b/apps/mobile/screens/(authenticated)/components/DrawerContent/index.ts @@ -0,0 +1 @@ +export { DrawerContent } from "./DrawerContent"; diff --git a/apps/mobile/screens/(authenticated)/components/DrawerToggleButton/DrawerToggleButton.tsx b/apps/mobile/screens/(authenticated)/components/DrawerToggleButton/DrawerToggleButton.tsx new file mode 100644 index 00000000000..e99d0294e48 --- /dev/null +++ b/apps/mobile/screens/(authenticated)/components/DrawerToggleButton/DrawerToggleButton.tsx @@ -0,0 +1,19 @@ +import { DrawerActions, useTheme } from "@react-navigation/native"; +import { useNavigation } from "expo-router"; +import { Menu } from "lucide-react-native"; +import { Pressable } from "react-native"; + +export function DrawerToggleButton() { + const navigation = useNavigation(); + const { colors } = useTheme(); + + return ( + navigation.dispatch(DrawerActions.openDrawer())} + hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }} + style={{ paddingLeft: 16 }} + > + + + ); +} diff --git a/apps/mobile/screens/(authenticated)/components/DrawerToggleButton/index.ts b/apps/mobile/screens/(authenticated)/components/DrawerToggleButton/index.ts new file mode 100644 index 00000000000..f9f9c66f92a --- /dev/null +++ b/apps/mobile/screens/(authenticated)/components/DrawerToggleButton/index.ts @@ -0,0 +1 @@ +export { DrawerToggleButton } from "./DrawerToggleButton"; diff --git a/apps/mobile/screens/(authenticated)/demo/DemoScreen.tsx b/apps/mobile/screens/(authenticated)/demo/DemoScreen.tsx deleted file mode 100644 index 635d655031e..00000000000 --- a/apps/mobile/screens/(authenticated)/demo/DemoScreen.tsx +++ /dev/null @@ -1,924 +0,0 @@ -import { eq, isNull } from "@tanstack/db"; -import { useLiveQuery } from "@tanstack/react-db"; -import { - AlertCircle, - Bold, - ChevronRight, - Info, - Italic, - Mail, - Star, - Underline, - User, -} from "lucide-react-native"; -import * as React from "react"; -import { Pressable, ScrollView, View } from "react-native"; -import { OrganizationSwitcher } from "@/components/OrganizationSwitcher"; -import { - Accordion, - AccordionContent, - AccordionItem, - AccordionTrigger, -} from "@/components/ui/accordion"; -import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, -} from "@/components/ui/alert-dialog"; -import { AspectRatio } from "@/components/ui/aspect-ratio"; -import { Avatar, AvatarFallback } from "@/components/ui/avatar"; -import { Badge } from "@/components/ui/badge"; -import { Button } from "@/components/ui/button"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { Checkbox } from "@/components/ui/checkbox"; -import { - Collapsible, - CollapsibleContent, - CollapsibleTrigger, -} from "@/components/ui/collapsible"; -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog"; -import { Icon } from "@/components/ui/icon"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "@/components/ui/popover"; -import { Progress } from "@/components/ui/progress"; -import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; -import { Separator } from "@/components/ui/separator"; -import { Skeleton } from "@/components/ui/skeleton"; -import { Switch } from "@/components/ui/switch"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; -import { Text } from "@/components/ui/text"; -import { Textarea } from "@/components/ui/textarea"; -import { Toggle, ToggleIcon } from "@/components/ui/toggle"; -import { - ToggleGroup, - ToggleGroupIcon, - ToggleGroupItem, -} from "@/components/ui/toggle-group"; -import { - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@/components/ui/tooltip"; -import { useCollections } from "@/providers/CollectionsProvider"; - -export function DemoScreen() { - const collections = useCollections(); - - // Live queries - const { data: organizations } = useLiveQuery( - (q) => q.from({ organizations: collections.organizations }), - [collections], - ); - - const { data: allTasks } = useLiveQuery( - (q) => q.from({ tasks: collections.tasks }), - [collections], - ); - - const { data: activeTasks } = useLiveQuery( - (q) => - q - .from({ tasks: collections.tasks }) - .where(({ tasks }) => isNull(tasks.deletedAt)), - [collections], - ); - - const { data: taskStatuses } = useLiveQuery( - (q) => q.from({ taskStatuses: collections.taskStatuses }), - [collections], - ); - - const { data: repositories } = useLiveQuery( - (q) => q.from({ repositories: collections.repositories }), - [collections], - ); - - const { data: members } = useLiveQuery( - (q) => q.from({ members: collections.members }), - [collections], - ); - - const { data: users } = useLiveQuery( - (q) => q.from({ users: collections.users }), - [collections], - ); - - const { data: invitations } = useLiveQuery( - (q) => q.from({ invitations: collections.invitations }), - [collections], - ); - - const { data: tasksWithStatus } = useLiveQuery( - (q) => - q - .from({ tasks: collections.tasks }) - .innerJoin({ status: collections.taskStatuses }, ({ tasks, status }) => - eq(tasks.statusId, status.id), - ) - .select(({ tasks, status }) => ({ - id: tasks.id, - title: tasks.title, - statusName: status.name, - statusColor: status.color, - })), - [collections], - ); - - // Component state - const [checkboxChecked, setCheckboxChecked] = React.useState(false); - const [switchChecked, setSwitchChecked] = React.useState(false); - const [radioValue, setRadioValue] = React.useState("option-1"); - const [selectValue, setSelectValue] = React.useState< - { value: string; label: string } | undefined - >(undefined); - const [progressValue, setProgressValue] = React.useState(33); - const [togglePressed, setTogglePressed] = React.useState(false); - const [toggleGroupValue, setToggleGroupValue] = React.useState([]); - const [collapsibleOpen, setCollapsibleOpen] = React.useState(false); - const [tabValue, setTabValue] = React.useState("tab1"); - const [inputValue, setInputValue] = React.useState(""); - const [textareaValue, setTextareaValue] = React.useState(""); - - return ( - - - {/* Header */} - - Component Demo - - All UI components + real-time synced data - - - - - - - - {/* ── Buttons ── */} - - - Button - All button variants and sizes - - - - - - - - - - - - - - - - - - - - {/* ── Badge ── */} - - - Badge - Status indicators - - - - - Default - - - Secondary - - - Destructive - - - Outline - - - - - - {/* ── Alert ── */} - - - Alert - Informational messages - - - - Heads up! - - This is a default alert component. - - - - Error - - Something went wrong. Please try again. - - - - - - {/* ── Avatar ── */} - - - Avatar - User profile images with fallback - - - - - - SP - - - - - KH - - - - - - - - - - - - {/* ── Input & Textarea ── */} - - - Input & Textarea - Text input fields - - - - - - - - -