import React from "react"; import { View } from "react-native"; import { useStyles } from "./FileView.style"; import { Icon } from "../../../Icon"; import { Text } from "../../../Text"; import type { FormattedFile } from "../../types"; import { StatusCode } from "../../types"; import { computeA11yLabel, mapFileTypeToIconName, sanitizeFileName, truncateFileNameForLine, } from "../../utils"; import { ProgressBar } from "../ProgressBar"; import { ErrorIcon } from "../ErrorIcon"; import { useAtlantisI18n } from "../../../hooks/useAtlantisI18n"; interface FileViewProps { readonly accessibilityLabel?: string; readonly showOverlay: boolean; readonly showError: boolean; readonly file: FormattedFile; readonly styleInGrid: boolean; readonly onUploadComplete: () => void; readonly surfaceColor?: string; } export function FileView({ accessibilityLabel, styleInGrid, file, showOverlay, showError, onUploadComplete, surfaceColor, }: FileViewProps) { const { t } = useAtlantisI18n(); const styles = useStyles(); const a11yLabel = computeA11yLabel({ accessibilityLabel, showOverlay, showError, t, }); const freezeProgressBar = file.status !== StatusCode.Completed && file.progress >= 0.9; return ( {(styleInGrid || !showError) && file.showFileTypeIndicator && ( )} {styleInGrid ? truncateFileNameForLine(sanitizeFileName(file.name)) : sanitizeFileName(file.name)} {!showError && showOverlay && ( )} {showError && ( )} ); }