Skip to content

Commit 8fdaf34

Browse files
fix(mobile): Settings split view keeps its selection and its header matches the page (pingdotgg#24644)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent e666c01 commit 8fdaf34

3 files changed

Lines changed: 37 additions & 15 deletions

File tree

‎apps/mobile/src/components/ui/ScreenScrollView.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import { createContext, use, type ComponentProps } from "react";
22
import { Platform } from "react-native";
3+
import { cn } from "../../lib/cn";
34
import { NativeScrollView as ScrollView } from "../../native/NativeScrollViewMarker";
45

56
export const ScreenScrollViewBottomInset = createContext(0);
7+
/**
8+
* The screen's surface class. UIKit's scroll-edge material under the header takes the scroll
9+
* view's own color; a clear scroll view gets the system's near-white bar over the screen's surface.
10+
*/
11+
export const ScreenScrollViewSurface = createContext<string | undefined>(undefined);
612

713
export function ScreenScrollView(props: ComponentProps<typeof ScrollView>) {
814
const bottomInset = use(ScreenScrollViewBottomInset);
15+
const surface = use(ScreenScrollViewSurface);
916
return (
1017
<ScrollView
1118
{...props}
19+
className={Platform.OS === "ios" && surface ? cn(surface, props.className) : props.className}
1220
contentInset={
1321
Platform.OS === "ios" && bottomInset > 0
1422
? { ...props.contentInset, bottom: (props.contentInset?.bottom ?? 0) + bottomInset }

‎apps/mobile/src/features/settings/SettingsRouteScreen.tsx‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
useNavigationTabOrder,
99
useHiddenNavigationTabs,
1010
} from "../workspace/navigation-tabs";
11+
import { currentWorkspaceSelections } from "../workspace/workspace-selection-store";
12+
import { rememberedSettingsPage } from "../workspace/workspace-tab-navigation";
1113
import { useSelectWorkspaceTab } from "../workspace/useSelectWorkspaceTab";
1214
import {
1315
ScreenScrollView as ScrollView,
@@ -42,10 +44,14 @@ export function SettingsRouteScreen() {
4244
const compactTabs = useCompactWorkspaceTabs();
4345
const { layout } = useAdaptiveWorkspaceLayout();
4446
const inSidebar = use(NativePrimaryColumnContext) !== null && layout.usesSplitView;
45-
// The page open beside the list: the route right above the Settings tab's route.
47+
// The page open beside the list: the route right above the Settings tab's route. While
48+
// another tab is open this list stays mounted, hidden, and must keep showing the page Settings
49+
// reopens on; otherwise returning shows it unselected for a frame before the page arrives.
4650
const selected = useNavigationState((state) => {
4751
const list = state.routes.findIndex((route) => route.name === "Settings");
48-
return list < 0 ? null : (state.routes[list + 1]?.name ?? null);
52+
return list < 0
53+
? rememberedSettingsPage(currentWorkspaceSelections())
54+
: (state.routes[list + 1]?.name ?? null);
4955
});
5056
const sidebar = useMemo(() => (inSidebar ? { selected } : null), [inSidebar, selected]);
5157
const content = hasCloudPublicConfig() ? (
@@ -56,7 +62,7 @@ export function SettingsRouteScreen() {
5662

5763
return (
5864
<SettingsSidebarContext value={sidebar}>
59-
<View className={`flex-1 ${surface.className}`}>
65+
<View className={`flex-1 ${inSidebar ? surface.className : "bg-screen"}`}>
6066
<SettingsEnvironmentFilterHeader />
6167
<ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
6268
{Platform.OS === "android" ? (
@@ -75,7 +81,8 @@ export function SettingsRouteScreen() {
7581
function ConfiguredSettingsRouteScreen() {
7682
// UIKit's scroll-edge material takes the scroll view's own color; like the chat list, match
7783
// the sidebar's surface so the bar doesn't darken over content at rest.
78-
const listSurface = use(NativePrimaryColumnContext) ? "bg-drawer" : "bg-screen";
84+
// Grouped cards only lift off the screen surface; the drawer is as dark as they are.
85+
const listSurface = use(SettingsSidebarContext) ? "bg-drawer" : "bg-screen";
7986
const insets = useSafeAreaInsets();
8087
const navigation = useNavigation();
8188
const { isLoaded, isSignedIn } = useAuth({ treatPendingAsSignedOut: false });
@@ -124,7 +131,8 @@ function ConfiguredSettingsRouteScreen() {
124131
function LocalSettingsRouteScreen() {
125132
// UIKit's scroll-edge material takes the scroll view's own color; like the chat list, match
126133
// the sidebar's surface so the bar doesn't darken over content at rest.
127-
const listSurface = use(NativePrimaryColumnContext) ? "bg-drawer" : "bg-screen";
134+
// Grouped cards only lift off the screen surface; the drawer is as dark as they are.
135+
const listSurface = use(SettingsSidebarContext) ? "bg-drawer" : "bg-screen";
128136
const insets = useSafeAreaInsets();
129137
const { savedConnectionsById } = useSavedRemoteConnections();
130138
const environmentCount = Object.keys(savedConnectionsById).length;

‎apps/mobile/src/features/settings/components/SettingsScreen.tsx‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import { useWorkspaceTabs } from "../../workspace/WorkspaceTabsContext";
99
import { useWorkspaceSurface } from "../../workspace/useWorkspaceSurface";
1010
import { useDeviceType } from "../../../native/native-layout-metrics";
1111
import { useCompactWorkspaceTabs } from "../../workspace/useSystemWorkspaceTabBar";
12-
import { ScreenScrollViewBottomInset } from "../../../components/ui/ScreenScrollView";
12+
import {
13+
ScreenScrollViewBottomInset,
14+
ScreenScrollViewSurface,
15+
} from "../../../components/ui/ScreenScrollView";
1316

1417
export { SettingsScreenContent };
1518

@@ -32,11 +35,12 @@ export function SettingsScreen(
3235
props.workspaceRoot ||
3336
(Platform.OS === "android" && workspace !== null && route.name === "Settings");
3437

38+
// Settings' grouped cards only lift off the screen surface, so the folded Duo doesn't take
39+
// the workspace's drawer surface here.
40+
const surfaceClassName = cover ? "bg-screen" : workspaceRoot ? surface.className : "bg-sheet";
41+
3542
return (
36-
<View
37-
collapsable={false}
38-
className={`flex-1 ${workspaceRoot || cover ? surface.className : "bg-sheet"}`}
39-
>
43+
<View collapsable={false} className={`flex-1 ${surfaceClassName}`}>
4044
<AppBar
4145
title={props.title}
4246
actions={props.actions}
@@ -46,11 +50,13 @@ export function SettingsScreen(
4650
hideBottomBorder={!props.formSheet}
4751
/>
4852
<ScreenScrollViewBottomInset value={deviceType === "pad" || compactTabs ? 80 : 0}>
49-
{props.formSheet ? (
50-
props.children
51-
) : (
52-
<SettingsScreenContent>{props.children}</SettingsScreenContent>
53-
)}
53+
<ScreenScrollViewSurface value={surfaceClassName}>
54+
{props.formSheet ? (
55+
props.children
56+
) : (
57+
<SettingsScreenContent>{props.children}</SettingsScreenContent>
58+
)}
59+
</ScreenScrollViewSurface>
5460
</ScreenScrollViewBottomInset>
5561
</View>
5662
);

0 commit comments

Comments
 (0)