1
-import { Toolbar } from "../../components/ui/Toolbar";
1
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
2
import { Chip } from "../../components/ui/Chip";
3
import { pullRequestTabOffset } from "./pullRequestTabScroll";
26
pullRequestActionLabel,
27
} from "./pullRequestActions";
28
import * as Clipboard from "expo-clipboard";
30
-import { Menu } from "../../components/ui/Menu";
31
-import { IconButton } from "../../components/ui/IconButton";
29
import { Button } from "../../components/ui/Button";
30
import { usePullRequestReviewDraft } from "./usePullRequestReviewDraft";
31
import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
53
import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
54
import { pullRequestStatus } from "./pullRequestStatus";
55
import { use, useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
59
-import {
60
- Linking,
61
- Platform,
62
- Pressable,
63
- RefreshControl,
64
- ScrollView,
65
- type ScrollViewProps,
66
- StyleSheet,
67
- View,
68
-} from "react-native";
69
-import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
56
+import { Linking, Platform, Pressable, RefreshControl, StyleSheet, View } from "react-native";
57
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
58
import { useSafeAreaInsets } from "react-native-safe-area-context";
59
60
import { AppText as Text } from "../../components/ui/AppText";
61
import { AppBar } from "../../components/ui/AppBar";
62
+import { useContentTopInset } from "../../components/ui/useBarInset";
63
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
64
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
76
-import { useWorkspaceSidebarHeaderItem } from "../layout/useWorkspaceSidebarHeaderItem";
65
import { useAndroidWorkspaceBack } from "../workspace/useAndroidWorkspaceNavigation";
66
import { EmptyState } from "../../components/ui/EmptyState";
67
import { SegmentedControl } from "../../components/ui/SegmentedControl";
68
import { SymbolView } from "../../components/ui/AppSymbol";
69
import { ScreenContent } from "../../components/ui/ScreenContent";
70
import { RelativeTime } from "../../components/RelativeTime";
83
-import { NativeStackScreenOptions } from "../../native/StackHeader";
71
import { usePullRequestConnected } from "./usePullRequestConnected";
72
import { usePullRequestLiveChecks } from "./usePullRequestLiveChecks";
73
import { pullRequestLabelColor } from "./pullRequestList";
125
126
const EMPTY_IDS: readonly string[] = [];
127
141
-function PullRequestTabScrollView(props: ScrollViewProps) {
142
- return (
143
- <ScrollViewMarker style={{ flex: 1 }}>
144
- <ScrollView {...props} />
145
- </ScrollViewMarker>
146
- );
147
-}
148
-
128
function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityFilter) {
129
const navigation = useNavigation();
130
const result = useEnvironmentQuery(composerPullRequests.activity(requestTarget(params)));
325
export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestParams>) {
326
const returnToList = useAndroidWorkspaceBack("pullRequests");
327
const { layout } = useAdaptiveWorkspaceLayout();
349
- const sidebarHeaderItem = useWorkspaceSidebarHeaderItem();
328
const navigation = useNavigation();
329
const insets = useSafeAreaInsets();
330
const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
353
- // Only iOS lists run under the bars; Android lists start below the header.
354
- const barInsets = Platform.OS === "ios" ? insets : { top: 0, bottom: 0 };
331
+ const contentTopInset = useContentTopInset();
332
+ // Only iOS lists run under the bottom safe area; Android's floating toolbar pads its own.
333
+ const contentBottomInset = Platform.OS === "ios" ? insets.bottom : 0;
334
const params = route.params;
335
usePullRequestEnvironmentFallback(params);
336
const connected = usePullRequestConnected(params.environmentId);
352
// has its own offset, which only its next scroll would record here.
353
const currentScrollOffset = useRef<{ tab: typeof section; offset: number }>({
354
tab: "overview",
376
- offset: -barInsets.top,
355
+ offset: -contentTopInset,
356
});
357
const bodyY = useRef(0);
358
const [headerHeight, setHeaderHeight] = useState(0);
376
const current =
377
currentScrollOffset.current.tab === from
378
? currentScrollOffset.current.offset
400
- : (scrollOffsets.current[from] ?? -barInsets.top);
379
+ : (scrollOffsets.current[from] ?? -contentTopInset);
380
scrollOffsets.current[section] = current;
402
- const headerEnd = Math.max(-barInsets.top, bodyY.current - barInsets.top);
381
+ const headerEnd = Math.max(-contentTopInset, bodyY.current - contentTopInset);
382
const offset = pullRequestTabOffset(current, scrollOffsets.current[next], headerEnd);
383
requestedSection.current = next;
384
scrollOffsets.current[next] = offset;
445
});
446
const jumpToFiles = () => {
447
scrollViews.current.overview?.scrollToOffset({
469
- offset: bodyY.current + filesY.current - barInsets.top,
448
+ offset: bodyY.current + filesY.current - contentTopInset,
449
animated: true,
450
});
451
pendingFilesJump.current = false;
460
};
461
return (
462
<PullRequestMarkdownRepository params={params} changeRequest={pr}>
484
- <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
485
- <NativeStackScreenOptions
486
- options={{
487
- title: `#${params.number}`,
488
- headerTitle: `#${params.number}`,
489
- unstable_headerSubtitle: connected
490
- ? params.repository
491
- : `${params.repository} · Offline`,
492
- unstable_headerLeftItems: sidebarHeaderItem ? () => [sidebarHeaderItem] : undefined,
493
- }}
494
- optionsVersion={[sidebarHeaderItem]}
463
+ <View className="flex-1 android:bg-header ios:bg-screen">
464
+ <AppBar
465
+ title={`#${params.number}`}
466
+ subtitle={connected ? params.repository : `${params.repository} · Offline`}
467
+ onBack={layout.usesSplitView ? undefined : returnToList}
468
+ menus={[
469
+ {
470
+ title: `${capitalizeTerm(terminology.singular)} actions`,
471
+ icon: "ellipsis",
472
+ items: [
473
+ ...(permissions.verdicts.length
474
+ ? [
475
+ {
476
+ id: "submit-review",
477
+ title: "Submit review",
478
+ icon: "text.bubble",
479
+ onPress: () =>
480
+ navigation.navigate("PullRequestReview", { ...params, mode: "review" }),
481
+ },
482
+ ]
483
+ : []),
484
+ ...(permissions.canComment
485
+ ? [
486
+ {
487
+ id: "add-comment",
488
+ title: "Add comment",
489
+ icon: "plus.bubble",
490
+ onPress: () =>
491
+ navigation.navigate("PullRequestReview", { ...params, mode: "comment" }),
492
+ },
493
+ ]
494
+ : []),
495
+ ...(permissions.canEditChangeRequest
496
+ ? [
497
+ {
498
+ id: "edit-title",
499
+ title: "Edit title",
500
+ icon: "pencil",
501
+ onPress: () =>
502
+ navigation.navigate("PullRequestEdit", { ...params, field: "title" }),
503
+ },
504
+ {
505
+ id: "edit-description",
506
+ title: "Edit description",
507
+ icon: "doc.text",
508
+ disabled: description.pending,
509
+ subtitle: description.pending ? "Saving…" : undefined,
510
+ onPress: () =>
511
+ navigation.navigate("PullRequestEdit", { ...params, field: "body" }),
512
+ },
513
+ ]
514
+ : []),
515
+ ...(maintainerEdits.visible
516
+ ? [
517
+ {
518
+ id: "maintainer-edits",
519
+ title: "Allow edits from maintainers",
520
+ icon: "pencil",
521
+ selected: maintainerEdits.value,
522
+ disabled: maintainerEdits.saving,
523
+ subtitle: maintainerEdits.subtitle,
524
+ onPress: maintainerEdits.toggle,
525
+ },
526
+ ]
527
+ : []),
528
+ ...(identity
529
+ ? [
530
+ {
531
+ id: "open-on-provider",
532
+ title: openOnProviderLabel(identity.provider),
533
+ icon: "arrow.up.right",
534
+ onPress: () => void Linking.openURL(identity.url),
535
+ },
536
+ {
537
+ id: "copy-link",
538
+ title: "Copy link",
539
+ icon: "link",
540
+ onPress: () => copyPullRequestLink(identity),
541
+ },
542
+ {
543
+ id: "share",
544
+ title: "Share…",
545
+ icon: "square.and.arrow.up",
546
+ onPress: () => sharePullRequestLink(identity),
547
+ },
548
+ ]
549
+ : []),
550
+ ...(stateAction
551
+ ? [
552
+ {
553
+ id: "state",
554
+ title: pullRequestActionLabel(stateAction, terminology),
555
+ icon: PR_ACTION_ICONS[stateAction],
556
+ destructive: stateAction === "close",
557
+ onPress: runStateAction,
558
+ },
559
+ ]
560
+ : []),
561
+ ...(showsDeleteBranch
562
+ ? [
563
+ {
564
+ id: "delete-branch",
565
+ title: pullRequestActionLabel("delete-branch", terminology),
566
+ icon: PR_ACTION_ICONS["delete-branch"],
567
+ destructive: true,
568
+ disabled: !action.available("delete-branch"),
569
+ subtitle: action.busy
570
+ ? "Deleting…"
571
+ : connected
572
+ ? pr.headBranch
573
+ : "Reconnect to delete this branch.",
574
+ onPress: confirmDeleteBranch,
575
+ },
576
+ ]
577
+ : []),
578
+ ],
579
+ },
580
+ ]}
581
/>
496
- {Platform.OS === "android" ? (
497
- <AppBar
498
- embedded
499
- title={`#${params.number}${connected ? "" : " · Offline"}`}
500
- subtitle={params.repository}
501
- onBack={layout.usesSplitView ? undefined : returnToList}
502
- actions={[
503
- ...(permissions.verdicts.length
504
- ? [
505
- {
506
- accessibilityLabel: "Submit review",
507
- icon: "text.bubble" as const,
508
- onPress: () =>
509
- navigation.navigate("PullRequestReview", { ...params, mode: "review" }),
510
- },
511
- ]
512
- : []),
513
- ...(permissions.canComment
514
- ? [
515
- {
516
- accessibilityLabel: "Add comment",
517
- icon: "plus.bubble" as const,
518
- onPress: () =>
519
- navigation.navigate("PullRequestReview", { ...params, mode: "comment" }),
520
- },
521
- ]
522
- : []),
523
- ...(permissions.canEditChangeRequest
524
- ? [
525
- {
526
- accessibilityLabel: "Edit title",
527
- icon: "pencil" as const,
528
- overflowOnly: true,
529
- onPress: () =>
530
- navigation.navigate("PullRequestEdit", { ...params, field: "title" }),
531
- },
532
- {
533
- accessibilityLabel: "Edit description",
534
- icon: "doc.text" as const,
535
- disabled: description.pending,
536
- subtitle: description.pending ? "Saving…" : undefined,
537
- overflowOnly: true,
538
- onPress: () =>
539
- navigation.navigate("PullRequestEdit", { ...params, field: "body" }),
540
- },
541
- ]
542
- : []),
543
- ...(maintainerEdits.visible
544
- ? [
545
- {
546
- accessibilityLabel: "Allow edits from maintainers",
547
- icon: "pencil" as const,
548
- selected: maintainerEdits.value,
549
- disabled: maintainerEdits.saving,
550
- subtitle: maintainerEdits.subtitle,
551
- overflowOnly: true,
552
- onPress: maintainerEdits.toggle,
553
- },
554
- ]
555
- : []),
556
- ...(identity
557
- ? [
558
- {
559
- accessibilityLabel: openOnProviderLabel(identity.provider),
560
- icon: "arrow.up.right" as const,
561
- onPress: () => void Linking.openURL(identity.url),
562
- },
563
- {
564
- accessibilityLabel: "Copy link",
565
- icon: "link" as const,
566
- overflowOnly: true,
567
- onPress: () => copyPullRequestLink(identity),
568
- },
569
- {
570
- accessibilityLabel: "Share…",
571
- icon: "square.and.arrow.up" as const,
572
- overflowOnly: true,
573
- onPress: () => sharePullRequestLink(identity),
574
- },
575
- ]
576
- : []),
577
- ...(stateAction
578
- ? [
579
- {
580
- accessibilityLabel: pullRequestActionLabel(stateAction, terminology),
581
- icon: PR_ACTION_ICONS[stateAction],
582
- destructive: stateAction === "close",
583
- overflowOnly: true,
584
- onPress: runStateAction,
585
- },
586
- ]
587
- : []),
588
- ...(showsDeleteBranch
589
- ? [
590
- {
591
- accessibilityLabel: pullRequestActionLabel("delete-branch", terminology),
592
- icon: PR_ACTION_ICONS["delete-branch"],
593
- disabled: !action.available("delete-branch"),
594
- destructive: true,
595
- overflowOnly: true,
596
- onPress: confirmDeleteBranch,
597
- },
598
- ]
599
- : []),
600
- ]}
601
- />
602
- ) : null}
603
- <Toolbar placement="right">
604
- <Toolbar.Menu
605
- title={capitalizeTerm(terminology.singular)}
606
- accessibilityLabel={`${capitalizeTerm(terminology.singular)} actions`}
607
- icon="ellipsis"
608
- >
609
- {permissions.verdicts.length ? (
610
- <Toolbar.MenuAction
611
- icon="text.bubble"
612
- onPress={() =>
613
- navigation.navigate("PullRequestReview", { ...params, mode: "review" })
614
- }
615
- >
616
- <Toolbar.Label>Submit review</Toolbar.Label>
617
- </Toolbar.MenuAction>
618
- ) : null}
619
- {permissions.canComment ? (
620
- <Toolbar.MenuAction
621
- icon="plus.bubble"
622
- onPress={() =>
623
- navigation.navigate("PullRequestReview", { ...params, mode: "comment" })
624
- }
625
- >
626
- <Toolbar.Label>Add comment</Toolbar.Label>
627
- </Toolbar.MenuAction>
628
- ) : null}
629
- {permissions.canEditChangeRequest ? (
630
- <Toolbar.MenuAction
631
- icon="pencil"
632
- onPress={() =>
633
- navigation.navigate("PullRequestEdit", { ...params, field: "title" })
634
- }
635
- >
636
- <Toolbar.Label>Edit title</Toolbar.Label>
637
- </Toolbar.MenuAction>
638
- ) : null}
639
- {permissions.canEditChangeRequest ? (
640
- <Toolbar.MenuAction
641
- icon="doc.text"
642
- disabled={description.pending}
643
- subtitle={description.pending ? "Saving…" : undefined}
644
- onPress={() => navigation.navigate("PullRequestEdit", { ...params, field: "body" })}
645
- >
646
- <Toolbar.Label>Edit description</Toolbar.Label>
647
- </Toolbar.MenuAction>
648
- ) : null}
649
- {maintainerEdits.visible ? (
650
- <Toolbar.MenuAction
651
- icon="pencil"
652
- isOn={maintainerEdits.value}
653
- disabled={maintainerEdits.saving}
654
- subtitle={maintainerEdits.subtitle}
655
- onPress={maintainerEdits.toggle}
656
- >
657
- <Toolbar.Label>Allow edits from maintainers</Toolbar.Label>
658
- </Toolbar.MenuAction>
659
- ) : null}
660
- {identity ? (
661
- <Toolbar.MenuAction
662
- icon="arrow.up.right"
663
- onPress={() => void Linking.openURL(identity.url)}
664
- >
665
- <Toolbar.Label>{openOnProviderLabel(identity.provider)}</Toolbar.Label>
666
- </Toolbar.MenuAction>
667
- ) : null}
668
- {identity ? (
669
- <Toolbar.MenuAction icon="link" onPress={() => copyPullRequestLink(identity)}>
670
- <Toolbar.Label>Copy link</Toolbar.Label>
671
- </Toolbar.MenuAction>
672
- ) : null}
673
- {identity ? (
674
- <Toolbar.MenuAction
675
- icon="square.and.arrow.up"
676
- onPress={() => sharePullRequestLink(identity)}
677
- >
678
- <Toolbar.Label>Share…</Toolbar.Label>
679
- </Toolbar.MenuAction>
680
- ) : null}
681
- {stateAction ? (
682
- <Toolbar.MenuAction
683
- icon={PR_ACTION_ICONS[stateAction]}
684
- destructive={stateAction === "close"}
685
- onPress={runStateAction}
686
- >
687
- <Toolbar.Label>{pullRequestActionLabel(stateAction, terminology)}</Toolbar.Label>
688
- </Toolbar.MenuAction>
689
- ) : null}
690
- {showsDeleteBranch ? (
691
- <Toolbar.MenuAction
692
- icon={PR_ACTION_ICONS["delete-branch"]}
693
- destructive
694
- disabled={!action.available("delete-branch")}
695
- subtitle={
696
- action.busy
697
- ? "Deleting…"
698
- : connected
699
- ? pr.headBranch
700
- : "Reconnect to delete this branch."
701
- }
702
- onPress={confirmDeleteBranch}
703
- >
704
- <Toolbar.Label>
705
- {pullRequestActionLabel("delete-branch", terminology)}
706
- </Toolbar.Label>
707
- </Toolbar.MenuAction>
708
- ) : null}
709
- </Toolbar.Menu>
710
- </Toolbar>
711
- <ScreenContent
712
- insetHorizontal={layout.usesSplitView}
713
- onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}
714
- >
582
+ <ScreenContent onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}>
583
{(["overview", "guide", "activity"] as const)
584
.filter((tab) => tab !== "guide" || guidesEnabled)
585
.map((tab) => (
602
currentScrollOffset.current = { tab, offset };
603
}}
604
className="flex-1"
737
- renderScrollComponent={
738
- Platform.OS === "ios" ? PullRequestTabScrollView : undefined
739
- }
605
+ renderScrollComponent={NativeScrollView}
606
// UIKit owns the bar's inset, so a minimizing bar and a resized column
607
// move the list in the same frame as the bar.
608
contentInsetAdjustmentBehavior="automatic"
743
- contentInsetStartAdjustment={barInsets.top}
609
+ contentInsetStartAdjustment={contentTopInset}
610
// RN scrollTo clamps against raw insets and ignores the automatic bar inset.
611
scrollToOverflowEnabled
612
refreshControl={
627
pendingDescriptionJump.current = false;
628
// Collapse changes the scroll range; restore the heading after that layout commits.
629
scrollViews.current.overview?.scrollToOffset({
764
- offset: bodyY.current + descriptionY.current - barInsets.top,
630
+ offset: bodyY.current + descriptionY.current - contentTopInset,
631
animated: false,
632
});
633
}}
638
// Short tabs must still be tall enough to preserve the collapsed header.
639
minHeight: Math.max(
640
0,
775
- viewportHeight + headerHeight - barInsets.top - barInsets.bottom,
641
+ viewportHeight + headerHeight - contentTopInset - contentBottomInset,
642
),
643
}}
644
data={[
826
const title = props.route.params.commit ? "Commit changes" : "Changes";
827
return (
828
<View className="flex-1 bg-screen">
963
- <NativeStackScreenOptions options={{ title, headerTitle: title }} />
964
- {Platform.OS === "android" ? (
965
- <AppBar embedded title={title} onBack={() => navigation.goBack()} />
966
- ) : null}
829
+ <AppBar title={title} onBack={() => navigation.goBack()} />
830
<View className="flex-1 items-center justify-center">
831
<AppActivityIndicator accessibilityLabel="Loading changes" />
832
</View>
835
}
836
837
function PullRequestFileRouteContent({ route }: PullRequestFileRouteProps) {
975
- const { layout } = useAdaptiveWorkspaceLayout();
838
const navigation = useNavigation();
839
const insets = useSafeAreaInsets();
840
+ const contentTopInset = useContentTopInset();
841
const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
842
const commit = route.params.commit;
843
const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(route.params)));
1013
const seekingFile = !targetFile && result.nextCursor !== null;
1014
const loadingDiff = (result.isPending && !data.rows.length) || (seekingFile && !result.error);
1015
return (
1153
- <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
1154
- <NativeStackScreenOptions
1155
- options={{
1156
- title,
1157
- headerTitle: title,
1158
- unstable_headerSubtitle: `${commit ? commit.slice(0, 7) : `#${route.params.number}`} · ${data.files.length} ${data.files.length === 1 ? "file" : "files"}${filter.hideTestFiles && filter.hiddenCount ? ` · ${filter.hiddenCount} ${filter.hiddenCount === 1 ? "test" : "tests"} hidden` : ""}`,
1159
- }}
1016
+ <View className="flex-1 android:bg-header ios:bg-screen">
1017
+ <AppBar
1018
+ title={title}
1019
+ subtitle={`${commit ? commit.slice(0, 7) : `#${route.params.number}`} · ${data.files.length} ${data.files.length === 1 ? "file" : "files"}${filter.hideTestFiles && filter.hiddenCount ? ` · ${filter.hiddenCount} ${filter.hiddenCount === 1 ? "test" : "tests"} hidden` : ""}`}
1020
+ onBack={() => navigation.goBack()}
1021
+ menus={[
1022
+ {
1023
+ title: "Diff options",
1024
+ icon: "ellipsis",
1025
+ items: [
1026
+ ...(permissions.verdicts.length
1027
+ ? [
1028
+ {
1029
+ id: "submit-review",
1030
+ title: "Submit review",
1031
+ icon: "text.bubble",
1032
+ onPress: () =>
1033
+ navigation.navigate("PullRequestReview", {
1034
+ ...route.params,
1035
+ mode: "review",
1036
+ }),
1037
+ },
1038
+ ]
1039
+ : []),
1040
+ ...(permissions.canComment
1041
+ ? [
1042
+ {
1043
+ id: "comment-on-pr",
1044
+ title: "Add comment",
1045
+ icon: "plus.bubble",
1046
+ onPress: () =>
1047
+ navigation.navigate("PullRequestReview", {
1048
+ ...route.params,
1049
+ mode: "comment",
1050
+ }),
1051
+ },
1052
+ ]
1053
+ : []),
1054
+ {
1055
+ id: "word-wrap",
1056
+ title: "Word wrap",
1057
+ icon: "text.alignleft",
1058
+ selected: appearance.codeWordBreak,
1059
+ onPress: () => setCodeWordBreak(!appearance.codeWordBreak),
1060
+ },
1061
+ {
1062
+ id: "hide-tests",
1063
+ title: "Hide test files",
1064
+ icon: "line.3.horizontal.decrease",
1065
+ selected: filter.hideTestFiles,
1066
+ onPress: toggleTestFiles,
1067
+ },
1068
+ ...(selectedRow && selectedFile && canCommentOnDiff
1069
+ ? [
1070
+ {
1071
+ id: "comment",
1072
+ title: route.params.replacingDraftId
1073
+ ? "Move draft to this line"
1074
+ : "Add review comment",
1075
+ icon: "bubble.left",
1076
+ onPress: () => commentOnLine(),
1077
+ },
1078
+ ]
1079
+ : []),
1080
+ ...(selectedRow && selectedFile
1081
+ ? [
1082
+ {
1083
+ id: "copy",
1084
+ title: "Copy line",
1085
+ icon: "document.on.document",
1086
+ onPress: () => void Clipboard.setStringAsync(selectedRow.content ?? ""),
1087
+ },
1088
+ ]
1089
+ : []),
1090
+ ],
1091
+ },
1092
+ ]}
1093
/>
1161
- {Platform.OS === "android" ? (
1162
- <AppBar
1163
- embedded
1164
- title={title}
1165
- onBack={() => navigation.goBack()}
1166
- trailing={
1167
- <Menu
1168
- actions={[
1169
- {
1170
- id: "word-wrap",
1171
- title: "Word wrap",
1172
- image: "text.alignleft",
1173
- state: appearance.codeWordBreak ? "on" : "off",
1174
- },
1175
- {
1176
- id: "hide-tests",
1177
- title: "Hide test files",
1178
- image: "line.3.horizontal.decrease",
1179
- state: filter.hideTestFiles ? "on" : "off",
1180
- },
1181
- ...(permissions.verdicts.length
1182
- ? [{ id: "submit-review", title: "Submit review", image: "text.bubble" }]
1183
- : []),
1184
- ...(permissions.canComment
1185
- ? [{ id: "comment-on-pr", title: "Add comment", image: "plus.bubble" }]
1186
- : []),
1187
- ...(selectedRow && selectedFile
1188
- ? [
1189
- ...(canCommentOnDiff ? [{ id: "comment", title: "Add review comment" }] : []),
1190
- { id: "copy", title: "Copy line" },
1191
- ]
1192
- : []),
1193
- ]}
1194
- onPressAction={({ nativeEvent }) => {
1195
- if (nativeEvent.event === "word-wrap") setCodeWordBreak(!appearance.codeWordBreak);
1196
- else if (nativeEvent.event === "hide-tests") toggleTestFiles();
1197
- else if (
1198
- nativeEvent.event === "submit-review" ||
1199
- nativeEvent.event === "comment-on-pr"
1200
- )
1201
- navigation.navigate("PullRequestReview", {
1202
- ...route.params,
1203
- mode: nativeEvent.event === "submit-review" ? "review" : "comment",
1204
- });
1205
- else if (nativeEvent.event === "comment") commentOnLine();
1206
- else void Clipboard.setStringAsync(selectedRow?.content ?? "");
1207
- }}
1208
- >
1209
- <View pointerEvents="none">
1210
- <IconButton icon="ellipsis" accessibilityLabel="Diff options" />
1211
- </View>
1212
- </Menu>
1213
- }
1214
- />
1215
- ) : null}
1216
- <Toolbar placement="right">
1217
- <Toolbar.Menu title="Diff options" accessibilityLabel="Diff options" icon="ellipsis">
1218
- {permissions.verdicts.length ? (
1219
- <Toolbar.MenuAction
1220
- icon="text.bubble"
1221
- onPress={() =>
1222
- navigation.navigate("PullRequestReview", { ...route.params, mode: "review" })
1223
- }
1224
- >
1225
- <Toolbar.Label>Submit review</Toolbar.Label>
1226
- </Toolbar.MenuAction>
1227
- ) : null}
1228
- {permissions.canComment ? (
1229
- <Toolbar.MenuAction
1230
- icon="plus.bubble"
1231
- onPress={() =>
1232
- navigation.navigate("PullRequestReview", { ...route.params, mode: "comment" })
1233
- }
1234
- >
1235
- <Toolbar.Label>Add comment</Toolbar.Label>
1236
- </Toolbar.MenuAction>
1237
- ) : null}
1238
- <Toolbar.MenuAction
1239
- icon="text.alignleft"
1240
- isOn={appearance.codeWordBreak}
1241
- onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
1242
- >
1243
- <Toolbar.Label>Word wrap</Toolbar.Label>
1244
- </Toolbar.MenuAction>
1245
- <Toolbar.MenuAction
1246
- icon="line.3.horizontal.decrease"
1247
- isOn={filter.hideTestFiles}
1248
- onPress={toggleTestFiles}
1249
- >
1250
- <Toolbar.Label>Hide test files</Toolbar.Label>
1251
- </Toolbar.MenuAction>
1252
- {selectedRow && selectedFile && canCommentOnDiff ? (
1253
- <Toolbar.MenuAction icon="bubble.left" onPress={() => commentOnLine()}>
1254
- <Toolbar.Label>
1255
- {route.params.replacingDraftId ? "Move draft to this line" : "Add review comment"}
1256
- </Toolbar.Label>
1257
- </Toolbar.MenuAction>
1258
- ) : null}
1259
- {selectedRow && selectedFile ? (
1260
- <Toolbar.MenuAction
1261
- icon="document.on.document"
1262
- onPress={() => void Clipboard.setStringAsync(selectedRow.content ?? "")}
1263
- >
1264
- <Toolbar.Label>Copy line</Toolbar.Label>
1265
- </Toolbar.MenuAction>
1266
- ) : null}
1267
- </Toolbar.Menu>
1268
- </Toolbar>
1094
{route.params.replacingDraftId ? (
1095
<Text className="px-4 py-2 text-xs text-foreground-muted">
1096
Select a current line, then choose “Move draft to this line” from its menu.
1102
{staleDiff ? (
1103
<View
1104
className="flex-row items-center gap-2 px-4 py-2"
1280
- style={{ paddingTop: Platform.OS === "ios" ? insets.top + 8 : 8 }}
1105
+ style={{ paddingTop: contentTopInset + 8 }}
1106
>
1107
<Text className="min-w-0 flex-1 text-xs text-foreground-muted">
1108
The branch changed. Reload before adding line comments.
1119
/>
1120
</View>
1121
) : null}
1297
- <ScreenContent insetHorizontal={layout.usesSplitView}>
1122
+ <ScreenContent>
1123
<View className="flex-1" collapsable={false}>
1124
{loadingDiff || result.error ? (
1300
- <View style={{ paddingTop: Platform.OS === "ios" && !staleDiff ? insets.top : 0 }}>
1125
+ <View style={{ paddingTop: staleDiff ? 0 : contentTopInset }}>
1126
<PullRequestReadStatus
1127
pending={loadingDiff}
1128
error={result.error}
1198
appearanceScheme={themeAppearance}
1199
rowHeight={nativeReviewDiffStyle.rowHeight}
1200
contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
1376
- contentInsetTop={Platform.OS === "ios" ? (staleDiff ? 0 : insets.top) : undefined}
1201
+ contentInsetTop={staleDiff ? 0 : contentTopInset}
1202
contentInsetBottom={Platform.OS === "android" ? toolbarHeight : insets.bottom}
1203
contentResetKey={`pull-request:${route.params.environmentId}:${route.params.repository}:${route.params.number}:${commit ?? "all"}`}
1204
/>
1208
!result.isPending &&
1209
!result.error &&
1210
!seekingFile ? (
1386
- <View style={{ paddingTop: Platform.OS === "ios" ? insets.top : 0 }}>
1211
+ <View style={{ paddingTop: contentTopInset }}>
1212
<EmptyState
1213
title="Only test files changed"
1214
detail="Test files are hidden from this review."