Skip to content

Commit b9eb9bf

Browse files
committed
fix(mobile): stabilize Git staging and simplify PR review controls
1 parent d4de385 commit b9eb9bf

16 files changed

Lines changed: 534 additions & 201 deletions

‎apps/mobile/modules/t3-review-diff/android/src/main/java/expo/modules/t3reviewdiff/T3ReviewDiffView.kt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,10 @@ private class DiffCanvasView(context: Context) : View(context) {
730730
hit.bottom,
731731
width,
732732
style
733-
).contains(event.x, event.y)
733+
).apply {
734+
inset(-12f * density, -12f * density)
735+
intersect(0f, hit.top.toFloat(), width.toFloat(), hit.bottom.toFloat())
736+
}.contains(event.x, event.y)
734737
) {
735738
if (!viewedCheckboxEnabled) return true
736739
RowTapTarget.VIEWED_CHECKBOX

‎apps/mobile/modules/t3-review-diff/ios/T3ReviewDiffView.swift‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,9 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
16141614
let interactiveRects = fileHeaderInteractiveRects(for: row, cardRect: rect)
16151615
let fileId = resolvedFileId(for: row)
16161616

1617-
if showViewedCheckbox && interactiveRects.checkbox.contains(point) {
1617+
// Keep the drawn mark small while giving it a full touch target in the file header.
1618+
let checkboxTouchRect = interactiveRects.checkbox.insetBy(dx: -12, dy: -12).intersection(rect)
1619+
if showViewedCheckbox && checkboxTouchRect.contains(point) {
16181620
if viewedCheckboxEnabled { onToggleViewedFile?(fileId) }
16191621
return
16201622
}
@@ -2503,7 +2505,13 @@ private final class ReviewDiffContentView: UIView, UIGestureRecognizerDelegate {
25032505
.foregroundColor: color,
25042506
.paragraphStyle: paragraphStyle,
25052507
]
2506-
(text as NSString).draw(in: rect, withAttributes: attributes)
2508+
(text as NSString).draw(
2509+
in: CGRect(
2510+
x: rect.minX, y: centeredTextY(in: rect, font: font),
2511+
width: rect.width, height: font.lineHeight
2512+
),
2513+
withAttributes: attributes
2514+
)
25072515
}
25082516

25092517
private func drawHunkRow(_ row: ReviewDiffNativeRow, rect: CGRect, context: CGContext) {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
import type { AppSymbolName } from "./AppSymbol";
2+
13
export interface SegmentedControlProps<Value extends number | string> {
24
readonly options: readonly {
35
readonly value: Value;
46
readonly label: string;
57
readonly badge?: number;
68
readonly accessibilityLabel?: string;
9+
readonly icon?: AppSymbolName;
710
}[];
811
readonly selected: Value;
912
readonly onSelect: (value: Value) => void;
1013
/** Sizing applies to the non-Material control. */
1114
readonly size?: "default" | "compact";
1215
readonly role?: "tab" | "button";
1316
readonly className?: string;
17+
readonly variant?: "default" | "tabs";
1418
}

‎apps/mobile/src/features/files/FileTreeBrowser.tsx‎

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export function FileTreeBrowser(props: {
120120
readonly onRefresh: () => void;
121121
readonly onSelectFile: (path: string) => void;
122122
readonly toolbar?: ReactNode;
123+
readonly pinnedToolbar?: boolean;
123124
}) {
124125
const [expandedPaths, setExpandedPaths] = useState<ReadonlySet<string>>(() => new Set());
125126
const [pendingSelection, setPendingSelection] = useState<{
@@ -221,29 +222,40 @@ export function FileTreeBrowser(props: {
221222

222223
// UIKit owns the header inset on every supported iOS version. Keep the
223224
// list as direct screen content so automatic inset adjustment can find it.
224-
return (
225+
const list = (
225226
<LegendList
226-
contentInsetStartAdjustment={headerInset}
227+
contentInsetStartAdjustment={props.pinnedToolbar ? 0 : headerInset}
227228
alwaysBounceVertical
228229
className="flex-1"
229230
data={visibleNodes}
230231
keyExtractor={(item) => item.node.path}
231-
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
232-
automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
232+
contentInsetAdjustmentBehavior={
233+
Platform.OS === "ios" && !props.pinnedToolbar ? "automatic" : "never"
234+
}
235+
automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios" && !props.pinnedToolbar}
233236
keyboardDismissMode="on-drag"
234237
keyboardShouldPersistTaps="handled"
235238
estimatedItemSize={42}
236239
recycleItems
237240
maintainVisibleContentPosition
238241
extraData={extraData}
239-
contentContainerStyle={{ paddingTop: 8, paddingBottom: 8 }}
242+
contentContainerStyle={{
243+
paddingTop: 8,
244+
paddingBottom:
245+
8 + (props.pinnedToolbar ? (columnMetrics?.safeArea.bottom ?? insets.bottom) : 0),
246+
}}
247+
scrollIndicatorInsets={
248+
props.pinnedToolbar
249+
? { bottom: columnMetrics?.safeArea.bottom ?? insets.bottom }
250+
: undefined
251+
}
240252
refreshControl={
241253
<RefreshControl refreshing={props.isRefreshing} onRefresh={props.onRefresh} />
242254
}
243255
renderItem={renderItem}
244256
ListHeaderComponent={
245257
<>
246-
{props.toolbar}
258+
{props.pinnedToolbar ? null : props.toolbar}
247259
{props.error && props.entries.length > 0 ? (
248260
<Text accessibilityRole="alert" className="mx-4 my-2 text-xs text-foreground-muted">
249261
{props.error}
@@ -292,4 +304,12 @@ export function FileTreeBrowser(props: {
292304
}
293305
/>
294306
);
307+
return props.pinnedToolbar ? (
308+
<View className="flex-1">
309+
<View style={{ paddingTop: headerInset }}>{props.toolbar}</View>
310+
{list}
311+
</View>
312+
) : (
313+
list
314+
);
295315
}

‎apps/mobile/src/features/files/ThreadFilesRouteScreen.tsx‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ import {
1717
} from "@t3tools/shared/filePreview";
1818
import { mediaFileReference } from "@t3tools/client-runtime/media-reference";
1919

20-
import { ScreenContent } from "../../components/ui/ScreenContent";
21-
import { AudioFilePreview } from "./AudioFilePreview";
22-
import { EmptyState } from "../../components/ui/EmptyState";
20+
import { AppTextInput } from "../../components/AppText";
21+
import { MaterialScreenContent } from "../../components/MaterialScreenContent";
22+
import { AudioFilePreview } from "../../components/AudioFilePreview";
23+
import { EmptyState } from "../../components/EmptyState";
2324
import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePreviewModal";
2425
import { LoadingScreen } from "../../components/LoadingScreen";
2526
import { resolveFileSelectionNavigationAction } from "../../lib/adaptive-navigation";
@@ -422,7 +423,10 @@ function FilesToolbarBottomFade() {
422423
}
423424

424425
export function ThreadFilesTreeScreen(
425-
props: ThreadFilesRouteScreenProps & { readonly workspaceTabs?: ReactNode },
426+
props: ThreadFilesRouteScreenProps & {
427+
readonly workspaceTabs?: ReactNode;
428+
readonly workspaceHeader?: ReactNode;
429+
},
426430
) {
427431
useAdaptiveWorkspacePaneRole("inspector");
428432
const navigation = useNavigation();
@@ -558,14 +562,16 @@ export function ThreadFilesTreeScreen(
558562

559563
const content = (
560564
<>
565+
{props.workspaceHeader ?? (
561566
<FilesBrowserHeader
562567
projectName={projectName}
563568
searchQuery={searchQuery}
564569
onSearchQueryChange={setSearchQuery}
565570
onRefresh={entriesQuery.refresh}
566571
onBack={handleReturnToThread}
567572
/>
568-
<ScreenContent insetHorizontal={layout.usesSplitView}>
573+
)}
574+
<MaterialScreenContent insetHorizontal={layout.usesSplitView}>
569575
<FileTreeBrowser
570576
key={JSON.stringify([environmentId, cwd])}
571577
entries={entriesQuery.entries}
@@ -581,7 +587,27 @@ export function ThreadFilesTreeScreen(
581587
onPreviewFile={handlePreviewFile}
582588
onRefresh={entriesQuery.refresh}
583589
onSelectFile={handleSelectFile}
584-
toolbar={props.workspaceTabs}
590+
pinnedToolbar={props.workspaceHeader !== undefined}
591+
toolbar={
592+
props.workspaceHeader ? (
593+
<>
594+
{props.workspaceTabs}
595+
<View className="px-3 py-2">
596+
<AppTextInput
597+
accessibilityLabel="Search files"
598+
placeholder="Search files"
599+
value={searchQuery}
600+
onChangeText={setSearchQuery}
601+
autoCapitalize="none"
602+
autoCorrect={false}
603+
className="min-h-9 py-2 text-sm"
604+
/>
605+
</View>
606+
</>
607+
) : (
608+
props.workspaceTabs
609+
)
610+
}
585611
/>
586612
<FilesToolbarBottomFade />
587613
</ScreenContent>

‎apps/mobile/src/features/pull-requests/PullRequestCommitPicker.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function PullRequestCommitPicker({
7272
<View className="gap-1 border-b border-border-subtle px-4 pb-3">
7373
<Text className="text-xs text-foreground-muted">
7474
{scope === null
75-
? "All commits"
75+
? "All"
7676
: `${selected.length} ${selected.length === 1 ? "commit" : "commits"} selected`}
7777
</Text>
7878
{scope !== null && first ? (
@@ -93,7 +93,7 @@ export function PullRequestCommitPicker({
9393
<SymbolView name="checkmark" size={13} tintColorClassName="accent-icon" />
9494
) : null}
9595
</View>
96-
<Text className="text-sm">All commits</Text>
96+
<Text className="text-sm">All</Text>
9797
</Pressable>
9898
<Pressable
9999
accessibilityRole="button"

‎apps/mobile/src/features/pull-requests/PullRequestControls.tsx‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export function PullRequestActionToolbar(props: {
108108
readonly params: PullRequestParams;
109109
readonly filePath?: string;
110110
readonly onOpenFiles?: () => void;
111+
readonly showFiles?: boolean;
111112
readonly onHeightChange?: (height: number) => void;
112113
}) {
113114
const navigation = useNavigation();
@@ -185,7 +186,13 @@ export function PullRequestActionToolbar(props: {
185186
)}
186187
</View>
187188
) : null}
188-
<IconButton icon="file.diff" accessibilityLabel="Changed files" onPress={openFiles} />
189+
{props.showFiles !== false ? (
190+
<IconButton
191+
icon="file.diff"
192+
accessibilityLabel="Changed files"
193+
onPress={openFiles}
194+
/>
195+
) : null}
189196
</View>
190197
</Toolbar>
191198
</View>
@@ -279,15 +286,17 @@ export function PullRequestActionToolbar(props: {
279286
)}
280287
</Toolbar.Menu>
281288
) : null;
282-
const filesControl = (
283-
<Toolbar.Button
284-
identifier="workspace-trailing-action"
285-
icon={{ type: "image", source: require("../../../assets/icons/file-diff.png") }}
286-
accessibilityLabel="Changed files"
287-
onPress={openFiles}
288-
separateBackground
289-
/>
290-
);
289+
// Tabler file-diff geometry, rasterized at 1x/2x/3x for UIKit template images.
290+
const filesControl =
291+
props.showFiles !== false ? (
292+
<Toolbar.Button
293+
identifier="workspace-trailing-action"
294+
icon={{ type: "image", source: require("../../../assets/icons/file-diff.png") }}
295+
accessibilityLabel="Changed files"
296+
onPress={openFiles}
297+
separateBackground
298+
/>
299+
) : null;
291300
if (verticalControls)
292301
return (
293302
<Toolbar placement="bottom">

0 commit comments

Comments
 (0)