From d5809ba597065ec2236bcb70cd2622ee386b2a91 Mon Sep 17 00:00:00 2001 From: jganenok Date: Thu, 4 Dec 2025 21:20:52 +0700 Subject: [PATCH] =?UTF-8?q?=D0=B2=20=D0=BF=D0=BE=D0=BB=D0=B5=20=D0=B2?= =?UTF-8?q?=D0=B2=D0=BE=D0=B4=D0=B0=20=D1=81=D0=BE=D0=BE=20=D0=B4=D0=B8?= =?UTF-8?q?=D0=BD=D0=B0=D0=BC=D0=B8=D1=87=D0=BD=D0=BE=20=D0=BF=D0=BE=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D1=87?= =?UTF-8?q?=D1=82=D0=BE=20=D0=BC=D1=8B=20=D0=B8=20=D0=BA=D0=B0=D0=BA=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BC=D0=B5=D1=82=D0=B8=D0=BB=D0=B8,=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B5=20=D1=81=D0=BE=D0=BE=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D1=8F=D1=8E=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=BF=D1=80=D0=B8=20=D1=88=D0=B8=D1=84=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/screens/chat_screen.dart | 35 ++++++++++++++++++++++- lib/services/chat_encryption_service.dart | 4 +-- 2 files changed, 36 insertions(+), 3 deletions(-) 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;