import { type ReactNode, useState } from 'react'; import { ScrollView, View } from 'react-native'; import { useNavigation } from '@react-navigation/native'; import { Button } from '../../atoms/Button'; import { IconButton } from '../../atoms/IconButton'; import { cn } from '../../lib/cn'; import { BottomMenu } from '../BottomMenu/BottomMenu'; import { ScreenHeader } from '../ScreenHeader'; import { TechnicalSheetDrawer } from '../TechnicalSheet'; import type { TechnicalSheet as TechnicalSheetType } from '../TechnicalSheet/TechnicalSheet.types'; export interface LayoutProps { children: ReactNode; title: string; breadcrumbs?: string[]; scrollable?: boolean; showBackButton?: boolean; rightAction?: ReactNode; footerButton?: { label: string; onPress: () => void; disabled?: boolean; loading?: boolean; }; technicalSheet?: TechnicalSheetType | null; isSelectionMode?: boolean; onObservationPress?: () => void | Promise; isObservationDisabled?: boolean; observationLabel?: string; observationIcon?: string; onAddPress?: () => void | Promise; onCreatePress?: () => void; onSelectAll?: () => void; onDeselectAll?: () => void; isAllSelected?: boolean; isAddDisabled?: boolean; observationBadgeCount?: number; } /** * Layout legacy. Mantiene la misma API que la versión Paper anterior pero * por dentro está implementado con NativeWind + Atoms. * * `Layout` es un alias directo de este component para unificar nomenclatura. */ export const Layout: React.FC = ({ children, title, breadcrumbs, scrollable = true, showBackButton = true, rightAction, footerButton, technicalSheet, isSelectionMode, onObservationPress, isObservationDisabled, observationLabel, observationIcon, onAddPress, onCreatePress, onSelectAll, onDeselectAll, isAllSelected, isAddDisabled, observationBadgeCount, }) => { const [isDrawerVisible, setIsDrawerVisible] = useState(false); const navigation = useNavigation(); const handleOpenDrawer = () => setIsDrawerVisible(true); const handleCloseDrawer = () => setIsDrawerVisible(false); const renderRightAction = () => { if (rightAction) return rightAction; if (isSelectionMode && onSelectAll && onDeselectAll) { return ( ); } return null; }; const shouldShowBottomMenu = technicalSheet || onObservationPress || showBackButton || onAddPress || onCreatePress; return ( {technicalSheet && ( )} {scrollable ? ( {children} ) : ( {children} )} {footerButton && ( )} {shouldShowBottomMenu && ( navigation.goBack()} showBackButton={showBackButton} onAddPress={onAddPress} isAddDisabled={isAddDisabled} isSelectionMode={isSelectionMode} observationLabel={observationLabel} observationIcon={observationIcon} observationBadgeCount={observationBadgeCount} onSelectAll={onSelectAll} onDeselectAll={onDeselectAll} /> )} ); };