add toggle for autmatically translated messages for notification and chat or manual translation on message action. Due to heavy battery usage.

This commit is contained in:
ericz
2026-05-20 21:24:54 +02:00
parent bc5f299350
commit 9ada4ea601
44 changed files with 424 additions and 24 deletions
+28
View File
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'dart:math' as math;
@@ -1320,6 +1321,18 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
}
void _showMessageActions(ChannelMessage message) {
final settings = context.read<AppSettingsService>().settings;
final translationService = context.read<TranslationService>();
final canTranslateMessage =
settings.translationEnabled &&
!settings.autoTranslateIncomingMessages &&
translationService.canTranslateIncoming(
text: message.text,
isCli: false,
isOutgoing: message.isOutgoing,
) &&
(message.translatedText?.trim().isEmpty ?? true);
showModalBottomSheet(
context: context,
builder: (sheetContext) => SafeArea(
@@ -1361,6 +1374,21 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
_copyMessageText(message.text);
},
),
if (canTranslateMessage)
ListTile(
leading: const Icon(Icons.translate),
title: Text(context.l10n.translation_translateMessage),
onTap: () {
Navigator.pop(sheetContext);
unawaited(
context.read<MeshCoreConnector>().translateChannelMessage(
widget.channel.index,
message,
manualTranslation: true,
),
);
},
),
if (!message.isOutgoing)
ListTile(
leading: const Icon(Icons.mark_chat_unread_outlined),