fluffychat/lib/pages/settings_chat/settings_chat_view.dart

136 lines
5.6 KiB
Dart
Raw Normal View History

2021-10-26 16:50:34 +00:00
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:go_router/go_router.dart';
2021-10-26 16:50:34 +00:00
2021-06-23 09:26:12 +00:00
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/setting_keys.dart';
2021-08-24 18:43:21 +00:00
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/voip/callkeep_manager.dart';
2021-06-23 09:26:12 +00:00
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
2022-02-19 10:58:21 +00:00
import 'package:fluffychat/widgets/matrix.dart';
2021-06-23 09:26:12 +00:00
import 'package:fluffychat/widgets/settings_switch_list_tile.dart';
2021-11-09 20:32:16 +00:00
import 'settings_chat.dart';
2021-06-23 09:26:12 +00:00
class SettingsChatView extends StatelessWidget {
final SettingsChatController controller;
const SettingsChatView(this.controller, {super.key});
2021-06-23 09:26:12 +00:00
@override
Widget build(BuildContext context) {
return Scaffold(
2022-01-29 11:35:03 +00:00
appBar: AppBar(title: Text(L10n.of(context)!.chat)),
2021-11-14 12:24:01 +00:00
body: ListTileTheme(
2023-01-26 08:47:30 +00:00
iconColor: Theme.of(context).textTheme.bodyLarge!.color,
2021-11-14 12:24:01 +00:00
child: MaxWidthBody(
child: Column(
children: [
2021-11-27 09:10:29 +00:00
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.formattedMessages,
subtitle: L10n.of(context)!.formattedMessagesDescription,
2021-11-14 12:24:01 +00:00
onChanged: (b) => AppConfig.renderHtml = b,
storeKey: SettingKeys.renderHtml,
defaultValue: AppConfig.renderHtml,
2021-08-24 18:43:21 +00:00
),
2021-11-27 09:10:29 +00:00
SettingsSwitchListTile.adaptive(
2024-04-14 10:00:43 +00:00
title: L10n.of(context)!.hideMemberChangesInPublicChats,
subtitle: L10n.of(context)!.hideMemberChangesInPublicChatsBody,
onChanged: (b) => AppConfig.hideUnimportantStateEvents = b,
storeKey: SettingKeys.hideUnimportantStateEvents,
defaultValue: AppConfig.hideUnimportantStateEvents,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.hideRedactedMessages,
subtitle: L10n.of(context)!.hideRedactedMessagesBody,
2021-11-14 12:24:01 +00:00
onChanged: (b) => AppConfig.hideRedactedEvents = b,
storeKey: SettingKeys.hideRedactedEvents,
defaultValue: AppConfig.hideRedactedEvents,
),
2021-11-27 09:10:29 +00:00
SettingsSwitchListTile.adaptive(
2024-04-14 10:00:43 +00:00
title: L10n.of(context)!.hideInvalidOrUnknownMessageFormats,
2021-11-14 12:24:01 +00:00
onChanged: (b) => AppConfig.hideUnknownEvents = b,
storeKey: SettingKeys.hideUnknownEvents,
defaultValue: AppConfig.hideUnknownEvents,
),
if (PlatformInfos.isMobile)
2021-11-27 09:10:29 +00:00
SettingsSwitchListTile.adaptive(
2022-02-19 10:58:21 +00:00
title: L10n.of(context)!.autoplayImages,
onChanged: (b) => AppConfig.autoplayImages = b,
storeKey: SettingKeys.autoplayImages,
defaultValue: AppConfig.autoplayImages,
),
2022-03-20 16:38:13 +00:00
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendOnEnter,
onChanged: (b) => AppConfig.sendOnEnter = b,
storeKey: SettingKeys.sendOnEnter,
defaultValue: AppConfig.sendOnEnter ?? !PlatformInfos.isMobile,
2022-03-20 16:38:13 +00:00
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.swipeRightToLeftToReply,
onChanged: (b) => AppConfig.swipeRightToLeftToReply = b,
storeKey: SettingKeys.swipeRightToLeftToReply,
defaultValue: AppConfig.swipeRightToLeftToReply,
),
2024-04-14 10:39:37 +00:00
Divider(
height: 1,
color: Theme.of(context).dividerColor,
),
2024-04-14 11:06:30 +00:00
ListTile(
title: Text(
L10n.of(context)!.customEmojisAndStickers,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
2024-04-14 10:39:37 +00:00
ListTile(
title: Text(L10n.of(context)!.customEmojisAndStickers),
subtitle: Text(L10n.of(context)!.customEmojisAndStickersBody),
onTap: () => context.go('/rooms/settings/chat/emotes'),
trailing: const Padding(
padding: EdgeInsets.all(16.0),
2024-04-14 11:06:30 +00:00
child: Icon(Icons.chevron_right_outlined),
2024-04-14 10:39:37 +00:00
),
),
Divider(
height: 1,
color: Theme.of(context).dividerColor,
),
2024-04-14 11:06:30 +00:00
ListTile(
title: Text(
L10n.of(context)!.calls,
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
2023-08-13 16:21:55 +00:00
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.experimentalVideoCalls,
onChanged: (b) {
AppConfig.experimentalVoip = b;
Matrix.of(context).createVoipPlugin();
return;
},
storeKey: SettingKeys.experimentalVoip,
defaultValue: AppConfig.experimentalVoip,
),
if (PlatformInfos.isMobile)
ListTile(
title: Text(L10n.of(context)!.callingPermissions),
onTap: () =>
CallKeepManager().checkoutPhoneAccountSetting(context),
trailing: const Padding(
padding: EdgeInsets.all(16.0),
child: Icon(Icons.call),
),
),
2021-11-14 12:24:01 +00:00
],
),
2021-06-23 09:26:12 +00:00
),
),
);
}
}