From 3ec2e9f9b5b4264cf3ef07fdad94b344a018f684 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Sat, 22 Feb 2020 08:44:50 +0100 Subject: [PATCH] Enhanced E2EE UX --- lib/components/list_items/message.dart | 6 ++- lib/views/chat.dart | 58 ++++++++++++++++++-------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/lib/components/list_items/message.dart b/lib/components/list_items/message.dart index d18dc20..02ea030 100644 --- a/lib/components/list_items/message.dart +++ b/lib/components/list_items/message.dart @@ -129,7 +129,11 @@ class Message extends StatelessWidget { event.messageType == MessageTypes.BadEncrypted && event.content["body"] == DecryptError.UNKNOWN_SESSION) RaisedButton( - child: Text(I18n.of(context).requestPermission), + color: color.withAlpha(100), + child: Text( + I18n.of(context).requestPermission, + style: TextStyle(color: textColor), + ), onPressed: () => Matrix.of(context) .tryRequestWithLoadingDialog(event.requestKey()), ), diff --git a/lib/views/chat.dart b/lib/views/chat.dart index 8f1419e..90e5029 100644 --- a/lib/views/chat.dart +++ b/lib/views/chat.dart @@ -611,6 +611,47 @@ class _ChatState extends State<_Chat> { ), ], ), + FutureBuilder>( + future: room.getUserDeviceKeys(), + builder: + (BuildContext context, snapshot) { + Color color; + if (room.encrypted && + snapshot.hasData) { + final List + deviceKeysList = snapshot.data; + color = Colors.orange; + if (deviceKeysList.indexWhere( + (DeviceKeys deviceKeys) => + deviceKeys.verified == + false && + deviceKeys.blocked == + false) == + -1) { + color = Colors.green[700]; + } + } else if (!room.encrypted && + room.joinRules != + JoinRules.public) { + color = Colors.red; + } + return IconButton( + icon: Icon( + room.encrypted + ? Icons.lock + : Icons.lock_open, + size: 20, + color: color), + onPressed: () => + Navigator.of(context).push( + AppRoute.defaultRoute( + context, + ChatEncryptionSettingsView( + widget.id), + ), + ), + ); + }), Expanded( child: Padding( padding: const EdgeInsets.symmetric( @@ -632,23 +673,6 @@ class _ChatState extends State<_Chat> { hintText: I18n.of(context).writeAMessage, border: InputBorder.none, - prefixIcon: - sendController.text.isEmpty - ? InkWell( - child: Icon(room.encrypted - ? Icons.lock - : Icons.lock_open), - onTap: () => - Navigator.of(context) - .push( - AppRoute.defaultRoute( - context, - ChatEncryptionSettingsView( - widget.id), - ), - ), - ) - : null, ), onChanged: (String text) { this.typingCoolDown?.cancel();