feat: Pick share keys with

This commit is contained in:
Krille 2025-02-04 15:07:07 +01:00
commit 9f9f52fa02
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652
7 changed files with 67 additions and 7 deletions

View file

@ -1,3 +1,4 @@
import 'package:fluffychat/config/setting_keys.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -108,6 +109,16 @@ class SettingsSecurityController extends State<SettingsSecurity> {
Future<void> dehydrateAction() => Matrix.of(context).dehydrateAction(context);
void changeShareKeysWith(ShareKeysWith? shareKeysWith) async {
if (shareKeysWith == null) return;
Matrix.of(context).store.setString(
SettingKeys.shareKeysWith,
shareKeysWith.name,
);
Matrix.of(context).client.shareKeysWith = shareKeysWith;
setState(() {});
}
@override
Widget build(BuildContext context) => SettingsSecurityView(this);
}

View file

@ -10,6 +10,7 @@ import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:fluffychat/widgets/settings_switch_list_tile.dart';
import 'package:matrix/matrix.dart';
import 'settings_security.dart';
class SettingsSecurityView extends StatelessWidget {
@ -88,6 +89,43 @@ class SettingsSecurityView extends StatelessWidget {
),
},
Divider(color: theme.dividerColor),
ListTile(
title: Text(
'Share keys with',
style: TextStyle(
color: theme.colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
subtitle: Text(
'Which devices should be trusted so that they can read along your messages in encrypted chats?',
),
),
ListTile(
title: Material(
borderRadius:
BorderRadius.circular(AppConfig.borderRadius / 2),
color: theme.colorScheme.onInverseSurface,
child: DropdownButton<ShareKeysWith>(
isExpanded: true,
padding: const EdgeInsets.symmetric(horizontal: 8.0),
borderRadius:
BorderRadius.circular(AppConfig.borderRadius / 2),
underline: const SizedBox.shrink(),
value: Matrix.of(context).client.shareKeysWith,
items: ShareKeysWith.values
.map(
(share) => DropdownMenuItem(
value: share,
child: Text(share.name),
),
)
.toList(),
onChanged: controller.changeShareKeysWith,
),
),
),
Divider(color: theme.dividerColor),
ListTile(
title: Text(
L10n.of(context).account,