1import { Host, Picker, Text } from "@expo/ui/swift-ui";
2import { pickerStyle, tag } from "@expo/ui/swift-ui/modifiers";
3import { StackActions, useNavigation } from "@react-navigation/native";
4import { Keyboard, View } from "react-native";
5import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
6import { useWorkspaceTabs } from "./WorkspaceTabsContext";
7import type { WorkspaceTab } from "./workspace-tabs-state";
8
9/** Wide iPad navigation belongs to the sidebar, leaving the detail's header unobstructed. */
10export function WorkspaceSidebarTabs() {
11 const workspace = useWorkspaceTabs()!;
12 const navigation = useNavigation();
13 const { themeAppearance } = useAppearancePreferences();
14 return (
15 <View className="px-4 pb-3 pt-2">
16 <Host
17 matchContents={{ vertical: true }}
18 colorScheme={themeAppearance}
19 style={{ width: "100%" }}
20 >
21 <Picker
22 label="Workspace"
23 selection={workspace.state.selectedTab}
24 onSelectionChange={(tab: WorkspaceTab) => {
25 if (tab === workspace.state.selectedTab) return;
26 Keyboard.dismiss();
27 if (navigation.getState()?.index) navigation.dispatch(StackActions.popToTop());
28 workspace.dispatch({ type: "select", tab });
29 }}
30 modifiers={[pickerStyle("segmented")]}
31 >
32 <Text modifiers={[tag("threads")]}>Threads</Text>
33 <Text modifiers={[tag("pullRequests")]}>Pull requests</Text>
34 </Picker>
35 </Host>
36 </View>
37 );
38}