From ead99f123bb41a6d255680afda414c5bb2266586 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 13 Jan 2026 13:58:57 +0200 Subject: [PATCH] Use InnerFlatList and Dialog.Header for drafts dialog - Switch from ScrollableInner to InnerFlatList - Add Dialog.Header with back button in left slot - Use sticky header Co-Authored-By: Claude Opus 4.5 --- .../com/composer/drafts/DraftsListDialog.tsx | 104 ++++++++++++------ 1 file changed, 70 insertions(+), 34 deletions(-) diff --git a/src/view/com/composer/drafts/DraftsListDialog.tsx b/src/view/com/composer/drafts/DraftsListDialog.tsx index 74abf65a80..1c9707431f 100644 --- a/src/view/com/composer/drafts/DraftsListDialog.tsx +++ b/src/view/com/composer/drafts/DraftsListDialog.tsx @@ -1,4 +1,4 @@ -import {useCallback} from 'react' +import {useCallback, useMemo} from 'react' import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -11,7 +11,9 @@ import { useLoadDraft, } from '#/state/drafts' import {atoms as a, useTheme} from '#/alf' +import {Button, ButtonIcon} from '#/components/Button' import * as Dialog from '#/components/Dialog' +import {ArrowLeft_Stroke2_Corner0_Rounded as ArrowLeftIcon} from '#/components/icons/Arrow' import {Loader} from '#/components/Loader' import {Text} from '#/components/Typography' import {DraftItem} from './DraftItem' @@ -48,42 +50,76 @@ export function DraftsListDialog({ [deleteDraft], ) + const backButton = useCallback( + () => ( + + ), + [control, _], + ) + + const listHeader = useMemo(() => { + return ( + + + Drafts + + + ) + }, [backButton]) + + const renderItem = useCallback( + ({item}: {item: DraftSummary}) => { + return ( + + ) + }, + [handleSelectDraft, handleDeleteDraft, isDeleting], + ) + + const emptyComponent = useMemo(() => { + if (isLoading) { + return ( + + + + ) + } + return ( + + + No drafts saved + + + ) + }, [isLoading, t.atoms.text_contrast_medium]) + return ( - - - - Your Drafts - - - {isLoading ? ( - - - - ) : drafts && drafts.length > 0 ? ( - - {drafts.map(draft => ( - - ))} - - ) : ( - - - No drafts saved - - - )} - - - - + item.id} + ListHeaderComponent={listHeader} + ListEmptyComponent={emptyComponent} + stickyHeaderIndices={[0]} + contentContainerStyle={[a.pb_lg]} + ItemSeparatorComponent={() => } + style={[a.px_lg]} + /> ) }