The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { useAndroidFloatingTabs } from "../../settings/appearance/AppearancePreferencesProvider"; |
| 2 | import { WorkspaceNoTabs } from "./WorkspaceNoTabs"; |
| 3 | import { useEnabledNavigationTabs } from "./navigation-tabs"; |
| 4 | import { NAVIGATION_TAB_ORDER } from "./navigation-tab-order"; |
| 5 | import { useNavigationState } from "@react-navigation/native"; |
| 6 | import { useSafeAreaInsets } from "react-native-safe-area-context"; |
| 7 | import { useAndroidControlSizing } from "../../../components/ui/useAndroidControlSizing"; |
| 8 | import { FLOATING_TABS } from "./floating-workspace-tabs"; |
| 9 | import { View } from "react-native"; |
| 10 | import { ScreenContent } from "../../../components/ui/ScreenContent"; |
| 11 | import { PullRequestsScreen } from "../../pull-requests/PullRequestsScreen"; |
| 12 | import { ListSearchToolbar } from "./ListSearchToolbar.android"; |
| 13 | import { IssuesScreen } from "../../issues/IssuesScreen"; |
| 14 | import { selectedIssueKey } from "../../issues/issueParams"; |
| 15 | import { selectedPullRequestKey } from "../../pull-requests/pullRequestSelection"; |
| 16 | import { AndroidHomeFabLayout } from "../../home/AndroidHomeFab"; |
| 17 | import { useAdaptiveWorkspaceLayout } from "../adaptive-workspace-context"; |
| 18 | import { useAndroidWorkspaceRoot } from "./AndroidWorkspaceTabsProvider"; |
| 19 | import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext"; |
| 20 | import { WorkspaceTabPanes } from "./WorkspaceTabPanes"; |
| 21 | import { WorkspaceThreadSidebar } from "./WorkspaceThreadSidebar"; |
| 22 | import { WorkspaceAppBarScope } from "../../../components/ui/WorkspaceAppBar.android"; |
| 23 | |
| 24 | /** The Home route in the sidebar column: the selected tab's list. */ |
| 25 | export function AndroidWorkspaceSidebar() { |
| 26 | const floatingTabsEnabled = useAndroidFloatingTabs(); |
| 27 | const workspace = useWorkspaceTabs()!; |
| 28 | const enabled = useEnabledNavigationTabs(); |
| 29 | const insets = useSafeAreaInsets(); |
| 30 | const { fabSize } = useAndroidControlSizing(); |
| 31 | const { revealPrimarySidebar, startNewTask } = useAdaptiveWorkspaceLayout(); |
| 32 | const selectedPullRequest = useNavigationState(selectedPullRequestKey); |
| 33 | const selectedIssue = useNavigationState(selectedIssueKey); |
| 34 | // Settings and Usage cover the sidebar. |
| 35 | const coveredByPage = |
| 36 | (useAndroidWorkspaceRoot()?.settingsOpen ?? false) || workspace.state.selectedTab === "usage"; |
| 37 | const bottomClearance = floatingTabsEnabled |
| 38 | ? insets.bottom + FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize |
| 39 | : 16; |
| 40 | const context = { ...workspace, bottomClearance }; |
| 41 | if (enabled.length === 0) return <WorkspaceNoTabs />; |
| 42 | return ( |
| 43 | <WorkspaceAppBarScope> |
| 44 | <WorkspaceTabPanes |
| 45 | tabs={NAVIGATION_TAB_ORDER} |
| 46 | selected={workspace.state.selectedTab} |
| 47 | renderTab={(tab) => |
| 48 | tab === "threads" ? ( |
| 49 | <AndroidHomeFabLayout sidebar disabled={coveredByPage} onStartNewTask={startNewTask}> |
| 50 | <WorkspaceThreadSidebar /> |
| 51 | </AndroidHomeFabLayout> |
| 52 | ) : tab === "usage" ? ( |
| 53 | <View className="flex-1 bg-screen" /> |
| 54 | ) : tab === "issues" ? ( |
| 55 | <WorkspaceTabsContext value={context}> |
| 56 | <IssuesScreen |
| 57 | sidebar |
| 58 | selectedIssueKey={selectedIssue} |
| 59 | renderFrame={(filters, list) => ( |
| 60 | <View className="flex-1 bg-header"> |
| 61 | <ListSearchToolbar |
| 62 | tab="issues" |
| 63 | filters={filters} |
| 64 | onRequestVisibility={revealPrimarySidebar} |
| 65 | /> |
| 66 | <ScreenContent insetHorizontal>{list}</ScreenContent> |
| 67 | </View> |
| 68 | )} |
| 69 | /> |
| 70 | </WorkspaceTabsContext> |
| 71 | ) : ( |
| 72 | <WorkspaceTabsContext value={context}> |
| 73 | <PullRequestsScreen |
| 74 | sidebar |
| 75 | selectedPullRequestKey={selectedPullRequest} |
| 76 | renderFrame={(filters, list) => ( |
| 77 | <View className="flex-1 bg-header"> |
| 78 | <ListSearchToolbar |
| 79 | tab="pullRequests" |
| 80 | filters={filters} |
| 81 | onRequestVisibility={revealPrimarySidebar} |
| 82 | /> |
| 83 | <ScreenContent insetHorizontal>{list}</ScreenContent> |
| 84 | </View> |
| 85 | )} |
| 86 | /> |
| 87 | </WorkspaceTabsContext> |
| 88 | ) |
| 89 | } |
| 90 | /> |
| 91 | </WorkspaceAppBarScope> |
| 92 | ); |
| 93 | } |