Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PullRequestRouteScreen.tsx

1,209 lines50.5 KB

1import { Toolbar } from "../../components/ui/Toolbar";
2import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
3import { Chip } from "../../components/ui/Chip";
4import { pullRequestTabOffset } from "./pullRequestTabScroll";
5import { guideFocusedRows, type GuideDiffFocus } from "./guide/guideDiffFocus";
6import { PullRequestGuideContent } from "./guide/PullRequestGuideScreen";
7import { useReviewGuidesEnabled } from "./guide/useReviewGuide";
8import {
9 filterPullRequestActivity,
10 DEFAULT_ACTIVITY_FILTER,
11 type ActivityFilter,
12} from "./pullRequestActivityFilter";
13import { PullRequestActivityFilters } from "./PullRequestActivityFilters";
14import type { LegendListRef } from "@legendapp/list/react-native";
15import { AnimatedLegendList } from "@legendapp/list/reanimated";
16import Animated from "react-native-reanimated";
17import {
18 PR_ROW_LAYOUT,
19 PR_ROW_ENTER,
20 PR_ROW_EXIT,
21 PR_POSITION_LAYOUT,
22} from "./pullRequestAnimations";
23import {
24 canPerformPullRequestAction,
25 openOnProviderLabel,
26 PR_ACTION_ICONS,
27 PR_ACTION_LABELS,
28} from "./pullRequestActions";
29import * as Clipboard from "expo-clipboard";
30import { Menu } from "../../components/ui/Menu";
31import { IconButton } from "../../components/ui/IconButton";
32import { Button } from "../../components/ui/Button";
33import { usePullRequestReviewDraft } from "./usePullRequestReviewDraft";
34import { usePullRequestFilesViewed } from "./usePullRequestFilesViewed";
35import { usePullRequestPermissions } from "./usePullRequestPermissions";
36import { usePullRequestAction } from "./usePullRequestAction";
37import { annotatePullRequestDiff, reviewPosition } from "./pullRequestDiffComments";
38import { usePullRequestFileFilter } from "./usePullRequestFileFilter";
39import { isPullRequestTestFile } from "./pullRequestFileFilters";
40import { useFocusEffect, useNavigation, type StaticScreenProps } from "@react-navigation/native";
41import { RegistryContext, useAtomRefresh } from "@effect/atom-react";
42import { pullRequestReviewKey } from "./pullRequestReviewDrafts";
43import { type PullRequestDetail, type PullRequestListEntry } from "@t3tools/contracts";
44import { PullRequestOverviewLoading } from "./PullRequestOverviewLoading";
45import { copyPullRequestLink, sharePullRequestLink } from "./pullRequestLink";
46import { pullRequestStatus } from "./pullRequestStatus";
47import { use, useEffect, useRef, useState } from "react";
48import {
49 Linking,
50 Platform,
51 Pressable,
52 RefreshControl,
53 ScrollView,
54 type ScrollViewProps,
55 StyleSheet,
56 View,
57} from "react-native";
58import { NativeScrollViewMarker as ScrollViewMarker } from "../../native/NativeScrollViewMarker";
59import { useSafeAreaInsets } from "react-native-safe-area-context";
60​
61import { AppText as Text } from "../../components/ui/AppText";
62import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
63import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
64import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
65import { AndroidWorkspaceSidebarButton } from "../layout/workspace-sidebar-toolbar";
66import { useAndroidWorkspaceBack } from "../workspace/useAndroidWorkspaceNavigation";
67import { EmptyState } from "../../components/ui/EmptyState";
68import { SegmentedControl } from "../../components/ui/SegmentedControl";
69import { SymbolView } from "../../components/ui/AppSymbol";
70import { relativeTime } from "../../lib/time";
71import { NativeStackScreenOptions } from "../../native/StackHeader";
72import { usePullRequestConnected } from "./usePullRequestConnected";
73import { composerPullRequests } from "../../state/pull-requests";
74import { useEnvironmentQuery } from "../../state/query";
75import { usePullToRefresh } from "../../state/use-pull-to-refresh";
76import {
77 isNativeReviewDiffDrawEvent,
78 resolveNativeReviewDiffView,
79 type NativeReviewDiffViewHandle,
80 type NativeReviewDiffViewProps,
81} from "../diffs/nativeReviewDiffSurface";
82import {
83 buildNativeReviewDiffData,
84 NATIVE_REVIEW_DIFF_CONTENT_WIDTH,
85} from "../review/nativeReviewDiffAdapter";
86import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
87import { useAppearanceCodeSurface } from "../settings/appearance/useAppearanceCodeSurface";
88import { useNativeReviewDiffBridge } from "../review/useNativeReviewDiffBridge";
89import { pullRequestTimelineRows } from "./PullRequestTimeline";
90import { PullRequestActionToolbar, PullRequestCardGroup } from "./PullRequestControls";
91import {
92 pullRequestTarget as requestTarget,
93 usePullRequestDiff,
94 type PullRequestDiffParams,
95 type PullRequestParams,
96} from "./usePullRequestDiff";
97import {
98 PullRequestAvatar,
99 PullRequestDiffStats,
100 PullRequestReadStatus,
101} from "./PullRequestPresentation";
102import { usePullRequestFilesSection } from "./PullRequestFiles";
103import { PullRequestDescription } from "./PullRequestDescription";
104import { PullRequestMarkdownRepository } from "./PullRequestMarkdown";
105import {
106 PullRequestStatusMenu,
107 PullRequestChecksRow,
108 PullRequestBranchRow,
109 PullRequestReviewersRow,
110} from "./PullRequestStatusRows";
111import { PullRequestMergeControls } from "./PullRequestMergeControls";
112import { PullRequestStackCard } from "./PullRequestStackCard";
113import { usePullRequestStack, type PullRequestStackState } from "./usePullRequestStack";
114import { usePullRequestEnvironmentFallback } from "./usePullRequestEnvironmentFallback";
115​
116const EMPTY_IDS: readonly string[] = [];
117​
118function PullRequestTabScrollView(props: ScrollViewProps) {
119 const insets = useSafeAreaInsets();
120 return (
121 <ScrollViewMarker style={{ flex: 1 }}>
122 <ScrollView
123 {...props}
124 automaticallyAdjustContentInsets={false}
125 contentInsetAdjustmentBehavior="never"
126 contentOffset={props.contentOffset ?? { x: 0, y: -insets.top }}
127 />
128 </ScrollViewMarker>
129 );
131​
132function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityFilter) {
133 const navigation = useNavigation();
134 const result = useEnvironmentQuery(composerPullRequests.activity(requestTarget(params)));
135 const filtered = result.data ? filterPullRequestActivity(result.data, filter) : null;
136 const rows = (() => {
137 if (!filtered) return [];
138 const rows = pullRequestTimelineRows(filtered.activity, params, navigation);
139 if (filter.newestFirst) {
140 const notice = rows.at(-1)?.key === "truncated" ? rows.pop() : undefined;
141 rows.reverse();
142 if (notice) rows.push(notice);
143 }
144 if (!rows.length)
145 rows.push({
146 key: "empty",
147 date: "",
148 content: (
149 <Text className="py-6 text-sm text-foreground-muted">
150 No activity matches these filters.
151 </Text>
152 ),
153 });
154 return rows;
155 })();
156 return {
157 rows,
158 hiddenCount: filtered?.hiddenCount ?? 0,
159 pending: result.isPending && !result.data,
160 error: result.error,
161 };
163​
164function PullRequestIdentity(props: {
165 readonly pr: PullRequestDetail | PullRequestListEntry;
166 readonly params: PullRequestParams;
167}) {
168 const { pr } = props;
169 const status = pullRequestStatus(pr);
170 return (
171 <View className="gap-3">
172 <View className="flex-row flex-wrap items-center gap-2">
173 {"capabilities" in pr ? (
174 <PullRequestStatusMenu pr={pr} params={props.params} />
175 ) : (
176 <View className="min-h-8 flex-row items-center gap-1.5">
177 <SymbolView name={status.icon} size={14} tintColorClassName={status.tint} />
178 <Text className={`text-xs font-t3-medium ${status.text}`}>{status.label}</Text>
179 </View>
180 )}
181 <PullRequestDiffStats additions={pr.additions} deletions={pr.deletions} compact />
182 {"changedFiles" in pr ? (
183 <Text className="text-2xs text-foreground-muted">
184 {pr.changedFiles} {pr.changedFiles === 1 ? "file" : "files"}
185 </Text>
186 ) : (
187 <View className="h-3 w-12 rounded bg-subtle-strong" />
188 )}
189 </View>
190 <Text selectable className="text-xl font-t3-bold leading-7">
191 {pr.title}
192 </Text>
193 <View className="flex-row items-center gap-2">
194 <PullRequestAvatar actor={pr.author} size={20} />
195 <Text className="min-w-0 flex-1 text-xs font-t3-medium" numberOfLines={1}>
196 {pr.author?.login ?? "Unknown author"}
197 </Text>
198 <Text className="shrink text-right text-2xs text-foreground-muted" numberOfLines={1}>
199 Updated {relativeTime(pr.updatedAt)} ago
200 </Text>
201 </View>
202 <View className="flex-row items-start gap-1.5">
203 <Pressable
204 accessibilityRole="button"
205 accessibilityLabel={`Copy base branch ${pr.baseBranch}`}
206 onPress={() => void Clipboard.setStringAsync(pr.baseBranch)}
207 className="min-w-0 shrink active:opacity-70"
208 hitSlop={8}
209 >
210 <Text className="font-mono text-2xs text-foreground-muted">{pr.baseBranch}</Text>
211 </Pressable>
212 <View className="pt-0.5">
213 <SymbolView name="arrow.left" size={11} tintColorClassName="accent-icon-muted" />
214 </View>
215 <Pressable
216 accessibilityRole="button"
217 accessibilityLabel={`Copy head branch ${pr.headBranch}`}
218 onPress={() => void Clipboard.setStringAsync(pr.headBranch)}
219 className="min-w-0 shrink active:opacity-70"
220 hitSlop={8}
221 >
222 <Text className="font-mono text-2xs text-foreground-muted">{pr.headBranch}</Text>
223 </Pressable>
224 </View>
225 </View>
226 );
228​
229function PullRequestOverview(props: {
230 readonly pr: PullRequestDetail;
231 readonly params: PullRequestParams;
232 readonly stack: PullRequestStackState;
233 readonly onDescriptionLayout: (y: number) => void;
234 readonly onDescriptionCollapse: () => void;
235 readonly descriptionExpanded: boolean;
236 readonly onDescriptionExpandedChange: (expanded: boolean) => void;
237}) {
238 const { pr } = props;
239 return (
240 <View className="gap-5">
241 <PullRequestStackCard params={props.params} state={props.stack} />
242 <PullRequestCardGroup>
243 <PullRequestChecksRow pr={pr} params={props.params} />
244 <PullRequestReviewersRow pr={pr} params={props.params} />
245 <Animated.View layout={PR_ROW_LAYOUT}>
246 <PullRequestBranchRow pr={pr} params={props.params} />
247 </Animated.View>
248 <Animated.View layout={PR_ROW_LAYOUT}>
249 <PullRequestMergeControls pr={pr} params={props.params} stack={props.stack} />
250 </Animated.View>
251 </PullRequestCardGroup>
252 {pr.labels.length ? (
253 <Animated.View layout={PR_ROW_LAYOUT} className="flex-row flex-wrap gap-2">
254 {pr.labels.map((label) => (
255 <Chip key={label.name} label={label.name} size="small" />
256 ))}
257 </Animated.View>
258 ) : null}
259 <Animated.View
260 layout={PR_POSITION_LAYOUT}
261 onLayout={(event) => props.onDescriptionLayout(event.nativeEvent.layout.y)}
262 >
263 <PullRequestDescription
264 markdown={pr.body}
265 onCollapse={props.onDescriptionCollapse}
266 expanded={props.descriptionExpanded}
267 onExpandedChange={props.onDescriptionExpandedChange}
268 />
269 </Animated.View>
270 </View>
271 );
273​
274function usePullRequestToolbarHeight(bottomInset: number) {
275 const { buttonSize } = useAndroidControlSizing();
276 return useState(() => (Platform.OS === "android" ? bottomInset + buttonSize + 40 : 0));
278​
279export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestParams>) {
280 const returnToList = useAndroidWorkspaceBack("pullRequests");
281 const { layout } = useAdaptiveWorkspaceLayout();
282 const navigation = useNavigation();
283 const insets = useSafeAreaInsets();
284 const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
285 const params = route.params;
286 usePullRequestEnvironmentFallback(params);
287 const connected = usePullRequestConnected(params.environmentId);
288 const [section, setSection] = useState<"overview" | "activity" | "guide">("overview");
289 const requestedSection = useRef(section);
290 const [listAnimationsReady, setListAnimationsReady] = useState(false);
291 const [descriptionExpanded, setDescriptionExpanded] = useState(false);
292 const filesContent = usePullRequestFilesSection(params);
293 const guidesEnabled = useReviewGuidesEnabled(params);
294 const [activityFilter, setActivityFilter] = useState<ActivityFilter>(DEFAULT_ACTIVITY_FILTER);
295 const activityContent = usePullRequestActivityRows(params, activityFilter);
296 const scrollOffsets = useRef<Record<string, number>>({});
297 const currentScrollOffset = useRef(-insets.top);
298 const bodyY = useRef(0);
299 const [headerHeight, setHeaderHeight] = useState(0);
300 const [viewportHeight, setViewportHeight] = useState(0);
301 const scrollViews = useRef<Partial<Record<typeof section, LegendListRef | null>>>({});
302 const selectSection = (next: typeof section) => {
303 if (next === section) return;
304 scrollOffsets.current[section] = currentScrollOffset.current;
305 const headerEnd = Math.max(-insets.top, bodyY.current - insets.top);
306 const offset = pullRequestTabOffset(
307 currentScrollOffset.current,
308 scrollOffsets.current[next],
309 headerEnd,
310 );
311 requestedSection.current = next;
312 scrollOffsets.current[next] = offset;
313 currentScrollOffset.current = offset;
314 scrollViews.current[next]?.scrollToOffset({ offset, animated: false });
315 setSection(next);
316 };
317 useEffect(() => {
318 if (!guidesEnabled && section === "guide") {
319 requestedSection.current = "overview";
320 currentScrollOffset.current = scrollOffsets.current.overview ?? -insets.top;
321 setSection("overview");
322 }
323 }, [guidesEnabled, section, insets.top]);
324 const tabContent = activityContent;
325 const filesY = useRef(0);
326 const descriptionY = useRef(0);
327 const pendingDescriptionJump = useRef(false);
328 const pendingFilesJump = useRef(false);
329 const detailAtom = composerPullRequests.detail(requestTarget(params));
330 const result = useEnvironmentQuery(detailAtom);
331 const pullRefresh = usePullToRefresh(detailAtom);
332 const { refresh: refreshDetail } = result;
333 useFocusEffect(() => refreshDetail());
334 const pr = result.data;
335 const summary = params.initialSummary;
336 const identity = pr ?? summary;
337 const permissions = usePullRequestPermissions(params, pr);
338 const action = usePullRequestAction(params, pr);
339 const showsDeleteBranch = pr !== null && canPerformPullRequestAction(pr, "delete-branch");
340 const confirmDeleteBranch = () =>
341 pr &&
342 action.confirm(
343 "delete-branch",
344 PR_ACTION_LABELS["delete-branch"],
345 `Delete ${pr.headBranch} from ${pr.headRepositoryNameWithOwner ?? pr.repository}? Local branches and worktrees are not changed.`,
346 );
347 const stack = usePullRequestStack(params, pr);
348 const refreshActivity = useAtomRefresh(composerPullRequests.activity(requestTarget(params)));
349 const refreshGuide = useAtomRefresh(composerPullRequests.reviewGuide(requestTarget(params)));
350 const registry = use(RegistryContext);
351 const refresh = () =>
352 pullRefresh.onRefresh(async (signal) => {
353 const target = requestTarget(params);
354 await composerPullRequests.invalidate
355 .run(registry, {
356 environmentId: target.environmentId,
357 input: { reference: target.input },
358 })
359 .catch(() => undefined);
360 if (signal.aborted) return;
361 if (guidesEnabled) refreshGuide();
362 stack.refresh();
363 refreshActivity();
364 filesContent.refresh();
365 });
366 const jumpToFiles = () => {
367 scrollViews.current.overview?.scrollToOffset({
368 offset: bodyY.current + filesY.current - insets.top,
369 animated: true,
370 });
371 pendingFilesJump.current = false;
372 };
373 const openFiles = () => {
374 if (section === "overview") jumpToFiles();
375 else {
376 pendingFilesJump.current = true;
377 selectSection("overview");
378 if (filesY.current > 0) requestAnimationFrame(jumpToFiles);
379 }
380 };
381 return (
382 <PullRequestMarkdownRepository
383 params={params}
384 value={pr?.provider === "github" ? pr.url : null}
385 >
386 <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
387 <NativeStackScreenOptions
388 options={{
389 title: `#${params.number}`,
390 headerTitle: `#${params.number}`,
391 unstable_headerSubtitle: connected
392 ? params.repository
393 : `${params.repository} · Offline`,
394 }}
395 />
396 {Platform.OS === "android" ? (
397 <AndroidScreenHeader
398 title={`#${params.number}${connected ? "" : " · Offline"}`}
399 subtitle={params.repository}
400 onBack={layout.usesSplitView ? undefined : returnToList}
401 leading={layout.usesSplitView ? <AndroidWorkspaceSidebarButton /> : undefined}
402 actions={[
403 ...(permissions.verdicts.length
404 ? [
405 {
406 accessibilityLabel: "Submit review",
407 icon: "text.bubble" as const,
408 onPress: () =>
409 navigation.navigate("PullRequestReview", { ...params, mode: "review" }),
410 },
411 ]
412 : []),
413 ...(permissions.canComment
414 ? [
415 {
416 accessibilityLabel: "Add comment",
417 icon: "plus.bubble" as const,
418 onPress: () =>
419 navigation.navigate("PullRequestReview", { ...params, mode: "comment" }),
420 },
421 ]
422 : []),
423 ...(identity
424 ? [
425 {
426 accessibilityLabel: openOnProviderLabel(identity.provider),
427 icon: "arrow.up.right" as const,
428 onPress: () => void Linking.openURL(identity.url),
429 },
430 {
431 accessibilityLabel: "Copy link",
432 icon: "link" as const,
433 overflowOnly: true,
434 onPress: () => copyPullRequestLink(identity),
435 },
436 {
437 accessibilityLabel: "Share…",
438 icon: "square.and.arrow.up" as const,
439 overflowOnly: true,
440 onPress: () => sharePullRequestLink(identity),
441 },
442 ]
443 : []),
444 ...(showsDeleteBranch
445 ? [
446 {
447 accessibilityLabel: PR_ACTION_LABELS["delete-branch"],
448 icon: PR_ACTION_ICONS["delete-branch"],
449 disabled: !action.available("delete-branch"),
450 destructive: true,
451 overflowOnly: true,
452 onPress: confirmDeleteBranch,
453 },
454 ]
455 : []),
456 ]}
457 />
458 ) : null}
459 <Toolbar placement="right">
460 <Toolbar.Menu
461 title="Pull request"
462 accessibilityLabel="Pull request actions"
463 icon="ellipsis"
464 >
465 {permissions.verdicts.length ? (
466 <Toolbar.MenuAction
467 icon="text.bubble"
468 onPress={() =>
469 navigation.navigate("PullRequestReview", { ...params, mode: "review" })
470 }
471 >
472 <Toolbar.Label>Submit review</Toolbar.Label>
473 </Toolbar.MenuAction>
474 ) : null}
475 {permissions.canComment ? (
476 <Toolbar.MenuAction
477 icon="plus.bubble"
478 onPress={() =>
479 navigation.navigate("PullRequestReview", { ...params, mode: "comment" })
480 }
481 >
482 <Toolbar.Label>Add comment</Toolbar.Label>
483 </Toolbar.MenuAction>
484 ) : null}
485 {identity ? (
486 <Toolbar.MenuAction
487 icon="arrow.up.right"
488 onPress={() => void Linking.openURL(identity.url)}
489 >
490 <Toolbar.Label>{openOnProviderLabel(identity.provider)}</Toolbar.Label>
491 </Toolbar.MenuAction>
492 ) : null}
493 {identity ? (
494 <Toolbar.MenuAction icon="link" onPress={() => copyPullRequestLink(identity)}>
495 <Toolbar.Label>Copy link</Toolbar.Label>
496 </Toolbar.MenuAction>
497 ) : null}
498 {identity ? (
499 <Toolbar.MenuAction
500 icon="square.and.arrow.up"
501 onPress={() => sharePullRequestLink(identity)}
502 >
503 <Toolbar.Label>Share…</Toolbar.Label>
504 </Toolbar.MenuAction>
505 ) : null}
506 {showsDeleteBranch ? (
507 <Toolbar.MenuAction
508 icon={PR_ACTION_ICONS["delete-branch"]}
509 destructive
510 disabled={!action.available("delete-branch")}
511 subtitle={
512 action.busy
513 ? "Deleting…"
514 : connected
515 ? pr.headBranch
516 : "Reconnect to delete this branch."
517 }
518 onPress={confirmDeleteBranch}
519 >
520 <Toolbar.Label>{PR_ACTION_LABELS["delete-branch"]}</Toolbar.Label>
521 </Toolbar.MenuAction>
522 ) : null}
523 </Toolbar.Menu>
524 </Toolbar>
525 <View
526 style={{
527 flex: 1,
528 marginHorizontal: Platform.OS === "android" && layout.usesSplitView ? 4 : 0,
529 }}
530 className={
531 Platform.OS === "android"
532 ? "overflow-hidden rounded-t-[28px] bg-sheet-solid"
533 : undefined
534 }
535 onLayout={(event) => setViewportHeight(event.nativeEvent.layout.height)}
536 >
537 {(["overview", "guide", "activity"] as const)
538 .filter((tab) => tab !== "guide" || guidesEnabled)
539 .map((tab) => (
540 <View
541 key={tab}
542 style={[StyleSheet.absoluteFill, { opacity: section === tab ? 1 : 0 }]}
543 pointerEvents={section === tab ? "auto" : "none"}
544 accessibilityElementsHidden={section !== tab}
545 importantForAccessibility={section === tab ? "auto" : "no-hide-descendants"}
546 >
547 <AnimatedLegendList
548 ref={(list) => {
549 scrollViews.current[tab] = list;
550 }}
551 initialScrollOffset={-insets.top}
552 onScroll={(event) => {
553 const offset = event.nativeEvent.contentOffset.y;
554 scrollOffsets.current[tab] = offset;
555 if (requestedSection.current === tab) currentScrollOffset.current = offset;
556 }}
557 className="flex-1"
558 renderScrollComponent={
559 Platform.OS === "ios" ? PullRequestTabScrollView : undefined
560 }
561 contentInsetAdjustmentBehavior="never"
562 contentInset={
563 Platform.OS === "ios" ? { top: insets.top, bottom: insets.bottom } : undefined
564 }
565 contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
566 refreshControl={
567 <RefreshControl
568 refreshing={section === tab && pullRefresh.refreshing}
569 onRefresh={refresh}
570 />
571 }
572 alwaysBounceVertical
573 scrollsToTop={section === tab}
574 onContentSizeChange={() => {
575 if (
576 tab !== "overview" ||
577 section !== "overview" ||
578 !pendingDescriptionJump.current
579 )
580 return;
581 pendingDescriptionJump.current = false;
582 // Collapse changes the scroll range; restore the heading after that layout commits.
583 scrollViews.current.overview?.scrollToOffset({
584 offset: bodyY.current + descriptionY.current - insets.top,
585 animated: false,
586 });
587 }}
588 contentContainerStyle={{
589 paddingHorizontal: 16,
590 paddingTop: 8,
591 paddingBottom: 24 + (Platform.OS === "android" ? toolbarHeight : 0),
592 // Short tabs must still be tall enough to preserve the collapsed header.
593 minHeight: Math.max(
594 0,
595 viewportHeight + headerHeight - insets.top - insets.bottom,
596 ),
597 }}
598 data={[
599 {
600 key: `${tab}:body`,
601 content: (
602 <View>
603 {tab === "overview" && identity ? (
604 <View>
605 {pr ? (
606 <PullRequestOverview
607 pr={pr}
608 params={params}
609 stack={stack}
610 descriptionExpanded={descriptionExpanded}
611 onDescriptionExpandedChange={setDescriptionExpanded}
612 onDescriptionLayout={(y) => {
613 descriptionY.current = y;
614 }}
615 onDescriptionCollapse={() => {
616 pendingDescriptionJump.current = true;
617 }}
618 />
619 ) : summary ? (
620 <PullRequestOverviewLoading
621 summary={summary}
622 params={params}
623 stack={stack}
624 />
625 ) : null}
626 <View
627 className="mt-8 border-t border-border-subtle pt-3"
628 onLayout={(event) => {
629 filesY.current = event.nativeEvent.layout.y;
630 if (pendingFilesJump.current) {
631 requestAnimationFrame(() => {
632 if (requestedSection.current === "overview") jumpToFiles();
633 });
634 }
635 }}
636 >
637 {filesContent.header}
638 </View>
639 </View>
640 ) : null}
641 {tab === "guide" ? <PullRequestGuideContent params={params} /> : null}
642 {tab === "activity" ? (
643 <PullRequestActivityFilters
644 value={activityFilter}
645 onChange={setActivityFilter}
646 hiddenCount={tabContent.hiddenCount}
647 />
648 ) : null}
649 {tab === "activity" ? (
650 <PullRequestReadStatus
651 pending={tabContent.pending}
652 error={tabContent.error}
653 />
654 ) : null}
655 </View>
656 ),
657 },
658 ...(tab === "overview"
659 ? identity
660 ? filesContent.rows
661 : []
662 : tab === "activity"
663 ? tabContent.rows
664 : []
665 ).map((row) => ({
666 ...row,
667 key: `${tab}:${row.key}`,
668 content: row.content,
669 })),
670 ]}
671 keyExtractor={(row) => row.key}
672 getItemType={(row) =>
673 row.key.endsWith(":body") ? row.key : row.key.split(":")[0]
674 }
675 // The overview body contains the clipped description and owns collapse scroll
676 // correction. Animating that cell fights both; file rows still fade individually.
677 itemLayoutAnimation={tab === "overview" ? undefined : PR_ROW_LAYOUT}
678 onLoad={() => setListAnimationsReady(true)}
679 renderItem={({ item }) => (
680 <Animated.View
681 key={item.key}
682 entering={
683 listAnimationsReady && !item.key.endsWith(":body")
684 ? PR_ROW_ENTER
685 : undefined
686 }
687 exiting={
688 listAnimationsReady && !item.key.endsWith(":body") ? PR_ROW_EXIT : undefined
689 }
690 >
691 {item.content}
692 </Animated.View>
693 )}
694 recycleItems={false}
695 estimatedItemSize={tab === "overview" ? 64 : 220}
696 maintainVisibleContentPosition={false}
697 ListHeaderComponent={
698 <>
699 <PullRequestReadStatus
700 pending={result.isPending && !identity}
701 error={result.error}
702 />
703 {identity ? (
704 <View
705 className="gap-5 pb-5"
706 onLayout={(event) => {
707 bodyY.current = event.nativeEvent.layout.height;
708 setHeaderHeight(event.nativeEvent.layout.height);
709 }}
710 >
711 <PullRequestIdentity pr={identity} params={params} />
712 <SegmentedControl
713 options={[
714 { value: "overview", label: "Overview" },
715 ...(guidesEnabled
716 ? [{ value: "guide" as const, label: "Guide" }]
717 : []),
718 { value: "activity", label: "Activity" },
719 ]}
720 selected={section}
721 onSelect={selectSection}
722 role="tab"
723 size="compact"
724 />
725 </View>
726 ) : null}
727 </>
728 }
729 ListFooterComponent={tab === "overview" ? filesContent.footer : null}
730 />
731 </View>
732 ))}
733 </View>
734 <PullRequestActionToolbar
735 pr={pr}
736 params={params}
737 onOpenFiles={openFiles}
738 onHeightChange={setToolbarHeight}
739 />
740 </View>
741 </PullRequestMarkdownRepository>
742 );
744​
745export function PullRequestFileRouteScreen({
746 route,
747}: StaticScreenProps<
748 PullRequestDiffParams & {
749 readonly path: string;
750 readonly fileSelectionId?: string;
751 readonly replacingDraftId?: string;
752 readonly focus?: GuideDiffFocus;
753 }
754>) {
755 const { layout } = useAdaptiveWorkspaceLayout();
756 const navigation = useNavigation();
757 const insets = useSafeAreaInsets();
758 const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
759 const commit = route.params.commit;
760 const result = usePullRequestDiff(route.params);
761 const filter = usePullRequestFileFilter(
762 result.parsed,
763 route.params.focus ? route.params.path : undefined,
764 );
765 const detail = useEnvironmentQuery(composerPullRequests.detail(requestTarget(route.params)));
766 const { refresh: refreshDetail } = detail;
767 useFocusEffect(() => refreshDetail());
768 const { loadMore } = result;
769 const parsed = filter.parsed;
770 const reviewDraft = usePullRequestReviewDraft(route.params);
771 const viewed = usePullRequestFilesViewed(route.params, commit ? null : detail.data);
772 const [commitViewedPaths, setCommitViewedPaths] = useState<ReadonlySet<string>>(() => new Set());
773 const permissions = usePullRequestPermissions(route.params, detail.data);
774 const scopeKey = pullRequestReviewKey(route.params);
775 const [diffHead, setDiffHead] = useState({ scopeKey, sha: detail.data?.headSha ?? null });
776 if (diffHead.scopeKey !== scopeKey || (!diffHead.sha && detail.data?.headSha))
777 setDiffHead({ scopeKey, sha: detail.data?.headSha ?? null });
778 const staleDiff = Boolean(
779 !commit && diffHead.sha && detail.data?.headSha && diffHead.sha !== detail.data.headSha,
780 );
781 const canCommentOnDiff =
782 permissions.canInlineComment &&
783 !commit &&
784 !staleDiff &&
785 !detail.isPending &&
786 !result.isPending &&
787 !result.error;
788 const activity = useEnvironmentQuery(composerPullRequests.activity(requestTarget(route.params)));
789 const baseData = buildNativeReviewDiffData(parsed);
790 const data = annotatePullRequestDiff(
791 baseData,
792 staleDiff || commit ? [] : (activity.data?.reviewThreads ?? []),
793 commit ? [] : reviewDraft.draft.comments,
794 diffHead.sha ?? undefined,
795 );
796 const viewedIds = data.files
797 .filter((file) => (commit ? commitViewedPaths.has(file.path) : viewed.isViewed(file.path)))
798 .map((file) => file.id);
799 const [selectedRowId, setSelectedRowId] = useState<string | null>(null);
800 const selectedRow = data.rows.find((row) => row.id === selectedRowId);
801 const selectedFile = data.files.find((file) => file.id === selectedRow?.fileId);
802 const commentOnLine = (rowId = selectedRowId) => {
803 const row = data.rows.find((row) => row.id === rowId);
804 const file = data.files.find((file) => file.id === row?.fileId);
805 if (!row || !file || !diffHead.sha || !canCommentOnDiff) return;
806 const position = reviewPosition(row);
807 if (!position) return;
808 const oldPath =
809 parsed.kind === "files"
810 ? parsed.files.find((entry) => entry.id === file.id)?.previousPath
811 : null;
812 if (route.params.replacingDraftId) navigation.setParams({ replacingDraftId: undefined });
813 navigation.navigate("PullRequestInlineComment", {
814 ...route.params,
815 ...(route.params.replacingDraftId ? { draftId: route.params.replacingDraftId } : {}),
816 path: file.path,
817 ...(oldPath ? { oldPath } : {}),
818 position,
819 headSha: diffHead.sha,
820 code: row.content ?? "",
821 });
822 };
823 const [jumpPath, setJumpPath] = useState(route.params.path);
824 const requestedFile =
825 result.parsed.kind === "files"
826 ? result.parsed.files.find((file) => file.path === jumpPath)
827 : undefined;
828 const targetFile =
829 data.files.find((file) => file.path === jumpPath) ??
830 (!jumpPath || requestedFile ? data.files[0] : undefined);
831 const focus = route.params.focus;
832 const focusedRows = guideFocusedRows(data.rows, targetFile?.id, focus);
833 const focusIndex = focusedRows.length
834 ? data.rows.findIndex((row) => row.id === focusedRows[0]?.id)
835 : -1;
836 const [collapsedIds, setCollapsedIds] = useState<readonly string[]>(EMPTY_IDS);
837 const [visibleFileId, setVisibleFileId] = useState<string | null>(null);
838 const nativeView = useRef<NativeReviewDiffViewHandle>(null);
839 const jumpStarted = useRef(false);
840 const lastSelection = useRef({ path: route.params.path, id: route.params.fileSelectionId });
841 useEffect(() => {
842 if (
843 lastSelection.current.path === route.params.path &&
844 lastSelection.current.id === route.params.fileSelectionId
845 )
846 return;
847 lastSelection.current = { path: route.params.path, id: route.params.fileSelectionId };
848 if (route.params.focus) navigation.setParams({ focus: undefined });
849 setJumpPath(route.params.path);
850 setSelectedRowId(null);
851 jumpStarted.current = false;
852 const file = data.files.find((entry) => entry.path === route.params.path);
853 if (!file || !nativeView.current) return;
854 setCollapsedIds((ids) => ids.filter((id) => id !== file.id));
855 jumpStarted.current = true;
856 void nativeView.current.scrollToFile(file.id, false).catch(() => {
857 jumpStarted.current = false;
858 });
859 }, [route.params.path, route.params.fileSelectionId, route.params.focus, data.files, navigation]);
860 const appliedFilter = useRef(filter.hideTestFiles);
861 useEffect(() => {
862 if (appliedFilter.current === filter.hideTestFiles) return;
863 appliedFilter.current = filter.hideTestFiles;
864 if (
865 result.parsed.kind === "files" &&
866 result.parsed.files.some((file) => isPullRequestTestFile(file.path))
867 ) {
868 jumpStarted.current = false;
869 }
870 }, [filter.hideTestFiles, result.parsed]);
871 const { nativeReviewDiffStyle } = useAppearanceCodeSurface();
872 const { themeAppearance, appearance, setCodeWordBreak } = useAppearancePreferences();
873 const bridge = useNativeReviewDiffBridge({
874 threadKey: null,
875 sectionId: `pull-request:${route.params.repository}:${route.params.number}:${commit ?? "all"}`,
876 diff: result.patch,
877 data,
878 collapsedFileIds: collapsedIds,
879 viewedFileIds: viewedIds,
880 selectedRowIds: selectedRowId ? [selectedRowId] : focusedRows.map((row) => row.id),
881 canHighlight: true,
882 });
883 const [NativeDiffView] = useState(() => resolveNativeReviewDiffView());
884 useEffect(() => {
885 if (!targetFile) loadMore();
886 }, [targetFile, loadMore]);
887 const { onDebug: updateVisibleRange } = bridge;
888 const onDebug: NonNullable<NativeReviewDiffViewProps["onDebug"]> = (event) => {
889 const drawn = isNativeReviewDiffDrawEvent(event.nativeEvent);
890 const decoded =
891 event.nativeEvent.message === "rows-decoded" && event.nativeEvent.rows === data.rows.length;
892 if (!drawn && !decoded) return;
893 // Filtering replaces the native row payload asynchronously. Old draw events
894 // must not consume the file jump or highlight the new payload's row indices.
895 if (
896 typeof event.nativeEvent.totalRows === "number" &&
897 event.nativeEvent.totalRows !== data.rows.length
898 )
899 return;
900 if (drawn) updateVisibleRange(event);
901 if (
902 targetFile &&
903 !jumpStarted.current &&
904 nativeView.current &&
905 (Platform.OS !== "ios" || decoded)
906 ) {
907 jumpStarted.current = true;
908 if (focusIndex >= 0) return;
909 void nativeView.current.scrollToFile(targetFile.id, false).catch(() => {
910 jumpStarted.current = false;
911 });
912 return;
913 }
914 if (!drawn) return;
915 const lastRow = event.nativeEvent.lastRowIndex;
916 if (typeof lastRow === "number" && lastRow >= data.rows.length - 40) loadMore();
917 };
918 const onToggleFile: NonNullable<NativeReviewDiffViewProps["onToggleFile"]> = (event) => {
919 const id = event.nativeEvent.fileId;
920 if (!id) return;
921 setCollapsedIds((ids) =>
922 ids.includes(id) ? ids.filter((value) => value !== id) : [...ids, id],
923 );
924 };
925 const visibleFile = data.files.find((file) => file.id === visibleFileId) ?? targetFile;
926 const toggleTestFiles = () => {
927 setJumpPath(visibleFile?.path ?? route.params.path);
928 setSelectedRowId(null);
929 filter.toggle();
930 };
931 const title = commit ? "Commit changes" : "Changes";
932 const seekingFile = !targetFile && result.nextCursor !== null;
933 const loadingDiff = (result.isPending && !data.rows.length) || (seekingFile && !result.error);
934 return (
935 <View className={Platform.OS === "android" ? "flex-1 bg-header" : "flex-1 bg-screen"}>
936 <NativeStackScreenOptions
937 options={{
938 title,
939 headerTitle: title,
940 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` : ""}`,
941 }}
942 />
943 {Platform.OS === "android" ? (
944 <AndroidScreenHeader
945 title={title}
946 onBack={() => navigation.goBack()}
947 trailing={
948 <Menu
949 actions={[
950 {
951 id: "word-wrap",
952 title: "Word wrap",
953 image: "text.alignleft",
954 state: appearance.codeWordBreak ? "on" : "off",
955 },
956 {
957 id: "hide-tests",
958 title: "Hide test files",
959 image: "line.3.horizontal.decrease",
960 state: filter.hideTestFiles ? "on" : "off",
961 },
962 ...(permissions.verdicts.length
963 ? [{ id: "submit-review", title: "Submit review", image: "text.bubble" }]
964 : []),
965 ...(permissions.canComment
966 ? [{ id: "comment-on-pr", title: "Add comment", image: "plus.bubble" }]
967 : []),
968 ...(selectedRow && selectedFile
969 ? [
970 ...(canCommentOnDiff ? [{ id: "comment", title: "Add review comment" }] : []),
971 { id: "copy", title: "Copy line" },
972 ]
973 : []),
974 ]}
975 onPressAction={({ nativeEvent }) => {
976 if (nativeEvent.event === "word-wrap") setCodeWordBreak(!appearance.codeWordBreak);
977 else if (nativeEvent.event === "hide-tests") toggleTestFiles();
978 else if (
979 nativeEvent.event === "submit-review" ||
980 nativeEvent.event === "comment-on-pr"
981 )
982 navigation.navigate("PullRequestReview", {
983 ...route.params,
984 mode: nativeEvent.event === "submit-review" ? "review" : "comment",
985 });
986 else if (nativeEvent.event === "comment") commentOnLine();
987 else void Clipboard.setStringAsync(selectedRow?.content ?? "");
988 }}
989 >
990 <View pointerEvents="none">
991 <IconButton icon="ellipsis" accessibilityLabel="Diff options" />
992 </View>
993 </Menu>
994 }
995 />
996 ) : null}
997 <Toolbar placement="right">
998 <Toolbar.Menu title="Diff options" accessibilityLabel="Diff options" icon="ellipsis">
999 {permissions.verdicts.length ? (
1000 <Toolbar.MenuAction
1001 icon="text.bubble"
1002 onPress={() =>
1003 navigation.navigate("PullRequestReview", { ...route.params, mode: "review" })
1006 <Toolbar.Label>Submit review</Toolbar.Label>
1007 </Toolbar.MenuAction>
1008 ) : null}
1009 {permissions.canComment ? (
1010 <Toolbar.MenuAction
1011 icon="plus.bubble"
1012 onPress={() =>
1013 navigation.navigate("PullRequestReview", { ...route.params, mode: "comment" })
1016 <Toolbar.Label>Add comment</Toolbar.Label>
1017 </Toolbar.MenuAction>
1018 ) : null}
1019 <Toolbar.MenuAction
1020 icon="text.alignleft"
1021 isOn={appearance.codeWordBreak}
1022 onPress={() => setCodeWordBreak(!appearance.codeWordBreak)}
1024 <Toolbar.Label>Word wrap</Toolbar.Label>
1025 </Toolbar.MenuAction>
1026 <Toolbar.MenuAction
1027 icon="line.3.horizontal.decrease"
1028 isOn={filter.hideTestFiles}
1029 onPress={toggleTestFiles}
1031 <Toolbar.Label>Hide test files</Toolbar.Label>
1032 </Toolbar.MenuAction>
1033 {selectedRow && selectedFile && canCommentOnDiff ? (
1034 <Toolbar.MenuAction icon="bubble.left" onPress={() => commentOnLine()}>
1035 <Toolbar.Label>
1036 {route.params.replacingDraftId ? "Move draft to this line" : "Add review comment"}
1037 </Toolbar.Label>
1038 </Toolbar.MenuAction>
1039 ) : null}
1040 {selectedRow && selectedFile ? (
1041 <Toolbar.MenuAction
1042 icon="document.on.document"
1043 onPress={() => void Clipboard.setStringAsync(selectedRow.content ?? "")}
1045 <Toolbar.Label>Copy line</Toolbar.Label>
1046 </Toolbar.MenuAction>
1047 ) : null}
1048 </Toolbar.Menu>
1049 </Toolbar>
1050 {route.params.replacingDraftId ? (
1051 <Text className="px-4 py-2 text-xs text-foreground-muted">
1052 Select a current line, then choose “Move draft to this line” from its menu.
1053 </Text>
1054 ) : null}
1055 {viewed.error ? (
1056 <Text className="px-4 py-2 text-xs text-danger-foreground">{viewed.error}</Text>
1057 ) : null}
1058 {staleDiff ? (
1059 <View
1060 className="flex-row items-center gap-2 px-4 py-2"
1061 style={{ paddingTop: Platform.OS === "ios" ? insets.top + 8 : 8 }}
1063 <Text className="min-w-0 flex-1 text-xs text-foreground-muted">
1064 The branch changed. Reload before adding line comments.
1065 </Text>
1066 <Button
1067 label="Reload changes"
1068 onPress={() => {
1069 result.refresh();
1070 setDiffHead({ scopeKey, sha: detail.data?.headSha ?? null });
1071 jumpStarted.current = false;
1072 setSelectedRowId(null);
1073 setCollapsedIds(EMPTY_IDS);
1074 }}
1075 />
1076 </View>
1077 ) : null}
1078 <View
1079 className={
1080 Platform.OS === "android"
1081 ? "flex-1 overflow-hidden rounded-t-[28px] bg-sheet-solid"
1082 : "flex-1"
1084 collapsable={false}
1085 style={{ marginHorizontal: Platform.OS === "android" && layout.usesSplitView ? 4 : 0 }}
1087 {loadingDiff || result.error ? (
1088 <View style={{ paddingTop: Platform.OS === "ios" && !staleDiff ? insets.top : 0 }}>
1089 <PullRequestReadStatus pending={loadingDiff} error={result.error} />
1090 </View>
1091 ) : null}
1092 {NativeDiffView && data.rows.length && !seekingFile ? (
1093 <View className="flex-1" collapsable={false}>
1094 <NativeDiffView
1095 initialRowIndex={focusIndex >= 0 ? Math.max(0, focusIndex - 3) : undefined}
1096 nativeViewRef={nativeView}
1097 refreshing={result.refreshing}
1098 onPullToRefresh={result.onPullRefresh}
1099 style={StyleSheet.absoluteFill}
1100 rowsJson={bridge.rowsJson}
1101 themeJson={bridge.themeJson}
1102 styleJson={bridge.styleJson}
1103 tokensPatchJson={bridge.tokensPatchJson}
1104 tokensResetKey={bridge.tokensResetKey}
1105 collapsedFileIdsJson={bridge.collapsedFileIdsJson}
1106 onDebug={onDebug}
1107 viewedFileIdsJson={bridge.viewedFileIdsJson}
1108 selectedRowIdsJson={bridge.selectedRowIdsJson}
1109 onPressLine={(event) => {
1110 const rowId = event.nativeEvent.rowId ?? null;
1111 setSelectedRowId(rowId);
1112 if (event.nativeEvent.gesture !== "longPress") commentOnLine(rowId);
1113 }}
1114 onToggleViewedFile={(event) => {
1115 const file = data.files.find((file) => file.id === event.nativeEvent.fileId);
1116 if (!file || (!commit && !viewed.canToggle)) return;
1117 const wasViewed = commit
1118 ? commitViewedPaths.has(file.path)
1119 : viewed.isViewed(file.path);
1120 setCollapsedIds((ids) =>
1121 wasViewed
1122 ? ids.filter((id) => id !== file.id)
1123 : ids.includes(file.id)
1124 ? ids
1125 : [...ids, file.id],
1126 );
1127 if (commit)
1128 setCommitViewedPaths((current) => {
1129 const next = new Set(current);
1130 if (next.has(file.path)) next.delete(file.path);
1131 else next.add(file.path);
1132 return next;
1133 });
1134 else void viewed.toggle(file.path);
1135 }}
1136 onToggleComment={(event) => {
1137 const id = event.nativeEvent.commentId;
1138 if (id?.startsWith("discussion:"))
1139 navigation.navigate("PullRequestDiscussion", {
1140 ...route.params,
1141 discussionId: id.slice("discussion:".length),
1142 });
1143 if (id?.startsWith("draft:")) {
1144 const draft = reviewDraft.draft.comments.find(
1145 (draft) => draft.id === id.slice("draft:".length),
1146 );
1147 if (draft)
1148 navigation.navigate("PullRequestInlineComment", {
1149 ...route.params,
1150 ...draft,
1151 draftId: draft.id,
1152 });
1154 }}
1155 onToggleFile={onToggleFile}
1156 onVisibleFileChange={(event) => setVisibleFileId(event.nativeEvent.fileId ?? null)}
1157 appearanceScheme={themeAppearance}
1158 rowHeight={nativeReviewDiffStyle.rowHeight}
1159 contentWidth={NATIVE_REVIEW_DIFF_CONTENT_WIDTH}
1160 contentInsetTop={Platform.OS === "ios" ? (staleDiff ? 0 : insets.top) : undefined}
1161 contentInsetBottom={Platform.OS === "android" ? toolbarHeight : insets.bottom}
1162 contentResetKey={`pull-request:${route.params.environmentId}:${route.params.repository}:${route.params.number}:${commit ?? "all"}`}
1163 />
1164 </View>
1165 ) : filter.hiddenCount > 0 &&
1166 !data.rows.length &&
1167 !result.isPending &&
1168 !result.error &&
1169 !seekingFile ? (
1170 <View style={{ paddingTop: Platform.OS === "ios" ? insets.top : 0 }}>
1171 <EmptyState
1172 title="Only test files changed"
1173 detail="Test files are hidden from this review."
1174 action={<Button label="Show test files" tone="contrast" onPress={filter.showAll} />}
1175 variant="plain"
1176 />
1177 </View>
1178 ) : !result.isPending && !result.error && !seekingFile ? (
1179 <EmptyState
1180 title="Diff unavailable"
1181 detail="Open this pull request on its provider to view the changes."
1182 variant="plain"
1183 />
1184 ) : null}
1185 {result.nextCursor && result.isPending && data.rows.length && !seekingFile ? (
1186 <View className="flex-row items-center justify-center gap-2 py-2">
1187 <AppActivityIndicator size="small" />
1188 <Text className="text-xs text-foreground-muted">Loading more files…</Text>
1189 </View>
1190 ) : null}
1191 {result.error && result.nextCursor ? (
1192 <View className="self-center">
1193 <Button label="Retry loading remaining files" tone="text" onPress={result.refresh} />
1194 </View>
1195 ) : null}
1196 {parsed.kind === "files" && parsed.notice ? (
1197 <Text className="px-4 py-2 text-2xs text-foreground-muted">{parsed.notice}</Text>
1198 ) : null}
1199 </View>
1200 <PullRequestActionToolbar
1201 pr={detail.data}
1202 params={route.params}
1203 filePath={visibleFile?.path}
1204 onOpenFiles={() => navigation.navigate("PullRequestFiles", route.params)}
1205 onHeightChange={setToolbarHeight}
1206 />
1207 </View>
1208 );