mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-21 08:11:06 +10:00
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:
@@ -1577,6 +1577,18 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
void _showMessageActions(Message message, Contact contact) {
|
||||
final settings = context.read<AppSettingsService>().settings;
|
||||
final translationService = context.read<TranslationService>();
|
||||
final canTranslateMessage =
|
||||
settings.translationEnabled &&
|
||||
!settings.autoTranslateIncomingMessages &&
|
||||
translationService.canTranslateIncoming(
|
||||
text: message.text,
|
||||
isCli: message.isCli,
|
||||
isOutgoing: message.isOutgoing,
|
||||
) &&
|
||||
(message.translatedText?.trim().isEmpty ?? true);
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (sheetContext) => SafeArea(
|
||||
@@ -1610,6 +1622,21 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
_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>().translateContactMessage(
|
||||
widget.contact.publicKeyHex,
|
||||
message,
|
||||
manualTranslation: true,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (!message.isOutgoing)
|
||||
ListTile(
|
||||
leading: const Icon(Icons.mark_chat_unread_outlined),
|
||||
|
||||
Reference in New Issue
Block a user