Files
tatuchat/lib/pages/settings_chat/settings_chat_view.dart
Welton Moura 0037b0b9cf
Some checks failed
Main Deploy Workflow / deploy_web (push) Has been cancelled
Main Deploy Workflow / deploy_playstore_internal (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
Initial commit
2026-09-11 15:59:56 -03:00

173 lines
7.3 KiB
Dart

// SPDX-FileCopyrightText: 2019-Present Christian Kußowski
// SPDX-FileCopyrightText: 2019-Present Contributors to FluffyChat
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:emoji_picker_flutter/emoji_picker_flutter.dart';
import 'package:tatchat/config/setting_keys.dart';
import 'package:tatchat/config/themes.dart';
import 'package:tatchat/l10n/l10n.dart';
import 'package:tatchat/utils/adaptive_bottom_sheet.dart';
import 'package:tatchat/utils/platform_infos.dart';
import 'package:tatchat/widgets/layouts/max_width_body.dart';
import 'package:tatchat/widgets/settings_switch_list_tile.dart';
import 'package:go_router/go_router.dart';
import 'package:material_ui/material_ui.dart';
import 'settings_chat.dart';
class SettingsChatView extends StatelessWidget {
final SettingsChatController controller;
const SettingsChatView(this.controller, {super.key});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: Text(L10n.of(context).chat),
automaticallyImplyLeading: !FluffyThemes.isColumnMode(context),
centerTitle: FluffyThemes.isColumnMode(context),
),
body: ListTileTheme(
iconColor: theme.textTheme.bodyLarge!.color,
child: MaxWidthBody(
child: Column(
children: [
SettingsSwitchListTile.adaptive(
title: L10n.of(context).formattedMessages,
subtitle: L10n.of(context).formattedMessagesDescription,
setting: AppSettings.renderHtml,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context).hideRedactedMessages,
subtitle: L10n.of(context).hideRedactedMessagesBody,
setting: AppSettings.hideRedactedEvents,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context).hideRoomsInSpaces,
setting: AppSettings.hideRoomsInSpaces,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context).hideInvalidOrUnknownMessageFormats,
setting: AppSettings.hideUnknownEvents,
),
if (PlatformInfos.isMobile)
SettingsSwitchListTile.adaptive(
title: L10n.of(context).autoplayImages,
setting: AppSettings.autoplayImages,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context).sendOnEnter,
setting: AppSettings.sendOnEnter,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context).swipeRightToLeftToReply,
setting: AppSettings.swipeRightToLeftToReply,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context).showThumbnailsInTimeline,
setting: AppSettings.showThumbnailsInTimeline,
),
SettingsSwitchListTile.adaptive(
title: L10n.of(context).doubleTapToReact,
subtitle: L10n.of(context).doubleTapToReactDescription,
setting: AppSettings.doubleTapToReact,
onChanged: (_) => controller.updateState(),
),
if (AppSettings.doubleTapToReact.value)
ListTile(
title: Text(L10n.of(context).doubleTapReaction),
trailing: Text(
AppSettings.doubleTapReaction.value,
style: const TextStyle(fontSize: 24),
),
onTap: () async {
final emoji = await showAdaptiveBottomSheet<String>(
context: context,
builder: (context) => Scaffold(
appBar: AppBar(
title: Text(L10n.of(context).doubleTapReaction),
leading: CloseButton(
onPressed: () => Navigator.of(context).pop(null),
),
),
body: SizedBox(
height: double.infinity,
child: EmojiPicker(
onEmojiSelected: (_, emoji) =>
Navigator.of(context).pop(emoji.emoji),
config: Config(
locale: Localizations.localeOf(context),
emojiViewConfig: const EmojiViewConfig(
backgroundColor: Colors.transparent,
),
bottomActionBarConfig:
const BottomActionBarConfig(enabled: false),
categoryViewConfig: CategoryViewConfig(
initCategory: Category.SMILEYS,
backspaceColor: theme.colorScheme.primary,
iconColor: theme.colorScheme.primary.withAlpha(
128,
),
iconColorSelected: theme.colorScheme.primary,
indicatorColor: theme.colorScheme.primary,
backgroundColor: theme.colorScheme.surface,
),
skinToneConfig: SkinToneConfig(
dialogBackgroundColor: Color.lerp(
theme.colorScheme.surface,
theme.colorScheme.primaryContainer,
0.75,
)!,
indicatorColor: theme.colorScheme.onSurface,
),
),
),
),
),
);
if (emoji != null) {
await AppSettings.doubleTapReaction.setItem(emoji);
controller.updateState();
}
},
),
Divider(color: theme.dividerColor),
ListTile(
title: Text(
L10n.of(context).customEmojisAndStickers,
style: TextStyle(
color: theme.colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
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),
child: Icon(Icons.chevron_right_outlined),
),
),
Divider(color: theme.dividerColor),
ListTile(
title: Text(
L10n.of(context).calls,
style: TextStyle(
color: theme.colorScheme.secondary,
fontWeight: FontWeight.bold,
),
),
),
],
),
),
),
);
}
}