chore: Resort settings and add more description text

This commit is contained in:
krille-chan 2024-01-20 14:45:44 +01:00
parent a7a8285a55
commit f7c89ddf9e
No known key found for this signature in database
4 changed files with 31 additions and 21 deletions

View file

@ -1529,11 +1529,6 @@
"type": "text",
"placeholders": {}
},
"renderRichContent": "Render rich message content",
"@renderRichContent": {
"type": "text",
"placeholders": {}
},
"replaceRoomWithNewerVersion": "Replace room with newer version",
"@replaceRoomWithNewerVersion": {
"type": "text",
@ -2417,5 +2412,10 @@
"roomName": {}
}
},
"sendReadReceipts": "Send read receipts"
"sendReadReceipts": "Send read receipts",
"sendTypingNotificationsDescription": "Other participants in a chat can see when you are typing a new message.",
"sendReadReceiptsDescription": "Andere Teilnehmer in einem Chat können sehen, ob du eine Nachricht gelesen hast.",
"formattedMessages": "Formatted messages",
"formattedMessagesDescription": "Display rich message content like bold text using markdown."
}

View file

@ -33,7 +33,8 @@ class SettingsChatView extends StatelessWidget {
),
const Divider(),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.renderRichContent,
title: L10n.of(context)!.formattedMessages,
subtitle: L10n.of(context)!.formattedMessagesDescription,
onChanged: (b) => AppConfig.renderHtml = b,
storeKey: SettingKeys.renderHtml,
defaultValue: AppConfig.renderHtml,
@ -64,18 +65,6 @@ class SettingsChatView extends StatelessWidget {
defaultValue: AppConfig.autoplayImages,
),
const Divider(),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendTypingNotifications,
onChanged: (b) => AppConfig.sendTypingNotifications = b,
storeKey: SettingKeys.sendTypingNotifications,
defaultValue: AppConfig.sendTypingNotifications,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendReadReceipts,
onChanged: (b) => AppConfig.sendPublicReadReceipts = b,
storeKey: SettingKeys.sendPublicReadReceipts,
defaultValue: AppConfig.sendPublicReadReceipts,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendOnEnter,
onChanged: (b) => AppConfig.sendOnEnter = b,

View file

@ -3,11 +3,14 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/utils/beautify_string_extension.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart';
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 'settings_security.dart';
class SettingsSecurityView extends StatelessWidget {
@ -105,7 +108,6 @@ class SettingsSecurityView extends StatelessWidget {
const Divider(height: 1),
ListTile(
leading: const Icon(Icons.tap_and_play),
trailing: const Icon(Icons.chevron_right_outlined),
title: Text(
L10n.of(context)!.dehydrate,
style: const TextStyle(color: Colors.red),
@ -114,7 +116,6 @@ class SettingsSecurityView extends StatelessWidget {
),
ListTile(
leading: const Icon(Icons.delete_outlined),
trailing: const Icon(Icons.chevron_right_outlined),
title: Text(
L10n.of(context)!.deleteAccount,
style: const TextStyle(color: Colors.red),
@ -129,6 +130,22 @@ class SettingsSecurityView extends StatelessWidget {
),
leading: const Icon(Icons.vpn_key_outlined),
),
const Divider(height: 1),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendTypingNotifications,
subtitle:
L10n.of(context)!.sendTypingNotificationsDescription,
onChanged: (b) => AppConfig.sendTypingNotifications = b,
storeKey: SettingKeys.sendTypingNotifications,
defaultValue: AppConfig.sendTypingNotifications,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendReadReceipts,
subtitle: L10n.of(context)!.sendReadReceiptsDescription,
onChanged: (b) => AppConfig.sendPublicReadReceipts = b,
storeKey: SettingKeys.sendPublicReadReceipts,
defaultValue: AppConfig.sendPublicReadReceipts,
),
],
);
},

View file

@ -6,6 +6,7 @@ class SettingsSwitchListTile extends StatefulWidget {
final bool defaultValue;
final String storeKey;
final String title;
final String? subtitle;
final Function(bool)? onChanged;
const SettingsSwitchListTile.adaptive({
@ -13,6 +14,7 @@ class SettingsSwitchListTile extends StatefulWidget {
this.defaultValue = false,
required this.storeKey,
required this.title,
this.subtitle,
this.onChanged,
});
@ -23,10 +25,12 @@ class SettingsSwitchListTile extends StatefulWidget {
class SettingsSwitchListTileState extends State<SettingsSwitchListTile> {
@override
Widget build(BuildContext context) {
final subtitle = widget.subtitle;
return SwitchListTile.adaptive(
value: Matrix.of(context).store.getBool(widget.storeKey) ??
widget.defaultValue,
title: Text(widget.title),
subtitle: subtitle == null ? null : Text(subtitle),
onChanged: (bool newValue) async {
widget.onChanged?.call(newValue);
await Matrix.of(context).store.setBool(widget.storeKey, newValue);