@@ -5,7 +5,7 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell
55import { effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled" ;
66import { sortInboxThreadsByReturn } from "@t3tools/client-runtime/state/thread-inbox" ;
77import { type ReactNode , useEffect , useMemo , useRef , useState } from "react" ;
8- import { Animated , FlatList , Modal , Pressable , View } from "react-native" ;
8+ import { Animated , FlatList , Modal , Pressable , useWindowDimensions , View } from "react-native" ;
99import { Gesture , GestureDetector , GestureHandlerRootView } from "react-native-gesture-handler" ;
1010import Reanimated , { ReduceMotion , useAnimatedStyle , withTiming } from "react-native-reanimated" ;
1111import { threadDragGapOffset } from "./threadDragGap" ;
@@ -14,6 +14,7 @@ import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
1414import { AppText as Text } from "../../components/ui/AppText" ;
1515import { SymbolView } from "../../components/ui/AppSymbol" ;
1616import { scopedThreadKey } from "../../lib/scopedEntities" ;
17+ import { deriveThreadArrangementSizing } from "../../lib/layout" ;
1718import { environmentServerConfigsAtom } from "../../state/server" ;
1819import { threadListEnvironmentsAtom } from "../../state/presentation" ;
1920import { environmentThreadShells } from "../../state/threads" ;
@@ -39,9 +40,8 @@ import {
3940} from "./threadListV2" ;
4041import { useThreadListNow } from "./use-thread-list-now" ;
4142import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-preferences" ;
43+ import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider" ;
4244
43- const ROW_HEIGHT = 56 ;
44- const HEADER_HEIGHT = 48 ;
4545const keyOf = ( thread : EnvironmentThreadShell ) => scopedThreadKey ( thread . environmentId , thread . id ) ;
4646type Section = "pinned" | "active" | "snoozed" | "settled" ;
4747type Destination = Exclude < ThreadMoveDestination , string > ;
@@ -163,6 +163,12 @@ function DragHandle(props: {
163163}
164164
165165function ThreadArrangementSheet ( props : { onClose : ( ) => void } ) {
166+ const { appearance } = useAppearancePreferences ( ) ;
167+ const { fontScale } = useWindowDimensions ( ) ;
168+ const { rowHeight, headerHeight } = deriveThreadArrangementSizing ( {
169+ baseFontSize : appearance . baseFontSize ,
170+ fontScale,
171+ } ) ;
166172 const threads = useAtomValue ( environmentThreadShells . navigationThreadShellsAtom ) ;
167173 const configs = useAtomValue ( environmentServerConfigsAtom ) ;
168174 const listEnvironments = useAtomValue ( threadListEnvironmentsAtom ) ;
@@ -230,20 +236,20 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
230236 let offset = 0 ;
231237 for ( const section of [ "pinned" , "active" , "snoozed" , "settled" ] as const ) {
232238 if ( section === "snoozed" && sections [ section ] . length === 0 ) continue ;
233- result . push ( { key : section , section, offset, height : HEADER_HEIGHT } ) ;
234- offset += HEADER_HEIGHT ;
239+ result . push ( { key : section , section, offset, height : headerHeight } ) ;
240+ offset += headerHeight ;
235241 if ( ( section === "snoozed" || section === "settled" ) && ! expanded [ section ] ) continue ;
236242 for ( const thread of section === "settled" ? visibleSettled : sections [ section ] ) {
237- result . push ( { key : keyOf ( thread ) , section, thread, offset, height : ROW_HEIGHT } ) ;
238- offset += ROW_HEIGHT ;
243+ result . push ( { key : keyOf ( thread ) , section, thread, offset, height : rowHeight } ) ;
244+ offset += rowHeight ;
239245 }
240246 if ( section === "settled" && settledCount > visibleSettled . length ) {
241- result . push ( { key : "settled-more" , section, more : true , offset, height : ROW_HEIGHT } ) ;
242- offset += ROW_HEIGHT ;
247+ result . push ( { key : "settled-more" , section, more : true , offset, height : rowHeight } ) ;
248+ offset += rowHeight ;
243249 }
244250 }
245251 return result ;
246- } , [ sections , expanded , visibleSettled , settledCount ] ) ;
252+ } , [ sections , expanded , visibleSettled , settledCount , rowHeight , headerHeight ] ) ;
247253 const list = useRef < FlatList < Row > > ( null ) ;
248254 const geometry = useRef ( { height : 0 , offset : 0 } ) ;
249255 const drag = useRef < Drag | null > ( null ) ;
@@ -261,7 +267,9 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
261267 setPreview ( null ) ;
262268 }
263269 const orderVersion = rows
264- . map ( ( row ) => `${ row . key } :${ row . thread ?. pinOrderKey } :${ row . thread ?. activeOrderKey } ` )
270+ . map (
271+ ( row ) => `${ row . key } :${ row . height } :${ row . thread ?. pinOrderKey } :${ row . thread ?. activeOrderKey } ` ,
272+ )
265273 . join ( "|" ) ;
266274 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- cancels the in-progress drag gesture when the thread order changes underneath it
267275 useEffect ( ( ) => {
@@ -282,7 +290,7 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
282290 current . translation = translation ;
283291 const { height, offset } = geometry . current ;
284292 const y = current . startY + translation ;
285- translateY . setValue ( Math . max ( 0 , Math . min ( height - ROW_HEIGHT , y - ROW_HEIGHT / 2 ) ) ) ;
293+ translateY . setValue ( Math . max ( 0 , Math . min ( height - rowHeight , y - rowHeight / 2 ) ) ) ;
286294 const contentY = Math . max ( 0 , y + offset ) ;
287295 const target =
288296 latest . current . rows . find ( ( row ) => contentY < row . offset + row . height ) ??
@@ -321,7 +329,7 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
321329 orderVersion,
322330 sourceSection : row . section ,
323331 thread : row . thread ,
324- startY : row . offset + ROW_HEIGHT / 2 - geometry . current . offset ,
332+ startY : row . offset + row . height / 2 - geometry . current . offset ,
325333 translation : 0 ,
326334 destination : null ,
327335 } ;
@@ -554,7 +562,7 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
554562 < Animated . View
555563 pointerEvents = "none"
556564 className = "absolute left-5 right-5 justify-center rounded-xl border border-border bg-screen px-4"
557- style = { { top : 0 , height : ROW_HEIGHT , transform : [ { translateY } ] } }
565+ style = { { top : 0 , height : rowHeight , transform : [ { translateY } ] } }
558566 >
559567 < Text
560568 numberOfLines = { visiblePreview . destination ?. section ? 1 : 2 }
0 commit comments