fluffychat/lib/pages/settings_security/settings_security_view.dart

116 lines
4.8 KiB
Dart
Raw Normal View History

2021-06-23 11:26:12 +02:00
import 'package:flutter/material.dart';
2021-10-26 18:50:34 +02:00
import 'package:adaptive_dialog/adaptive_dialog.dart';
2021-06-23 11:26:12 +02:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/utils/beautify_string_extension.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
import 'package:fluffychat/widgets/matrix.dart';
2021-11-09 21:32:16 +01:00
import 'settings_security.dart';
2021-06-23 11:26:12 +02:00
class SettingsSecurityView extends StatelessWidget {
final SettingsSecurityController controller;
2022-01-29 12:35:03 +01:00
const SettingsSecurityView(this.controller, {Key? key}) : super(key: key);
2021-06-23 11:26:12 +02:00
@override
Widget build(BuildContext context) {
return Scaffold(
2022-01-29 12:35:03 +01:00
appBar: AppBar(title: Text(L10n.of(context)!.security)),
2021-11-14 13:24:01 +01:00
body: ListTileTheme(
2022-01-29 12:35:03 +01:00
iconColor: Theme.of(context).textTheme.bodyText1!.color,
2021-11-14 13:24:01 +01:00
child: MaxWidthBody(
withScrolling: true,
child: Column(
children: [
2021-12-25 10:20:18 +01:00
ListTile(
trailing: const Icon(Icons.panorama_fish_eye),
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.whoCanSeeMyStories),
2021-12-25 10:20:18 +01:00
onTap: () => VRouter.of(context).to('stories'),
),
2021-06-23 11:26:12 +02:00
ListTile(
2021-11-14 13:24:01 +01:00
trailing: const Icon(Icons.close),
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.ignoredUsers),
2021-11-14 13:24:01 +01:00
onTap: () => VRouter.of(context).to('ignorelist'),
2021-11-11 19:39:55 +01:00
),
ListTile(
2021-11-14 13:24:01 +01:00
trailing: const Icon(Icons.vpn_key_outlined),
title: Text(
2022-01-29 12:35:03 +01:00
L10n.of(context)!.changePassword,
2021-11-14 13:24:01 +01:00
),
onTap: controller.changePasswordAccountAction,
2021-11-11 19:39:55 +01:00
),
ListTile(
2021-11-14 13:24:01 +01:00
trailing: const Icon(Icons.mail_outlined),
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.passwordRecovery),
2021-11-14 13:24:01 +01:00
onTap: () => VRouter.of(context).to('3pid'),
2021-11-11 19:39:55 +01:00
),
2021-11-14 13:24:01 +01:00
if (Matrix.of(context).client.encryption != null) ...{
const Divider(thickness: 1),
if (PlatformInfos.isMobile)
ListTile(
trailing: const Icon(Icons.lock_outlined),
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.appLock),
2021-11-14 13:24:01 +01:00
onTap: controller.setAppLockAction,
),
ListTile(
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.yourPublicKey),
2021-11-14 13:24:01 +01:00
onTap: () => showOkAlertDialog(
useRootNavigator: false,
context: context,
2022-01-29 12:35:03 +01:00
title: L10n.of(context)!.yourPublicKey,
2021-11-14 13:24:01 +01:00
message:
Matrix.of(context).client.fingerprintKey.beautified,
2022-01-29 12:35:03 +01:00
okLabel: L10n.of(context)!.ok,
2021-11-14 13:24:01 +01:00
),
trailing: const Icon(Icons.vpn_key_outlined),
),
2022-01-29 12:35:03 +01:00
if (!Matrix.of(context).client.encryption!.crossSigning.enabled)
2021-12-25 10:20:18 +01:00
ListTile(
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.crossSigningEnabled),
2021-12-25 10:20:18 +01:00
trailing: const Icon(Icons.error, color: Colors.red),
onTap: () => controller.showBootstrapDialog(context),
),
2022-01-29 12:35:03 +01:00
if (!Matrix.of(context).client.encryption!.keyManager.enabled)
2021-12-25 10:20:18 +01:00
ListTile(
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.onlineKeyBackupEnabled),
2021-12-25 10:20:18 +01:00
trailing: const Icon(Icons.error, color: Colors.red),
onTap: () => controller.showBootstrapDialog(context),
),
if (Matrix.of(context).client.isUnknownSession)
ListTile(
title: const Text('Session verified'),
trailing: const Icon(Icons.error, color: Colors.red),
onTap: () => controller.showBootstrapDialog(context),
),
2021-11-14 13:24:01 +01:00
FutureBuilder(
future: () async {
return (await Matrix.of(context)
.client
2022-01-29 12:35:03 +01:00
.encryption!
.keyManager
.isCached()) &&
(await Matrix.of(context)
.client
2022-01-29 12:35:03 +01:00
.encryption!
.crossSigning
.isCached());
}(),
2021-12-25 10:20:18 +01:00
builder: (context, snapshot) => snapshot.data == true
? Container()
: ListTile(
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.keysCached),
2021-12-25 10:20:18 +01:00
trailing: const Icon(Icons.error, color: Colors.red),
onTap: () => controller.showBootstrapDialog(context),
),
2021-11-14 13:24:01 +01:00
),
},
],
),
2021-06-23 11:26:12 +02:00
),
),
);
}
}