Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

useSystemWorkspaceTabBar.ts

20 lines989 Bytes

1import { Platform } from "react-native";
2import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
3import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
4​
5/** Where an iOS split window shows the workspace tabs instead of UIKit's tab bar. */
6export function useSidebarWorkspaceTabs(): "picker" | "toolbar" | null {
7 const { layout } = useAdaptiveWorkspaceLayout();
8 const deviceType = useDeviceType();
9 const metrics = useNativeLayoutMetrics();
10 if (Platform.OS !== "ios" || !layout.usesSplitView) return null;
11 if (deviceType === "pad") return "picker";
12 // The Duo's side rail carries UIKit's tabs. Unfolded in portrait it has no
13 // rail, so the tabs sit in the thread list's own toolbar.
14 return (metrics?.verticalBarEdge ?? "none") === "none" ? "toolbar" : null;
16​
17export function useSystemWorkspaceTabBar() {
18 const sidebarTabs = useSidebarWorkspaceTabs();
19 return Platform.OS === "ios" && sidebarTabs === null;