import {
projectCloneDisplayName,
projectCloneProgressSummary,
type ProjectCloneSnapshot,
} from "@t3tools/contracts";
import { Pressable, View } from "react-native";
import { AppActivityIndicator } from "./AppActivityIndicator";
import { cn } from "../lib/cn";
import { AppText as Text } from "./AppText";
/**
* Live state of the clone that backs a freshly added project, shown above
* the composer while the draft waits for its files. Running clones offer
* Cancel; failed or cancelled ones offer Retry and Remove project.
*/
export function ProjectCloneBanner(props: {
readonly clone: ProjectCloneSnapshot;
readonly onCancel: () => void;
readonly onRetry: () => void;
readonly onRemove: () => void;
}) {
const { clone } = props;
const name = projectCloneDisplayName(clone);
if (clone.phase === "running") {
return (
Cloning {name}
{projectCloneProgressSummary(clone)}
);
}
const cancelled = clone.phase === "cancelled";
return (
{cancelled ? `Cancelled cloning ${name}` : `Failed to clone ${name}`}
{clone.error ? (
{clone.error}
) : null}
);
}
function BannerAction(props: { readonly label: string; readonly onPress: () => void }) {
return (
{props.label}
);
}