Skip to content

Commit 4ec00f2

Browse files
t3dotggclaude
andcommitted
fix(mobile): Android split view drops the nav rail and aligns read-only rows
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 16918b5 commit 4ec00f2

12 files changed

Lines changed: 96 additions & 196 deletions

‎apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3WorkspaceNavigationModule.kt‎

Lines changed: 24 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@ package expo.modules.t3nativecontrols
33
import android.content.Context
44
import android.view.ViewGroup
55
import androidx.compose.foundation.layout.WindowInsets
6-
import androidx.compose.foundation.layout.Spacer
76
import androidx.compose.foundation.layout.fillMaxSize
87
import androidx.compose.material3.Icon
98
import androidx.compose.material3.MaterialTheme
109
import androidx.compose.material3.NavigationBar
1110
import androidx.compose.material3.NavigationBarItem
1211
import androidx.compose.material3.NavigationBarItemDefaults
13-
import androidx.compose.material3.NavigationRail
14-
import androidx.compose.material3.NavigationRailItem
15-
import androidx.compose.material3.NavigationRailItemDefaults
1612
import androidx.compose.material3.Text
1713
import androidx.compose.material3.darkColorScheme
1814
import androidx.compose.material3.lightColorScheme
@@ -39,7 +35,6 @@ class T3WorkspaceNavigationModule : Module() {
3935
Prop("selectedTab") { view: T3WorkspaceNavigationView, value: String ->
4036
view.selectedTab = value
4137
}
42-
Prop("rail") { view: T3WorkspaceNavigationView, value: Boolean -> view.rail = value }
4338
Prop("dark") { view: T3WorkspaceNavigationView, value: Boolean -> view.dark = value }
4439
Prop("textScale") { view: T3WorkspaceNavigationView, value: Float -> view.textScale = value }
4540
Prop("containerColor") { view: T3WorkspaceNavigationView, value: Int ->
@@ -59,7 +54,7 @@ class T3WorkspaceNavigationModule : Module() {
5954
}
6055
}
6156

62-
/** One Material3 selection surface moves from below the list to its leading edge. */
57+
/** Material3 bottom navigation for the compact workspace. */
6358
class T3WorkspaceNavigationView(
6459
context: Context,
6560
appContext: AppContext
@@ -69,7 +64,6 @@ class T3WorkspaceNavigationView(
6964

7065
private val onTabSelected by EventDispatcher()
7166
var selectedTab by mutableStateOf("threads")
72-
var rail by mutableStateOf(false)
7367
var dark by mutableStateOf(false)
7468
var textScale by mutableStateOf(1f)
7569
var containerColor by mutableStateOf(0)
@@ -108,58 +102,29 @@ class T3WorkspaceNavigationView(
108102
setContent {
109103
MaterialTheme(colorScheme = if (dark) darkColorScheme() else lightColorScheme()) {
110104
val tabs = listOf("threads", "pullRequests")
111-
if (rail) {
112-
NavigationRail(
113-
modifier = Modifier.fillMaxSize(),
114-
containerColor = Color(containerColor),
115-
windowInsets = WindowInsets(0),
116-
) {
117-
Spacer(Modifier.weight(1f))
118-
tabs.forEach { tab ->
119-
NavigationRailItem(
120-
selected = selectedTab == tab,
121-
onClick = { onTabSelected(mapOf("tab" to tab)) },
122-
icon = { tabIcon(tab) },
123-
label = {
124-
val title = if (tab == "threads") "Chats" else "PRs"
125-
Text(title, fontSize = (12 * textScale).sp)
126-
},
127-
colors = NavigationRailItemDefaults.colors(
128-
selectedIconColor = Color(selectedColor),
129-
selectedTextColor = Color(selectedColor),
130-
indicatorColor = Color(indicatorColor),
131-
unselectedIconColor = Color(unselectedColor),
132-
unselectedTextColor = Color(unselectedColor),
133-
),
134-
)
135-
}
136-
Spacer(Modifier.weight(1f))
137-
}
138-
} else {
139-
NavigationBar(
140-
modifier = Modifier.fillMaxSize(),
141-
containerColor = Color(containerColor),
142-
tonalElevation = androidx.compose.ui.unit.Dp(0f),
143-
windowInsets = WindowInsets(0),
144-
) {
145-
tabs.forEach { tab ->
146-
NavigationBarItem(
147-
selected = selectedTab == tab,
148-
onClick = { onTabSelected(mapOf("tab" to tab)) },
149-
icon = { tabIcon(tab) },
150-
label = {
151-
val title = if (tab == "threads") "Chats" else "Pull requests"
152-
Text(title, fontSize = (12 * textScale).sp)
153-
},
154-
colors = NavigationBarItemDefaults.colors(
155-
selectedIconColor = Color(selectedColor),
156-
selectedTextColor = Color(selectedColor),
157-
indicatorColor = Color(indicatorColor),
158-
unselectedIconColor = Color(unselectedColor),
159-
unselectedTextColor = Color(unselectedColor),
160-
),
161-
)
162-
}
105+
NavigationBar(
106+
modifier = Modifier.fillMaxSize(),
107+
containerColor = Color(containerColor),
108+
tonalElevation = androidx.compose.ui.unit.Dp(0f),
109+
windowInsets = WindowInsets(0),
110+
) {
111+
tabs.forEach { tab ->
112+
NavigationBarItem(
113+
selected = selectedTab == tab,
114+
onClick = { onTabSelected(mapOf("tab" to tab)) },
115+
icon = { tabIcon(tab) },
116+
label = {
117+
val title = if (tab == "threads") "Chats" else "Pull requests"
118+
Text(title, fontSize = (12 * textScale).sp)
119+
},
120+
colors = NavigationBarItemDefaults.colors(
121+
selectedIconColor = Color(selectedColor),
122+
selectedTextColor = Color(selectedColor),
123+
indicatorColor = Color(indicatorColor),
124+
unselectedIconColor = Color(unselectedColor),
125+
unselectedTextColor = Color(unselectedColor),
126+
),
127+
)
163128
}
164129
}
165130
}

‎apps/mobile/src/features/home/ThreadListToolbar.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useCallback, useEffect, useRef, useState, type ComponentProps } from "react";
22
import { useNavigation, useNavigationState } from "@react-navigation/native";
33
import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
4+
import { useWorkspaceListNavigation } from "../workspace/useAndroidWorkspaceNavigation";
45
import {
56
BackHandler,
67
Keyboard,
@@ -47,6 +48,7 @@ export function ThreadListToolbar(props: {
4748
const { height: toolbarHeight, ...headerPadding } = useToolbarLayout();
4849
const { state } = useWorkspaceState();
4950
const { onRequestVisibility, onSearchQueryChange } = props;
51+
const showPullRequests = useWorkspaceListNavigation("pullRequests");
5052
const searchRef = useRef<TextInputInstance>(null);
5153
const [searchOpen, setSearchOpen] = useState(false);
5254
const searching = searchOpen || props.searchQuery.length > 0;
@@ -124,6 +126,13 @@ export function ThreadListToolbar(props: {
124126
brand={<CompactBrandTitle allowFontScaling={false} />}
125127
/>
126128
</View>
129+
{props.sidebar && workspace ? (
130+
<AndroidHeaderIconButton
131+
accessibilityLabel="Show pull requests"
132+
icon="arrow.triangle.pull"
133+
onPress={showPullRequests}
134+
/>
135+
) : null}
127136
<AndroidHeaderIconButton
128137
accessibilityLabel="Search threads"
129138
icon="magnifyingglass"

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ import {
6060
useHardwareKeyboardCommand,
6161
} from "../keyboard/hardwareKeyboardCommands";
6262
import { AndroidHomeFabLayout } from "../home/AndroidHomeFab";
63-
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
64-
import {
65-
AndroidWorkspaceNavigation,
66-
ANDROID_WORKSPACE_RAIL_WIDTH,
67-
} from "../workspace/AndroidWorkspaceNavigation";
6863
import { AndroidWorkspaceSidebar } from "../workspace/AndroidWorkspaceSidebar";
6964
import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
7065
import { HomeListOptionsProvider } from "../home/home-list-options";
@@ -241,7 +236,6 @@ function AdaptiveWorkspaceLayoutContent(
241236
const windowDimensions = useWindowDimensions();
242237
const nativeMetrics = useNativeLayoutMetrics();
243238
const { width: viewportWidth, height } = nativeMetrics ?? windowDimensions;
244-
const { scale: androidControlScale } = useAndroidControlSizing();
245239
const pathname = props.pathname;
246240
const navigation = useNavigation();
247241
const activeRoleOwner = useRef<symbol | null>(null);
@@ -267,11 +261,6 @@ function AdaptiveWorkspaceLayoutContent(
267261
usesSplitView: baseLayout.usesSplitView,
268262
});
269263
const showPrimarySidebar = primarySidebarPinned || primarySidebarPreferredVisible;
270-
const shouldRenderNavigationRail = Platform.OS === "android" && baseLayout.usesSplitView;
271-
const navigationRailWidth =
272-
shouldRenderNavigationRail && showPrimarySidebar
273-
? ANDROID_WORKSPACE_RAIL_WIDTH * Math.max(1, androidControlScale)
274-
: 0;
275264
const [hinge, setHinge] = useState<VerticalHinge | null>(null);
276265
const [windowHinge, setWindowHinge] = useState<VerticalHinge | null>(null);
277266
const handleHingeChange = useCallback(
@@ -282,29 +271,28 @@ function AdaptiveWorkspaceLayoutContent(
282271
[],
283272
);
284273
const layout = useMemo(
285-
() =>
286-
alignListPaneToHinge({
287-
layout: baseLayout,
288-
hinge,
289-
viewportWidth,
290-
leadingWidth: navigationRailWidth,
291-
}),
292-
[baseLayout, hinge, viewportWidth, navigationRailWidth],
274+
() => alignListPaneToHinge({ layout: baseLayout, hinge, viewportWidth }),
275+
[baseLayout, hinge, viewportWidth],
293276
);
294-
const width = viewportWidth - navigationRailWidth;
295277
const shouldRenderPrimarySidebar = layout.usesSplitView;
296278
const fileInspector = useMemo(
297279
() =>
298280
deriveFileInspectorPaneLayout({
299281
layout,
300-
viewportWidth: width,
282+
viewportWidth,
301283
preferredWidth: fileInspectorPreferredWidth ?? undefined,
302284
reservedLeadingWidth:
303285
shouldRenderPrimarySidebar && showPrimarySidebar
304286
? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
305287
: 0,
306288
}),
307-
[fileInspectorPreferredWidth, layout, showPrimarySidebar, shouldRenderPrimarySidebar, width],
289+
[
290+
fileInspectorPreferredWidth,
291+
layout,
292+
showPrimarySidebar,
293+
shouldRenderPrimarySidebar,
294+
viewportWidth,
295+
],
308296
);
309297
const auxiliaryPaneRole: WorkspaceAuxiliaryPaneRole =
310298
focusedAuxiliaryPaneRole ?? (/\/files(?:\/|$)/.test(pathname) ? "inspector" : "supplementary");
@@ -320,7 +308,7 @@ function AdaptiveWorkspaceLayoutContent(
320308
() =>
321309
deriveWorkspacePaneLayout({
322310
layout,
323-
viewportWidth: width,
311+
viewportWidth,
324312
primarySidebarPreferredVisible: showPrimarySidebar,
325313
auxiliaryPanePreferredVisible,
326314
auxiliaryPaneRole,
@@ -332,7 +320,7 @@ function AdaptiveWorkspaceLayoutContent(
332320
auxiliaryPanePreferredWidth,
333321
layout,
334322
showPrimarySidebar,
335-
width,
323+
viewportWidth,
336324
],
337325
);
338326
const activeThread = parseActiveThreadPath(pathname);
@@ -582,7 +570,6 @@ function AdaptiveWorkspaceLayoutContent(
582570
const renderedSidebarWidth = useSharedValue(
583571
panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0) : 0,
584572
);
585-
const renderedRailWidth = useSharedValue(navigationRailWidth);
586573
useEffect(() => {
587574
if (nativeWorkspace) return;
588575
const targetWidth = panes.primarySidebarVisible
@@ -591,19 +578,15 @@ function AdaptiveWorkspaceLayoutContent(
591578
renderedSidebarWidth.value = withTiming(targetWidth, WORKSPACE_PANE_TIMING, (finished) => {
592579
if (finished && Platform.OS === "android") runOnJS(settleContentWidth)(contentRevision);
593580
});
594-
renderedRailWidth.set(withTiming(navigationRailWidth, WORKSPACE_PANE_TIMING));
595581
}, [
596582
nativeWorkspace,
597-
navigationRailWidth,
598583
layout.listPaneWidth,
599584
layout.listPaneGap,
600585
panes.primarySidebarVisible,
601586
renderedSidebarWidth,
602-
renderedRailWidth,
603587
settleContentWidth,
604588
contentRevision,
605589
]);
606-
const railAnimatedStyle = useAnimatedStyle(() => ({ width: renderedRailWidth.value }));
607590
// Showing or hiding the sidebar clips a fixed-width list. A hinge resize instead tracks the
608591
// animated edge, so the header actions slide with it rather than jumping or being covered.
609592
const listPaneGap = layout.listPaneGap ?? 0;
@@ -624,13 +607,7 @@ function AdaptiveWorkspaceLayoutContent(
624607
// merely clip/reveal it over a matching background.
625608
const renderedInspectorWidth = useSharedValue(inspectorColumnTargetWidth);
626609
const renderedContentWidth = useDerivedValue(() =>
627-
Math.max(
628-
0,
629-
viewportWidth -
630-
renderedRailWidth.value -
631-
renderedSidebarWidth.value -
632-
renderedInspectorWidth.value,
633-
),
610+
Math.max(0, viewportWidth - renderedSidebarWidth.value - renderedInspectorWidth.value),
634611
);
635612

636613
const selectAndroidWorkspace = useAndroidWorkspaceSelection();
@@ -745,17 +722,6 @@ function AdaptiveWorkspaceLayoutContent(
745722
className={Platform.OS === "android" ? "flex-1 flex-row bg-header" : "flex-1 flex-row"}
746723
>
747724
<AndroidHingeObserver onChange={handleHingeChange} />
748-
{shouldRenderNavigationRail ? (
749-
<Animated.View
750-
className="self-stretch overflow-hidden"
751-
accessibilityElementsHidden={navigationRailWidth === 0}
752-
importantForAccessibility={navigationRailWidth > 0 ? "auto" : "no-hide-descendants"}
753-
pointerEvents={navigationRailWidth > 0 ? "auto" : "none"}
754-
style={railAnimatedStyle}
755-
>
756-
<AndroidWorkspaceNavigation rail onSelect={revealPrimarySidebar} />
757-
</Animated.View>
758-
) : null}
759725
{shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (
760726
<Animated.View
761727
className="self-stretch overflow-hidden"

‎apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ import { SearchField } from "../../components/ui/SearchField";
1010
import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
1111
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
1212
import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
13+
import { useWorkspaceListNavigation } from "../workspace/useAndroidWorkspaceNavigation";
1314

1415
/** PR search shares the thread list's native Android header placement. */
15-
export function PullRequestToolbar(props: { readonly onRequestVisibility?: () => void }) {
16+
export function PullRequestToolbar(props: {
17+
readonly sidebar?: boolean;
18+
readonly onRequestVisibility?: () => void;
19+
}) {
1620
const navigation = useNavigation();
1721
const workspace = useWorkspaceTabs()!;
1822
const { dispatch, getScrollOffset, recordScrollOffset, isTabActive } = workspace;
1923
const homeFocused = useNavigationState((state) => state.routes[state.index]?.name === "Home");
2024
const listFocused = homeFocused && workspace.state.selectedTab === "pullRequests";
2125
const { onRequestVisibility } = props;
26+
const showThreads = useWorkspaceListNavigation("threads");
2227
const tab = workspace.state.tabs.pullRequests;
2328
const input = useRef<TextInputInstance>(null);
2429
const searching = tab.searchMode !== "resting";
@@ -98,6 +103,15 @@ export function PullRequestToolbar(props: { readonly onRequestVisibility?: () =>
98103
searching
99104
? []
100105
: [
106+
...(props.sidebar
107+
? [
108+
{
109+
accessibilityLabel: "Show threads",
110+
icon: "text.bubble",
111+
onPress: showThreads,
112+
} as const,
113+
]
114+
: []),
101115
{
102116
accessibilityLabel: "Search pull requests",
103117
icon: "magnifyingglass",

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
11981198
</RowPressable>
11991199
);
12001200

1201-
if (!canOperateThread) return rowContent(() => {});
1201+
if (!canOperateThread)
1202+
return <View style={rowAppearance.swipeContainerStyle}>{rowContent(() => {})}</View>;
12021203

12031204
return (
12041205
<View collapsable={false}>

0 commit comments

Comments
 (0)