Skip to content

Commit 574c5d8

Browse files
committed
fix(mobile): preserve iOS scrollfade with branding
1 parent 33ea6b1 commit 574c5d8

4 files changed

Lines changed: 60 additions & 13 deletions

File tree

‎apps/mobile/src/Stack.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { DynamicColorIOS, Platform, Pressable, ScrollView, StyleSheet } from "re
1515
import { useResolveClassNames } from "uniwind";
1616

1717
import { AppText as Text } from "./components/AppText";
18-
import { renderCompactBrandTitle } from "./components/CompactBrandTitle";
18+
import { getCompactBrandHeaderOptions } from "./components/CompactBrandTitle";
1919
import { ArchivedThreadsRouteScreen } from "./features/archive/ArchivedThreadsRouteScreen";
2020
import { useAgentNotificationNavigation } from "./features/agent-awareness/notificationNavigation";
2121
import { ClerkSettingsSheetDetentProvider } from "./features/cloud/ClerkSettingsSheetDetent";
@@ -384,8 +384,7 @@ export const RootStack = createNativeStackNavigator({
384384
...GLASS_HEADER_OPTIONS,
385385
contentStyle: { backgroundColor: "transparent" },
386386
headerBackVisible: false,
387-
headerTitle: renderCompactBrandTitle,
388-
title: "Threads",
387+
...getCompactBrandHeaderOptions(),
389388
},
390389
}),
391390
Thread: createNativeStackScreen({

‎apps/mobile/src/components/CompactBrandTitle.tsx‎

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
11
import Constants from "expo-constants";
2+
import type {
3+
NativeStackHeaderItem,
4+
NativeStackNavigationOptions,
5+
} from "@react-navigation/native-stack";
26
import { Platform, View } from "react-native";
37

48
import { AppText as Text } from "./AppText";
59
import { T3Wordmark } from "./T3Wordmark";
610
import { IPAD_HOME_TITLE_OFFSET } from "../lib/layoutMetrics";
711
import { resolveMobileStageLabel } from "../lib/mobileBranding";
812
import { useThemeColor } from "../lib/useThemeColor";
13+
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../native/native-glass";
14+
15+
// Native leading items inherit different UIKit margins than title views.
16+
const IOS_NATIVE_LEADING_TITLE_OFFSET = -6;
17+
const IPAD_NATIVE_LEADING_TITLE_OFFSET = 7;
918

1019
/**
1120
* Compact brand lockup sized for native navigation bars.
1221
*/
13-
export function CompactBrandTitle() {
22+
export function CompactBrandTitle(
23+
props: {
24+
readonly nativeLeadingItem?: boolean;
25+
} = {},
26+
) {
1427
const iconColor = useThemeColor("--color-icon");
1528
const mutedColor = useThemeColor("--color-foreground-muted");
1629
const subtleColor = useThemeColor("--color-subtle");
1730
const stageLabel = resolveMobileStageLabel(Constants.expoConfig?.extra?.appVariant);
31+
const titleOffset =
32+
Platform.OS !== "ios"
33+
? 0
34+
: props.nativeLeadingItem
35+
? Platform.isPad
36+
? IPAD_NATIVE_LEADING_TITLE_OFFSET
37+
: IOS_NATIVE_LEADING_TITLE_OFFSET
38+
: Platform.isPad
39+
? IPAD_HOME_TITLE_OFFSET
40+
: 0;
1841

1942
return (
2043
<View
@@ -26,7 +49,7 @@ export function CompactBrandTitle() {
2649
alignItems: "center",
2750
flexDirection: "row",
2851
gap: 6,
29-
marginLeft: Platform.OS === "ios" && Platform.isPad ? IPAD_HOME_TITLE_OFFSET : 0,
52+
marginLeft: titleOffset,
3053
}}
3154
>
3255
<T3Wordmark color={iconColor} height={15} />
@@ -67,3 +90,32 @@ export function CompactBrandTitle() {
6790
export function renderCompactBrandTitle() {
6891
return <CompactBrandTitle />;
6992
}
93+
94+
export function renderCompactBrandHeaderItems(): NativeStackHeaderItem[] {
95+
return [
96+
{
97+
element: <CompactBrandTitle nativeLeadingItem />,
98+
hidesSharedBackground: true,
99+
type: "custom",
100+
},
101+
];
102+
}
103+
104+
export function getCompactBrandHeaderOptions(
105+
fallbackTitleStyle?: NativeStackNavigationOptions["headerTitleStyle"],
106+
): NativeStackNavigationOptions {
107+
if (Platform.OS === "ios" && NATIVE_LIQUID_GLASS_SUPPORTED) {
108+
return {
109+
headerTitle: "Threads",
110+
headerTitleStyle: { color: "transparent", fontSize: 18, fontWeight: "800" },
111+
title: "Threads",
112+
unstable_headerLeftItems: renderCompactBrandHeaderItems,
113+
};
114+
}
115+
116+
return {
117+
headerTitle: renderCompactBrandTitle,
118+
headerTitleStyle: fallbackTitleStyle,
119+
title: "Threads",
120+
};
121+
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as Order from "effect/Order";
33
import { useNavigation } from "@react-navigation/native";
44
import { useEffect, useMemo, useState } from "react";
55

6-
import { renderCompactBrandTitle } from "../../components/CompactBrandTitle";
6+
import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";
77
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
88
import { useProjects, useThreadShells } from "../../state/entities";
99
import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
@@ -109,9 +109,7 @@ export function HomeRouteScreen() {
109109
>
110110
<>
111111
{/* Restore the compact title after the split branch blanks the detail header. */}
112-
<NativeStackScreenOptions
113-
options={{ title: "Threads", headerTitle: renderCompactBrandTitle }}
114-
/>
112+
<NativeStackScreenOptions options={getCompactBrandHeaderOptions()} />
115113
<HomeHeader
116114
environments={environments}
117115
projects={projectFilterOptions}

‎apps/mobile/src/features/threads/sidebar-navigation-shell.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import type { ReactNode } from "react";
1212
import { Platform, useColorScheme } from "react-native";
1313

14-
import { renderCompactBrandTitle } from "../../components/CompactBrandTitle";
14+
import { getCompactBrandHeaderOptions } from "../../components/CompactBrandTitle";
1515
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
1616
import { nativeHeaderScrollEdgeEffects } from "../../native/StackHeader";
1717

@@ -36,11 +36,9 @@ const SIDEBAR_SCREEN_OPTIONS: SidebarScreenOptions = {
3636
headerShadowVisible: false,
3737
headerShown: true,
3838
headerStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? { backgroundColor: "transparent" } : undefined,
39-
headerTitle: renderCompactBrandTitle,
40-
headerTitleStyle: { fontSize: 18, fontWeight: "800" },
39+
...getCompactBrandHeaderOptions({ fontSize: 18, fontWeight: "800" }),
4140
headerTransparent: NATIVE_LIQUID_GLASS_SUPPORTED,
4241
scrollEdgeEffects: NATIVE_LIQUID_GLASS_SUPPORTED ? SCROLL_EDGE_EFFECTS : undefined,
43-
title: "Threads",
4442
unstable_navigationItemStyle: NATIVE_LIQUID_GLASS_SUPPORTED ? "editor" : undefined,
4543
};
4644

0 commit comments

Comments
 (0)