Skip to content

Commit 8b4d3a4

Browse files
fix(mobile): keep the arrangement safe-area content sized and themed
1 parent 25df2de commit 8b4d3a4

1 file changed

Lines changed: 171 additions & 169 deletions

File tree

‎apps/mobile/src/features/threads/ThreadArrangementSheet.tsx‎

Lines changed: 171 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -374,182 +374,184 @@ export function ThreadArrangementSheet(props: { onClose: () => void }) {
374374
<GestureHandlerRootView style={{ flex: 1 }}>
375375
{/* A Modal is its own native hierarchy, so measure its own safe area, including side
376376
insets for the camera, instead of the presenting screen's. */}
377-
<SafeAreaProvider>
378-
<SafeAreaView className="flex-1 bg-screen">
379-
<SheetHeader
380-
presentation="inline"
381-
title="Arrange threads"
382-
onClose={props.onClose}
383-
accessibilityLabel="Close arrange threads"
384-
/>
385-
<Text className="px-5 pb-3 text-sm text-foreground-muted">
386-
Drag to reorder, pin, or settle. Changes save when you drop.
387-
</Text>
388-
<View
389-
onLayout={(event) => {
390-
geometry.current.height = event.nativeEvent.layout.height;
391-
}}
392-
className="flex-1"
393-
style={{ overflow: "hidden" }}
394-
>
395-
<FlatList
396-
ref={list}
397-
data={rows}
398-
keyExtractor={(row) => row.key}
399-
scrollEnabled={visiblePreview === null}
400-
removeClippedSubviews={false}
401-
onScroll={(event) => {
402-
geometry.current.offset = event.nativeEvent.contentOffset.y;
377+
<SafeAreaProvider style={{ flex: 1 }}>
378+
<View className="flex-1 bg-screen">
379+
<SafeAreaView style={{ flex: 1 }}>
380+
<SheetHeader
381+
presentation="inline"
382+
title="Arrange threads"
383+
onClose={props.onClose}
384+
accessibilityLabel="Close arrange threads"
385+
/>
386+
<Text className="px-5 pb-3 text-sm text-foreground-muted">
387+
Drag to reorder, pin, or settle. Changes save when you drop.
388+
</Text>
389+
<View
390+
onLayout={(event) => {
391+
geometry.current.height = event.nativeEvent.layout.height;
403392
}}
404-
scrollEventThrottle={16}
405-
getItemLayout={(_, index) => ({
406-
length: rows[index]!.height,
407-
offset: rows[index]!.offset,
408-
index,
409-
})}
410-
renderItem={({ item }) => {
411-
const thread = item.thread;
412-
const planner =
413-
item.section === "pinned" || item.section === "active"
414-
? planners[item.section]
415-
: null;
416-
const capabilities =
417-
thread && configs.get(thread.environmentId)?.environment.capabilities;
418-
const sectionActions = thread
419-
? (["pinned", "active", "settled"] as const).flatMap<{
420-
name: "pinned" | "active" | "settled";
421-
label: string;
422-
}>((section) => {
423-
if (section === item.section) return [];
424-
const label = threadDragAction(item.section, section);
425-
if (!label) return [];
426-
if (section === "settled")
427-
return capabilities?.threadSettlement ? [{ name: section, label }] : [];
428-
if (
429-
((section === "pinned" || thread.pinnedAt != null) &&
430-
!capabilities?.threadPinning) ||
431-
(section === "active" &&
432-
item.section === "settled" &&
433-
!capabilities?.threadSettlement) ||
434-
(section === "active" &&
435-
item.section === "snoozed" &&
436-
!capabilities?.threadSnooze)
437-
)
438-
return [];
439-
return planners[section](item.key, {
440-
section,
441-
targetId: null,
442-
placement: "before",
393+
className="flex-1"
394+
style={{ overflow: "hidden" }}
395+
>
396+
<FlatList
397+
ref={list}
398+
data={rows}
399+
keyExtractor={(row) => row.key}
400+
scrollEnabled={visiblePreview === null}
401+
removeClippedSubviews={false}
402+
onScroll={(event) => {
403+
geometry.current.offset = event.nativeEvent.contentOffset.y;
404+
}}
405+
scrollEventThrottle={16}
406+
getItemLayout={(_, index) => ({
407+
length: rows[index]!.height,
408+
offset: rows[index]!.offset,
409+
index,
410+
})}
411+
renderItem={({ item }) => {
412+
const thread = item.thread;
413+
const planner =
414+
item.section === "pinned" || item.section === "active"
415+
? planners[item.section]
416+
: null;
417+
const capabilities =
418+
thread && configs.get(thread.environmentId)?.environment.capabilities;
419+
const sectionActions = thread
420+
? (["pinned", "active", "settled"] as const).flatMap<{
421+
name: "pinned" | "active" | "settled";
422+
label: string;
423+
}>((section) => {
424+
if (section === item.section) return [];
425+
const label = threadDragAction(item.section, section);
426+
if (!label) return [];
427+
if (section === "settled")
428+
return capabilities?.threadSettlement ? [{ name: section, label }] : [];
429+
if (
430+
((section === "pinned" || thread.pinnedAt != null) &&
431+
!capabilities?.threadPinning) ||
432+
(section === "active" &&
433+
item.section === "settled" &&
434+
!capabilities?.threadSettlement) ||
435+
(section === "active" &&
436+
item.section === "snoozed" &&
437+
!capabilities?.threadSnooze)
438+
)
439+
return [];
440+
return planners[section](item.key, {
441+
section,
442+
targetId: null,
443+
placement: "before",
444+
})
445+
? [{ name: section, label }]
446+
: [];
443447
})
444-
? [{ name: section, label }]
445-
: [];
446-
})
447-
: [];
448-
return (
449-
<ArrangementRow
450-
height={item.height}
451-
dragging={visiblePreview !== null}
452-
lifted={item.key === sourceRow?.key}
453-
offset={
454-
sourceRow && insertionOffset !== undefined
455-
? threadDragGapOffset(
456-
item.offset,
457-
sourceRow.offset,
458-
sourceRow.height,
459-
insertionOffset,
460-
)
461-
: 0
462-
}
463-
>
464-
{thread ? (
465-
<>
466-
<Text numberOfLines={2} className="flex-1 text-base">
467-
{thread.title}
468-
</Text>
469-
<DragHandle
470-
title={thread.title}
471-
disabled={
472-
dropBusy ||
473-
pendingOrder !== null ||
474-
!(
475-
configs.get(thread.environmentId)?.environment.capabilities
476-
.threadPinReorder ||
477-
configs.get(thread.environmentId)?.environment.capabilities
478-
.threadActiveReorder
448+
: [];
449+
return (
450+
<ArrangementRow
451+
height={item.height}
452+
dragging={visiblePreview !== null}
453+
lifted={item.key === sourceRow?.key}
454+
offset={
455+
sourceRow && insertionOffset !== undefined
456+
? threadDragGapOffset(
457+
item.offset,
458+
sourceRow.offset,
459+
sourceRow.height,
460+
insertionOffset,
479461
)
480-
}
481-
sectionActions={sectionActions}
482-
onSectionMove={(section) => {
483-
void moveThread(thread, {
484-
section,
485-
targetId: null,
486-
placement: "before",
487-
});
488-
}}
489-
canMoveUp={planner?.(item.key, "up") != null}
490-
canMoveDown={planner?.(item.key, "down") != null}
491-
onStep={(direction) => {
492-
void moveThread(thread, direction);
493-
}}
494-
onStart={() => start(item)}
495-
onMove={update}
496-
onEnd={(cancelled) => {
497-
const current = drag.current;
498-
if (cancelled || !current?.destination) {
499-
stop();
500-
return;
462+
: 0
463+
}
464+
>
465+
{thread ? (
466+
<>
467+
<Text numberOfLines={2} className="flex-1 text-base">
468+
{thread.title}
469+
</Text>
470+
<DragHandle
471+
title={thread.title}
472+
disabled={
473+
dropBusy ||
474+
pendingOrder !== null ||
475+
!(
476+
configs.get(thread.environmentId)?.environment.capabilities
477+
.threadPinReorder ||
478+
configs.get(thread.environmentId)?.environment.capabilities
479+
.threadActiveReorder
480+
)
501481
}
502-
if (frame.current !== null) cancelAnimationFrame(frame.current);
503-
frame.current = null;
504-
drag.current = null;
505-
void moveThread(current.thread, current.destination).finally(stop);
482+
sectionActions={sectionActions}
483+
onSectionMove={(section) => {
484+
void moveThread(thread, {
485+
section,
486+
targetId: null,
487+
placement: "before",
488+
});
489+
}}
490+
canMoveUp={planner?.(item.key, "up") != null}
491+
canMoveDown={planner?.(item.key, "down") != null}
492+
onStep={(direction) => {
493+
void moveThread(thread, direction);
494+
}}
495+
onStart={() => start(item)}
496+
onMove={update}
497+
onEnd={(cancelled) => {
498+
const current = drag.current;
499+
if (cancelled || !current?.destination) {
500+
stop();
501+
return;
502+
}
503+
if (frame.current !== null) cancelAnimationFrame(frame.current);
504+
frame.current = null;
505+
drag.current = null;
506+
void moveThread(current.thread, current.destination).finally(stop);
507+
}}
508+
/>
509+
</>
510+
) : (
511+
<Pressable
512+
disabled={item.section === "pinned" || item.section === "active"}
513+
className="flex-1 justify-center self-stretch"
514+
onPress={() => {
515+
const section = item.section;
516+
if (section === "snoozed" || section === "settled")
517+
setExpanded((value) => ({ ...value, [section]: !value[section] }));
506518
}}
507-
/>
508-
</>
509-
) : (
510-
<Pressable
511-
disabled={item.section === "pinned" || item.section === "active"}
512-
className="flex-1 justify-center self-stretch"
513-
onPress={() => {
514-
const section = item.section;
515-
if (section === "snoozed" || section === "settled")
516-
setExpanded((value) => ({ ...value, [section]: !value[section] }));
517-
}}
518-
>
519-
<Text className="text-sm font-t3-semibold text-foreground-muted">
520-
{item.section[0]!.toUpperCase() + item.section.slice(1)} (
521-
{sections[item.section].length})
522-
</Text>
523-
</Pressable>
524-
)}
525-
</ArrangementRow>
526-
);
527-
}}
528-
/>
529-
{visiblePreview ? (
530-
<Animated.View
531-
pointerEvents="none"
532-
className="absolute left-5 right-5 justify-center rounded-xl border border-border bg-screen px-4"
533-
style={{ top: 0, height: ROW_HEIGHT, transform: [{ translateY }] }}
534-
>
535-
<Text
536-
numberOfLines={visiblePreview.destination?.section ? 1 : 2}
537-
className="text-base font-t3-medium"
519+
>
520+
<Text className="text-sm font-t3-semibold text-foreground-muted">
521+
{item.section[0]!.toUpperCase() + item.section.slice(1)} (
522+
{sections[item.section].length})
523+
</Text>
524+
</Pressable>
525+
)}
526+
</ArrangementRow>
527+
);
528+
}}
529+
/>
530+
{visiblePreview ? (
531+
<Animated.View
532+
pointerEvents="none"
533+
className="absolute left-5 right-5 justify-center rounded-xl border border-border bg-screen px-4"
534+
style={{ top: 0, height: ROW_HEIGHT, transform: [{ translateY }] }}
538535
>
539-
{visiblePreview.thread.title}
540-
</Text>
541-
{visiblePreview.destination?.section ? (
542-
<Text className="text-xs text-foreground-muted">
543-
{threadDragAction(
544-
visiblePreview.sourceSection,
545-
visiblePreview.destination.section,
546-
)}
536+
<Text
537+
numberOfLines={visiblePreview.destination?.section ? 1 : 2}
538+
className="text-base font-t3-medium"
539+
>
540+
{visiblePreview.thread.title}
547541
</Text>
548-
) : null}
549-
</Animated.View>
550-
) : null}
551-
</View>
552-
</SafeAreaView>
542+
{visiblePreview.destination?.section ? (
543+
<Text className="text-xs text-foreground-muted">
544+
{threadDragAction(
545+
visiblePreview.sourceSection,
546+
visiblePreview.destination.section,
547+
)}
548+
</Text>
549+
) : null}
550+
</Animated.View>
551+
) : null}
552+
</View>
553+
</SafeAreaView>
554+
</View>
553555
</SafeAreaProvider>
554556
</GestureHandlerRootView>
555557
</Modal>

0 commit comments

Comments
 (0)