mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-16 17:09:31 +01:00
Enhance chatencryptionsettings page
This commit is contained in:
parent
0116031812
commit
6f48a68798
@ -97,6 +97,11 @@ class MatrixState extends State<Matrix> {
|
||||
|
||||
hideLoadingDialog() => Navigator.of(_loadingDialogContext)?.pop();
|
||||
|
||||
bool get encryptionEnabled =>
|
||||
client.userDeviceKeys.containsKey(client.userID) &&
|
||||
client.userDeviceKeys[client.userID].deviceKeys
|
||||
.containsKey(client.deviceID);
|
||||
|
||||
Future<String> downloadAndSaveContent(MxContent content,
|
||||
{int width, int height, ThumbnailMethod method}) async {
|
||||
final bool thumbnail = width == null && height == null ? false : true;
|
||||
|
@ -400,6 +400,20 @@ class _ChatState extends State<_Chat> {
|
||||
decoration: InputDecoration(
|
||||
hintText: I18n.of(context).writeAMessage,
|
||||
border: InputBorder.none,
|
||||
suffixIcon: 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();
|
||||
@ -422,17 +436,6 @@ class _ChatState extends State<_Chat> {
|
||||
}
|
||||
},
|
||||
),
|
||||
)),
|
||||
SizedBox(width: 8),
|
||||
if (sendController.text.isEmpty)
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
room.encrypted ? Icons.lock : Icons.lock_open),
|
||||
onPressed: () => Navigator.of(context).push(
|
||||
AppRoute.defaultRoute(
|
||||
context,
|
||||
ChatEncryptionSettingsView(widget.id),
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
|
@ -8,6 +8,7 @@ import 'package:fluffychat/utils/beautify_string_extension.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/views/chat_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
class ChatEncryptionSettingsView extends StatelessWidget {
|
||||
final String id;
|
||||
@ -49,6 +50,7 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
|
||||
Widget build(BuildContext context) {
|
||||
room ??= Matrix.of(context).client.getRoomById(widget.id);
|
||||
roomUpdate ??= room.onUpdate.stream.listen((s) => setState(() => null));
|
||||
print(Matrix.of(context).client.userDeviceKeys.length);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@ -59,15 +61,19 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
|
||||
ListTile(
|
||||
title: Text(I18n.of(context).encryptionAlgorithm),
|
||||
subtitle: Text(room.encryptionAlgorithm ?? I18n.of(context).none),
|
||||
trailing: Icon(room.encrypted ? Icons.lock : Icons.lock_open),
|
||||
trailing: Icon(room.encrypted ? Icons.lock : Icons.lock_open,
|
||||
color: room.encrypted ? Colors.green : Colors.red),
|
||||
onTap: () {
|
||||
if (room.encrypted) return;
|
||||
if (!Matrix.of(context).encryptionEnabled) {
|
||||
Toast.show(I18n.of(context).needPantalaimonWarning, context,
|
||||
duration: 8);
|
||||
return;
|
||||
}
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => ConfirmDialog(
|
||||
I18n.of(context).enableEncryptionWarning +
|
||||
" " +
|
||||
I18n.of(context).needPantalaimonWarning,
|
||||
I18n.of(context).enableEncryptionWarning,
|
||||
I18n.of(context).yes,
|
||||
(context) => Matrix.of(context).tryRequestWithLoadingDialog(
|
||||
room.enableEncryption(),
|
||||
@ -83,6 +89,7 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
|
||||
),
|
||||
),
|
||||
Divider(height: 1),
|
||||
if (room.encrypted)
|
||||
ListTile(
|
||||
title: Text(
|
||||
"${I18n.of(context).participatingUserDevices}:",
|
||||
@ -91,7 +98,8 @@ class _ChatEncryptionSettingsState extends State<ChatEncryptionSettings> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(height: 1),
|
||||
if (room.encrypted) Divider(height: 1),
|
||||
if (room.encrypted)
|
||||
FutureBuilder<List<DeviceKeys>>(
|
||||
future: room.getUserDeviceKeys(),
|
||||
builder: (BuildContext context, snapshot) {
|
||||
|
@ -110,8 +110,8 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "166b1a9464843cd17e86d9330ac8782d6081f46b"
|
||||
resolved-ref: "166b1a9464843cd17e86d9330ac8782d6081f46b"
|
||||
ref: "6a6ca40e96712d2ad3638fec7ec3ec5b17eaedca"
|
||||
resolved-ref: "6a6ca40e96712d2ad3638fec7ec3ec5b17eaedca"
|
||||
url: "https://gitlab.com/famedly/famedlysdk.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
@ -27,7 +27,7 @@ dependencies:
|
||||
famedlysdk:
|
||||
git:
|
||||
url: https://gitlab.com/famedly/famedlysdk.git
|
||||
ref: 166b1a9464843cd17e86d9330ac8782d6081f46b
|
||||
ref: 4bf6a4bcb60ca8877b5f2d435978e47358c20cad
|
||||
|
||||
localstorage: ^3.0.1+4
|
||||
bubble: ^1.1.9+1
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:fluffychat/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Test if the app starts', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
|
Loading…
Reference in New Issue
Block a user