mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-18 16:36:27 +10:00
Merge branch 'dev' into sync-progressbar
This commit is contained in:
@@ -561,6 +561,7 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
TranslationService translationService,
|
||||
) {
|
||||
final settings = settingsService.settings;
|
||||
final translationEnabled = settings.translationEnabled;
|
||||
return Card(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -581,11 +582,41 @@ class AppSettingsScreen extends StatelessWidget {
|
||||
),
|
||||
const Divider(height: 1),
|
||||
SwitchListTile(
|
||||
secondary: const Icon(Icons.outgoing_mail),
|
||||
title: Text(context.l10n.translation_composerTitle),
|
||||
subtitle: Text(context.l10n.translation_composerSubtitle),
|
||||
secondary: Icon(
|
||||
Icons.auto_awesome_outlined,
|
||||
color: translationEnabled ? null : Colors.grey,
|
||||
),
|
||||
title: Text(
|
||||
context.l10n.translation_autoIncomingTitle,
|
||||
style: TextStyle(color: translationEnabled ? null : Colors.grey),
|
||||
),
|
||||
subtitle: Text(
|
||||
context.l10n.translation_autoIncomingSubtitle,
|
||||
style: TextStyle(color: translationEnabled ? null : Colors.grey),
|
||||
),
|
||||
value: settings.autoTranslateIncomingMessages,
|
||||
onChanged: translationEnabled
|
||||
? settingsService.setAutoTranslateIncomingMessages
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 1),
|
||||
SwitchListTile(
|
||||
secondary: Icon(
|
||||
Icons.outgoing_mail,
|
||||
color: translationEnabled ? null : Colors.grey,
|
||||
),
|
||||
title: Text(
|
||||
context.l10n.translation_composerTitle,
|
||||
style: TextStyle(color: translationEnabled ? null : Colors.grey),
|
||||
),
|
||||
subtitle: Text(
|
||||
context.l10n.translation_composerSubtitle,
|
||||
style: TextStyle(color: translationEnabled ? null : Colors.grey),
|
||||
),
|
||||
value: settings.composerTranslationEnabled,
|
||||
onChanged: settingsService.setComposerTranslationEnabled,
|
||||
onChanged: translationEnabled
|
||||
? settingsService.setComposerTranslationEnabled
|
||||
: null,
|
||||
),
|
||||
const Divider(height: 1),
|
||||
ListTile(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:math' as math;
|
||||
|
||||
@@ -1388,6 +1389,15 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
}
|
||||
|
||||
void _showMessageActions(ChannelMessage message) {
|
||||
final translationService = context.read<TranslationService>();
|
||||
final canTranslateMessage =
|
||||
translationService.canTranslateIncoming(
|
||||
text: message.text,
|
||||
isCli: false,
|
||||
isOutgoing: message.isOutgoing,
|
||||
) &&
|
||||
(message.translatedText?.trim().isEmpty ?? true);
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (sheetContext) => SafeArea(
|
||||
@@ -1429,6 +1439,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),
|
||||
|
||||
@@ -1580,6 +1580,15 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
}
|
||||
|
||||
void _showMessageActions(Message message, Contact contact) {
|
||||
final translationService = context.read<TranslationService>();
|
||||
final canTranslateMessage =
|
||||
translationService.canTranslateIncoming(
|
||||
text: message.text,
|
||||
isCli: message.isCli,
|
||||
isOutgoing: message.isOutgoing,
|
||||
) &&
|
||||
(message.translatedText?.trim().isEmpty ?? true);
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (sheetContext) => SafeArea(
|
||||
@@ -1613,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