diff --git a/apps/mobile/src/components/ui/ListChoiceRow.tsx b/apps/mobile/src/components/ui/ListChoiceRow.tsx index 0b320296bfe69..23408f6afbfe5 100644 --- a/apps/mobile/src/components/ui/ListChoiceRow.tsx +++ b/apps/mobile/src/components/ui/ListChoiceRow.tsx @@ -1,5 +1,5 @@ import type { ReactNode } from "react"; -import { Platform, View } from "react-native"; +import { Platform, View, type PressableProps } from "react-native"; import { useResolveClassNames } from "uniwind"; import { cn } from "../../lib/cn"; @@ -17,6 +17,8 @@ export function ListChoiceRow(props: { readonly separated?: boolean; readonly disabled?: boolean; readonly onPress: () => void; + /** Lets a wrapping long-press Menu observe the touch. */ + readonly onTouchStart?: PressableProps["onTouchStart"]; }) { const rippleStyle = useResolveClassNames("bg-subtle-strong"); return ( @@ -27,6 +29,7 @@ export function ListChoiceRow(props: { accessibilityState={{ checked: props.selected, disabled: Boolean(props.disabled) }} disabled={props.disabled} onPress={props.onPress} + onTouchStart={props.onTouchStart} android_ripple={{ color: rippleStyle.backgroundColor }} unstable_pressDelay={Platform.OS === "android" ? 50 : undefined} // Like UIKit and Material lists, only the checkmark or radio marks the selected row. diff --git a/apps/mobile/src/features/home/thread-swipe-actions.tsx b/apps/mobile/src/features/home/thread-swipe-actions.tsx index b1f9650990b94..82b58c4dfab39 100644 --- a/apps/mobile/src/features/home/thread-swipe-actions.tsx +++ b/apps/mobile/src/features/home/thread-swipe-actions.tsx @@ -239,7 +239,8 @@ interface ThreadSwipeableProps { readonly enableTrackpadSwipe?: boolean; /** Omitted uses Delete only with the built-in Delete secondary action; otherwise it uses primary. */ readonly fullSwipeAction?: "delete" | "primary"; - readonly fullSwipeWidth: number; + /** Initial full-swipe width used until the row's own layout is measured. */ + readonly fullSwipeWidth?: number; /** The list animates item layout; collapse in one step so its transition moves siblings once. */ readonly listAnimatesLayout?: boolean; readonly onDelete: () => void; @@ -262,7 +263,9 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) { const swipeableRef = useRef(null); const hasSecondaryAction = props.secondaryAction !== null; const actionsWidth = swipeActionsWidth(hasSecondaryAction); - const fullSwipeThreshold = Math.max(actionsWidth + 44, props.fullSwipeWidth * 0.58); + const [measuredRowWidth, setMeasuredRowWidth] = useState(0); + const swipeWidth = measuredRowWidth > 0 ? measuredRowWidth : (props.fullSwipeWidth ?? 0); + const fullSwipeThreshold = Math.max(actionsWidth + 44, swipeWidth * 0.58); const fullSwipeAction = props.fullSwipeAction ?? (props.secondaryAction === undefined ? "delete" : "primary"); const close = useCallback(() => swipeableRef.current?.close(), []); @@ -281,7 +284,7 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) { const [collapsedInList, setCollapsedInList] = useState(false); const dismissing = useSharedValue(false); const rowHeight = useSharedValue(0); - const rowWidth = useSharedValue(props.fullSwipeWidth); + const rowWidth = useSharedValue(props.fullSwipeWidth ?? 0); const collapse = useSharedValue(0); const fallbackTranslation = useSharedValue(0); const actionOpacity = useSharedValue(1); @@ -544,6 +547,7 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) { onLayout={({ nativeEvent: { layout } }) => { rowHeight.set(layout.height); setMeasuredRowHeight(layout.height); + setMeasuredRowWidth(layout.width); rowWidth.set(layout.width); }} > diff --git a/apps/mobile/src/features/settings/VoiceModelSection.tsx b/apps/mobile/src/features/settings/VoiceModelSection.tsx index 7a745bb970ea8..e40651963c263 100644 --- a/apps/mobile/src/features/settings/VoiceModelSection.tsx +++ b/apps/mobile/src/features/settings/VoiceModelSection.tsx @@ -5,6 +5,7 @@ import { useNavigation } from "@react-navigation/native"; import { cancelEnvironmentSpeechModelDownload, installEnvironmentSpeechModel, + removeEnvironmentSpeechModel, selectEnvironmentSpeechModel, } from "@t3tools/client-runtime/voice-input"; import { @@ -14,17 +15,19 @@ import { } from "@t3tools/contracts"; import { AsyncResult } from "effect/reactivity"; import { type ReactNode, useEffect, useState } from "react"; -import { Platform, Text as NativeText, View } from "react-native"; +import { Platform, Pressable, Text as NativeText, View } from "react-native"; import { m } from "../../i18n/messages"; import { SymbolView } from "../../components/ui/AppSymbol"; import { AppText as Text } from "../../components/ui/AppText"; import * as Dialog from "../../components/ui/Dialog"; +import { Menu } from "../../components/ui/Menu"; import { ListActionRow } from "../../components/ui/ListActionRow"; import { ListChoiceRow } from "../../components/ui/ListChoiceRow"; import { ListRow } from "../../components/ui/ListRow"; import { Progress } from "../../components/ui/Progress"; import { formatBytes } from "../../lib/formatBytes"; +import { ThreadSwipeable } from "../home/thread-swipe-actions"; import { useEnvironmentScope } from "../../state/session"; import { runSpeech, @@ -109,6 +112,25 @@ export function useVoiceModels(environmentId: EnvironmentId, label: string) { runSpeech(selectEnvironmentSpeechModel(connection, model.id)), ); }, + remove: (model: EnvironmentSpeechModel) => { + if (!ready) return; + Dialog.confirm({ + title: gt("Delete {model}?", { model: model.name }), + message: gt( + "{environment} will delete {size} of model files. You can download it again later.", + { + environment: label, + size: formatBytes(model.size), + }, + ), + confirmText: gt("Delete", { $context: "verb" }), + destructive: true, + onConfirm: () => + void run(gt("Could not delete the model"), () => + runSpeech(removeEnvironmentSpeechModel(connection, model.id)), + ), + }); + }, cancel: (model: EnvironmentSpeechModel) => { if (!ready) return; void run(gt("Could not cancel the download"), () => @@ -202,9 +224,16 @@ function ModelStats(props: { readonly model: EnvironmentSpeechModel; readonly la ); } -function DownloadedGlyph() { +function DownloadedGlyph(props: { readonly label: string; readonly onPress?: () => void }) { return ( - + - + ); } @@ -235,10 +264,17 @@ export function VoiceModelRow(props: { const gt = useGT(); const { model, voice, separated } = props; const meta = ; - if (model.state === "installed") - return ( + if (model.state === "installed") { + const removable = voice.canManage && !voice.busy && !voice.downloading; + const remove = () => voice.remove(model); + const choice = ( } + leading={ + + } label={model.name} description={model.description} meta={meta} @@ -248,6 +284,45 @@ export function VoiceModelRow(props: { onPress={() => voice.select(model)} /> ); + if (!removable) return choice; + const row = ( + { + if (nativeEvent.event === "delete") remove(); + }} + shouldOpenOnLongPress + > + {choice} + + ); + return ( + + {() => row} + + ); + } const progress = model.downloaded === undefined ? undefined : model.downloaded / model.size; if (isDownloading(model) || voice.requested === model.id) return ( diff --git a/apps/mobile/src/i18n/translations/de.json b/apps/mobile/src/i18n/translations/de.json index e6fe9966910cb..b5d33aafbf2c4 100644 --- a/apps/mobile/src/i18n/translations/de.json +++ b/apps/mobile/src/i18n/translations/de.json @@ -5703,5 +5703,10 @@ "99451a5d2d40440f": "Zurückgezogen von {by}.", "3ee30a50b70fffab": "Zurückgezogen von {by}: {reason}", "201490988858b511": "zurückgezogen von {by}", - "46d614fa7b4bf1e5": "Workflow-Ausführungen" + "46d614fa7b4bf1e5": "Workflow-Ausführungen", + "6381c4a2297e37e6": "{model} löschen?", + "00b5905cc4800231": "{environment} löscht {size} an Modelldateien. Du kannst das Modell später erneut herunterladen.", + "c73437a48071f19d": "Löschen", + "51fd61b9c85dec5d": "Das Modell konnte nicht gelöscht werden", + "88fa0730d8c7eab4": "{model} löschen" } diff --git a/apps/mobile/src/i18n/translations/en.json b/apps/mobile/src/i18n/translations/en.json index 13d1178a1eb5c..6c1b888ef696c 100644 --- a/apps/mobile/src/i18n/translations/en.json +++ b/apps/mobile/src/i18n/translations/en.json @@ -5705,5 +5705,10 @@ "99451a5d2d40440f": "Withdrawn by {by}.", "3ee30a50b70fffab": "Withdrawn by {by}: {reason}", "201490988858b511": "withdrawn by {by}", - "46d614fa7b4bf1e5": "Workflow runs" + "46d614fa7b4bf1e5": "Workflow runs", + "6381c4a2297e37e6": "Delete {model}?", + "00b5905cc4800231": "{environment} will delete {size} of model files. You can download it again later.", + "c73437a48071f19d": "Delete", + "51fd61b9c85dec5d": "Could not delete the model", + "88fa0730d8c7eab4": "Delete {model}" } diff --git a/apps/mobile/src/i18n/translations/es.json b/apps/mobile/src/i18n/translations/es.json index b839834f248e0..5f9807f569b39 100644 --- a/apps/mobile/src/i18n/translations/es.json +++ b/apps/mobile/src/i18n/translations/es.json @@ -5697,5 +5697,10 @@ "99451a5d2d40440f": "Retirada por {by}.", "3ee30a50b70fffab": "Retirada por {by}: {reason}", "201490988858b511": "retirada por {by}", - "46d614fa7b4bf1e5": "Ejecuciones de flujos de trabajo" + "46d614fa7b4bf1e5": "Ejecuciones de flujos de trabajo", + "6381c4a2297e37e6": "¿Eliminar {model}?", + "00b5905cc4800231": "{environment} eliminará {size} de archivos del modelo. Puedes volver a descargarlo más tarde.", + "c73437a48071f19d": "Eliminar", + "51fd61b9c85dec5d": "No se pudo eliminar el modelo", + "88fa0730d8c7eab4": "Eliminar {model}" } diff --git a/apps/mobile/src/i18n/translations/fr.json b/apps/mobile/src/i18n/translations/fr.json index 8a659455e3b59..c0370bee45cf6 100644 --- a/apps/mobile/src/i18n/translations/fr.json +++ b/apps/mobile/src/i18n/translations/fr.json @@ -5697,5 +5697,10 @@ "99451a5d2d40440f": "Retirée par {by}.", "3ee30a50b70fffab": "Retirée par {by} : {reason}", "201490988858b511": "retirée par {by}", - "46d614fa7b4bf1e5": "Exécutions de workflow" + "46d614fa7b4bf1e5": "Exécutions de workflow", + "6381c4a2297e37e6": "Supprimer {model} ?", + "00b5905cc4800231": "{environment} va supprimer {size} de fichiers de modèle. Vous pourrez le télécharger à nouveau plus tard.", + "c73437a48071f19d": "Supprimer", + "51fd61b9c85dec5d": "Impossible de supprimer le modèle", + "88fa0730d8c7eab4": "Supprimer {model}" } diff --git a/apps/mobile/src/i18n/translations/ja.json b/apps/mobile/src/i18n/translations/ja.json index adb255de9dd11..a657b952276d8 100644 --- a/apps/mobile/src/i18n/translations/ja.json +++ b/apps/mobile/src/i18n/translations/ja.json @@ -5674,5 +5674,10 @@ "99451a5d2d40440f": "{by} が取り下げました。", "3ee30a50b70fffab": "{by} が取り下げました: {reason}", "201490988858b511": "{by} が取り下げ", - "46d614fa7b4bf1e5": "ワークフローの実行" + "46d614fa7b4bf1e5": "ワークフローの実行", + "6381c4a2297e37e6": "{model} を削除しますか?", + "00b5905cc4800231": "{environment} は {size} のモデルファイルを削除します。後で再度ダウンロードできます。", + "c73437a48071f19d": "削除", + "51fd61b9c85dec5d": "モデルを削除できませんでした", + "88fa0730d8c7eab4": "{model} を削除" } diff --git a/apps/mobile/src/i18n/translations/ko.json b/apps/mobile/src/i18n/translations/ko.json index 0ff760787a094..dd98ca252a26d 100644 --- a/apps/mobile/src/i18n/translations/ko.json +++ b/apps/mobile/src/i18n/translations/ko.json @@ -5681,5 +5681,10 @@ "99451a5d2d40440f": "{by}에서 철회했습니다.", "3ee30a50b70fffab": "{by}에서 철회했습니다: {reason}", "201490988858b511": "{by}에서 철회함", - "46d614fa7b4bf1e5": "워크플로 실행" + "46d614fa7b4bf1e5": "워크플로 실행", + "6381c4a2297e37e6": "{model}을(를) 삭제할까요?", + "00b5905cc4800231": "{environment}에서 모델 파일 {size}를 삭제합니다. 나중에 다시 다운로드할 수 있습니다.", + "c73437a48071f19d": "삭제", + "51fd61b9c85dec5d": "모델을 삭제할 수 없습니다", + "88fa0730d8c7eab4": "{model} 삭제" } diff --git a/apps/mobile/src/i18n/translations/pt-BR.json b/apps/mobile/src/i18n/translations/pt-BR.json index 66624b02182fc..217d54e87e9b8 100644 --- a/apps/mobile/src/i18n/translations/pt-BR.json +++ b/apps/mobile/src/i18n/translations/pt-BR.json @@ -5697,5 +5697,10 @@ "99451a5d2d40440f": "Retirada por {by}.", "3ee30a50b70fffab": "Retirada por {by}: {reason}", "201490988858b511": "retirada por {by}", - "46d614fa7b4bf1e5": "Execuções de workflow" + "46d614fa7b4bf1e5": "Execuções de workflow", + "6381c4a2297e37e6": "Excluir {model}?", + "00b5905cc4800231": "{environment} vai excluir {size} de arquivos de modelo. Você pode baixá-lo novamente mais tarde.", + "c73437a48071f19d": "Excluir", + "51fd61b9c85dec5d": "Não foi possível excluir o modelo", + "88fa0730d8c7eab4": "Excluir {model}" } diff --git a/apps/mobile/src/i18n/translations/ru.json b/apps/mobile/src/i18n/translations/ru.json index f3f1fdd012ace..02327de35ae21 100644 --- a/apps/mobile/src/i18n/translations/ru.json +++ b/apps/mobile/src/i18n/translations/ru.json @@ -5777,5 +5777,10 @@ "99451a5d2d40440f": "Отозван: {by}.", "3ee30a50b70fffab": "Отозван ({by}): {reason}", "201490988858b511": "отозван: {by}", - "46d614fa7b4bf1e5": "Запуски воркфлоу" + "46d614fa7b4bf1e5": "Запуски воркфлоу", + "6381c4a2297e37e6": "Удалить {model}?", + "00b5905cc4800231": "{environment} удалит {size} файлов модели. Вы сможете скачать её снова позже.", + "c73437a48071f19d": "Удалить", + "51fd61b9c85dec5d": "Не удалось удалить модель", + "88fa0730d8c7eab4": "Удалить {model}" } diff --git a/apps/mobile/src/i18n/translations/sv.json b/apps/mobile/src/i18n/translations/sv.json index 351210012940e..0b3658f64f081 100644 --- a/apps/mobile/src/i18n/translations/sv.json +++ b/apps/mobile/src/i18n/translations/sv.json @@ -5703,5 +5703,10 @@ "99451a5d2d40440f": "Återkallad av {by}.", "3ee30a50b70fffab": "Återkallad av {by}: {reason}", "201490988858b511": "återkallad av {by}", - "46d614fa7b4bf1e5": "Arbetsflödeskörningar" + "46d614fa7b4bf1e5": "Arbetsflödeskörningar", + "6381c4a2297e37e6": "Ta bort {model}?", + "00b5905cc4800231": "{environment} tar bort {size} modellfiler. Du kan ladda ned den igen senare.", + "c73437a48071f19d": "Ta bort", + "51fd61b9c85dec5d": "Kunde inte ta bort modellen", + "88fa0730d8c7eab4": "Ta bort {model}" } diff --git a/apps/mobile/src/i18n/translations/zh.json b/apps/mobile/src/i18n/translations/zh.json index 04afa392e5fe2..4f3e8d1cb150a 100644 --- a/apps/mobile/src/i18n/translations/zh.json +++ b/apps/mobile/src/i18n/translations/zh.json @@ -5684,5 +5684,10 @@ "99451a5d2d40440f": "已由 {by} 撤回。", "3ee30a50b70fffab": "已由 {by} 撤回:{reason}", "201490988858b511": "已由 {by} 撤回", - "46d614fa7b4bf1e5": "工作流运行" + "46d614fa7b4bf1e5": "工作流运行", + "6381c4a2297e37e6": "删除 {model}?", + "00b5905cc4800231": "{environment} 将删除 {size} 的模型文件。之后可以重新下载。", + "c73437a48071f19d": "删除", + "51fd61b9c85dec5d": "无法删除模型", + "88fa0730d8c7eab4": "删除 {model}" }