import { View, Text, Pressable, ActivityIndicator } from "react-native"; import { StyleSheet, useUnistyles } from "react-native-unistyles"; import { X, ArrowUp, RefreshCcw } from "lucide-react-native"; import { VolumeMeter } from "./volume-meter"; import { FOOTER_HEIGHT } from "@/constants/layout"; import type { DictationStatus } from "@/hooks/use-dictation"; interface VoiceNoteRecordingOverlayProps { volume: number; duration: number; onCancel: () => void; onSend: () => void; isTranscribing?: boolean; status?: DictationStatus; onRetry?: () => void; onDiscardFailed?: () => void; } function formatDuration(seconds: number): string { const mins = Math.floor(seconds / 60); const secs = seconds % 60; return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`; } export function VoiceNoteRecordingOverlay({ volume, duration, onCancel, onSend, isTranscribing = false, status = "idle", onRetry, onDiscardFailed, }: VoiceNoteRecordingOverlayProps) { const { theme } = useUnistyles(); const isRetrying = status === "retrying"; const isFailed = status === "failed"; const primaryDisabled = isTranscribing || isRetrying; const handlePrimary = isFailed ? onRetry ?? onSend : onSend; const handleCancel = isFailed && onDiscardFailed ? onDiscardFailed : onCancel; return ( {/* Cancel button */} {/* Center: Volume meter and timer */} {formatDuration(duration)} {/* Send button */} {isRetrying ? ( ) : isTranscribing ? ( ) : isFailed ? ( ) : ( )} ); } const BUTTON_SIZE = 56; const VERTICAL_PADDING = (FOOTER_HEIGHT - BUTTON_SIZE) / 2; const styles = StyleSheet.create((theme) => ({ container: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingHorizontal: theme.spacing[4], paddingVertical: VERTICAL_PADDING, height: FOOTER_HEIGHT, }, cancelButton: { width: BUTTON_SIZE, height: BUTTON_SIZE, borderRadius: theme.borderRadius.full, backgroundColor: "rgba(0, 0, 0, 0.15)", alignItems: "center", justifyContent: "center", }, centerContainer: { flex: 1, flexDirection: "row", alignItems: "center", justifyContent: "center", gap: theme.spacing[4], }, timerText: { fontSize: theme.fontSize.xl, fontWeight: theme.fontWeight.semibold, fontVariant: ["tabular-nums"], }, sendButton: { width: BUTTON_SIZE, height: BUTTON_SIZE, borderRadius: theme.borderRadius.full, alignItems: "center", justifyContent: "center", }, buttonDisabled: { opacity: 0.5, }, }));