fluffychat/lib/pages/settings_chat/settings_chat_view.dart

99 lines
4.1 KiB
Dart
Raw Permalink Normal View History

2021-10-26 18:50:34 +02:00
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:vrouter/vrouter.dart';
2021-06-23 11:26:12 +02:00
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/setting_keys.dart';
2021-08-24 20:43:21 +02:00
import 'package:fluffychat/utils/platform_infos.dart';
2021-06-23 11:26:12 +02:00
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
2022-02-19 11:58:21 +01:00
import 'package:fluffychat/widgets/matrix.dart';
2021-06-23 11:26:12 +02:00
import 'package:fluffychat/widgets/settings_switch_list_tile.dart';
2021-11-09 21:32:16 +01:00
import 'settings_chat.dart';
2021-06-23 11:26:12 +02:00
class SettingsChatView extends StatelessWidget {
final SettingsChatController controller;
2022-01-29 12:35:03 +01:00
const SettingsChatView(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)!.chat)),
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-11-27 10:10:29 +01:00
SettingsSwitchListTile.adaptive(
2022-01-29 12:35:03 +01:00
title: L10n.of(context)!.renderRichContent,
2021-11-14 13:24:01 +01:00
onChanged: (b) => AppConfig.renderHtml = b,
storeKey: SettingKeys.renderHtml,
defaultValue: AppConfig.renderHtml,
2021-08-24 20:43:21 +02:00
),
2021-11-27 10:10:29 +01:00
SettingsSwitchListTile.adaptive(
2022-01-29 12:35:03 +01:00
title: L10n.of(context)!.hideRedactedEvents,
2021-11-14 13:24:01 +01:00
onChanged: (b) => AppConfig.hideRedactedEvents = b,
storeKey: SettingKeys.hideRedactedEvents,
defaultValue: AppConfig.hideRedactedEvents,
),
2021-11-27 10:10:29 +01:00
SettingsSwitchListTile.adaptive(
2022-01-29 12:35:03 +01:00
title: L10n.of(context)!.hideUnknownEvents,
2021-11-14 13:24:01 +01:00
onChanged: (b) => AppConfig.hideUnknownEvents = b,
storeKey: SettingKeys.hideUnknownEvents,
defaultValue: AppConfig.hideUnknownEvents,
),
if (PlatformInfos.isMobile)
2021-11-27 10:10:29 +01:00
SettingsSwitchListTile.adaptive(
2022-02-19 11:58:21 +01:00
title: L10n.of(context)!.autoplayImages,
onChanged: (b) => AppConfig.autoplayImages = b,
storeKey: SettingKeys.autoplayImages,
defaultValue: AppConfig.autoplayImages,
),
2022-03-20 17:38:13 +01:00
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.sendOnEnter,
onChanged: (b) => AppConfig.sendOnEnter = b,
storeKey: SettingKeys.sendOnEnter,
defaultValue: AppConfig.sendOnEnter,
),
2022-02-19 11:58:21 +01:00
if (Matrix.of(context).webrtcIsSupported)
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.experimentalVideoCalls,
onChanged: (b) {
AppConfig.experimentalVoip = b;
Matrix.of(context).createVoipPlugin();
return;
},
storeKey: SettingKeys.experimentalVoip,
defaultValue: AppConfig.experimentalVoip,
2021-11-14 13:24:01 +01:00
),
const Divider(height: 1),
ListTile(
2022-01-29 12:35:03 +01:00
title: Text(L10n.of(context)!.emoteSettings),
2021-11-14 13:24:01 +01:00
onTap: () => VRouter.of(context).to('emotes'),
trailing: const Padding(
padding: EdgeInsets.all(16.0),
child: Icon(Icons.insert_emoticon_outlined),
),
2021-11-13 21:21:13 +01:00
),
const Divider(height: 1),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.showDirectChatsInSpaces,
onChanged: (b) => AppConfig.showDirectChatsInSpaces = b,
storeKey: SettingKeys.showDirectChatsInSpaces,
defaultValue: AppConfig.showDirectChatsInSpaces,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context)!.separateChatTypes,
onChanged: (b) => AppConfig.separateChatTypes = b,
storeKey: SettingKeys.separateChatTypes,
defaultValue: AppConfig.separateChatTypes,
),
2021-11-14 13:24:01 +01:00
],
),
2021-06-23 11:26:12 +02:00
),
),
);
}
}