import { useState } from "react"; import { ActivityIndicator, View } from "react-native"; import { WebView } from "react-native-webview"; import { AppText as Text } from "../../components/AppText"; import { LoadingStrip } from "../../components/LoadingStrip"; export function WorkspaceFileWebPreview(props: { readonly uri: string | null }) { const [loadProgress, setLoadProgress] = useState(0); const [loadError, setLoadError] = useState(null); if (props.uri === null) { return ( Preparing preview... ); } return ( {loadProgress > 0 && loadProgress < 1 ? : null} {loadError ? ( Preview failed {loadError} ) : null} { setLoadProgress(event.nativeEvent.progress); }} onLoadStart={() => { setLoadProgress(0.05); setLoadError(null); }} onLoadEnd={() => { setLoadProgress(0); }} onError={(event) => { setLoadProgress(0); setLoadError(event.nativeEvent.description || "The file could not be rendered."); }} renderLoading={() => ( )} style={{ flex: 1, backgroundColor: "transparent" }} /> ); }