Skip to content

Commit b68a22d

Browse files
committed
fix(mobile): give drafts the current thread card layout
1 parent 1d626d0 commit b68a22d

1 file changed

Lines changed: 85 additions & 52 deletions

File tree

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 85 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,22 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
364364
readonly simultaneousSwipeGesture?: ComponentProps<typeof ThreadSwipeable>["simultaneousWith"];
365365
}) {
366366
const { pendingTask, onSelectPendingTask, onDeletePendingTask } = props;
367-
const { width: windowWidth } = useWindowDimensions();
367+
const { width: windowWidth, fontScale } = useWindowDimensions();
368+
const titleTypography = useScaledTextRole("body");
369+
const metadataTypography = useScaledTextRole("label");
370+
const projectIconSize = titleTypography.fontSize * 1.25 * fontScale;
371+
const machineIconSize = metadataTypography.fontSize * fontScale;
372+
// Android's nonlinear system text scaling can differ from the fontScale estimate.
373+
const [androidTitleLineHeight, setTitleLineHeight] = useState(
374+
titleTypography.lineHeight * fontScale,
375+
);
376+
const titleLineHeight =
377+
Platform.OS === "android" ? androidTitleLineHeight : titleTypography.lineHeight * fontScale;
368378
const dormant = useSwipeRowDormant(props.activationKey);
369379
const theme = useUniwindTheme();
370380
const sidebarPane = props.pane === "sidebar";
371-
const rowAppearance = getThreadListV2RowAppearance(theme, sidebarPane, props.selected ?? false);
381+
const selected = props.selected ?? false;
382+
const rowAppearance = getThreadListV2RowAppearance(theme, sidebarPane, selected);
372383
const isDraft = pendingTask.kind === "draft";
373384
const deleteLabel = isDraft ? "Discard" : "Delete";
374385
const handleDelete = useCallback(
@@ -416,72 +427,101 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
416427
[onDeletePendingTask, pendingTask],
417428
);
418429

430+
const titleTextInset = props.project ? projectIconSize + 8 : 0;
419431
const rowContent = (
420432
<>
421-
<View className="flex-row items-center gap-1.5">
433+
<View className="flex-row items-start gap-2">
422434
{props.project ? (
423-
<ProjectFavicon
424-
environmentId={pendingTask.environmentId}
425-
faviconPath={props.project.faviconPath}
426-
projectIcon={props.project.projectIcon}
427-
size={15}
428-
projectTitle={props.project.title}
429-
workspaceRoot={props.project.workspaceRoot}
430-
/>
435+
<View className="justify-center" style={{ height: titleLineHeight }}>
436+
<ProjectFavicon
437+
environmentId={pendingTask.environmentId}
438+
faviconPath={props.project.faviconPath}
439+
projectIcon={props.project.projectIcon}
440+
size={projectIconSize}
441+
projectTitle={projectTitle}
442+
workspaceRoot={props.project.workspaceRoot}
443+
/>
444+
</View>
431445
) : null}
432446
<Text
433447
className={cn(
434-
"flex-1 text-sm font-t3-medium text-foreground-muted",
435-
sidebarPane && "text-drawer-foreground-muted",
448+
"flex-1 text-base font-t3-medium",
449+
selected
450+
? selectedThreadRowColors.foregroundClassName
451+
: rowAppearance.foregroundClassName,
436452
)}
437-
numberOfLines={1}
453+
numberOfLines={2}
454+
onTextLayout={
455+
Platform.OS === "android"
456+
? ({ nativeEvent }) => {
457+
const firstLine = nativeEvent.lines[0];
458+
if (firstLine && Math.abs(firstLine.height - titleLineHeight) > 0.5) {
459+
setTitleLineHeight(firstLine.height);
460+
}
461+
}
462+
: undefined
463+
}
438464
>
439-
{projectTitle}
465+
{pendingTask.title}
440466
</Text>
441-
{isDraft ? (
442-
<View className="flex-row items-center gap-1">
467+
<View className="flex-row items-center gap-1" style={{ minHeight: titleLineHeight }}>
468+
{isDraft ? (
443469
<SymbolView
444470
name="square.and.pencil"
445-
size={10}
446-
tintColorClassName="accent-adaptive-amber-700-300"
471+
size={13}
472+
tintColorClassName={
473+
selected
474+
? selectedThreadRowColors.iconTintClassName
475+
: "accent-adaptive-amber-700-300"
476+
}
447477
type="monochrome"
478+
weight="semibold"
448479
/>
449-
<Text className="text-xs text-adaptive-amber-700-300">Draft</Text>
450-
</View>
451-
) : (
480+
) : null}
452481
<Text
453482
className={cn(
454-
"text-xs text-foreground-tertiary",
455-
sidebarPane && "text-drawer-foreground-muted",
483+
"text-xs",
484+
isDraft && "font-t3-bold",
485+
selected
486+
? selectedThreadRowColors.foregroundClassName
487+
: isDraft
488+
? "text-adaptive-amber-700-300"
489+
: rowAppearance.tertiaryForegroundClassName,
456490
)}
457491
>
458-
Sends on reconnect
492+
{isDraft ? "Draft" : "Sends on reconnect"}
459493
</Text>
460-
)}
494+
</View>
461495
</View>
462-
<Text
463-
className={cn(
464-
"mt-1 text-base font-t3-medium text-foreground",
465-
sidebarPane && "text-drawer-foreground",
466-
)}
467-
numberOfLines={1}
468-
>
469-
{pendingTask.title}
470-
</Text>
471496
{branch || props.environmentLabel ? (
472-
<View className="mt-1 flex-row items-center gap-1">
497+
<View className="mt-1 flex-row items-center gap-1" style={{ paddingLeft: titleTextInset }}>
498+
{props.environmentLabel && props.environmentMachine ? (
499+
<EnvironmentMachineSymbol
500+
kind={props.environmentMachine}
501+
size={machineIconSize}
502+
tintColorClassName={
503+
selected
504+
? selectedThreadRowColors.mutedIconTintClassName
505+
: rowAppearance.tertiaryIconTintClassName
506+
}
507+
/>
508+
) : null}
473509
<Text
474510
className={cn(
475511
"shrink text-xs text-foreground-muted",
476-
sidebarPane && "text-drawer-foreground-muted",
512+
selected
513+
? selectedThreadRowColors.mutedForegroundClassName
514+
: rowAppearance.mutedForegroundClassName,
477515
)}
478516
numberOfLines={1}
479517
>
480518
{branch ? (
481519
<Text
482520
className={cn(
483-
"text-xs text-foreground-muted",
484-
sidebarPane && "text-drawer-foreground-muted",
521+
"text-xs",
522+
selected
523+
? selectedThreadRowColors.mutedForegroundClassName
524+
: rowAppearance.mutedForegroundClassName,
485525
)}
486526
style={{ fontFamily: MONO_FONT }}
487527
>
@@ -492,23 +532,16 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
492532
{props.environmentLabel ? (
493533
<Text
494534
className={cn(
495-
"text-xs text-foreground-tertiary",
496-
sidebarPane && "text-drawer-foreground-muted",
535+
"text-xs",
536+
selected
537+
? selectedThreadRowColors.mutedForegroundClassName
538+
: rowAppearance.tertiaryForegroundClassName,
497539
)}
498540
>
499541
{props.environmentLabel}
500542
</Text>
501543
) : null}
502544
</Text>
503-
{props.environmentLabel && props.environmentMachine ? (
504-
<EnvironmentMachineSymbol
505-
kind={props.environmentMachine}
506-
size={11}
507-
tintColorClassName={
508-
sidebarPane ? "accent-drawer-foreground-muted" : "accent-foreground-tertiary"
509-
}
510-
/>
511-
) : null}
512545
</View>
513546
) : null}
514547
</>
@@ -562,8 +595,8 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
562595
rowContent
563596
) : (
564597
<View>
565-
<View className="px-5 py-2.5">{rowContent}</View>
566-
{props.showTrailingDivider !== false ? (
598+
<View className={THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME}>{rowContent}</View>
599+
{THREAD_LIST_V2_ROW_DIVIDERS && props.showTrailingDivider !== false ? (
567600
<View className="ml-5 h-px bg-border-subtle" />
568601
) : null}
569602
</View>

0 commit comments

Comments
 (0)