Skip to content

Commit b6e354d

Browse files
refactor(mobile): remaining sheets take platform looks from components/ui
Review, review comment, Files, the inspector, Git overview, linked and searched pull requests, and thread settings no longer branch on Platform or use android:/ios: classes. PaneSheet, SheetPane, ContentBand/ContentStatus, PaneListItem, KeyboardSheetBody, list metrics and sheet inset hooks carry the differences instead. KeyboardSheetBody also clears the iOS glass sheet bar, which the review comment composer's selection label used to sit under. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 0857f88 commit b6e354d

27 files changed

Lines changed: 557 additions & 344 deletions
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { View } from "react-native";
2+
3+
import { cn } from "../../lib/cn";
4+
import { AppActivityIndicator } from "./AppActivityIndicator";
5+
import { AppText as Text } from "./AppText";
6+
import type { ContentBandProps, ContentStatusProps } from "./ContentBand.types";
7+
export type { ContentBandProps, ContentStatusProps } from "./ContentBand.types";
8+
9+
/** A rounded card floating in the content's margin. */
10+
export function ContentBand(props: ContentBandProps) {
11+
return (
12+
<View
13+
className={cn(
14+
"m-2 rounded-[20px] px-4",
15+
props.spacing === "roomy" ? "gap-3 py-4" : "py-3",
16+
props.tone === "warning" ? "bg-warning" : "bg-card",
17+
)}
18+
>
19+
{props.children}
20+
</View>
21+
);
22+
}
23+
24+
/** Material centers an empty state in the space it has. */
25+
export function ContentStatus(props: ContentStatusProps) {
26+
if (props.loading) {
27+
return (
28+
<View className="items-center gap-3 px-4 py-6">
29+
<AppActivityIndicator size="small" />
30+
<Text className="text-xs text-foreground-muted">{props.detail}</Text>
31+
</View>
32+
);
33+
}
34+
return (
35+
<View className="items-center px-6 py-5">
36+
{props.title ? (
37+
<Text className="text-sm font-t3-bold text-foreground">{props.title}</Text>
38+
) : null}
39+
<Text className="mt-2 text-center text-xs leading-normal text-foreground-muted">
40+
{props.detail}
41+
</Text>
42+
</View>
43+
);
44+
}
45+
46+
export const contentStatusContainerStyle = { flexGrow: 1, justifyContent: "center" } as const;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { View } from "react-native";
2+
3+
import { cn } from "../../lib/cn";
4+
import { AppActivityIndicator } from "./AppActivityIndicator";
5+
import { AppText as Text } from "./AppText";
6+
import type { ContentBandProps, ContentStatusProps } from "./ContentBand.types";
7+
export type { ContentBandProps, ContentStatusProps } from "./ContentBand.types";
8+
9+
/** A full-width band above or in place of content, ruled off from what follows. */
10+
export function ContentBand(props: ContentBandProps) {
11+
return (
12+
<View
13+
className={cn(
14+
"border-b px-4",
15+
props.spacing === "roomy" ? "gap-3 py-4" : "py-3",
16+
props.tone === "warning" ? "border-warning-border bg-warning" : "border-border bg-card",
17+
)}
18+
>
19+
{props.children}
20+
</View>
21+
);
22+
}
23+
24+
export function ContentStatus(props: ContentStatusProps) {
25+
if (props.loading) {
26+
return (
27+
<View className="items-center gap-3 border-b border-border bg-card px-4 py-6">
28+
<AppActivityIndicator size="small" />
29+
<Text className="text-xs text-foreground-muted">{props.detail}</Text>
30+
</View>
31+
);
32+
}
33+
return (
34+
<View className="border-b border-border bg-card px-4 py-5">
35+
{props.title ? (
36+
<Text className="text-sm font-t3-bold text-foreground">{props.title}</Text>
37+
) : null}
38+
<Text className="text-xs leading-normal text-foreground-muted">{props.detail}</Text>
39+
</View>
40+
);
41+
}
42+
43+
/** The scroll content style for a ContentStatus with nothing else in the scroll view. */
44+
export const contentStatusContainerStyle = undefined;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { ReactNode } from "react";
2+
3+
export interface ContentBandProps {
4+
readonly tone?: "card" | "warning";
5+
/** "roomy" for a band holding a block of content, such as a raw patch. */
6+
readonly spacing?: "compact" | "roomy";
7+
readonly children: ReactNode;
8+
}
9+
10+
/** A status at the top of otherwise empty content, such as "No changes" or a loading diff. */
11+
export interface ContentStatusProps {
12+
readonly title?: string;
13+
readonly detail: string;
14+
readonly loading?: boolean;
15+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { View } from "react-native";
2+
import { KeyboardAvoidingView, KeyboardStickyView } from "react-native-keyboard-controller";
3+
import { useSafeAreaInsets } from "react-native-safe-area-context";
4+
5+
import type { KeyboardSheetBodyProps } from "./KeyboardSheetBody.types";
6+
export type { KeyboardSheetBodyProps } from "./KeyboardSheetBody.types";
7+
8+
const TOOLBAR_CLEARANCE = 72;
9+
10+
/** The toolbar sticks to the keyboard on its own, over the body's bottom edge. */
11+
export function KeyboardSheetBody(props: KeyboardSheetBodyProps) {
12+
const insets = useSafeAreaInsets();
13+
return (
14+
<>
15+
<KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
16+
<View
17+
className="flex-1 px-5"
18+
style={{
19+
paddingTop: 8,
20+
paddingBottom: props.toolbar ? TOOLBAR_CLEARANCE : Math.max(insets.bottom, 18),
21+
}}
22+
>
23+
{props.children}
24+
</View>
25+
</KeyboardAvoidingView>
26+
{props.toolbar ? (
27+
<KeyboardStickyView
28+
className="absolute inset-x-0 bottom-0"
29+
offset={{ closed: 0, opened: 0 }}
30+
>
31+
<View
32+
className="flex-row items-center gap-3 border-t border-border bg-sheet px-5 pt-2"
33+
style={{ paddingBottom: Math.max(insets.bottom, 10) }}
34+
>
35+
{props.toolbar}
36+
</View>
37+
</KeyboardStickyView>
38+
) : null}
39+
</>
40+
);
41+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { View } from "react-native";
2+
import { KeyboardAvoidingView } from "react-native-keyboard-controller";
3+
import { useSafeAreaInsets } from "react-native-safe-area-context";
4+
5+
import type { KeyboardSheetBodyProps } from "./KeyboardSheetBody.types";
6+
import { useBarOverlap } from "./useBarInset";
7+
export type { KeyboardSheetBodyProps } from "./KeyboardSheetBody.types";
8+
9+
/** A sheet's body that stays above the keyboard, with its toolbar between the two. */
10+
export function KeyboardSheetBody(props: KeyboardSheetBodyProps) {
11+
const insets = useSafeAreaInsets();
12+
// The sheet's glass bar floats over its content, and only scroll views inset for it on their own.
13+
const barOverlap = useBarOverlap();
14+
return (
15+
<KeyboardAvoidingView automaticOffset behavior="padding" className="flex-1">
16+
<View
17+
className="flex-1 px-5"
18+
style={{
19+
paddingTop: barOverlap + 8,
20+
paddingBottom: props.toolbar ? 0 : Math.max(insets.bottom, 18),
21+
}}
22+
>
23+
{props.children}
24+
</View>
25+
{props.toolbar ? (
26+
<View className="flex-row items-center gap-3 bg-sheet px-5 py-2">{props.toolbar}</View>
27+
) : null}
28+
</KeyboardAvoidingView>
29+
);
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ReactNode } from "react";
2+
3+
export interface KeyboardSheetBodyProps {
4+
readonly children: ReactNode;
5+
/** A row of actions that rides the keyboard, such as attach and send. */
6+
readonly toolbar?: ReactNode;
7+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Pressable } from "react-native";
2+
3+
import { cn } from "../../lib/cn";
4+
import type { PaneListItemProps } from "./PaneListItem.types";
5+
export type { PaneListItemProps } from "./PaneListItem.types";
6+
7+
export function PaneListItem(props: PaneListItemProps) {
8+
return (
9+
<Pressable
10+
accessibilityRole="button"
11+
accessibilityState={{ selected: props.selected }}
12+
className={cn(
13+
"mt-1 min-h-12 justify-center rounded-[20px] px-3 py-2 active:bg-subtle",
14+
props.selected && "bg-subtle-strong",
15+
)}
16+
onPress={props.onPress}
17+
>
18+
{props.children}
19+
</Pressable>
20+
);
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Pressable } from "react-native";
2+
3+
import type { PaneListItemProps } from "./PaneListItem.types";
4+
export type { PaneListItemProps } from "./PaneListItem.types";
5+
6+
/** A selectable entry in a pane's navigation list, such as a changed file. */
7+
export function PaneListItem(props: PaneListItemProps) {
8+
return (
9+
<Pressable
10+
accessibilityRole="button"
11+
accessibilityState={{ selected: props.selected }}
12+
className={
13+
props.selected
14+
? "mt-1 min-h-12 justify-center rounded-xl bg-subtle-strong px-3 py-2"
15+
: "mt-1 min-h-12 justify-center rounded-xl px-3 py-2 active:bg-subtle"
16+
}
17+
onPress={props.onPress}
18+
>
19+
{props.children}
20+
</Pressable>
21+
);
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ReactNode } from "react";
2+
3+
export interface PaneListItemProps {
4+
readonly selected: boolean;
5+
readonly onPress: () => void;
6+
readonly children: ReactNode;
7+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { View } from "react-native";
2+
import { FormSheet } from "react-native-screens";
3+
import { useResolveClassNames } from "uniwind";
4+
5+
import { BottomSheetContext } from "./BottomSheetContext";
6+
import type { PaneSheetProps } from "./PaneSheet.types";
7+
export type { PaneSheetProps } from "./PaneSheet.types";
8+
9+
/** A native sheet holding a pane that draws its own bar, which runs up under the drawn grabber. */
10+
export function PaneSheet({ children, ...props }: PaneSheetProps) {
11+
const containerStyle = useResolveClassNames("bg-header");
12+
return (
13+
<FormSheet {...props} preferredCornerRadius={28} nativeContainerStyle={containerStyle}>
14+
<BottomSheetContext value>
15+
{/* Android FormSheet does not bound flex children. */}
16+
<View collapsable={false} className="absolute inset-0 bg-header pt-3">
17+
{children}
18+
<View
19+
pointerEvents="none"
20+
className="absolute top-1 h-1 w-8 self-center rounded-full bg-header-foreground/40"
21+
/>
22+
</View>
23+
</BottomSheetContext>
24+
</FormSheet>
25+
);
26+
}

0 commit comments

Comments
 (0)