Skip to content
TypeScript

fix(android): navigation chrome takes less of the screen (#20813)

Julius Marminge832dc8fd73ce
diff --git a/apps/mobile/deps/react-native-screens-5.0.0-t3.27.tgz b/apps/mobile/deps/react-native-screens-5.0.0-t3.27.tgz
deleted file mode 100644
index 4aa9184ac20..00000000000
Binary files a/apps/mobile/deps/react-native-screens-5.0.0-t3.27.tgz and /dev/null differ
diff --git a/apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz b/apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz
new file mode 100644
index 00000000000..33a1dcca072
Binary files /dev/null and b/apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz differ
diff --git a/apps/mobile/modules/t3-native-controls/android/build.gradle b/apps/mobile/modules/t3-native-controls/android/build.gradle
index 01e035450f0..9ecf11f68db 100644
--- a/apps/mobile/modules/t3-native-controls/android/build.gradle
+++ b/apps/mobile/modules/t3-native-controls/android/build.gradle
@@ -26,6 +26,7 @@ android {
dependencies {
implementation project(':expo-modules-core')
implementation 'androidx.compose.ui:ui-android:1.10.6'
+ implementation 'androidx.activity:activity:1.8.2'
implementation 'androidx.compose.material3:material3-android:1.5.0-alpha17'
implementation 'androidx.window:window:1.5.1'
}
diff --git a/apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3WorkspaceNavigationModule.kt b/apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3WorkspaceNavigationModule.kt
index 3d48060dcaf..3a924af4889 100644
--- a/apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3WorkspaceNavigationModule.kt
+++ b/apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3WorkspaceNavigationModule.kt
@@ -2,25 +2,60 @@ package expo.modules.t3nativecontrols
import android.content.Context
import android.view.ViewGroup
+import androidx.activity.ComponentActivity
+import androidx.activity.OnBackPressedCallback
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.foundation.background
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.Column
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
+import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.width
+import androidx.compose.foundation.selection.selectable
+import androidx.compose.foundation.selection.selectableGroup
+import androidx.compose.foundation.shape.CircleShape
+import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
+import androidx.compose.material3.Scrim
+import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.DisposableEffect
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
+import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.draw.alpha
+import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.clipToBounds
+import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.res.painterResource
+import androidx.compose.ui.semantics.Role
+import androidx.compose.ui.semantics.clearAndSetSemantics
+import androidx.compose.ui.semantics.contentDescription
+import androidx.compose.ui.semantics.semantics
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.lerp
import androidx.compose.ui.unit.sp
import expo.modules.kotlin.AppContext
import expo.modules.kotlin.modules.Module
@@ -28,6 +63,8 @@ import expo.modules.kotlin.modules.ModuleDefinition
import expo.modules.kotlin.viewevent.EventDispatcher
import expo.modules.kotlin.views.ExpoView
+private val TABS = listOf("threads", "pullRequests", "settings")
+
class T3WorkspaceNavigationModule : Module() {
override fun definition() = ModuleDefinition {
Name("T3WorkspaceNavigation")
@@ -35,8 +72,21 @@ class T3WorkspaceNavigationModule : Module() {
Prop("selectedTab") { view: T3WorkspaceNavigationView, value: String ->
view.selectedTab = value
}
+ Prop("rail") { view: T3WorkspaceNavigationView, value: Boolean -> view.rail = value }
Prop("dark") { view: T3WorkspaceNavigationView, value: Boolean -> view.dark = value }
Prop("textScale") { view: T3WorkspaceNavigationView, value: Float -> view.textScale = value }
+ Prop("newEnabled") { view: T3WorkspaceNavigationView, value: Boolean ->
+ view.newEnabled = value
+ }
+ Prop("safeAreaTop") { view: T3WorkspaceNavigationView, value: Float ->
+ view.safeAreaTop = value
+ }
+ Prop("safeAreaBottom") { view: T3WorkspaceNavigationView, value: Float ->
+ view.safeAreaBottom = value
+ }
+ Prop("headerHeight") { view: T3WorkspaceNavigationView, value: Float ->
+ view.headerHeight = value
+ }
Prop("containerColor") { view: T3WorkspaceNavigationView, value: Int ->
view.containerColor = value
}
@@ -49,12 +99,18 @@ class T3WorkspaceNavigationModule : Module() {
Prop("unselectedColor") { view: T3WorkspaceNavigationView, value: Int ->
view.unselectedColor = value
}
- Events("onTabSelected")
+ Prop("actionColor") { view: T3WorkspaceNavigationView, value: Int ->
+ view.actionColor = value
+ }
+ Prop("actionContentColor") { view: T3WorkspaceNavigationView, value: Int ->
+ view.actionContentColor = value
+ }
+ Events("onTabSelected", "onNewThread", "onOverlayChange")
}
}
}
-/** Material3 bottom navigation for the compact workspace. */
+/** One Material3 selection surface moves from below the list to its leading edge. */
class T3WorkspaceNavigationView(
context: Context,
appContext: AppContext
@@ -63,13 +119,22 @@ class T3WorkspaceNavigationView(
override val shouldUseAndroidLayout = true
private val onTabSelected by EventDispatcher()
+ private val onNewThread by EventDispatcher()
+ private val onOverlayChange by EventDispatcher()
var selectedTab by mutableStateOf("threads")
+ var rail by mutableStateOf(false)
var dark by mutableStateOf(false)
var textScale by mutableStateOf(1f)
+ var newEnabled by mutableStateOf(false)
+ var safeAreaTop by mutableStateOf(0f)
+ var safeAreaBottom by mutableStateOf(0f)
+ var headerHeight by mutableStateOf(56f)
var containerColor by mutableStateOf(0)
var selectedColor by mutableStateOf(0)
var indicatorColor by mutableStateOf(0)
var unselectedColor by mutableStateOf(0)
+ var actionColor by mutableStateOf(0)
+ var actionContentColor by mutableStateOf(0)
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
// Fabric measures the replacement bar before attaching it on a fold.
@@ -101,30 +166,30 @@ class T3WorkspaceNavigationView(
)
setContent {
MaterialTheme(colorScheme = if (dark) darkColorScheme() else lightColorScheme()) {
- val tabs = listOf("threads", "pullRequests")
- NavigationBar(
- modifier = Modifier.fillMaxSize(),
- containerColor = Color(containerColor),
- tonalElevation = androidx.compose.ui.unit.Dp(0f),
- windowInsets = WindowInsets(0),
- ) {
- tabs.forEach { tab ->
- NavigationBarItem(
- selected = selectedTab == tab,
- onClick = { onTabSelected(mapOf("tab" to tab)) },
- icon = { tabIcon(tab) },
- label = {
- val title = if (tab == "threads") "Chats" else "Pull requests"
- Text(title, fontSize = (12 * textScale).sp)
- },
- colors = NavigationBarItemDefaults.colors(
- selectedIconColor = Color(selectedColor),
- selectedTextColor = Color(selectedColor),
- indicatorColor = Color(indicatorColor),
- unselectedIconColor = Color(unselectedColor),
- unselectedTextColor = Color(unselectedColor),
- ),
- )
+ if (rail) {
+ rail()
+ } else {
+ NavigationBar(
+ modifier = Modifier.fillMaxSize(),
+ containerColor = Color(containerColor),
+ tonalElevation = androidx.compose.ui.unit.Dp(0f),
+ windowInsets = WindowInsets(0),
+ ) {
+ TABS.forEach { tab ->
+ NavigationBarItem(
+ selected = selectedTab == tab,
+ onClick = { onTabSelected(mapOf("tab" to tab)) },
+ icon = { Icon(tabIconPainter(tab), contentDescription = null) },
+ label = { Text(tabTitle(tab), fontSize = (12 * textScale).sp) },
+ colors = NavigationBarItemDefaults.colors(
+ selectedIconColor = Color(selectedColor),
+ selectedTextColor = Color(selectedColor),
+ indicatorColor = Color(indicatorColor),
+ unselectedIconColor = Color(unselectedColor),
+ unselectedTextColor = Color(unselectedColor),
+ ),
+ )
+ }
}
}
}
@@ -135,15 +200,192 @@ class T3WorkspaceNavigationView(
}
@Composable
- private fun tabIcon(tab: String) {
- val drawable = if (tab == "threads") {
- R.drawable.t3_chats
- } else {
- R.drawable.t3_pull_requests
- }
- Icon(
- painter = painterResource(drawable),
- contentDescription = if (tab == "threads") "Chats" else "Pull requests",
+ private fun rail() {
+ // One rail surface widens in place over the list. Material's ModalWideNavigationRail
+ // instead moves its destinations into a dialog window copy, which blanks them for a few
+ // frames while the window attaches and lays them out at a different height.
+ var expanded by remember { mutableStateOf(false) }
+ // React Native sizes this view to the rail. While the rail is open it spans the workspace,
+ // and it only widens once the host has made room, so the surface is never clipped.
+ var roomy by remember { mutableStateOf(false) }
+ val progress by animateFloatAsState(
+ targetValue = if (expanded && roomy) 1f else 0f,
+ animationSpec = MaterialTheme.motionScheme.defaultSpatialSpec(),
)
+ val overlay = expanded || progress != 0f
+ LaunchedEffect(overlay) { onOverlayChange(mapOf("overlay" to overlay)) }
+ // The activity handles Back before React Native, so an open rail closes first.
+ val backDispatcher = (appContext.currentActivity as? ComponentActivity)?.onBackPressedDispatcher
+ DisposableEffect(backDispatcher, expanded) {
+ val callback = object : OnBackPressedCallback(expanded) {
+ override fun handleOnBackPressed() {
+ expanded = false
+ }
+ }
+ backDispatcher?.addCallback(callback)
+ onDispose { callback.remove() }
+ }
+ val density = LocalDensity.current
+ Box(
+ Modifier.fillMaxSize().onSizeChanged {
+ roomy = with(density) { it.width.toDp() } >= EXPANDED_RAIL_WIDTH
+ },
+ ) {
+ val fraction = progress.coerceIn(0f, 1f)
+ if (fraction > 0f) {
+ Scrim(
+ contentDescription = "Close navigation rail",
+ onClick = { expanded = false },
+ alpha = { fraction },
+ )
+ }
+ Column(
+ Modifier
+ .fillMaxHeight()
+ .width(lerp(RAIL_WIDTH, EXPANDED_RAIL_WIDTH, progress.coerceAtLeast(0f)))
+ .shadow(RAIL_SHADOW * fraction, RAIL_EXPANDED_SHAPE, clip = false)
+ .background(Color(containerColor), RAIL_EXPANDED_SHAPE)
+ .padding(top = safeAreaTop.dp, bottom = safeAreaBottom.dp + 12.dp)
+ .selectableGroup(),
+ ) {
+ // As tall as the list toolbar so the menu lines up with the toolbar's actions.
+ Box(
+ Modifier.height(headerHeight.dp).padding(start = RAIL_INSET),
+ contentAlignment = Alignment.CenterStart,
+ ) {
+ IconButton(
+ onClick = { expanded = !expanded },
+ modifier = Modifier.semantics {
+ contentDescription =
+ if (expanded) "Collapse navigation rail" else "Expand navigation rail"
+ },
+ ) {
+ Icon(
+ painterResource(R.drawable.t3_menu),
+ contentDescription = null,
+ tint = Color(unselectedColor),
+ )
+ }
+ }
+ newThreadButton(fraction) {
+ expanded = false
+ onNewThread(emptyMap<String, Any>())
+ }
+ Spacer(Modifier.weight(1f))
+ TABS.forEach { tab ->
+ railItem(tab, fraction) {
+ expanded = false
+ onTabSelected(mapOf("tab" to tab))
+ }
+ }
+ Spacer(Modifier.weight(1f))
+ }
+ }
+ }
+
+ /** The collapsed FAB widens with the rail and reveals its label as it goes. */
+ @Composable
+ private fun newThreadButton(fraction: Float, onClick: () -> Unit) {
+ Surface(
+ onClick = onClick,
+ enabled = newEnabled,
+ shape = MaterialTheme.shapes.large,
+ color = Color(actionColor),
+ contentColor = Color(actionContentColor),
+ shadowElevation = 3.dp,
+ modifier = Modifier
+ .padding(start = RAIL_INSET, top = 12.dp)
+ .height(FAB_SIZE)
+ .width(lerp(FAB_SIZE, EXPANDED_RAIL_WIDTH - RAIL_INSET * 2, fraction))
+ .alpha(if (newEnabled) 1f else DISABLED_ALPHA)
+ .semantics { contentDescription = "New thread" },
+ ) {
+ Row(
+ Modifier.padding(start = (FAB_SIZE - ICON_SIZE) / 2).clipToBounds(),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Icon(painterResource(R.drawable.t3_new_thread), contentDescription = null)
+ Text(
+ "New thread",
+ Modifier.padding(start = 12.dp).alpha(labelAlpha(fraction)).clearAndSetSemantics {},
+ style = MaterialTheme.typography.labelLarge,
+ fontSize = (14 * textScale).sp,
+ maxLines = 1,
+ softWrap = false,
+ )
+ }
+ }
+ }
+
+ /**
+ * A destination whose indicator stretches from a circle around the icon into a pill around
+ * the icon and label. The icon never moves, so the collapsed and expanded rails share it.
+ */
+ @Composable
+ private fun railItem(tab: String, fraction: Float, onClick: () -> Unit) {
+ val selected = selectedTab == tab
+ val title = expandedTabTitle(tab)
+ val tint = Color(if (selected) selectedColor else unselectedColor)
+ Box(
+ Modifier
+ .padding(start = RAIL_INSET, bottom = 4.dp)
+ .height(ITEM_HEIGHT)
+ .width(lerp(ITEM_HEIGHT, EXPANDED_RAIL_WIDTH - RAIL_INSET * 2, fraction))
+ .clip(CircleShape)
+ .background(if (selected) Color(indicatorColor) else Color.Transparent)
+ .selectable(selected = selected, role = Role.Tab, onClick = onClick)
+ .semantics { contentDescription = title },
+ ) {
+ Row(
+ Modifier.fillMaxHeight().padding(start = (ITEM_HEIGHT - ICON_SIZE) / 2).clipToBounds(),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Icon(tabIconPainter(tab), contentDescription = null, tint = tint)
+ Text(
+ title,
+ Modifier.padding(start = 12.dp).alpha(labelAlpha(fraction)).clearAndSetSemantics {},
+ color = tint,
+ style = MaterialTheme.typography.labelLarge,
+ fontSize = (14 * textScale).sp,
+ maxLines = 1,
+ softWrap = false,
+ )
+ }
+ }
+ }
+
+ private fun tabTitle(tab: String) = when (tab) {
+ "threads" -> "Chats"
+ "pullRequests" -> "PRs"
+ else -> "Settings"
+ }
+
+ private fun expandedTabTitle(tab: String) =
+ if (tab == "pullRequests") "Pull Requests" else tabTitle(tab)
+
+ @Composable
+ private fun tabIconPainter(tab: String) = painterResource(
+ when (tab) {
+ "threads" -> R.drawable.t3_chats
+ "pullRequests" -> R.drawable.t3_pull_requests
+ else -> R.drawable.t3_settings
+ }
+ )
+
+ private companion object {
+ // Material's 80dp compact rail, minus 8dp: still a 48dp touch target with 12dp margins.
+ val RAIL_WIDTH = 72.dp
+ val EXPANDED_RAIL_WIDTH = 240.dp
+ val RAIL_INSET = 12.dp
+ val ITEM_HEIGHT = 48.dp
+ val FAB_SIZE = 48.dp
+ val ICON_SIZE = 24.dp
+ val RAIL_SHADOW = 6.dp
+ val RAIL_EXPANDED_SHAPE = RoundedCornerShape(topEnd = 16.dp, bottomEnd = 16.dp)
+ const val DISABLED_ALPHA = 0.4f
+
+ // Labels fade in over the second half of the widening, once there is room for them, and
+ // fade out over the first half of the narrowing, before the surface clips them.
+ fun labelAlpha(fraction: Float) = ((fraction - 0.5f) / 0.5f).coerceIn(0f, 1f)
}
}
diff --git a/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_menu.xml b/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_menu.xml
new file mode 100644
index 00000000000..d483560d378
--- /dev/null
+++ b/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_menu.xml
@@ -0,0 +1,3 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#000000" android:pathData="M3,6H21V8H3ZM3,11H21V13H3ZM3,16H21V18H3Z" />
+</vector>
diff --git a/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_new_thread.xml b/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_new_thread.xml
new file mode 100644
index 00000000000..109e695d016
--- /dev/null
+++ b/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_new_thread.xml
@@ -0,0 +1,4 @@
+<!-- Tabler Icons edit (MIT), the same glyph as the phone's New thread button (assets/icons/compose.xml). -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#000000" android:pathData="M7,6 L6,6 C4.3431,6 3,7.3431 3,9 L3,18 C3,19.6569 4.3431,21 6,21 L15,21 C16.6569,21 18,19.6569 18,18 L18,17 C18,16.4477 17.5523,16 17,16 C16.4477,16 16,16.4477 16,17 L16,18 C16,18.5523 15.5523,19 15,19 L6,19 C5.4477,19 5,18.5523 5,18 L5,9 C5,8.4477 5.4477,8 6,8 L7,8 C7.5523,8 8,7.5523 8,7 C8,6.4477 7.5523,6 7,6 Z M21.0921,5.8779 L21.092,5.8778 L20.3849,6.5849 L21.092,7.292 C22.3027,6.0814 22.3027,4.1186 21.092,2.908 C19.8814,1.6973 17.9186,1.6973 16.708,2.908 L8.2942,11.2916 C8.1059,11.4793 8,11.7342 8,12 L8,15 C8,15.5523 8.4477,16 9,16 L12,16 C12.2658,16 12.5207,15.8942 12.7084,15.7058 L21.0934,7.2908 C21.4832,6.8996 21.4821,6.2665 21.0908,5.8766 C20.6996,5.4868 20.0665,5.4879 19.6766,5.8792 L11.2916,14.2942 L12,14 L9,14 L10,15 L10,12 L9.7058,12.7084 L18.1209,4.3235 C18.5518,3.8926 19.2482,3.8926 19.6778,4.3222 C20.1074,4.7518 20.1074,5.4482 19.6778,5.8778 C19.2873,6.2683 19.2873,6.9015 19.6778,7.292 L19.6779,7.2921 C20.0684,7.6826 20.7016,7.6826 21.0921,7.2921 C21.4826,6.9016 21.4826,6.2684 21.0921,5.8779 Z M15.2929,5.7071 L18.2929,8.7071 C18.6834,9.0976 19.3166,9.0976 19.7071,8.7071 C20.0976,8.3166 20.0976,7.6834 19.7071,7.2929 L16.7071,4.2929 C16.3166,3.9024 15.6834,3.9024 15.2929,4.2929 C14.9024,4.6834 14.9024,5.3166 15.2929,5.7071 Z" />
+</vector>
diff --git a/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_settings.xml b/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_settings.xml
new file mode 100644
index 00000000000..3c4dfa57233
--- /dev/null
+++ b/apps/mobile/modules/t3-native-controls/android/src/main/res/drawable/t3_settings.xml
@@ -0,0 +1,3 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
+ <path android:fillColor="#000000" android:pathData="M19.43,12.98C19.47,12.66 19.5,12.34 19.5,12C19.5,11.66 19.47,11.34 19.43,11.02L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.97 19.05,5.05L16.56,6.05C16.04,5.65 15.48,5.32 14.87,5.07L14.49,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.51,2.42L9.13,5.07C8.52,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.72,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11.02C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.66 4.57,12.98L2.46,14.63C2.27,14.78 2.22,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.95C7.96,18.35 8.52,18.68 9.13,18.93L9.51,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.49,21.58L14.87,18.93C15.48,18.68 16.04,18.34 16.56,17.95L19.05,18.95C19.28,19.04 19.54,18.95 19.66,18.73L21.66,15.27C21.79,15.05 21.73,14.78 21.54,14.63L19.43,12.98ZM12,15.5C10.07,15.5 8.5,13.93 8.5,12C8.5,10.07 10.07,8.5 12,8.5C13.93,8.5 15.5,10.07 15.5,12C15.5,13.93 13.93,15.5 12,15.5Z" />
+</vector>
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index 349eb8a1e9b..a20120edd4d 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -133,7 +133,7 @@
"react-native-pdf-jsi": "5.0.0",
"react-native-reanimated": "4.7.1",
"react-native-safe-area-context": "~5.10.1",
- "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.27.tgz",
+ "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.29.tgz",
"react-native-shiki-engine": "^0.3.12",
"react-native-svg": "15.16.0",
"react-native-webview": "14.0.1",
diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsx
index 6d7ebcb9ffe..16abe358e91 100644
--- a/apps/mobile/src/Stack.tsx
+++ b/apps/mobile/src/Stack.tsx
@@ -32,7 +32,9 @@ import { useResolveClassNames } from "uniwind";
import { AppText as Text } from "./components/ui/AppText";
import { androidWorkspaceDestinationAnimation } from "./lib/android-workspace-navigation";
import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle";
+import { WorkspaceConnectionStatusProvider } from "./features/home/WorkspaceConnectionTitle";
import { WorkspaceRootScreen } from "./features/workspace/WorkspaceRootScreen";
+import { AndroidWorkspaceSettings } from "./features/workspace/AndroidWorkspaceSettings";
import { AndroidWorkspaceTabsProvider } from "./features/workspace/AndroidWorkspaceTabsProvider";
import {
PullRequestRouteScreen,
@@ -219,6 +221,9 @@ const SettingsContentStack = createV5SheetStackNavigator({
linking: "",
options: {
title: "Settings",
+ // Android draws its own app bar here. Hidden only from inside the screen, the native one
+ // showed for the first frame of the Settings tab and pushed the page down.
+ headerShown: Platform.OS !== "android",
},
}),
SettingsEnvironments: createNativeStackScreen({
@@ -562,7 +567,12 @@ const WORKSPACE_OVERLAY_ROUTES = new Set([
]);
function workspaceLocationFromState(state: NavigationState) {
- const routes = state.routes.filter((route) => !WORKSPACE_OVERLAY_ROUTES.has(route.name));
+ // Android opens Settings as a workspace page rather than an overlay, so the layout sees it.
+ const routes = state.routes.filter(
+ (route) =>
+ !WORKSPACE_OVERLAY_ROUTES.has(route.name) ||
+ (Platform.OS === "android" && route.name === "SettingsSheet"),
+ );
const effectiveState =
routes.length > 0 && routes.length !== state.routes.length
? ({ ...state, routes, index: routes.length - 1 } as NavigationState)
@@ -618,16 +628,18 @@ function RootStackLayout(props: {
<ThreadOutboxDrainWorker />
<ShowcaseCaptureCoordinator pathname={pathname} />
<ExistingThreadSettingsRouteProvider>
- <AndroidWorkspaceTabsProvider>
- <AdaptiveWorkspaceLayout
- pathname={workspaceLocation.pathname}
- workspaceRouteKey={workspaceLocation.routeKey}
- selectedPullRequestKey={selectedPullRequestKey(props.state)}
- >
- {props.children}
- <HardwareKeyboardCommandOverlay />
- </AdaptiveWorkspaceLayout>
- </AndroidWorkspaceTabsProvider>
+ <WorkspaceConnectionStatusProvider>
+ <AndroidWorkspaceTabsProvider state={props.state}>
+ <AdaptiveWorkspaceLayout
+ pathname={workspaceLocation.pathname}
+ workspaceRouteKey={workspaceLocation.routeKey}
+ selectedPullRequestKey={selectedPullRequestKey(props.state)}
+ >
+ {props.children}
+ <HardwareKeyboardCommandOverlay />
+ </AdaptiveWorkspaceLayout>
+ </AndroidWorkspaceTabsProvider>
+ </WorkspaceConnectionStatusProvider>
</ExistingThreadSettingsRouteProvider>
</HardwareKeyboardCommandProvider>
);
@@ -913,11 +925,14 @@ const RootStackConfig = createWorkspaceStackNavigator({
}),
SettingsSheet: createNativeStackScreen({
screen: SettingsSheetStack,
+ layout: ({ children }) => <AndroidWorkspaceSettings>{children}</AndroidWorkspaceSettings>,
linking: "settings",
options: {
...NESTED_NAVIGATOR_OPTIONS,
gestureEnabled: true,
headerShown: false,
+ // Android opens Settings as a top-level tab, so it swaps like the other tabs.
+ ...(Platform.OS === "android" ? { animation: "none" as const } : null),
},
}),
SettingsLegal: createNativeStackScreen({
diff --git a/apps/mobile/src/components/ui/NativeAppBar.android.tsx b/apps/mobile/src/components/ui/NativeAppBar.android.tsx
index b06b0908356..2c028fded80 100644
--- a/apps/mobile/src/components/ui/NativeAppBar.android.tsx
+++ b/apps/mobile/src/components/ui/NativeAppBar.android.tsx
@@ -14,10 +14,13 @@ export function NativeAppBar(props: {
const { colors } = useControlTheme();
const layout = useToolbarLayout();
return (
- <NativeThemeHost matchContents={{ vertical: true }} style={{ width: "100%" }}>
+ // The bar's height is fixed, so React Native lays out the screen below it from the first frame
+ // instead of at zero height until Compose has measured and reported the bar.
+ <NativeThemeHost style={{ width: "100%", height: layout.height }}>
<TopAppBar
applyWindowInsets={false}
- modifiers={[fillMaxWidth(), height(Math.max(64, layout.height))]}
+ // Every header shares the list toolbar's height, so titles line up across panes.
+ modifiers={[fillMaxWidth(), height(layout.height)]}
colors={{
containerColor: colors["--color-header"],
titleContentColor: colors["--color-header-foreground"],
diff --git a/apps/mobile/src/features/home/AndroidHomeFab.android.tsx b/apps/mobile/src/features/home/AndroidHomeFab.android.tsx
index e8a29ce516c..7c6fa8c6850 100644
--- a/apps/mobile/src/features/home/AndroidHomeFab.android.tsx
+++ b/apps/mobile/src/features/home/AndroidHomeFab.android.tsx
@@ -36,10 +36,12 @@ export function AndroidHomeFabLayout(props: ComponentProps<typeof SharedAndroidH
}, []);
// Remount only the FAB when its font or pane changes to clear the cached expanded width.
+ // The split-view sidebar has no FAB: the navigation rail carries New thread. On phones it
+ // keeps Material's 16dp corner margin; the bottom bar already consumes the gesture inset.
return (
<View className="flex-1" onLayout={(event) => setLayoutWidth(event.nativeEvent.layout.width)}>
<FabScrollContext value={onScroll}>{props.children}</FabScrollContext>
- {!props.disabled && state.hasConnections && layoutWidth !== null ? (
+ {!props.disabled && !props.sidebar && state.hasConnections && layoutWidth !== null ? (
<NewThreadButton
key={`${appearance.baseFontSize}:${fontScale}:${layoutWidth}`}
extended
diff --git a/apps/mobile/src/features/home/HomeHeader.android.tsx b/apps/mobile/src/features/home/HomeHeader.android.tsx
index d6eb9c20356..8666329f87a 100644
--- a/apps/mobile/src/features/home/HomeHeader.android.tsx
+++ b/apps/mobile/src/features/home/HomeHeader.android.tsx
@@ -98,7 +98,6 @@ export function HomeHeader(props: HomeHeaderProps) {
filterActions={menuActions}
filterCustomized={hasCustomListOptions}
onFilterAction={handleMenuAction}
- onOpenSettings={props.onOpenSettings}
onOpenEnvironments={props.onOpenEnvironments}
/>
</>
diff --git a/apps/mobile/src/features/home/ThreadListToolbar.tsx b/apps/mobile/src/features/home/ThreadListToolbar.tsx
index 974f29b83b6..9a66d1e28ec 100644
--- a/apps/mobile/src/features/home/ThreadListToolbar.tsx
+++ b/apps/mobile/src/features/home/ThreadListToolbar.tsx
@@ -1,7 +1,6 @@
import { useCallback, useEffect, useRef, useState, type ComponentProps } from "react";
import { useNavigation, useNavigationState } from "@react-navigation/native";
import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
-import { useWorkspaceListNavigation } from "../workspace/useAndroidWorkspaceNavigation";
import {
BackHandler,
Keyboard,
@@ -9,22 +8,16 @@ import {
View,
type LayoutChangeEvent,
} from "react-native";
-import { useSafeAreaInsets } from "react-native-safe-area-context";
import type { MenuAction } from "@react-native-menu/menu";
import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
-import { CompactBrandTitle } from "../../components/CompactBrandTitle";
-import { FloatingActionButton } from "../../components/ui/FloatingActionButton";
import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
import { Menu } from "../../components/ui/Menu";
import { SearchField } from "../../components/ui/SearchField";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
-import { WorkspaceConnectionTitle } from "./WorkspaceConnectionTitle";
-import { useWorkspaceState } from "../../state/workspace";
-import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
+import { WorkspaceListToolbarRow } from "../workspace/WorkspaceListToolbarRow";
+import { useWorkspaceConnectionState } from "../../state/workspace";
import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
-import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
-import { androidHomeFabPosition } from "./AndroidHomeFab.shared";
/** One toolbar height for the compact list and expanded sidebar, including search. */
export function ThreadListToolbar(props: {
@@ -33,25 +26,20 @@ export function ThreadListToolbar(props: {
readonly filterActions: MenuAction[];
readonly filterCustomized: boolean;
readonly onFilterAction: NonNullable<ComponentProps<typeof Menu>["onPressAction"]>;
- readonly onOpenSettings: () => void;
readonly onOpenEnvironments: () => void;
readonly sidebar?: boolean;
readonly onLayout?: (event: LayoutChangeEvent) => void;
readonly onRequestVisibility?: () => void;
}) {
- const insets = useSafeAreaInsets();
const navigation = useNavigation();
const workspace = useWorkspaceTabs();
const isTabActive = workspace?.isTabActive;
const homeFocused = useNavigationState((state) => state.routes[state.index]?.name === "Home");
const listFocused =
homeFocused && (workspace === null || workspace.state.selectedTab === "threads");
- const { fabSize } = useAndroidControlSizing();
- const fab = androidHomeFabPosition(insets.bottom, props.sidebar);
- const { height: toolbarHeight, ...headerPadding } = useToolbarLayout();
- const { state } = useWorkspaceState();
+ const { paddingTop, paddingBottom } = useToolbarLayout();
+ const connectionState = useWorkspaceConnectionState();
const { onRequestVisibility, onSearchQueryChange } = props;
- const showPullRequests = useWorkspaceListNavigation("pullRequests");
const searchRef = useRef<TextInputInstance>(null);
const [searchOpen, setSearchOpen] = useState(false);
const searching = searchOpen || props.searchQuery.length > 0;
@@ -100,68 +88,34 @@ export function ThreadListToolbar(props: {
onChangeText={onSearchQueryChange}
/>
);
+ const filterButton = connectionState.hasConnections ? (
+ <AndroidAnchoredMenu actions={props.filterActions} onPressAction={props.onFilterAction}>
+ {(open) => (
+ <AndroidHeaderIconButton
+ accessibilityLabel="Filter threads"
+ icon={filterIcon}
+ onPress={open}
+ />
+ )}
+ </AndroidAnchoredMenu>
+ ) : null;
return (
- <>
- <View
- onLayout={props.onLayout}
- className={
- props.sidebar ? "absolute inset-x-0 top-0 z-[4] bg-header px-2" : "bg-header px-2"
- }
- style={headerPadding}
- >
- <View className="flex-row items-center gap-1" style={{ minHeight: toolbarHeight }}>
- {searching ? (
- <>
- <AndroidHeaderIconButton
- accessibilityLabel="Close search"
- icon="arrow.left"
- onPress={closeSearch}
- />
- {searchField}
- </>
- ) : (
- <>
- <View className="min-w-0 flex-1 pl-4">
- <WorkspaceConnectionTitle
- grow
- onPress={props.onOpenEnvironments}
- brand={<CompactBrandTitle allowFontScaling={false} fit />}
- />
- </View>
- {props.sidebar && workspace ? (
- <AndroidHeaderIconButton
- accessibilityLabel="Show pull requests"
- icon={PullRequestGlyph.pullRequest}
- onPress={showPullRequests}
- />
- ) : null}
- <AndroidHeaderIconButton
- accessibilityLabel="Search threads"
- icon="magnifyingglass"
- onPress={openSearch}
- />
- <AndroidHeaderIconButton
- accessibilityLabel="Open settings"
- icon="gearshape"
- onPress={props.onOpenSettings}
- />
- </>
- )}
- </View>
- </View>
- {state.hasConnections ? (
- <View
- className="absolute z-[5]"
- style={{ right: fab.right, bottom: fab.bottom + fabSize + 8 }}
- >
- <AndroidAnchoredMenu actions={props.filterActions} onPressAction={props.onFilterAction}>
- {(open) => (
- <FloatingActionButton label="Filter threads" icon={filterIcon} onPress={open} />
- )}
- </AndroidAnchoredMenu>
- </View>
- ) : null}
- </>
+ <View
+ onLayout={props.onLayout}
+ className={props.sidebar ? "absolute inset-x-0 top-0 z-[4] bg-header px-2" : "bg-header px-2"}
+ style={{ paddingTop, paddingBottom }}
+ >
+ <WorkspaceListToolbarRow
+ searching={searching}
+ searchField={searchField}
+ onCloseSearch={closeSearch}
+ onOpenSearch={openSearch}
+ searchAccessibilityLabel="Search threads"
+ titleAccessibilityLabel="T3 Code, Threads"
+ onOpenEnvironments={props.onOpenEnvironments}
+ filter={filterButton}
+ />
+ </View>
);
}
diff --git a/apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx b/apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx
index f1b9bfd5b92..ab22cd6e7d4 100644
--- a/apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx
+++ b/apps/mobile/src/features/home/WorkspaceConnectionTitle.tsx
@@ -1,5 +1,5 @@
import type { NativeStackNavigationOptions } from "@react-navigation/native-stack";
-import { useEffect, useState, type ReactNode } from "react";
+import { createContext, use, useEffect, useMemo, useState, type ReactNode } from "react";
import { Animated, Platform, Pressable, View } from "react-native";
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
@@ -20,22 +20,47 @@ import {
const STATUS_SHOW_DELAY_MS = 800;
const FADE_IN_MS = 250;
-function useDelayedConnectionStatus(): WorkspaceConnectionStatusPresentation | null {
+type ConnectionStatus = WorkspaceConnectionStatusPresentation & {
+ /** Only while the status first appears. A header that shows it later shows it at once. */
+ readonly fadeIn: boolean;
+};
+
+const ConnectionStatusContext = createContext<ConnectionStatus | null>(null);
+
+/**
+ * The delay hides brief reconnects, so it is the workspace's, not each header's: every header
+ * shows the status from the same moment. Headers read it from context instead of subscribing
+ * themselves, because a hidden Android tab drops its subscriptions and showed a stale status for
+ * a moment when it came back, while context still reaches it.
+ */
+export function WorkspaceConnectionStatusProvider(props: { readonly children: ReactNode }) {
const { state } = useWorkspaceState();
const presentation = workspaceConnectionStatusPresentation(state);
const hasStatus = presentation !== null;
- const [visible, setVisible] = useState(false);
+ const [phase, setPhase] = useState<"waiting" | "fading" | "shown">("waiting");
useEffect(() => {
- if (!hasStatus) {
- setVisible(false);
- return;
- }
- const timer = setTimeout(() => setVisible(true), STATUS_SHOW_DELAY_MS);
- return () => clearTimeout(timer);
+ if (!hasStatus) return;
+ const timers = [
+ setTimeout(() => setPhase("fading"), STATUS_SHOW_DELAY_MS),
+ setTimeout(() => setPhase("shown"), STATUS_SHOW_DELAY_MS + FADE_IN_MS),
+ ];
+ return () => {
+ for (const timer of timers) clearTimeout(timer);
+ setPhase("waiting");
+ };
}, [hasStatus]);
- return visible ? presentation : null;
+ const label = presentation?.label;
+ const showsProgress = presentation?.showsProgress ?? false;
+ const status = useMemo(
+ () =>
+ label === undefined || phase === "waiting"
+ ? null
+ : { label, showsProgress, fadeIn: phase === "fading" },
+ [label, showsProgress, phase],
+ );
+ return <ConnectionStatusContext value={status}>{props.children}</ConnectionStatusContext>;
}
/**
@@ -46,12 +71,15 @@ function useDelayedConnectionStatus(): WorkspaceConnectionStatusPresentation | n
*/
function StatusFadeIn(props: {
readonly children: ReactNode;
+ readonly animate: boolean;
readonly grow?: boolean;
readonly maxWidth?: number;
}) {
+ const { animate } = props;
const [opacity] = useState(() => new Animated.Value(0));
useEffect(() => {
+ if (!animate) return;
const animation = Animated.timing(opacity, {
duration: FADE_IN_MS,
toValue: 1,
@@ -59,12 +87,18 @@ function StatusFadeIn(props: {
});
animation.start();
return () => animation.stop();
- }, [opacity]);
+ }, [animate, opacity]);
return (
<Animated.View
style={[
- { alignItems: "center", flexDirection: "row", maxWidth: props.maxWidth, opacity },
+ {
+ alignItems: "center",
+ flexDirection: "row",
+ maxWidth: props.maxWidth,
+ // A hidden tab never runs the fade, so its value would still be 0 when the tab returns.
+ opacity: animate ? opacity : 1,
+ },
props.grow ? { flex: 1, minWidth: 0 } : null,
]}
>
@@ -81,7 +115,7 @@ export function WorkspaceConnectionTitle(props: {
readonly statusOffset?: number;
readonly maxWidth?: number;
}) {
- const status = useDelayedConnectionStatus();
+ const status = use(ConnectionStatusContext);
const size = props.size ?? "navbar";
const { scale } = useAndroidControlSizing();
@@ -96,7 +130,7 @@ export function WorkspaceConnectionTitle(props: {
}
return (
- <StatusFadeIn grow={props.grow} maxWidth={props.maxWidth}>
+ <StatusFadeIn animate={status.fadeIn} grow={props.grow} maxWidth={props.maxWidth}>
<Pressable
accessibilityHint="Opens environment settings"
accessibilityLabel={status.label}
diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
index 669537b6fae..480ca463dac 100644
--- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
@@ -60,6 +60,10 @@ import {
useHardwareKeyboardCommand,
} from "../keyboard/hardwareKeyboardCommands";
import { AndroidHomeFabLayout } from "../home/AndroidHomeFab";
+import {
+ AndroidWorkspaceNavigation,
+ ANDROID_WORKSPACE_RAIL_WIDTH,
+} from "../workspace/AndroidWorkspaceNavigation";
import { AndroidWorkspaceSidebar } from "../workspace/AndroidWorkspaceSidebar";
import { useAndroidWorkspaceSelection } from "../workspace/useAndroidWorkspaceSelection";
import { HomeListOptionsProvider } from "../home/home-list-options";
@@ -235,6 +239,9 @@ function AdaptiveWorkspaceLayoutContent(
const nativeMetrics = useNativeLayoutMetrics();
const { width: viewportWidth, height } = nativeMetrics ?? windowDimensions;
const pathname = props.pathname;
+ // Android's Settings tab is a full workspace page: the rail stays, the sidebar and
+ // auxiliary panes hide.
+ const workspacePage = Platform.OS === "android" && pathname.startsWith("/settings");
const navigation = useNavigation();
const activeRoleOwner = useRef<symbol | null>(null);
const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
@@ -247,6 +254,7 @@ function AdaptiveWorkspaceLayoutContent(
null,
);
const [primarySidebarSearchQuery, setPrimarySidebarSearchQuery] = useState("");
+ const [railOverlay, setRailOverlay] = useState(false);
const [focusedAuxiliaryPaneRole, setFocusedAuxiliaryPaneRole] =
useState<WorkspaceAuxiliaryPaneRole | null>(null);
// The compiler can't memoize these derivations: they stay live across later hook calls. Fresh
@@ -262,7 +270,13 @@ function AdaptiveWorkspaceLayoutContent(
nativeWorkspace,
usesSplitView: baseLayout.usesSplitView,
});
- const showPrimarySidebar = primarySidebarPinned || primarySidebarPreferredVisible;
+ const showPrimarySidebar =
+ !workspacePage && (primarySidebarPinned || primarySidebarPreferredVisible);
+ const shouldRenderNavigationRail = Platform.OS === "android" && baseLayout.usesSplitView;
+ const navigationRailWidth =
+ shouldRenderNavigationRail && (showPrimarySidebar || workspacePage)
+ ? ANDROID_WORKSPACE_RAIL_WIDTH
+ : 0;
const [hinge, setHinge] = useState<VerticalHinge | null>(null);
const [windowHinge, setWindowHinge] = useState<VerticalHinge | null>(null);
const handleHingeChange = (next: VerticalHinge | null, nextWindow: VerticalHinge | null) => {
@@ -270,35 +284,38 @@ function AdaptiveWorkspaceLayoutContent(
setWindowHinge(nextWindow);
};
const layout = useMemo(
- () => alignListPaneToHinge({ layout: baseLayout, hinge, viewportWidth }),
- [baseLayout, hinge, viewportWidth],
+ () =>
+ alignListPaneToHinge({
+ layout: baseLayout,
+ hinge,
+ viewportWidth,
+ leadingWidth: navigationRailWidth,
+ }),
+ [baseLayout, hinge, navigationRailWidth, viewportWidth],
);
+ const width = viewportWidth - navigationRailWidth;
+ // The sidebar stays mounted under a workspace page, so its list is ready on the way back.
const shouldRenderPrimarySidebar = layout.usesSplitView;
const fileInspector = useMemo(
() =>
deriveFileInspectorPaneLayout({
layout,
- viewportWidth,
+ viewportWidth: width,
preferredWidth: fileInspectorPreferredWidth ?? undefined,
reservedLeadingWidth:
shouldRenderPrimarySidebar && showPrimarySidebar
? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
: 0,
}),
- [
- fileInspectorPreferredWidth,
- layout,
- showPrimarySidebar,
- shouldRenderPrimarySidebar,
- viewportWidth,
- ],
+ [fileInspectorPreferredWidth, layout, showPrimarySidebar, shouldRenderPrimarySidebar, width],
);
const auxiliaryPaneRole: WorkspaceAuxiliaryPaneRole =
focusedAuxiliaryPaneRole ?? (/\/files(?:\/|$)/.test(pathname) ? "inspector" : "supplementary");
const auxiliaryPanePreferredVisible =
- auxiliaryPaneRole === "inspector"
+ !workspacePage &&
+ (auxiliaryPaneRole === "inspector"
? fileInspectorPreferredVisible
- : supplementaryPanePreferredVisible;
+ : supplementaryPanePreferredVisible);
const auxiliaryPanePreferredWidth =
auxiliaryPaneRole === "inspector"
? fileInspectorPreferredWidth
@@ -307,7 +324,7 @@ function AdaptiveWorkspaceLayoutContent(
() =>
deriveWorkspacePaneLayout({
layout,
- viewportWidth,
+ viewportWidth: width,
primarySidebarPreferredVisible: showPrimarySidebar,
auxiliaryPanePreferredVisible,
auxiliaryPaneRole,
@@ -319,7 +336,7 @@ function AdaptiveWorkspaceLayoutContent(
auxiliaryPanePreferredWidth,
layout,
showPrimarySidebar,
- viewportWidth,
+ width,
],
);
const activeThread = parseActiveThreadPath(pathname);
@@ -484,6 +501,7 @@ function AdaptiveWorkspaceLayoutContent(
: null;
const [contentSizing, setContentSizing] = useState({
viewportWidth,
+ workspacePage,
target: contentTargetWidth,
sidebarVisible: panes.primarySidebarVisible,
width: contentTargetWidth,
@@ -495,11 +513,15 @@ function AdaptiveWorkspaceLayoutContent(
if (
Platform.OS === "android" &&
(contentSizing.viewportWidth !== viewportWidth ||
+ contentSizing.workspacePage !== workspacePage ||
contentSizing.target !== contentTargetWidth ||
contentSizing.sidebarVisible !== panes.primarySidebarVisible ||
contentSizing.listPaneTarget !== layout.listPaneWidth)
) {
- const sameViewport = contentSizing.viewportWidth === viewportWidth;
+ // A workspace page swaps the sidebar in the same frame, so nothing animates to wait for.
+ const sameViewport =
+ contentSizing.viewportWidth === viewportWidth &&
+ contentSizing.workspacePage === workspacePage;
const openingSidebar =
sameViewport && !contentSizing.sidebarVisible && panes.primarySidebarVisible;
// A book-posture hinge resizes the visible list pane instead of revealing it.
@@ -514,6 +536,7 @@ function AdaptiveWorkspaceLayoutContent(
contentTargetWidth !== null;
setContentSizing({
viewportWidth,
+ workspacePage,
target: contentTargetWidth,
sidebarVisible: panes.primarySidebarVisible,
// Clip the wide navigator while the sidebar opens or widens, then reflow once at the
@@ -556,23 +579,41 @@ function AdaptiveWorkspaceLayoutContent(
const renderedSidebarWidth = useSharedValue(
panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0) : 0,
);
+ const renderedRailWidth = useSharedValue(navigationRailWidth);
+ const leavingWorkspacePage = useRef(false);
useEffect(() => {
if (nativeWorkspace) return;
+ renderedRailWidth.set(withTiming(navigationRailWidth, WORKSPACE_PANE_TIMING));
+ // A workspace page hides the sidebar through React instead, in the same commit that mounts
+ // the page. Animating it here would hide it a few frames before the page appears.
+ if (workspacePage) {
+ leavingWorkspacePage.current = true;
+ return;
+ }
+ const snap = leavingWorkspacePage.current;
+ leavingWorkspacePage.current = false;
const targetWidth = panes.primarySidebarVisible
? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
: 0;
- renderedSidebarWidth.value = withTiming(targetWidth, WORKSPACE_PANE_TIMING, (finished) => {
- if (finished && Platform.OS === "android") runOnJS(settleContentWidth)(contentRevision);
- });
+ // The content beside it already took its final width when the page closed.
+ renderedSidebarWidth.set(
+ withTiming(targetWidth, snap ? { duration: 0 } : WORKSPACE_PANE_TIMING, (finished) => {
+ if (finished && Platform.OS === "android") runOnJS(settleContentWidth)(contentRevision);
+ }),
+ );
}, [
nativeWorkspace,
+ navigationRailWidth,
layout.listPaneWidth,
layout.listPaneGap,
panes.primarySidebarVisible,
renderedSidebarWidth,
+ renderedRailWidth,
settleContentWidth,
contentRevision,
+ workspacePage,
]);
+ const railAnimatedStyle = useAnimatedStyle(() => ({ width: renderedRailWidth.value }));
// Showing or hiding the sidebar clips a fixed-width list. A hinge resize instead tracks the
// animated edge, so the header actions slide with it rather than jumping or being covered.
const listPaneGap = layout.listPaneGap ?? 0;
@@ -593,7 +634,13 @@ function AdaptiveWorkspaceLayoutContent(
// merely clip/reveal it over a matching background.
const renderedInspectorWidth = useSharedValue(inspectorColumnTargetWidth);
const renderedContentWidth = useDerivedValue(() =>
- Math.max(0, viewportWidth - renderedSidebarWidth.value - renderedInspectorWidth.value),
+ Math.max(
+ 0,
+ viewportWidth -
+ renderedRailWidth.value -
+ renderedSidebarWidth.value -
+ renderedInspectorWidth.value,
+ ),
);
const selectAndroidWorkspace = useAndroidWorkspaceSelection();
@@ -682,6 +729,9 @@ function AdaptiveWorkspaceLayoutContent(
className={Platform.OS === "android" ? "flex-1 flex-row bg-header" : "flex-1 flex-row"}
>
<AndroidHingeObserver onChange={handleHingeChange} />
+ {shouldRenderNavigationRail ? (
+ <Animated.View className="self-stretch" style={railAnimatedStyle} />
+ ) : null}
{shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (
<Animated.View
className="self-stretch overflow-hidden"
@@ -691,7 +741,13 @@ function AdaptiveWorkspaceLayoutContent(
panes.primarySidebarVisible ? "auto" : "no-hide-descendants"
}
pointerEvents={panes.primarySidebarVisible ? "auto" : "none"}
- style={sidebarAnimatedStyle}
+ // Under a workspace page the sidebar leaves the row but keeps its size, so its
+ // lists never lay out at zero size and are ready, unchanged, on the way back. The
+ // content pane, laid out after it, covers it, in the same mount as the page.
+ style={[
+ workspacePage ? { position: "absolute", top: 0, bottom: 0, left: 0 } : null,
+ sidebarAnimatedStyle,
+ ]}
>
<Animated.View className="flex-1" style={listPaneAnimatedStyle}>
<RenderErrorBoundary
@@ -764,6 +820,20 @@ function AdaptiveWorkspaceLayoutContent(
setAuxiliaryPaneWidth={setAuxiliaryPaneWidth}
onClosed={handleWorkspaceInspectorClosed}
/>
+ {shouldRenderNavigationRail && navigationRailWidth > 0 ? (
+ // The rail reserves its slot above and draws over the panes, so it can widen over
+ // the list in place. It takes the whole workspace only while it is open.
+ <View
+ className="absolute inset-y-0 left-0"
+ style={railOverlay ? { right: 0 } : { width: navigationRailWidth }}
+ >
+ <AndroidWorkspaceNavigation
+ rail
+ onSelect={revealPrimarySidebar}
+ onOverlayChange={setRailOverlay}
+ />
+ </View>
+ ) : null}
</View>
</WindowHingeContext>
</AdaptiveWorkspaceContext.Provider>
diff --git a/apps/mobile/src/features/pull-requests/PullRequestFilterMenuContext.tsx b/apps/mobile/src/features/pull-requests/PullRequestFilterMenuContext.tsx
new file mode 100644
index 00000000000..68a423f80aa
--- /dev/null
+++ b/apps/mobile/src/features/pull-requests/PullRequestFilterMenuContext.tsx
@@ -0,0 +1,50 @@
+import type { MenuAction } from "@react-native-menu/menu";
+import {
+ createContext,
+ use,
+ useLayoutEffect,
+ useState,
+ type Dispatch,
+ type ReactNode,
+ type SetStateAction,
+} from "react";
+
+export interface PullRequestFilterMenu {
+ readonly actions: readonly MenuAction[];
+ readonly onSelect: (id: string) => void;
+ /** Whether any filter, the environment, or a non-default sort is active. */
+ readonly customized: boolean;
+}
+
+const MenuContext = createContext<PullRequestFilterMenu | null>(null);
+const PublishContext = createContext<Dispatch<SetStateAction<PullRequestFilterMenu | null>> | null>(
+ null,
+);
+
+/**
+ * The Android PR header opens the full filter menu, but the facets (authors, labels) and the
+ * controls live in the list below it. The list publishes its menu here; only the header reads
+ * it, so the list's own renders don't fan out.
+ */
+export function PullRequestFilterMenuProvider(props: { readonly children: ReactNode }) {
+ const [menu, setMenu] = useState<PullRequestFilterMenu | null>(null);
+ return (
+ <PublishContext value={setMenu}>
+ <MenuContext value={menu}>{props.children}</MenuContext>
+ </PublishContext>
+ );
+}
+
+export function usePullRequestFilterMenu() {
+ return use(MenuContext);
+}
+
+export function usePublishPullRequestFilterMenu(menu: PullRequestFilterMenu | null) {
+ const publish = use(PublishContext);
+ // A layout effect, so the header's filter button lands in the same frame as the list. There is
+ // no cleanup: the list lives exactly as long as this provider, and a hidden tab runs its
+ // cleanups, which would drop the button for a few frames every time the tab came back.
+ useLayoutEffect(() => {
+ if (publish && menu) publish(menu);
+ }, [publish, menu]);
+}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestListFilters.tsx b/apps/mobile/src/features/pull-requests/PullRequestListFilters.tsx
index be9b6ccff0e..2a9e71bc2f2 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestListFilters.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestListFilters.tsx
@@ -3,6 +3,7 @@ import { useMemo } from "react";
import { Platform, ScrollView } from "react-native";
import type { MenuProps } from "../../components/ui/Menu.types";
import { ListFilterMenu } from "../workspace/ListFilterMenu";
+import { usePublishPullRequestFilterMenu } from "./PullRequestFilterMenuContext";
import { useProjects, useThreadShells } from "../../state/entities";
import { useMobileProjectGroupingSettings } from "../../state/project-grouping";
import { buildHomeProjectScopes, sortHomeProjectScopes } from "../home/homeThreadList";
@@ -63,6 +64,8 @@ function useProjectsInSidebarOrder<Project extends { id: string; environmentId:
}
export function PullRequestListFilters(props: {
+ /** Android sidebar rows sit further in than full-width rows; the pills follow them. */
+ readonly sidebar?: boolean;
readonly environments: readonly { id: string; label: string }[];
readonly environmentId: string | null;
readonly onEnvironmentChange: (id: string | null) => void;
@@ -100,6 +103,8 @@ export function PullRequestListFilters(props: {
break;
case "reset":
props.onChange(DEFAULT_PR_LIST_CONTROLS);
+ // The Android header menu also holds the environment, so its reset clears that too.
+ if (next === "environment") props.onEnvironmentChange(null);
break;
case "state":
props.onChange({ ...value, state: next as PullRequestListControls["state"] });
@@ -217,26 +222,89 @@ export function PullRequestListFilters(props: {
),
},
{ id: "sort", title: SORTS[value.sort], subactions: choices("sort", SORTS, value.sort) },
- {
- id: id("reset", ""),
- title: "Reset filters",
- attributes: { disabled: count === 0 && value.sort === "updated" },
- },
];
+ const reset = (withEnvironment: boolean): MenuProps["actions"][number] => ({
+ id: id("reset", withEnvironment ? "environment" : ""),
+ title: "Reset filters",
+ attributes: {
+ disabled:
+ count === 0 &&
+ value.sort === "updated" &&
+ (!withEnvironment || props.environmentId === null),
+ },
+ });
const labels = [...new Set([...selectedLabels, ...props.labels])].slice(0, 60);
const authors = [
...new Set([...(author && author !== "me" ? [author] : []), ...props.authors]),
].slice(0, 60);
+ const environmentActions = choices(
+ "environment",
+ Object.fromEntries([
+ ["", "All environments"],
+ ...props.environments.map((environment) => [environment.id, environment.label]),
+ ]),
+ props.environmentId ?? "",
+ );
+ const stateActions = choices("state", STATES, value.state);
+ const involvementActions = choices("involvement", INVOLVEMENT, value.involvement);
+ const labelActions: MenuProps["actions"] = [
+ { id: id("labels", ""), title: "All labels", state: selectedLabels.length ? "off" : "on" },
+ ...labels.map((label) => ({
+ id: id("label", label),
+ title: label,
+ state: selectedLabelSet.has(label) ? ("on" as const) : ("off" as const),
+ })),
+ ];
+ const authorActions = choices(
+ "author",
+ Object.fromEntries([
+ ["", "All authors"],
+ ["me", "Me"],
+ ...authors.map((login) => [login, login]),
+ ]),
+ author ?? "",
+ );
+ const customized = count > 0 || value.sort !== "updated" || props.environmentId !== null;
+ // The Android header's filter button opens every filter.
+ const headerMenu =
+ Platform.OS === "android"
+ ? {
+ actions: [
+ { id: "environment", title: "Environment", subactions: environmentActions },
+ { id: "state", title: "State", subactions: stateActions },
+ { id: "involvement", title: "Involvement", subactions: involvementActions },
+ { id: "labels", title: "Labels", subactions: labelActions },
+ { id: "author", title: "Author", subactions: authorActions },
+ ...more,
+ reset(true),
+ ],
+ onSelect: select,
+ customized,
+ }
+ : null;
+ usePublishPullRequestFilterMenu(headerMenu);
return (
- <ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={ROW_STYLE}>
- <ListFilterMenu
- label={count ? String(count) : "Filters"}
- icon
- active={count > 0}
- accessibilityLabel={count ? `Filters, ${count} active` : "More filters"}
- actions={more}
- onSelect={select}
- />
+ <ScrollView
+ horizontal
+ showsHorizontalScrollIndicator={false}
+ // In the Android sidebar the first pill lines up with the rows' content instead
+ // (8dp row margin + 12dp padding).
+ contentContainerStyle={
+ props.sidebar && Platform.OS === "android"
+ ? { ...ROW_STYLE, paddingHorizontal: 20 }
+ : ROW_STYLE
+ }
+ >
+ {Platform.OS === "android" ? null : (
+ <ListFilterMenu
+ label={count ? String(count) : "Filters"}
+ icon
+ active={count > 0}
+ accessibilityLabel={count ? `Filters, ${count} active` : "More filters"}
+ actions={[...more, reset(false)]}
+ onSelect={select}
+ />
+ )}
{props.environments.length > 1 ? (
<ListFilterMenu
label={
@@ -244,14 +312,7 @@ export function PullRequestListFilters(props: {
?.label ?? "All environments"
}
accessibilityLabel="Choose pull request environment"
- actions={choices(
- "environment",
- Object.fromEntries([
- ["", "All environments"],
- ...props.environments.map((environment) => [environment.id, environment.label]),
- ]),
- props.environmentId ?? "",
- )}
+ actions={environmentActions}
onSelect={select}
/>
) : null}
@@ -259,47 +320,28 @@ export function PullRequestListFilters(props: {
label={STATES[value.state]}
active={value.state !== "open"}
accessibilityLabel="Filter by state"
- actions={choices("state", STATES, value.state)}
+ actions={stateActions}
onSelect={select}
/>
<ListFilterMenu
label={INVOLVEMENT[value.involvement]}
active={value.involvement !== "all"}
accessibilityLabel="Filter by involvement"
- actions={choices("involvement", INVOLVEMENT, value.involvement)}
+ actions={involvementActions}
onSelect={select}
/>
<ListFilterMenu
label={selectedLabels.length ? `Labels ${selectedLabels.length}` : "Labels"}
active={selectedLabels.length > 0}
accessibilityLabel="Filter by label"
- actions={[
- {
- id: id("labels", ""),
- title: "All labels",
- state: selectedLabels.length ? "off" : "on",
- },
- ...labels.map((label) => ({
- id: id("label", label),
- title: label,
- state: selectedLabelSet.has(label) ? ("on" as const) : ("off" as const),
- })),
- ]}
+ actions={labelActions}
onSelect={select}
/>
<ListFilterMenu
label={author === "me" ? "By you" : (author ?? "Author")}
active={Boolean(author)}
accessibilityLabel="Filter by author"
- actions={choices(
- "author",
- Object.fromEntries([
- ["", "All authors"],
- ["me", "Me"],
- ...authors.map((login) => [login, login]),
- ]),
- author ?? "",
- )}
+ actions={authorActions}
onSelect={select}
/>
</ScrollView>
diff --git a/apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx b/apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx
index 9b320fb26e7..fd0211a69d5 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestToolbar.android.tsx
@@ -1,29 +1,24 @@
import { useNavigation, useNavigationState } from "@react-navigation/native";
import { useCallback, useEffect, useRef } from "react";
import { BackHandler, Keyboard, View, type TextInputInstance } from "react-native";
-import {
- AndroidHeaderIconButton,
- AndroidScreenHeader,
-} from "../../components/ui/AndroidScreenHeader";
-import { CompactBrandTitle } from "../../components/CompactBrandTitle";
+import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
+import { AndroidAnchoredMenu } from "../../components/ui/AndroidAnchoredMenu";
import { SearchField } from "../../components/ui/SearchField";
-import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
+import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
+import { WorkspaceListToolbarRow } from "../workspace/WorkspaceListToolbarRow";
import { useWorkspaceTabs } from "../workspace/WorkspaceTabsContext";
-import { useWorkspaceListNavigation } from "../workspace/useAndroidWorkspaceNavigation";
+import { usePullRequestFilterMenu } from "./PullRequestFilterMenuContext";
-/** PR search shares the thread list's native Android header placement. */
-export function PullRequestToolbar(props: {
- readonly sidebar?: boolean;
- readonly onRequestVisibility?: () => void;
-}) {
+/** PR search shares the thread list's Android header row. */
+export function PullRequestToolbar(props: { readonly onRequestVisibility?: () => void }) {
const navigation = useNavigation();
+ const filters = usePullRequestFilterMenu();
const workspace = useWorkspaceTabs()!;
const { dispatch, getScrollOffset, recordScrollOffset, isTabActive } = workspace;
const homeFocused = useNavigationState((state) => state.routes[state.index]?.name === "Home");
const listFocused = homeFocused && workspace.state.selectedTab === "pullRequests";
const { onRequestVisibility } = props;
- const showThreads = useWorkspaceListNavigation("threads");
const tab = workspace.state.tabs.pullRequests;
const input = useRef<TextInputInstance>(null);
const searching = tab.searchMode !== "resting";
@@ -57,11 +52,12 @@ export function PullRequestToolbar(props: {
});
return () => subscription.remove();
}, [searching, closeSearch, listFocused, navigation, isTabActive]);
+ const { paddingTop, paddingBottom } = useToolbarLayout();
return (
- <AndroidScreenHeader
- title="Pull requests"
- titleContent={
- searching ? (
+ <View className="bg-header px-2" style={{ paddingTop, paddingBottom }}>
+ <WorkspaceListToolbarRow
+ searching={searching}
+ searchField={
<SearchField
inputRef={input}
accessibilityLabel="Search pull requests"
@@ -70,65 +66,38 @@ export function PullRequestToolbar(props: {
value={tab.query}
onChangeText={(query) => dispatch({ type: "query", tab: "pullRequests", query })}
/>
- ) : (
- <View className="min-w-0 flex-1 pl-3">
- <WorkspaceConnectionTitle
- grow
- brand={
- <CompactBrandTitle
- allowFontScaling={false}
- accessibilityLabel="T3 Code, Pull requests"
- fit
+ }
+ onCloseSearch={closeSearch}
+ onOpenSearch={openSearch}
+ searchAccessibilityLabel="Search pull requests"
+ titleAccessibilityLabel="T3 Code, Pull requests"
+ onOpenEnvironments={() =>
+ navigation.navigate("SettingsSheet", {
+ screen: "SettingsContent",
+ params: { screen: "SettingsEnvironments" },
+ })
+ }
+ filter={
+ filters ? (
+ <AndroidAnchoredMenu
+ actions={filters.actions}
+ onPressAction={({ nativeEvent }) => filters.onSelect(nativeEvent.event)}
+ >
+ {(open) => (
+ <AndroidHeaderIconButton
+ accessibilityLabel="Filter pull requests"
+ icon={
+ filters.customized
+ ? "line.3.horizontal.decrease.circle.fill"
+ : "line.3.horizontal.decrease.circle"
+ }
+ onPress={open}
/>
- }
- onPress={() =>
- navigation.navigate("SettingsSheet", {
- screen: "SettingsContent",
- params: { screen: "SettingsEnvironments" },
- })
- }
- />
- </View>
- )
- }
- leading={
- searching ? (
- <AndroidHeaderIconButton
- accessibilityLabel="Close search"
- icon="arrow.left"
- onPress={closeSearch}
- />
- ) : undefined
- }
- actions={
- searching
- ? []
- : [
- ...(props.sidebar
- ? [
- {
- accessibilityLabel: "Show threads",
- icon: "text.bubble",
- onPress: showThreads,
- } as const,
- ]
- : []),
- {
- accessibilityLabel: "Search pull requests",
- icon: "magnifyingglass",
- onPress: openSearch,
- },
- {
- accessibilityLabel: "Open settings",
- icon: "gearshape",
- onPress: () =>
- navigation.navigate("SettingsSheet", {
- screen: "SettingsContent",
- params: { screen: "Settings" },
- }),
- },
- ]
- }
- />
+ )}
+ </AndroidAnchoredMenu>
+ ) : null
+ }
+ />
+ </View>
);
}
diff --git a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
index 7b2e7df98c6..70adb062397 100644
--- a/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
+++ b/apps/mobile/src/features/pull-requests/PullRequestsScreen.tsx
@@ -70,7 +70,6 @@ export function PullRequestsScreen(
const configs = useAtomValue(environmentServerConfigsAtom);
const insets = useSafeAreaInsets();
const [initialOffset] = useState(() => workspace.getScrollOffset("pullRequests"));
- const [initialAnchor] = useState(() => workspace.getScrollAnchor("pullRequests"));
const listRef = useRef<LegendListRef>(null);
const tab = workspace.state.tabs.pullRequests;
const maintainVisiblePosition = useMemo(
@@ -206,9 +205,6 @@ export function PullRequestsScreen(
animated: false,
});
}, [tab.searchMode, tab.scrollOffset, insets.top]);
- const initialIndex = initialAnchor
- ? entries.findIndex((entry) => pullRequestKey(entry) === initialAnchor.key)
- : -1;
return (
<View className={sidebar ? "flex-1 bg-drawer" : "flex-1 bg-screen"}>
@@ -233,19 +229,17 @@ export function PullRequestsScreen(
/>
}
alwaysBounceVertical
+ // Android flashes a list's scrollbar whenever it becomes visible, which was every return
+ // to this tab. The thread list shows none either.
+ showsVerticalScrollIndicator={Platform.OS !== "android"}
recycleItems
renderScrollComponent={Platform.OS === "ios" ? PullRequestScrollView : undefined}
contentInsetAdjustmentBehavior="never"
contentInset={Platform.OS === "ios" ? { top: insets.top } : undefined}
+ // A plain offset: LegendList adds the list header to an index-based restore, which
+ // landed every return one header lower.
initialScrollOffset={
- !initialAnchor && initialOffset > 0
- ? initialOffset - (Platform.OS === "ios" ? insets.top : 0)
- : undefined
- }
- initialScrollIndex={
- initialIndex >= 0 && initialAnchor
- ? { index: initialIndex, viewOffset: initialAnchor.viewOffset, viewPosition: 0 }
- : undefined
+ initialOffset > 0 ? initialOffset - (Platform.OS === "ios" ? insets.top : 0) : undefined
}
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
contentContainerStyle={{
@@ -259,13 +253,6 @@ export function PullRequestsScreen(
event.nativeEvent.contentOffset.y + (Platform.OS === "ios" ? insets.top : 0),
),
);
- const list = listRef.current?.getState();
- const item = list ? entries[list.start] : undefined;
- if (list && item)
- workspace.recordScrollAnchor("pullRequests", {
- key: pullRequestKey(item),
- viewOffset: list.positionAtIndex(list.start) - event.nativeEvent.contentOffset.y,
- });
}}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="handled"
@@ -273,6 +260,7 @@ export function PullRequestsScreen(
ListHeaderComponent={
<>
<PullRequestListFilters
+ sidebar={sidebar}
environments={environments.map((item) => ({
id: String(item.environmentId),
label: item.environmentLabel,
diff --git a/apps/mobile/src/features/settings/components/SettingsScreen.tsx b/apps/mobile/src/features/settings/components/SettingsScreen.tsx
index c6ce3d919c9..b3f8176ebce 100644
--- a/apps/mobile/src/features/settings/components/SettingsScreen.tsx
+++ b/apps/mobile/src/features/settings/components/SettingsScreen.tsx
@@ -1,10 +1,11 @@
-import { useNavigation } from "@react-navigation/native";
+import { useNavigation, useNavigationState, useRoute } from "@react-navigation/native";
import type { ReactNode } from "react";
import { Platform, View } from "react-native";
import type { AppBarProps } from "../../../components/ui/AppBar.types";
import { AppBar } from "../../../components/ui/AppBar";
import { ScreenContent as SettingsScreenContent } from "../../../components/ui/ScreenContent";
+import { useWorkspaceTabs } from "../../workspace/WorkspaceTabsContext";
export { SettingsScreenContent };
@@ -15,6 +16,12 @@ export function SettingsScreen(
},
) {
const navigation = useNavigation();
+ const route = useRoute();
+ const index = useNavigationState((state) => state.index);
+ const workspace = useWorkspaceTabs();
+ // Android opens Settings as a workspace tab; its root page has nothing to go back to.
+ const workspaceRoot =
+ Platform.OS === "android" && workspace !== null && index === 0 && route.name === "Settings";
return (
<View collapsable={false} className="flex-1 bg-sheet">
@@ -23,7 +30,7 @@ export function SettingsScreen(
actions={props.actions}
trailing={Platform.OS === "android" ? props.trailing : undefined}
sidebar={false}
- onBack={() => navigation.goBack()}
+ onBack={workspaceRoot ? undefined : () => navigation.goBack()}
hideBottomBorder={!props.formSheet}
/>
{props.formSheet ? (
diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
index 1cd870b006b..e454e6ec91c 100644
--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
@@ -875,7 +875,6 @@ function ThreadNavigationSidebarPane(
filterActions={listMenuActions}
filterCustomized={filterCustomized}
onFilterAction={handleListMenuAction}
- onOpenSettings={props.onOpenSettings}
onOpenEnvironments={props.onOpenEnvironmentSettings}
onRequestVisibility={props.onRequestVisibility}
/>
diff --git a/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx b/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
index 552b54c4fcf..78ee563b430 100644
--- a/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
+++ b/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.android.tsx
@@ -1,6 +1,5 @@
import { requireNativeView } from "expo";
-import { useNavigation } from "@react-navigation/native";
-import { resetAndroidWorkspace } from "../../lib/android-workspace-navigation";
+import { CommonActions, useNavigation } from "@react-navigation/native";
import {
Keyboard,
processColor,
@@ -12,20 +11,40 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useKeyboardState } from "react-native-keyboard-controller";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
+import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
+import { useWorkspaceConnectionState } from "../../state/workspace";
import { androidWorkspaceNavigationColors } from "./android-workspace-navigation-colors";
+import {
+ androidWorkspaceTabNavigationState,
+ type AndroidWorkspaceNavigationTab,
+} from "./android-workspace-tabs";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
+import { useAndroidWorkspaceRoot } from "./AndroidWorkspaceTabsProvider";
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
-import type { WorkspaceTab } from "./workspace-tabs-state";
+
+// Matches RAIL_WIDTH in the native rail.
+export const ANDROID_WORKSPACE_RAIL_WIDTH = 72;
interface NativeNavigationProps extends ViewProps {
- readonly selectedTab: WorkspaceTab;
+ readonly rail: boolean;
+ readonly selectedTab: AndroidWorkspaceNavigationTab;
readonly dark: boolean;
readonly textScale: number;
+ readonly newEnabled: boolean;
+ readonly safeAreaTop: number;
+ readonly safeAreaBottom: number;
+ readonly headerHeight: number;
readonly containerColor: number;
readonly selectedColor: number;
readonly indicatorColor: number;
readonly unselectedColor: number;
- readonly onTabSelected: (event: NativeSyntheticEvent<{ readonly tab: WorkspaceTab }>) => void;
+ readonly actionColor: number;
+ readonly actionContentColor: number;
+ readonly onTabSelected: (
+ event: NativeSyntheticEvent<{ readonly tab: AndroidWorkspaceNavigationTab }>,
+ ) => void;
+ readonly onNewThread: () => void;
+ readonly onOverlayChange: (event: NativeSyntheticEvent<{ readonly overlay: boolean }>) => void;
}
const NativeNavigation = requireNativeView<NativeNavigationProps>("T3WorkspaceNavigation");
@@ -35,36 +54,73 @@ function nativeColor(value: string) {
return typeof color === "number" ? color : 0;
}
-export function AndroidWorkspaceNavigation() {
+export function AndroidWorkspaceNavigation(props: {
+ readonly rail?: boolean;
+ readonly onSelect?: () => void;
+ /** The rail needs the whole workspace while it widens over the list. */
+ readonly onOverlayChange?: (overlay: boolean) => void;
+}) {
const workspace = useWorkspaceTabs()!;
+ const root = useAndroidWorkspaceRoot();
const navigation = useNavigation();
const insets = useSafeAreaInsets();
+ const toolbar = useToolbarLayout();
+ const connectionState = useWorkspaceConnectionState();
const keyboardVisible = useKeyboardState((state) => state.isVisible);
const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
const { scale } = useAndroidControlSizing();
+ const rail = Boolean(props.rail);
const { containerColor, indicatorColor, selectedColor, unselectedColor } =
- androidWorkspaceNavigationColors(colors);
- if (keyboardVisible) return null;
+ androidWorkspaceNavigationColors(colors, rail);
+ const selectedTab: AndroidWorkspaceNavigationTab = root?.settingsOpen
+ ? "settings"
+ : workspace.state.selectedTab;
+ if (!rail && keyboardVisible) return null;
return (
- <View style={{ backgroundColor: containerColor, paddingBottom: insets.bottom }}>
+ <View
+ style={
+ // The rail draws its own surface and pads the system bars; while open it spans the
+ // workspace, so the rest of it must stay transparent.
+ rail ? { flex: 1 } : { backgroundColor: containerColor, paddingBottom: insets.bottom }
+ }
+ >
<NativeNavigation
- selectedTab={workspace.state.selectedTab}
+ rail={rail}
+ selectedTab={selectedTab}
dark={themeAppearance === "dark"}
textScale={scale}
+ newEnabled={connectionState.hasConnections}
+ safeAreaTop={toolbar.paddingTop}
+ safeAreaBottom={insets.bottom}
+ headerHeight={toolbar.height}
containerColor={nativeColor(containerColor)}
selectedColor={nativeColor(selectedColor)}
indicatorColor={nativeColor(indicatorColor)}
unselectedColor={nativeColor(unselectedColor)}
+ actionColor={nativeColor(colors["--color-primary"])}
+ actionContentColor={nativeColor(colors["--color-primary-foreground"])}
onTabSelected={(event) => {
Keyboard.dismiss();
const tab = event.nativeEvent.tab;
- if (tab !== workspace.state.selectedTab) {
- workspace.dispatch({ type: "select", tab });
- resetAndroidWorkspace(navigation);
+ if (tab !== selectedTab) {
+ if (tab !== "settings") workspace.dispatch({ type: "select", tab });
+ // Reset the root stack even when a nested settings navigator has focus.
+ if (root) {
+ navigation.dispatch({
+ ...CommonActions.reset(androidWorkspaceTabNavigationState(root.getState(), tab)),
+ target: root.key,
+ });
+ }
}
+ props.onSelect?.();
+ }}
+ onNewThread={() => {
+ Keyboard.dismiss();
+ navigation.navigate("NewTaskSheet", { screen: "NewTask" });
}}
- style={{ height: 80 * Math.max(1, scale) }}
+ onOverlayChange={(event) => props.onOverlayChange?.(event.nativeEvent.overlay)}
+ style={rail ? { flex: 1 } : { height: 80 * Math.max(1, scale) }}
/>
</View>
);
diff --git a/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.tsx b/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.tsx
index 251dc977a9d..7d3bbd80e2e 100644
--- a/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.tsx
+++ b/apps/mobile/src/features/workspace/AndroidWorkspaceNavigation.tsx
@@ -1,3 +1,9 @@
-export function AndroidWorkspaceNavigation() {
+export function AndroidWorkspaceNavigation(_props: {
+ readonly rail?: boolean;
+ readonly onSelect?: () => void;
+ readonly onOverlayChange?: (overlay: boolean) => void;
+}) {
return null;
}
+
+export const ANDROID_WORKSPACE_RAIL_WIDTH = 72;
diff --git a/apps/mobile/src/features/workspace/AndroidWorkspaceSettings.tsx b/apps/mobile/src/features/workspace/AndroidWorkspaceSettings.tsx
new file mode 100644
index 00000000000..c246604a8d8
--- /dev/null
+++ b/apps/mobile/src/features/workspace/AndroidWorkspaceSettings.tsx
@@ -0,0 +1,20 @@
+import type { ReactNode } from "react";
+import { Platform, View } from "react-native";
+import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
+import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
+import { AndroidWorkspaceNavigation } from "./AndroidWorkspaceNavigation";
+
+/** Settings keeps its existing stack inside the full workspace, above compact navigation. */
+export function AndroidWorkspaceSettings(props: { readonly children: ReactNode }) {
+ const { layout } = useAdaptiveWorkspaceLayout();
+ const insets = useSafeAreaInsets();
+ if (Platform.OS !== "android") return props.children;
+ return (
+ <View className="flex-1 bg-header">
+ <SafeAreaInsetsContext value={layout.usesSplitView ? insets : { ...insets, bottom: 0 }}>
+ <View className="flex-1">{props.children}</View>
+ </SafeAreaInsetsContext>
+ {layout.usesSplitView ? null : <AndroidWorkspaceNavigation />}
+ </View>
+ );
+}
diff --git a/apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx b/apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
index f59d31037f6..498550d2a11 100644
--- a/apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
+++ b/apps/mobile/src/features/workspace/AndroidWorkspaceSidebar.android.tsx
@@ -1,9 +1,11 @@
import { useMemo, type ReactNode } from "react";
import { View } from "react-native";
import { ScreenContent } from "../../components/ui/ScreenContent";
+import { PullRequestFilterMenuProvider } from "../pull-requests/PullRequestFilterMenuContext";
import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
import { PullRequestToolbar } from "../pull-requests/PullRequestToolbar.android";
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
+import { WorkspaceTabPanes } from "./WorkspaceTabPanes";
export function AndroidWorkspaceSidebar(props: {
readonly children: ReactNode;
@@ -12,16 +14,29 @@ export function AndroidWorkspaceSidebar(props: {
}) {
const workspace = useWorkspaceTabs()!;
const context = useMemo(() => ({ ...workspace, bottomClearance: 16 }), [workspace]);
- return workspace.state.selectedTab === "threads" ? (
- props.children
- ) : (
- <WorkspaceTabsContext value={context}>
- <View className="flex-1 bg-header">
- <PullRequestToolbar sidebar onRequestVisibility={props.onRequestVisibility} />
- <ScreenContent insetHorizontal>
- <PullRequestsScreen sidebar selectedPullRequestKey={props.selectedPullRequestKey} />
- </ScreenContent>
- </View>
- </WorkspaceTabsContext>
+ return (
+ <WorkspaceTabPanes
+ tabs={["threads", "pullRequests"]}
+ selected={workspace.state.selectedTab}
+ renderTab={(tab) =>
+ tab === "threads" ? (
+ props.children
+ ) : (
+ <WorkspaceTabsContext value={context}>
+ <PullRequestFilterMenuProvider>
+ <View className="flex-1 bg-header">
+ <PullRequestToolbar onRequestVisibility={props.onRequestVisibility} />
+ <ScreenContent insetHorizontal>
+ <PullRequestsScreen
+ sidebar
+ selectedPullRequestKey={props.selectedPullRequestKey}
+ />
+ </ScreenContent>
+ </View>
+ </PullRequestFilterMenuProvider>
+ </WorkspaceTabsContext>
+ )
+ }
+ />
);
}
diff --git a/apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx b/apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx
index 6230fe28046..6b9c65a1a68 100644
--- a/apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx
+++ b/apps/mobile/src/features/workspace/AndroidWorkspaceTabsProvider.tsx
@@ -1,10 +1,54 @@
-import type { ReactNode } from "react";
+import type { NavigationState } from "@react-navigation/native";
+import {
+ createContext,
+ use,
+ useCallback,
+ useLayoutEffect,
+ useMemo,
+ useRef,
+ type ReactNode,
+} from "react";
import { Platform } from "react-native";
+import { androidWorkspaceSettingsOpen } from "./android-workspace-tabs";
import { WorkspaceTabsProvider } from "./WorkspaceTabsContext";
-export function AndroidWorkspaceTabsProvider(props: { readonly children: ReactNode }) {
+interface AndroidWorkspaceRoot {
+ /**
+ * The root stack's key and state. The rail renders in the root navigator's layout, where
+ * `useNavigation()` resolves to the container ref: its dispatch goes to the focused
+ * navigator and hands that navigator's state to a callback. A tab press from inside nested
+ * Settings must reset the root stack, so the rail reads the root state here and targets
+ * the root key.
+ */
+ readonly key: string;
+ readonly getState: () => NavigationState;
+ /** Settings is derived from navigation rather than kept in the tab reducer. */
+ readonly settingsOpen: boolean;
+}
+
+const AndroidWorkspaceRootContext = createContext<AndroidWorkspaceRoot | null>(null);
+
+export function useAndroidWorkspaceRoot() {
+ return use(AndroidWorkspaceRootContext);
+}
+
+/** Android keeps one tab controller above the root navigator and split sidebar. */
+export function AndroidWorkspaceTabsProvider(props: {
+ readonly state: NavigationState;
+ readonly children: ReactNode;
+}) {
+ const stateRef = useRef(props.state);
+ useLayoutEffect(() => {
+ stateRef.current = props.state;
+ }, [props.state]);
+ const getState = useCallback(() => stateRef.current, []);
+ const key = props.state.key;
+ const settingsOpen = Platform.OS === "android" && androidWorkspaceSettingsOpen(props.state);
+ const root = useMemo(() => ({ key, getState, settingsOpen }), [key, getState, settingsOpen]);
return Platform.OS === "android" ? (
- <WorkspaceTabsProvider>{props.children}</WorkspaceTabsProvider>
+ <WorkspaceTabsProvider>
+ <AndroidWorkspaceRootContext value={root}>{props.children}</AndroidWorkspaceRootContext>
+ </WorkspaceTabsProvider>
) : (
props.children
);
diff --git a/apps/mobile/src/features/workspace/WorkspaceListToolbarRow.tsx b/apps/mobile/src/features/workspace/WorkspaceListToolbarRow.tsx
new file mode 100644
index 00000000000..07515a8d712
--- /dev/null
+++ b/apps/mobile/src/features/workspace/WorkspaceListToolbarRow.tsx
@@ -0,0 +1,63 @@
+import type { ReactNode } from "react";
+import { View } from "react-native";
+import { AndroidHeaderIconButton } from "../../components/ui/AndroidScreenHeader";
+import { CompactBrandTitle } from "../../components/CompactBrandTitle";
+import { useToolbarLayout } from "../../components/ui/useToolbarLayout";
+import { WorkspaceConnectionTitle } from "../home/WorkspaceConnectionTitle";
+
+/**
+ * The Android header row above each workspace tab's list. Both tabs draw this same row, so
+ * switching tabs leaves the title and buttons where they were. It is plain React Native rather
+ * than the Compose app bar: a hidden tab lays out at zero size, and Compose-hosted content takes
+ * several frames to measure again when the tab comes back.
+ */
+export function WorkspaceListToolbarRow(props: {
+ readonly searching: boolean;
+ readonly searchField: ReactNode;
+ readonly onCloseSearch: () => void;
+ readonly onOpenSearch: () => void;
+ readonly searchAccessibilityLabel: string;
+ readonly titleAccessibilityLabel: string;
+ readonly onOpenEnvironments: () => void;
+ /** Stays trailing while searching, so it never moves and still narrows the results. */
+ readonly filter: ReactNode;
+}) {
+ const { height } = useToolbarLayout();
+ return (
+ <View className="flex-row items-center gap-1" style={{ minHeight: height }}>
+ {props.searching ? (
+ <>
+ <AndroidHeaderIconButton
+ accessibilityLabel="Close search"
+ icon="arrow.left"
+ onPress={props.onCloseSearch}
+ />
+ {props.searchField}
+ {props.filter}
+ </>
+ ) : (
+ <>
+ <View className="min-w-0 flex-1 pl-4">
+ <WorkspaceConnectionTitle
+ grow
+ onPress={props.onOpenEnvironments}
+ brand={
+ <CompactBrandTitle
+ allowFontScaling={false}
+ accessibilityLabel={props.titleAccessibilityLabel}
+ fit
+ />
+ }
+ />
+ </View>
+ <AndroidHeaderIconButton
+ accessibilityLabel={props.searchAccessibilityLabel}
+ icon="magnifyingglass"
+ onPress={props.onOpenSearch}
+ />
+ {props.filter}
+ </>
+ )}
+ </View>
+ );
+}
diff --git a/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx b/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
index 367ee3acbff..bbc8c62f983 100644
--- a/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
+++ b/apps/mobile/src/features/workspace/WorkspaceRootScreen.android.tsx
@@ -7,11 +7,16 @@ import { EmptyState } from "../../components/ui/EmptyState";
import { ScreenContent } from "../../components/ui/ScreenContent";
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
import { HomeRouteScreen } from "../home/HomeRouteScreen";
+import { PullRequestFilterMenuProvider } from "../pull-requests/PullRequestFilterMenuContext";
import { PullRequestsScreen } from "../pull-requests/PullRequestsScreen";
import { PullRequestToolbar } from "../pull-requests/PullRequestToolbar.android";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { AndroidWorkspaceNavigation } from "./AndroidWorkspaceNavigation";
import { WorkspaceTabsContext, useWorkspaceTabs } from "./WorkspaceTabsContext";
+import { WorkspaceTabPanes } from "./WorkspaceTabPanes";
+import type { WorkspaceTab } from "./workspace-tabs-state";
+
+const TABS: readonly WorkspaceTab[] = ["threads", "pullRequests"];
export function WorkspaceRootScreen() {
const { layout } = useAdaptiveWorkspaceLayout();
@@ -25,22 +30,31 @@ export function WorkspaceRootScreen() {
}),
[workspace, fabClearance],
);
+ const tab = workspace.state.selectedTab;
if (layout.usesSplitView) {
- return workspace.state.selectedTab === "threads" ? (
- <HomeRouteScreen />
- ) : (
- <>
- <NativeStackScreenOptions options={{ headerShown: false }} />
- <AndroidScreenHeader title="Pull requests" />
- <View className="flex-1 items-center justify-center px-10">
- <EmptyState
- title="Select a pull request"
- detail="Choose a pull request from the sidebar to review it."
- variant="plain"
- />
- </View>
- </>
+ return (
+ <WorkspaceTabPanes
+ tabs={TABS}
+ selected={tab}
+ renderTab={(tab) =>
+ tab === "threads" ? (
+ <HomeRouteScreen />
+ ) : (
+ <>
+ <NativeStackScreenOptions options={{ headerShown: false }} />
+ <AndroidScreenHeader title="Pull requests" />
+ <View className="flex-1 items-center justify-center px-10">
+ <EmptyState
+ title="Select a pull request"
+ detail="Choose a pull request from the sidebar to review it."
+ variant="plain"
+ />
+ </View>
+ </>
+ )
+ }
+ />
);
}
@@ -49,18 +63,22 @@ export function WorkspaceRootScreen() {
<View className="flex-1 bg-header">
<NativeStackScreenOptions options={{ headerShown: false }} />
<SafeAreaInsetsContext value={{ ...insets, bottom: 0 }}>
- <View className="flex-1">
- {workspace.state.selectedTab === "threads" ? (
- <HomeRouteScreen />
- ) : (
- <>
- <PullRequestToolbar />
- <ScreenContent>
- <PullRequestsScreen />
- </ScreenContent>
- </>
- )}
- </View>
+ <WorkspaceTabPanes
+ tabs={TABS}
+ selected={tab}
+ renderTab={(tab) =>
+ tab === "threads" ? (
+ <HomeRouteScreen />
+ ) : (
+ <PullRequestFilterMenuProvider>
+ <PullRequestToolbar />
+ <ScreenContent>
+ <PullRequestsScreen />
+ </ScreenContent>
+ </PullRequestFilterMenuProvider>
+ )
+ }
+ />
</SafeAreaInsetsContext>
<AndroidWorkspaceNavigation />
</View>
diff --git a/apps/mobile/src/features/workspace/WorkspaceTabPanes.tsx b/apps/mobile/src/features/workspace/WorkspaceTabPanes.tsx
new file mode 100644
index 00000000000..d4cc8c0c2ef
--- /dev/null
+++ b/apps/mobile/src/features/workspace/WorkspaceTabPanes.tsx
@@ -0,0 +1,26 @@
+import { Activity, useState, type ReactNode } from "react";
+import { View } from "react-native";
+
+/**
+ * Top-level tabs swap in a single frame. A tab mounts on its first visit and then stays mounted
+ * while hidden, so returning to it shows its list as it was left instead of an empty one that
+ * fills in. Hidden tabs keep their state but run no effects, so they register no keyboard
+ * commands, back handlers, or header options.
+ */
+export function WorkspaceTabPanes<Tab extends string>(props: {
+ readonly tabs: readonly Tab[];
+ readonly selected: Tab;
+ readonly renderTab: (tab: Tab) => ReactNode;
+}) {
+ const [visited, setVisited] = useState<readonly Tab[]>(() => [props.selected]);
+ if (!visited.includes(props.selected)) {
+ setVisited([...visited, props.selected]);
+ }
+ return props.tabs.map((tab) =>
+ visited.includes(tab) ? (
+ <Activity key={tab} mode={tab === props.selected ? "visible" : "hidden"}>
+ <View className="flex-1">{props.renderTab(tab)}</View>
+ </Activity>
+ ) : null,
+ );
+}
diff --git a/apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx b/apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx
index 7e6c2cb5911..863701444d0 100644
--- a/apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx
+++ b/apps/mobile/src/features/workspace/WorkspaceTabsContext.tsx
@@ -17,11 +17,6 @@ import {
type WorkspaceTabsState,
} from "./workspace-tabs-state";
-export interface WorkspaceScrollAnchor {
- readonly key: string;
- readonly viewOffset: number;
-}
-
export const WorkspaceTabsContext = createContext<{
readonly state: WorkspaceTabsState;
readonly dispatch: Dispatch<WorkspaceTabsAction>;
@@ -29,8 +24,6 @@ export const WorkspaceTabsContext = createContext<{
readonly bottomClearance: number;
readonly getScrollOffset: (tab: WorkspaceTab) => number;
readonly recordScrollOffset: (tab: WorkspaceTab, offset: number) => void;
- readonly getScrollAnchor: (tab: WorkspaceTab) => WorkspaceScrollAnchor | undefined;
- readonly recordScrollAnchor: (tab: WorkspaceTab, anchor: WorkspaceScrollAnchor) => void;
} | null>(null);
export function useWorkspaceTabs() {
@@ -45,15 +38,10 @@ export function WorkspaceTabsProvider(props: { readonly children: ReactNode }) {
}, [state.selectedTab]);
const isTabActive = useCallback((tab: WorkspaceTab) => activeTab.current === tab, []);
const scrollOffsets = useRef({ threads: 0, pullRequests: 0 });
- const scrollAnchors = useRef<Partial<Record<WorkspaceTab, WorkspaceScrollAnchor>>>({});
const getScrollOffset = useCallback((tab: WorkspaceTab) => scrollOffsets.current[tab], []);
const recordScrollOffset = useCallback((tab: WorkspaceTab, offset: number) => {
scrollOffsets.current[tab] = offset;
}, []);
- const getScrollAnchor = useCallback((tab: WorkspaceTab) => scrollAnchors.current[tab], []);
- const recordScrollAnchor = useCallback((tab: WorkspaceTab, anchor: WorkspaceScrollAnchor) => {
- scrollAnchors.current[tab] = anchor;
- }, []);
const context = useMemo(
() => ({
state,
@@ -62,10 +50,8 @@ export function WorkspaceTabsProvider(props: { readonly children: ReactNode }) {
bottomClearance: 0,
getScrollOffset,
recordScrollOffset,
- getScrollAnchor,
- recordScrollAnchor,
}),
- [state, isTabActive, getScrollOffset, recordScrollOffset, getScrollAnchor, recordScrollAnchor],
+ [state, isTabActive, getScrollOffset, recordScrollOffset],
);
return <WorkspaceTabsContext value={context}>{props.children}</WorkspaceTabsContext>;
}
diff --git a/apps/mobile/src/features/workspace/android-workspace-navigation-colors.test.ts b/apps/mobile/src/features/workspace/android-workspace-navigation-colors.test.ts
index 00418107c95..efdf234e6c9 100644
--- a/apps/mobile/src/features/workspace/android-workspace-navigation-colors.test.ts
+++ b/apps/mobile/src/features/workspace/android-workspace-navigation-colors.test.ts
@@ -34,14 +34,19 @@ function expectVisibleSelection(colors: ReturnType<typeof androidWorkspaceNaviga
}
describe("Android workspace navigation colors", () => {
- it.each(MOBILE_THEME_IDS)("keeps %s selection visible", (themeId) => {
- for (const appearance of ["light", "dark"] as const) {
- const variables = getMobileThemeRuntimeVariables(themeId, appearance, "android");
- const snapshot = { ...variables };
- expectVisibleSelection(androidWorkspaceNavigationColors(variables));
- expect(variables).toEqual(snapshot);
- }
- });
+ it.each(MOBILE_THEME_IDS)(
+ "keeps %s selection visible in both navigation positions",
+ (themeId) => {
+ for (const appearance of ["light", "dark"] as const) {
+ const variables = getMobileThemeRuntimeVariables(themeId, appearance, "android");
+ const snapshot = { ...variables };
+ for (const rail of [false, true]) {
+ expectVisibleSelection(androidWorkspaceNavigationColors(variables, rail));
+ }
+ expect(variables).toEqual(snapshot);
+ }
+ },
+ );
it.each(["#6750a4", "#006a6a", "#9c4146"])(
"keeps Material You selection visible for system seed %s",
@@ -85,17 +90,19 @@ describe("Android workspace navigation colors", () => {
appearance,
getMobileThemeRuntimeVariables("material-you", appearance, "android"),
);
- expectVisibleSelection(androidWorkspaceNavigationColors(variables));
+ for (const rail of [false, true]) {
+ expectVisibleSelection(androidWorkspaceNavigationColors(variables, rail));
+ }
}
},
);
it("preserves an already visible tonal fill", () => {
const variables = getMobileThemeRuntimeVariables("t3-chat", "light", "android");
- const colors = androidWorkspaceNavigationColors({
- ...variables,
- "--color-secondary": "#e091cf",
- });
+ const colors = androidWorkspaceNavigationColors(
+ { ...variables, "--color-secondary": "#e091cf" },
+ true,
+ );
expect(colors.indicatorColor).toBe("#e091cf");
expectVisibleSelection(colors);
});
diff --git a/apps/mobile/src/features/workspace/android-workspace-navigation-colors.ts b/apps/mobile/src/features/workspace/android-workspace-navigation-colors.ts
index efcade30fbe..774f20aad8b 100644
--- a/apps/mobile/src/features/workspace/android-workspace-navigation-colors.ts
+++ b/apps/mobile/src/features/workspace/android-workspace-navigation-colors.ts
@@ -5,12 +5,11 @@ import {
type MobileThemeVariables,
} from "../../lib/mobileTheme";
-export function androidWorkspaceNavigationColors(colors: MobileThemeVariables) {
+export function androidWorkspaceNavigationColors(colors: MobileThemeVariables, rail: boolean) {
const header = flattenThemeColor(colors["--color-header"], colors["--color-screen"]);
- const containerColor = flattenThemeColor(
- themeColorWithAlpha(colors["--color-header-foreground"], 0.05),
- header,
- );
+ const containerColor = rail
+ ? header
+ : flattenThemeColor(themeColorWithAlpha(colors["--color-header-foreground"], 0.05), header);
const indicatorColor = themeColorWithContrast(
flattenThemeColor(colors["--color-secondary"], containerColor),
containerColor,
diff --git a/apps/mobile/src/features/workspace/android-workspace-tabs.ts b/apps/mobile/src/features/workspace/android-workspace-tabs.ts
new file mode 100644
index 00000000000..999838f52dc
--- /dev/null
+++ b/apps/mobile/src/features/workspace/android-workspace-tabs.ts
@@ -0,0 +1,47 @@
+import type { NavigationState } from "@react-navigation/native";
+import { androidWorkspaceNavigationState } from "../../lib/android-workspace-navigation";
+import type { WorkspaceTab } from "./workspace-tabs-state";
+
+/** Settings joins the two list tabs as a top-level Android destination. */
+export type AndroidWorkspaceNavigationTab = WorkspaceTab | "settings";
+
+const WORKSPACE_ROUTES = new Set(["Home", "Thread", "PullRequest", "SettingsSheet"]);
+
+/**
+ * The Settings tab reuses the settings navigator, reset over Home alone so stale chat and
+ * PR history is dropped while nested settings pages keep an ordinary Back.
+ */
+export function androidWorkspaceTabNavigationState(
+ state: NavigationState,
+ tab: AndroidWorkspaceNavigationTab,
+) {
+ const home = androidWorkspaceNavigationState(state);
+ if (tab !== "settings") return home;
+ return {
+ ...home,
+ index: 1,
+ routes: [
+ ...home.routes,
+ {
+ name: "SettingsSheet",
+ params: { screen: "SettingsContent", params: { screen: "Settings" } },
+ },
+ ],
+ };
+}
+
+/** Settings stays selected while its navigator is the topmost workspace route. */
+export function androidWorkspaceSettingsOpen(state: NavigationState): boolean {
+ const top = state.routes
+ .slice(0, state.index + 1)
+ .findLast((route) => WORKSPACE_ROUTES.has(route.name));
+ return top?.name === "SettingsSheet";
+}
+
+export function androidWorkspaceTabFromNavigationState(
+ state: NavigationState,
+ selected: AndroidWorkspaceNavigationTab,
+): AndroidWorkspaceNavigationTab {
+ if (androidWorkspaceSettingsOpen(state)) return "settings";
+ return selected === "settings" ? "threads" : selected;
+}
diff --git a/apps/mobile/src/lib/android-workspace-navigation.test.ts b/apps/mobile/src/lib/android-workspace-navigation.test.ts
index 68f3732acab..724eec15809 100644
--- a/apps/mobile/src/lib/android-workspace-navigation.test.ts
+++ b/apps/mobile/src/lib/android-workspace-navigation.test.ts
@@ -1,5 +1,10 @@
import * as NodeModule from "node:module";
import { describe, expect, it } from "vite-plus/test";
+import {
+ androidWorkspaceTabFromNavigationState,
+ androidWorkspaceTabNavigationState,
+ type AndroidWorkspaceNavigationTab,
+} from "../features/workspace/android-workspace-tabs";
import {
androidWorkspaceNavigationState,
resetAndroidWorkspace,
@@ -229,3 +234,53 @@ describe("Android workspace navigation", () => {
expect(names(apply(root, action!))).toEqual(["Home", "Thread"]);
});
});
+
+describe("Android Settings tab", () => {
+ type State = ReturnType<typeof router.getInitialState>;
+ type Tab = AndroidWorkspaceNavigationTab;
+ const openTab = (state: State, tab: Tab) =>
+ apply(state, CommonActions.reset(androidWorkspaceTabNavigationState(state, tab)));
+ const selectedTab = (state: State, previous: Tab) =>
+ androidWorkspaceTabFromNavigationState(state, previous);
+
+ it("opens over Home alone, dropping chat and PR history, and Back returns to Home", () => {
+ const previous = legacyHistory();
+ const settings = openTab(previous, "settings");
+ expect(names(settings)).toEqual(["Home", "SettingsSheet"]);
+ expect(settings.routes[0]?.key).toBe(previous.routes[0]?.key);
+ expect(selectedTab(settings, "threads")).toBe("settings");
+ const back = apply(settings, StackActions.pop());
+ expect(names(back)).toEqual(["Home"]);
+ expect(back.routes[0]?.key).toBe(previous.routes[0]?.key);
+ expect(selectedTab(back, "settings")).not.toBe("settings");
+ });
+
+ it("stays selected under a nested settings page until a list tab returns to Home", () => {
+ const previous = legacyHistory();
+ const settings = openTab(previous, "settings");
+ // Usage pushes inside the nested settings navigator, which the root router never sees.
+ const usage: State = {
+ ...settings,
+ routes: settings.routes.map((route) =>
+ route.name === "SettingsSheet"
+ ? {
+ ...route,
+ state: {
+ routes: [
+ {
+ name: "SettingsContent",
+ state: { index: 1, routes: [{ name: "Settings" }, { name: "SettingsUsage" }] },
+ },
+ ],
+ },
+ }
+ : route,
+ ),
+ };
+ expect(selectedTab(usage, "threads")).toBe("settings");
+ const list = openTab(usage, "pullRequests");
+ expect(names(list)).toEqual(["Home"]);
+ expect(list.routes[0]?.key).toBe(previous.routes[0]?.key);
+ expect(selectedTab(list, "pullRequests")).toBe("pullRequests");
+ });
+});
diff --git a/apps/mobile/src/lib/layout.test.ts b/apps/mobile/src/lib/layout.test.ts
index 47f225012bf..52415e79974 100644
--- a/apps/mobile/src/lib/layout.test.ts
+++ b/apps/mobile/src/lib/layout.test.ts
@@ -420,15 +420,30 @@ describe("deriveWorkspacePaneLayout", () => {
describe("alignListPaneToHinge", () => {
const layout = deriveLayout({ width: 852, height: 880 });
- it("ends the list pane at a book-posture hinge", () => {
+ it("ends the list pane at a book-posture hinge after the rail", () => {
expect(
- alignListPaneToHinge({ layout, hinge: { x: 426, width: 0 }, viewportWidth: 852 }),
- ).toMatchObject({ listPaneWidth: 426, listPaneGap: 0 });
+ alignListPaneToHinge({
+ layout,
+ hinge: { x: 426, width: 0 },
+ viewportWidth: 852,
+ leadingWidth: 96,
+ }),
+ ).toMatchObject({ listPaneWidth: 330, listPaneGap: 0 });
});
it("keeps the default split when either side of the hinge would be too narrow", () => {
- const narrowList = { layout, hinge: { x: 250, width: 0 }, viewportWidth: 852 };
- const narrowDetail = { layout, hinge: { x: 600, width: 0 }, viewportWidth: 852 };
+ const narrowList = {
+ layout,
+ hinge: { x: 300, width: 0 },
+ viewportWidth: 852,
+ leadingWidth: 96,
+ };
+ const narrowDetail = {
+ layout,
+ hinge: { x: 600, width: 0 },
+ viewportWidth: 852,
+ leadingWidth: 0,
+ };
expect(alignListPaneToHinge(narrowList)).toBe(layout);
expect(alignListPaneToHinge(narrowDetail)).toBe(layout);
});
diff --git a/apps/mobile/src/lib/layout.ts b/apps/mobile/src/lib/layout.ts
index f3d4c40c2c3..8b1e344826e 100644
--- a/apps/mobile/src/lib/layout.ts
+++ b/apps/mobile/src/lib/layout.ts
@@ -139,18 +139,26 @@ export interface VerticalHinge {
readonly width: number;
}
-/** Moves the list/detail split onto a book-posture hinge so neither pane straddles the crease. */
+/**
+ * Moves the list/detail split onto a book-posture hinge so neither pane straddles the crease.
+ * `leadingWidth` is chrome left of the list pane, such as the Android navigation rail.
+ */
export function alignListPaneToHinge(input: {
readonly layout: Layout;
readonly hinge: VerticalHinge | null;
readonly viewportWidth: number;
+ readonly leadingWidth: number;
}): Layout {
const { layout, hinge } = input;
if (!hinge || !layout.usesSplitView) return layout;
- if (hinge.x < SPLIT_SIDEBAR_MIN_WIDTH || input.viewportWidth - hinge.x - hinge.width < 320) {
+ const listPaneWidth = hinge.x - input.leadingWidth;
+ if (
+ listPaneWidth < SPLIT_SIDEBAR_MIN_WIDTH ||
+ input.viewportWidth - hinge.x - hinge.width < 320
+ ) {
return layout;
}
- return { ...layout, listPaneWidth: hinge.x, listPaneGap: hinge.width };
+ return { ...layout, listPaneWidth, listPaneGap: hinge.width };
}
/**
diff --git a/docs/operations/mobile-screens-fork.md b/docs/operations/mobile-screens-fork.md
index f9da54a93ab..db92950963c 100644
--- a/docs/operations/mobile-screens-fork.md
+++ b/docs/operations/mobile-screens-fork.md
@@ -1,7 +1,7 @@
# Building the mobile Screens dependency
The mobile v5 stack uses a committed tarball from the
-[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.27).
+[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.29).
The fork owns the integration changes; the app does not patch this package.
Each archive includes compiled JavaScript, declarations, native source and
`t3-fork.json` recording its version, source commit and upstream base.
diff --git a/patches/[email protected] b/patches/[email protected]
new file mode 100644
index 00000000000..af01af2df0b
--- /dev/null
+++ b/patches/[email protected]
@@ -0,0 +1,42 @@
+diff --git a/android/src/main/java/expo/modules/kotlin/views/ExpoView.kt b/android/src/main/java/expo/modules/kotlin/views/ExpoView.kt
+index c732ab4..2e3f40e 100644
+--- a/android/src/main/java/expo/modules/kotlin/views/ExpoView.kt
++++ b/android/src/main/java/expo/modules/kotlin/views/ExpoView.kt
+@@ -3,6 +3,7 @@ package expo.modules.kotlin.views
+ import android.content.Context
+ import android.graphics.Canvas
+ import android.widget.LinearLayout
++import androidx.core.view.OneShotPreDrawListener
+ import androidx.annotation.UiThread
+ import com.facebook.react.uimanager.BackgroundStyleApplicator
+ import com.facebook.react.uimanager.StateWrapper
+@@ -47,12 +48,27 @@ abstract class ExpoView(
+ layout(left, top, right, bottom)
+ }
+
++ private var isLayoutScheduled = false
++
+ override fun requestLayout() {
+ super.requestLayout()
+- if (shouldUseAndroidLayout) {
++ if (shouldUseAndroidLayout && !isLayoutScheduled) {
+ // We need to force measure and layout, because React Native doesn't do it for us.
+- post { measureAndLayout() }
++ // A posted layout runs after the frame being prepared is drawn, so a view that changes in a
++ // mount would show unlaid-out content for a frame. The pre-draw listener lays it out before
++ // that frame instead; the post covers a request that no frame follows.
++ isLayoutScheduled = true
++ OneShotPreDrawListener.add(this) { runScheduledLayout() }
++ post { runScheduledLayout() }
++ }
++ }
++
++ private fun runScheduledLayout() {
++ if (!isLayoutScheduled) {
++ return
+ }
++ isLayoutScheduled = false
++ measureAndLayout()
+ }
+
+ override fun forceLayout() {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c689f1e4ab6..ed2566a4e22 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -177,6 +177,7 @@ patchedDependencies:
[email protected]: bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd
[email protected]: cfff57561b0ee59b5addb3b2e6c6f20906e967507a530ab67e8db8108e520ba4
[email protected]: 2c2f8c73a23d48804c8b537b8cd73c25eb331aa47d82eaa481c6766cb81e5add
+ [email protected]: f0b0fd100550ed76e5c25b4d13eb7c9ff62825f8f197c53edf7bf447c50c9fb7
[email protected]: cd09b6d1744dde4efa081b5619ebcff38877d98f7502a51cab121629dece8237
[email protected]: ad248759641ddd71b8331c09dbb3b18c8a551785f2df507533805babd3c0c124
[email protected]: 8623cb034b720c5ef2da8012c765805a7298909bd92eaf8381f64dbde41b77dd
@@ -375,7 +376,7 @@ importers:
'@react-navigation/native-stack':
specifier: 7.21.0
- version: 7.21.0(patch_hash=caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e)(f7bd434a41a50f5d33209f0baf5b709c)
+ version: 7.21.0(patch_hash=caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e)(6f7595467acac269803072e24b2c2fee)
'@shikijs/core':
specifier: 4.2.0
version: 4.2.0
@@ -587,8 +588,8 @@ importers:
specifier: ~5.10.1
react-native-screens:
- specifier: file:deps/react-native-screens-5.0.0-t3.27.tgz
+ specifier: file:deps/react-native-screens-5.0.0-t3.29.tgz
react-native-shiki-engine:
specifier: ^0.3.12
@@ -11258,9 +11259,9 @@ packages:
react: '*'
react-native: '*'
- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.27.tgz:
- resolution: {integrity: sha512-krNMVmduM2fXeJYveadSz6NkYI/AFN3hAAirjk42Z9wkBrPtuhmcp3E2+Me95Xdj5LBL3G3dgltUjo5vYeEtLw==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.27.tgz}
- version: 5.0.0-t3.27
+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz:
+ resolution: {integrity: sha512-Y5gaQmd/p1SOeCh7Esyaj1DEycDJ7XFNUdXS1ZDOsuwF5yK1h8yu4H4tCw6mKDrSVV8bNPBYhf4qs5/AaNe3zQ==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz}
+ version: 5.0.0-t3.29
peerDependencies:
react: '*'
react-native: '*'
@@ -16464,7 +16465,7 @@ snapshots:
optionalDependencies:
- '@react-navigation/[email protected](patch_hash=caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e)(f7bd434a41a50f5d33209f0baf5b709c)':
+ '@react-navigation/[email protected](patch_hash=caae6552051bce91a85f567f3a08f9c8d25ce4c53f65a9391a67f016bb1d798e)(6f7595467acac269803072e24b2c2fee)':
dependencies:
'@react-navigation/elements': 2.9.45(da16e244bd876bd7d4e1e8899c8eabfd)
@@ -16472,7 +16473,7 @@ snapshots:
react: 19.3.0
- react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.27.tgz([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
+ react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
sf-symbols-typescript: 2.2.0
warn-once: 0.1.1
transitivePeerDependencies:
@@ -19761,7 +19762,7 @@ snapshots:
- supports-color
- typescript
dependencies:
expo-modules-macros: 0.20.0
@@ -19942,7 +19943,7 @@ snapshots:
expo-keep-awake: 58.0.3([email protected])([email protected])
expo-modules-autolinking: 58.0.13([email protected])
pretty-format: 29.7.0
react: 19.3.0
@@ -22639,7 +22640,7 @@ snapshots:
react: 19.3.0
- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.27.tgz([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.29.tgz([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
dependencies:
react: 19.3.0
react-freeze: 1.0.4([email protected])
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 73827916a40..ac0a089fb95 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -345,6 +345,9 @@ patchedDependencies:
# Android: a nested WebView hands a vertical drag to its scrolling parent at the page's edge.
+ # Android: a Compose host that requests layout in a mount (a new screen's app bar) is laid out
+ # before that frame is drawn, instead of a frame later.
# Android: Maven-resolved gradle plugins (expo-widgets) have no sourceDir; without this
# skip, the fingerprint silently drops every Expo native module and OTAs reach stale binaries.