diff --git a/lib/screens/chat_screen.dart b/lib/screens/chat_screen.dart index db3f21b..97fcc93 100644 --- a/lib/screens/chat_screen.dart +++ b/lib/screens/chat_screen.dart @@ -433,6 +433,8 @@ class _ChatScreenState extends State { bool _sendEncryptedForCurrentChat = false; bool _specialMessagesEnabled = false; + bool _formatWarningVisible = false; + bool _showKometColorPicker = false; String? _currentKometColorPrefix; @@ -1948,6 +1950,16 @@ class _ChatScreenState extends State { } void _applyTextFormat(String type) { + final isEncryptionActive = + _encryptionConfigForCurrentChat != null && + _encryptionConfigForCurrentChat!.password.isNotEmpty && + _sendEncryptedForCurrentChat; + if (isEncryptionActive) { + setState(() { + _formatWarningVisible = true; + }); + return; + } final selection = _textController.selection; if (!selection.isValid || selection.isCollapsed) return; final from = selection.start; @@ -4320,7 +4332,6 @@ class _ChatScreenState extends State { ), const SizedBox(height: 4), Row( - mainAxisAlignment: MainAxisAlignment.start, children: [ IconButton( iconSize: 18, @@ -4371,6 +4382,28 @@ class _ChatScreenState extends State { ), tooltip: 'Зачеркнуть', ), + const SizedBox(width: 8), + Expanded( + child: AnimatedOpacity( + opacity: _formatWarningVisible + ? 1 + : 0, + duration: const Duration( + milliseconds: 200, + ), + child: Text( + 'Форматирование не доступно в шифрованных сообщениях.', + style: TextStyle( + fontSize: 11, + color: Theme.of( + context, + ).colorScheme.error, + ), + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ), + ), ], ), ], diff --git a/lib/services/chat_encryption_service.dart b/lib/services/chat_encryption_service.dart index 547e8df..2b2cd52 100644 --- a/lib/services/chat_encryption_service.dart +++ b/lib/services/chat_encryption_service.dart @@ -21,7 +21,7 @@ class ChatEncryptionConfig { factory ChatEncryptionConfig.fromJson(Map json) { return ChatEncryptionConfig( password: (json['password'] as String?) ?? '', - sendEncrypted: (json['sendEncrypted'] as bool?) ?? false, + sendEncrypted: (json['sendEncrypted'] as bool?) ?? true, ); } } @@ -54,7 +54,7 @@ class ChatEncryptionService { if (legacyPassword != null && legacyPassword.isNotEmpty) { final legacyConfig = ChatEncryptionConfig( password: legacyPassword, - sendEncrypted: false, + sendEncrypted: true, ); await _saveConfig(chatId, legacyConfig); return legacyConfig;