fluffychat/lib/pages/settings_style/settings_style_view.dart

246 lines
10 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2021-10-26 16:50:34 +00:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
2023-08-11 11:55:38 +00:00
import 'package:fluffychat/config/themes.dart';
2021-10-26 16:50:34 +00:00
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
import '../../config/app_config.dart';
2021-05-22 06:53:52 +00:00
import '../../widgets/matrix.dart';
2021-11-09 20:32:16 +00:00
import 'settings_style.dart';
2021-05-22 07:13:47 +00:00
class SettingsStyleView extends StatelessWidget {
2021-04-18 07:18:23 +00:00
final SettingsStyleController controller;
const SettingsStyleView(this.controller, {Key? key}) : super(key: key);
2021-01-15 18:41:55 +00:00
@override
Widget build(BuildContext context) {
const colorPickerSize = 32.0;
2022-01-29 11:35:03 +00:00
final wallpaper = Matrix.of(context).wallpaper;
return Scaffold(
appBar: AppBar(
leading: const Center(child: BackButton()),
title: Text(L10n.of(context)!.changeTheme),
),
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(
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
.onBackground,
),
),
Text(
L10n.of(context)!.systemTheme,
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onBackground,
),
),
],
),
),
),
),
2022-05-18 06:54:50 +00:00
),
)
: Material(
color: color,
elevation: 6,
borderRadius:
BorderRadius.circular(colorPickerSize),
child: SizedBox(
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,
),
)
: null,
),
2022-05-18 06:54:50 +00:00
),
),
),
2022-05-18 06:54:50 +00:00
)
.toList(),
),
),
2023-08-11 11:55:38 +00:00
const SizedBox(height: 8),
const Divider(height: 1),
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,
title: Text(L10n.of(context)!.systemTheme),
2021-04-18 07:18:23 +00:00
onChanged: controller.switchTheme,
),
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,
title: Text(L10n.of(context)!.lightTheme),
2021-04-18 07:18:23 +00:00
onChanged: controller.switchTheme,
),
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,
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
),
2021-10-14 16:09:30 +00:00
const Divider(height: 1),
2021-04-09 16:26:44 +00:00
ListTile(
title: Text(
L10n.of(context)!.wallpaper,
2021-04-09 16:26:44 +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,
),
2021-02-07 07:59:58 +00:00
),
),
2022-01-29 11:35:03 +00:00
if (wallpaper != null)
2021-04-09 16:26:44 +00:00
ListTile(
title: Image.file(
2022-01-29 11:35:03 +00:00
wallpaper,
2021-04-09 16:26:44 +00:00
height: 38,
fit: BoxFit.cover,
),
2021-10-14 16:09:30 +00:00
trailing: const Icon(
2021-11-14 12:24:01 +00:00
Icons.delete_outlined,
2021-04-09 16:26:44 +00:00
color: Colors.red,
),
2021-04-18 07:18:23 +00:00
onTap: controller.deleteWallpaperAction,
2021-02-07 07:59:58 +00:00
),
Builder(
builder: (context) {
return ListTile(
title: Text(L10n.of(context)!.changeWallpaper),
trailing: Icon(
Icons.photo_outlined,
color: Theme.of(context).textTheme.bodyLarge?.color,
),
onTap: controller.setWallpaperAction,
);
},
),
2021-10-14 16:09:30 +00:00
const Divider(height: 1),
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,
),
),
),
Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: 12),
2021-11-13 12:06:36 +00:00
child: Material(
2023-07-22 09:11:35 +00:00
color: Theme.of(context).colorScheme.primaryContainer,
2023-07-22 09:50:00 +00:00
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
2021-11-13 12:06:36 +00:00
child: Padding(
2023-08-11 11:33:16 +00:00
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
2023-07-22 09:11:35 +00:00
),
2021-11-13 12:06:36 +00:00
child: Text(
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor',
style: TextStyle(
2023-07-22 09:11:35 +00:00
color: Theme.of(context).colorScheme.onPrimaryContainer,
2021-11-13 12:06:36 +00:00
fontSize:
AppConfig.messageFontSize * AppConfig.fontSizeFactor,
),
2021-04-09 16:26:44 +00:00
),
2021-02-07 07:59:58 +00:00
),
),
),
ListTile(
title: Text(L10n.of(context)!.fontSize),
trailing: Text('× ${AppConfig.fontSizeFactor}'),
),
Slider.adaptive(
2021-04-09 16:26:44 +00:00
min: 0.5,
max: 2.5,
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
),
],
),
),
);
}
}