Centralize native header scroll edge effects
This commit is contained in:
1 parent
8fb62e1ba3
commit
dfbfc25a8f
10 files changed
+58
-76
No files matched your search
@@ -25,7 +25,7 @@ import { EmptyState } from "../../components/EmptyState";
|
||||
import { LoadingScreen } from "../../components/LoadingScreen";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { resolveFileSelectionNavigationAction } from "../../lib/adaptive-navigation";
|
||||
import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect";
|
||||
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
|
||||
import { buildThreadFilesNavigation, buildThreadRoutePath } from "../../lib/routes";
|
||||
import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
|
||||
@@ -61,7 +61,7 @@ import {
|
||||
import { useWorkspaceFileAssetUrl } from "./workspaceFileAssetUrl";
|
||||
|
||||
type FileViewMode = "preview" | "source";
|
||||
const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
|
||||
function firstRouteParam(value: string | string[] | undefined): string | null {
|
||||
if (Array.isArray(value)) {
|
||||
@@ -585,12 +585,7 @@ export function ThreadFilesTreeScreen() {
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerShadowVisible: false,
|
||||
headerTitle: renderHeaderTitle,
|
||||
scrollEdgeEffects: {
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
},
|
||||
scrollEdgeEffects: HEADER_SCROLL_EDGE_EFFECTS,
|
||||
unstable_navigationItemStyle: Platform.OS === "ios" ? "editor" : undefined,
|
||||
unstable_headerToolbarItems: usesCompactMailToolbar
|
||||
? () => [
|
||||
@@ -765,12 +760,7 @@ export function ThreadFileScreen() {
|
||||
headerShadowVisible: false,
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerTintColor: iconColor,
|
||||
scrollEdgeEffects: {
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
},
|
||||
scrollEdgeEffects: HEADER_SCROLL_EDGE_EFFECTS,
|
||||
title: basename(relativePath),
|
||||
unstable_navigationItemStyle: Platform.OS === "ios" ? "editor" : undefined,
|
||||
}}
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
} from "react-native-screens";
|
||||
|
||||
import { AppText as Text, AppTextInput as TextInput } from "../../components/AppText";
|
||||
import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { projectEnvironment } from "../../state/projects";
|
||||
import { useEnvironmentQuery } from "../../state/query";
|
||||
@@ -32,7 +32,7 @@ export function ThreadFileNavigatorPane(props: {
|
||||
const iconColor = String(useThemeColor("--color-icon-muted"));
|
||||
const foregroundColor = String(useThemeColor("--color-foreground"));
|
||||
const sheetColor = String(useThemeColor("--color-sheet"));
|
||||
const topScrollEdgeEffect = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
const headerScrollEdgeEffects = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
const entriesQuery = useEnvironmentQuery(
|
||||
projectEnvironment.listEntries({
|
||||
environmentId: props.environmentId,
|
||||
@@ -90,12 +90,7 @@ export function ThreadFileNavigatorPane(props: {
|
||||
enabled
|
||||
isNativeStack
|
||||
screenId="thread-file-navigator-native"
|
||||
scrollEdgeEffects={{
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
top: topScrollEdgeEffect,
|
||||
}}
|
||||
scrollEdgeEffects={headerScrollEdgeEffects}
|
||||
style={{ backgroundColor: sheetColor, flex: 1 }}
|
||||
>
|
||||
{fileTree}
|
||||
|
||||
@@ -32,7 +32,7 @@ import { AppText as Text } from "../../components/AppText";
|
||||
import { environmentCatalog } from "../../connection/catalog";
|
||||
import { useEnvironmentPresentation } from "../../state/presentation";
|
||||
import { useAtomCommand } from "../../state/use-atom-command";
|
||||
import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
|
||||
import { useThreadDraftForThread } from "../../state/use-thread-composer-state";
|
||||
@@ -61,7 +61,7 @@ import { resolveReviewAvailability } from "./reviewAvailability";
|
||||
import { resolveSelectedReviewFileId } from "./reviewPaneSelection";
|
||||
import { buildReviewSectionMenu } from "./review-section-menu";
|
||||
|
||||
const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
|
||||
const REVIEW_HEADER_SPACING = 0;
|
||||
|
||||
@@ -593,12 +593,7 @@ export function ReviewSheet() {
|
||||
backgroundColor: "transparent",
|
||||
},
|
||||
headerTitle: renderHeaderTitle,
|
||||
scrollEdgeEffects: {
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
},
|
||||
scrollEdgeEffects: HEADER_SCROLL_EDGE_EFFECTS,
|
||||
unstable_navigationItemStyle: Platform.OS === "ios" ? "editor" : undefined,
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -25,7 +25,7 @@ import { terminalEnvironment } from "../../state/terminal";
|
||||
import { useAtomCommand } from "../../state/use-atom-command";
|
||||
import { useWorkspaceState } from "../../state/workspace";
|
||||
import { buildThreadTerminalNavigation } from "../../lib/routes";
|
||||
import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect";
|
||||
import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
|
||||
import {
|
||||
useAttachedTerminalSession,
|
||||
@@ -74,7 +74,7 @@ import {
|
||||
const DEFAULT_TERMINAL_COLS = 80;
|
||||
const DEFAULT_TERMINAL_ROWS = 24;
|
||||
const TERMINAL_ACCESSORY_HEIGHT = 52;
|
||||
const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
|
||||
type PendingModifier = "ctrl" | "meta";
|
||||
type HostPlatform = "mac" | "linux" | "windows" | "unknown";
|
||||
@@ -979,14 +979,7 @@ export function ThreadTerminalRouteScreen() {
|
||||
fontWeight: "800",
|
||||
}
|
||||
: undefined,
|
||||
scrollEdgeEffects: usesNativeHeaderGlass
|
||||
? {
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
}
|
||||
: undefined,
|
||||
scrollEdgeEffects: usesNativeHeaderGlass ? HEADER_SCROLL_EDGE_EFFECTS : undefined,
|
||||
title: headerTitle.topLine,
|
||||
unstable_navigationItemStyle: usesNativeHeaderGlass ? "editor" : undefined,
|
||||
}}
|
||||
|
||||
@@ -69,7 +69,7 @@ import {
|
||||
import { buildReviewParsedDiff } from "../review/reviewModel";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { deriveCenteredContentHorizontalPadding, type LayoutVariant } from "../../lib/layout";
|
||||
import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect";
|
||||
import { buildThreadFilesNavigation } from "../../lib/routes";
|
||||
import { MOBILE_CODE_SURFACE, MOBILE_TYPOGRAPHY } from "../../lib/typography";
|
||||
import { markdownFileIconSource } from "@t3tools/mobile-markdown-text/file-icons";
|
||||
@@ -88,7 +88,7 @@ const MESSAGE_TIME_FORMATTER = new Intl.DateTimeFormat(undefined, {
|
||||
hour: "numeric",
|
||||
minute: "2-digit",
|
||||
});
|
||||
const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
|
||||
function formatMessageTime(input: string): string {
|
||||
const timestamp = Date.parse(input);
|
||||
@@ -1499,15 +1499,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
return (
|
||||
<>
|
||||
<View style={{ flex: 1 }} onLayout={handleViewportLayout}>
|
||||
<ScrollViewMarker
|
||||
style={{ flex: 1 }}
|
||||
scrollEdgeEffects={{
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
right: "hidden",
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
}}
|
||||
>
|
||||
<ScrollViewMarker style={{ flex: 1 }} scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}>
|
||||
<KeyboardAwareLegendList
|
||||
ref={props.listRef}
|
||||
key={props.threadId}
|
||||
|
||||
@@ -14,7 +14,7 @@ import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { ControlPillMenu } from "../../components/ControlPill";
|
||||
import { StatusPill } from "../../components/StatusPill";
|
||||
import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect";
|
||||
import { scopedThreadKey } from "../../lib/scopedEntities";
|
||||
import { relativeTime } from "../../lib/time";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
@@ -41,7 +41,7 @@ import { threadStatusTone } from "./threadPresentation";
|
||||
|
||||
const SIDEBAR_STICKY_HEADER_HEIGHT = 106;
|
||||
const SIDEBAR_STICKY_HEADER_FADE_HEIGHT = 44;
|
||||
const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
const IOS_SEARCH_FILL_DARK = "rgba(118, 118, 128, 0.24)";
|
||||
const IOS_SEARCH_FILL_LIGHT = "rgba(118, 118, 128, 0.12)";
|
||||
const SIDEBAR_HEADER_WASH_OPACITY = {
|
||||
@@ -667,12 +667,7 @@ export function ThreadNavigationSidebar(props: {
|
||||
enabled
|
||||
isNativeStack
|
||||
screenId="thread-navigation-sidebar-native"
|
||||
scrollEdgeEffects={{
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
}}
|
||||
scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}
|
||||
style={[styles.container, { backgroundColor }]}
|
||||
>
|
||||
<View style={{ flex: 1, paddingBottom: insets.bottom }}>
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
import { scopedThreadKey } from "../../lib/scopedEntities";
|
||||
import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
|
||||
import { connectionTone } from "../connection/connectionTone";
|
||||
import { nativeTopScrollEdgeEffect } from "../../lib/native-scroll-edge-effect";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../lib/native-scroll-edge-effect";
|
||||
|
||||
import {
|
||||
useRemoteConnections,
|
||||
@@ -76,7 +76,7 @@ type NativeHeaderItems = ReturnType<
|
||||
NonNullable<NativeStackNavigationOptions["unstable_headerRightItems"]>
|
||||
>;
|
||||
|
||||
const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
|
||||
function InspectorPaneRoleActivation() {
|
||||
useAdaptiveWorkspacePaneRole("inspector");
|
||||
@@ -721,12 +721,7 @@ function ThreadRouteContent(
|
||||
title: layout.usesSplitView ? "" : selectedThread.title,
|
||||
headerBackVisible: !layout.usesSplitView,
|
||||
headerBackTitle: "",
|
||||
scrollEdgeEffects: {
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
},
|
||||
scrollEdgeEffects: HEADER_SCROLL_EDGE_EFFECTS,
|
||||
headerSearchBarOptions: usesThreadSearchToolbar
|
||||
? {
|
||||
ref: threadSearchBarRef,
|
||||
|
||||
@@ -14,7 +14,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useThemeColor } from "../../../lib/useThemeColor";
|
||||
|
||||
import { AppText as Text } from "../../../components/AppText";
|
||||
import { nativeTopScrollEdgeEffect } from "../../../lib/native-scroll-edge-effect";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../../lib/native-scroll-edge-effect";
|
||||
import { tryOpenExternalUrl } from "../../../lib/openExternalUrl";
|
||||
import { buildThreadReviewRoutePath } from "../../../lib/routes";
|
||||
import { useEnvironmentQuery } from "../../../state/query";
|
||||
@@ -25,7 +25,7 @@ import { useSelectedThreadWorktree } from "../../../state/use-selected-thread-wo
|
||||
import { vcsEnvironment } from "../../../state/vcs";
|
||||
import { MetaCard, SheetListRow, menuItemIconName, statusSummary } from "./gitSheetComponents";
|
||||
|
||||
const TOP_SCROLL_EDGE_EFFECT = nativeTopScrollEdgeEffect(Platform.OS, Platform.Version);
|
||||
const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version);
|
||||
|
||||
export function GitOverviewSheet(
|
||||
props: {
|
||||
@@ -268,12 +268,7 @@ export function GitOverviewSheet(
|
||||
enabled
|
||||
isNativeStack
|
||||
screenId="thread-git-inspector-native"
|
||||
scrollEdgeEffects={{
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
top: TOP_SCROLL_EDGE_EFFECT,
|
||||
}}
|
||||
scrollEdgeEffects={HEADER_SCROLL_EDGE_EFFECTS}
|
||||
style={{ backgroundColor: sheetColor, flex: 1 }}
|
||||
>
|
||||
{content}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import { nativeTopScrollEdgeEffect } from "./native-scroll-edge-effect";
|
||||
import {
|
||||
nativeHeaderScrollEdgeEffects,
|
||||
nativeTopScrollEdgeEffect,
|
||||
} from "./native-scroll-edge-effect";
|
||||
|
||||
describe("nativeTopScrollEdgeEffect", () => {
|
||||
it("keeps the automatic native treatment on iOS 26", () => {
|
||||
@@ -16,3 +19,14 @@ describe("nativeTopScrollEdgeEffect", () => {
|
||||
expect(nativeTopScrollEdgeEffect("android", 27)).toBe("automatic");
|
||||
});
|
||||
});
|
||||
|
||||
describe("nativeHeaderScrollEdgeEffects", () => {
|
||||
it("keeps non-top header edges hidden while applying the platform top effect", () => {
|
||||
expect(nativeHeaderScrollEdgeEffects("ios", "27.0")).toEqual({
|
||||
top: "soft",
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,10 @@
|
||||
export type NativeTopScrollEdgeEffect = "automatic" | "soft";
|
||||
export type NativeHeaderScrollEdgeEffects = {
|
||||
readonly top: NativeTopScrollEdgeEffect;
|
||||
readonly bottom: "hidden";
|
||||
readonly left: "hidden";
|
||||
readonly right: "hidden";
|
||||
};
|
||||
|
||||
function majorVersion(version: number | string): number {
|
||||
if (typeof version === "number") {
|
||||
@@ -20,3 +26,15 @@ export function nativeTopScrollEdgeEffect(
|
||||
): NativeTopScrollEdgeEffect {
|
||||
return os === "ios" && majorVersion(version) >= 27 ? "soft" : "automatic";
|
||||
}
|
||||
|
||||
export function nativeHeaderScrollEdgeEffects(
|
||||
os: string,
|
||||
version: number | string,
|
||||
): NativeHeaderScrollEdgeEffects {
|
||||
return {
|
||||
top: nativeTopScrollEdgeEffect(os, version),
|
||||
bottom: "hidden",
|
||||
left: "hidden",
|
||||
right: "hidden",
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user