2020-11-25 19:39:54 +00:00
|
|
|
|
import 'package:flutter/material.dart';
|
2021-10-26 16:50:34 +00:00
|
|
|
|
|
2020-11-25 19:39:54 +00:00
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
|
2024-02-11 16:04:46 +00:00
|
|
|
|
import 'package:fluffychat/config/setting_keys.dart';
|
2023-08-11 11:55:38 +00:00
|
|
|
|
import 'package:fluffychat/config/themes.dart';
|
2024-01-25 15:52:36 +00:00
|
|
|
|
import 'package:fluffychat/utils/account_config.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/avatar.dart';
|
2021-10-26 16:50:34 +00:00
|
|
|
|
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
2024-01-25 15:52:36 +00:00
|
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
|
|
|
|
import 'package:fluffychat/widgets/mxc_image.dart';
|
2021-04-15 11:03:14 +00:00
|
|
|
|
import '../../config/app_config.dart';
|
2024-02-11 16:04:46 +00:00
|
|
|
|
import '../../widgets/settings_switch_list_tile.dart';
|
2021-11-09 20:32:16 +00:00
|
|
|
|
import 'settings_style.dart';
|
2020-11-25 19:39:54 +00:00
|
|
|
|
|
2021-05-22 07:13:47 +00:00
|
|
|
|
class SettingsStyleView extends StatelessWidget {
|
2021-04-18 07:18:23 +00:00
|
|
|
|
final SettingsStyleController controller;
|
2020-11-25 19:39:54 +00:00
|
|
|
|
|
2023-10-28 11:03:16 +00:00
|
|
|
|
const SettingsStyleView(this.controller, {super.key});
|
2021-01-15 18:41:55 +00:00
|
|
|
|
|
2020-11-25 19:39:54 +00:00
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2021-11-13 16:57:55 +00:00
|
|
|
|
const colorPickerSize = 32.0;
|
2024-01-25 15:52:36 +00:00
|
|
|
|
final client = Matrix.of(context).client;
|
2020-11-25 19:39:54 +00:00
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
2023-08-13 16:23:36 +00:00
|
|
|
|
leading: const Center(child: BackButton()),
|
2022-01-01 12:43:51 +00:00
|
|
|
|
title: Text(L10n.of(context)!.changeTheme),
|
2020-11-25 19:39:54 +00:00
|
|
|
|
),
|
2022-05-18 06:54:50 +00:00
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
2021-04-09 16:26:44 +00:00
|
|
|
|
body: MaxWidthBody(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
2023-08-11 11:55:38 +00:00
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(
|
|
|
|
|
L10n.of(context)!.setColorTheme,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2022-05-18 06:54:50 +00:00
|
|
|
|
SizedBox(
|
|
|
|
|
height: colorPickerSize + 24,
|
|
|
|
|
child: ListView(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
children: SettingsStyleController.customColors
|
|
|
|
|
.map(
|
|
|
|
|
(color) => Padding(
|
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
|
child: InkWell(
|
2021-11-13 16:57:55 +00:00
|
|
|
|
borderRadius: BorderRadius.circular(colorPickerSize),
|
2022-05-18 06:54:50 +00:00
|
|
|
|
onTap: () => controller.setChatColor(color),
|
|
|
|
|
child: color == null
|
|
|
|
|
? Material(
|
2023-08-11 11:55:38 +00:00
|
|
|
|
elevation: 6,
|
2022-05-18 06:54:50 +00:00
|
|
|
|
shadowColor: AppConfig.colorSchemeSeed,
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.circular(colorPickerSize),
|
2023-08-11 11:55:38 +00:00
|
|
|
|
child: DecoratedBox(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
colorPickerSize,
|
|
|
|
|
),
|
|
|
|
|
gradient: FluffyThemes.backgroundGradient(
|
|
|
|
|
context,
|
|
|
|
|
255,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
height: colorPickerSize,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 8.0,
|
|
|
|
|
),
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
if (controller.currentColor ==
|
|
|
|
|
null)
|
|
|
|
|
Padding(
|
|
|
|
|
padding:
|
|
|
|
|
const EdgeInsets.only(
|
|
|
|
|
right: 8.0,
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.check,
|
|
|
|
|
size: 16,
|
|
|
|
|
color: Theme.of(context)
|
|
|
|
|
.colorScheme
|
2024-05-16 07:05:04 +00:00
|
|
|
|
.onSurface,
|
2023-08-11 11:55:38 +00:00
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
L10n.of(context)!.systemTheme,
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Theme.of(context)
|
|
|
|
|
.colorScheme
|
2024-05-16 07:05:04 +00:00
|
|
|
|
.onSurface,
|
2023-08-11 11:55:38 +00:00
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2022-05-18 06:54:50 +00:00
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: Material(
|
|
|
|
|
color: color,
|
|
|
|
|
elevation: 6,
|
|
|
|
|
borderRadius:
|
|
|
|
|
BorderRadius.circular(colorPickerSize),
|
|
|
|
|
child: SizedBox(
|
2023-03-02 09:57:52 +00:00
|
|
|
|
width: colorPickerSize,
|
|
|
|
|
height: colorPickerSize,
|
|
|
|
|
child: controller.currentColor == color
|
|
|
|
|
? const Center(
|
|
|
|
|
child: Icon(
|
2022-05-18 06:54:50 +00:00
|
|
|
|
Icons.check,
|
|
|
|
|
size: 16,
|
|
|
|
|
color: Colors.white,
|
2023-03-02 09:57:52 +00:00
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
),
|
2022-05-18 06:54:50 +00:00
|
|
|
|
),
|
2021-11-13 16:57:55 +00:00
|
|
|
|
),
|
|
|
|
|
),
|
2022-05-18 06:54:50 +00:00
|
|
|
|
)
|
|
|
|
|
.toList(),
|
|
|
|
|
),
|
2021-11-13 16:57:55 +00:00
|
|
|
|
),
|
2023-08-11 11:55:38 +00:00
|
|
|
|
const SizedBox(height: 8),
|
2024-04-14 09:48:51 +00:00
|
|
|
|
Divider(
|
|
|
|
|
height: 1,
|
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
|
),
|
2023-08-11 11:55:38 +00:00
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(
|
|
|
|
|
L10n.of(context)!.setTheme,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2022-12-24 10:48:48 +00:00
|
|
|
|
RadioListTile<ThemeMode>(
|
2021-04-18 07:18:23 +00:00
|
|
|
|
groupValue: controller.currentTheme,
|
2022-12-24 10:48:48 +00:00
|
|
|
|
value: ThemeMode.system,
|
2022-01-01 12:43:51 +00:00
|
|
|
|
title: Text(L10n.of(context)!.systemTheme),
|
2021-04-18 07:18:23 +00:00
|
|
|
|
onChanged: controller.switchTheme,
|
2020-11-25 19:39:54 +00:00
|
|
|
|
),
|
2022-12-24 10:48:48 +00:00
|
|
|
|
RadioListTile<ThemeMode>(
|
2021-04-18 07:18:23 +00:00
|
|
|
|
groupValue: controller.currentTheme,
|
2022-12-24 10:48:48 +00:00
|
|
|
|
value: ThemeMode.light,
|
2022-01-01 12:43:51 +00:00
|
|
|
|
title: Text(L10n.of(context)!.lightTheme),
|
2021-04-18 07:18:23 +00:00
|
|
|
|
onChanged: controller.switchTheme,
|
2020-11-25 19:39:54 +00:00
|
|
|
|
),
|
2022-12-24 10:48:48 +00:00
|
|
|
|
RadioListTile<ThemeMode>(
|
2021-04-18 07:18:23 +00:00
|
|
|
|
groupValue: controller.currentTheme,
|
2022-12-24 10:48:48 +00:00
|
|
|
|
value: ThemeMode.dark,
|
2022-01-01 12:43:51 +00:00
|
|
|
|
title: Text(L10n.of(context)!.darkTheme),
|
2021-04-18 07:18:23 +00:00
|
|
|
|
onChanged: controller.switchTheme,
|
2021-04-09 16:26:44 +00:00
|
|
|
|
),
|
2024-04-14 09:48:51 +00:00
|
|
|
|
Divider(
|
|
|
|
|
height: 1,
|
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
|
),
|
2024-02-11 16:04:46 +00:00
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(
|
2024-04-14 09:48:51 +00:00
|
|
|
|
L10n.of(context)!.overview,
|
2024-02-11 16:04:46 +00:00
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SettingsSwitchListTile.adaptive(
|
|
|
|
|
title: L10n.of(context)!.presencesToggle,
|
|
|
|
|
onChanged: (b) => AppConfig.showPresences = b,
|
|
|
|
|
storeKey: SettingKeys.showPresences,
|
|
|
|
|
defaultValue: AppConfig.showPresences,
|
|
|
|
|
),
|
2024-04-14 09:48:51 +00:00
|
|
|
|
SettingsSwitchListTile.adaptive(
|
|
|
|
|
title: L10n.of(context)!.separateChatTypes,
|
|
|
|
|
onChanged: (b) => AppConfig.separateChatTypes = b,
|
|
|
|
|
storeKey: SettingKeys.separateChatTypes,
|
|
|
|
|
defaultValue: AppConfig.separateChatTypes,
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
height: 1,
|
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
|
),
|
2021-04-09 16:26:44 +00:00
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(
|
2023-08-11 11:55:38 +00:00
|
|
|
|
L10n.of(context)!.messagesStyle,
|
2021-02-07 07:59:58 +00:00
|
|
|
|
style: TextStyle(
|
2021-05-24 08:59:00 +00:00
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
2021-04-09 16:26:44 +00:00
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2024-01-25 15:52:36 +00:00
|
|
|
|
StreamBuilder(
|
2024-05-29 09:20:32 +00:00
|
|
|
|
stream: client.onSync.stream.where(
|
|
|
|
|
(syncUpdate) =>
|
|
|
|
|
syncUpdate.accountData?.any(
|
|
|
|
|
(accountData) =>
|
|
|
|
|
accountData.type ==
|
|
|
|
|
ApplicationAccountConfigExtension.accountDataKey,
|
|
|
|
|
) ??
|
|
|
|
|
false,
|
2021-02-07 07:59:58 +00:00
|
|
|
|
),
|
2024-01-25 15:52:36 +00:00
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
final accountConfig = client.applicationAccountConfig;
|
|
|
|
|
final wallpaperOpacity = accountConfig.wallpaperOpacity ?? 1;
|
|
|
|
|
final wallpaperOpacityIsDefault = wallpaperOpacity == 1;
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
AnimatedContainer(
|
|
|
|
|
duration: FluffyThemes.animationDuration,
|
|
|
|
|
curve: FluffyThemes.animationCurve,
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
decoration: const BoxDecoration(),
|
|
|
|
|
clipBehavior: Clip.hardEdge,
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
|
|
|
|
if (accountConfig.wallpaperUrl != null)
|
|
|
|
|
Opacity(
|
|
|
|
|
opacity: wallpaperOpacity,
|
|
|
|
|
child: MxcImage(
|
|
|
|
|
uri: accountConfig.wallpaperUrl,
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
isThumbnail: true,
|
|
|
|
|
width: FluffyThemes.columnWidth * 2,
|
|
|
|
|
height: 156,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
left: 12 + 12 + Avatar.defaultSize,
|
|
|
|
|
right: 12,
|
|
|
|
|
top: accountConfig.wallpaperUrl == null ? 0 : 12,
|
|
|
|
|
bottom: 12,
|
|
|
|
|
),
|
|
|
|
|
child: Material(
|
2024-03-10 13:56:45 +00:00
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2024-01-25 15:52:36 +00:00
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
|
AppConfig.borderRadius,
|
|
|
|
|
),
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 16,
|
|
|
|
|
vertical: 8,
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor',
|
|
|
|
|
style: TextStyle(
|
2024-03-10 13:56:45 +00:00
|
|
|
|
color:
|
|
|
|
|
Theme.of(context).colorScheme.onPrimary,
|
2024-01-25 15:52:36 +00:00
|
|
|
|
fontSize: AppConfig.messageFontSize *
|
|
|
|
|
AppConfig.fontSizeFactor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.wallpaper),
|
|
|
|
|
leading: const Icon(Icons.photo_outlined),
|
|
|
|
|
trailing: accountConfig.wallpaperUrl == null
|
|
|
|
|
? null
|
|
|
|
|
: IconButton(
|
|
|
|
|
icon: const Icon(Icons.delete_outlined),
|
|
|
|
|
color: Theme.of(context).colorScheme.error,
|
|
|
|
|
onPressed: controller.deleteChatWallpaper,
|
|
|
|
|
),
|
|
|
|
|
onTap: controller.setWallpaper,
|
|
|
|
|
),
|
|
|
|
|
AnimatedSize(
|
|
|
|
|
duration: FluffyThemes.animationDuration,
|
|
|
|
|
curve: FluffyThemes.animationCurve,
|
|
|
|
|
child: accountConfig.wallpaperUrl != null
|
|
|
|
|
? SwitchListTile.adaptive(
|
|
|
|
|
title: Text(L10n.of(context)!.transparent),
|
|
|
|
|
secondary: const Icon(Icons.blur_linear_outlined),
|
|
|
|
|
value: !wallpaperOpacityIsDefault,
|
|
|
|
|
onChanged: (_) =>
|
|
|
|
|
controller.setChatWallpaperOpacity(
|
|
|
|
|
wallpaperOpacityIsDefault ? 0.4 : 1,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
2021-02-07 07:59:58 +00:00
|
|
|
|
),
|
2022-01-03 22:19:51 +00:00
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context)!.fontSize),
|
2022-01-11 06:31:45 +00:00
|
|
|
|
trailing: Text('× ${AppConfig.fontSizeFactor}'),
|
2022-01-03 22:19:51 +00:00
|
|
|
|
),
|
2021-12-23 12:34:04 +00:00
|
|
|
|
Slider.adaptive(
|
2021-04-09 16:26:44 +00:00
|
|
|
|
min: 0.5,
|
|
|
|
|
max: 2.5,
|
2021-12-12 18:37:42 +00:00
|
|
|
|
divisions: 20,
|
2021-04-09 16:26:44 +00:00
|
|
|
|
value: AppConfig.fontSizeFactor,
|
|
|
|
|
semanticFormatterCallback: (d) => d.toString(),
|
2021-04-18 07:18:23 +00:00
|
|
|
|
onChanged: controller.changeFontSizeFactor,
|
2021-04-09 16:26:44 +00:00
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2020-11-25 19:39:54 +00:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|