2020-11-25 20:39:54 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
|
|
|
import 'package:adaptive_theme/adaptive_theme.dart';
|
2020-11-25 20:39:54 +01:00
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
2021-10-26 18:50:34 +02:00
|
|
|
import 'package:fluffychat/widgets/layouts/max_width_body.dart';
|
2021-04-15 13:03:14 +02:00
|
|
|
import '../../config/app_config.dart';
|
2021-05-22 08:53:52 +02:00
|
|
|
import '../../widgets/matrix.dart';
|
2021-11-09 21:32:16 +01:00
|
|
|
import 'settings_style.dart';
|
2020-11-25 20:39:54 +01:00
|
|
|
|
2021-05-22 09:13:47 +02:00
|
|
|
class SettingsStyleView extends StatelessWidget {
|
2021-04-18 09:18:23 +02:00
|
|
|
final SettingsStyleController controller;
|
2020-11-25 20:39:54 +01:00
|
|
|
|
2021-05-22 09:13:47 +02:00
|
|
|
const SettingsStyleView(this.controller, {Key key}) : super(key: key);
|
2021-01-15 19:41:55 +01:00
|
|
|
|
2020-11-25 20:39:54 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-04-18 09:18:23 +02:00
|
|
|
controller.currentTheme ??= AdaptiveTheme.of(context).mode;
|
2021-11-13 17:57:55 +01:00
|
|
|
const colorPickerSize = 32.0;
|
2020-11-25 20:39:54 +01:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2021-10-14 18:09:30 +02:00
|
|
|
leading: const BackButton(),
|
2020-11-25 20:39:54 +01:00
|
|
|
title: Text(L10n.of(context).changeTheme),
|
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
body: MaxWidthBody(
|
|
|
|
withScrolling: true,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2021-11-13 17:57:55 +01:00
|
|
|
Row(
|
|
|
|
children: SettingsStyleController.customColors
|
|
|
|
.map(
|
|
|
|
(color) => Padding(
|
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: InkWell(
|
|
|
|
borderRadius: BorderRadius.circular(colorPickerSize),
|
|
|
|
onTap: () => controller.setChatColor(color),
|
|
|
|
child: Material(
|
|
|
|
color: color,
|
|
|
|
elevation: 6,
|
|
|
|
borderRadius: BorderRadius.circular(colorPickerSize),
|
|
|
|
child: SizedBox(
|
|
|
|
width: colorPickerSize,
|
|
|
|
height: colorPickerSize,
|
|
|
|
child: AppConfig.chatColor.value == color.value
|
|
|
|
? const Center(
|
|
|
|
child: Icon(
|
|
|
|
Icons.check,
|
|
|
|
size: 16,
|
|
|
|
color: Colors.white,
|
|
|
|
))
|
|
|
|
: null),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.toList(),
|
|
|
|
),
|
|
|
|
const Divider(height: 1),
|
2021-04-09 18:26:44 +02:00
|
|
|
RadioListTile<AdaptiveThemeMode>(
|
2021-04-18 09:18:23 +02:00
|
|
|
groupValue: controller.currentTheme,
|
2021-04-09 18:26:44 +02:00
|
|
|
value: AdaptiveThemeMode.system,
|
|
|
|
title: Text(L10n.of(context).systemTheme),
|
2021-04-18 09:18:23 +02:00
|
|
|
onChanged: controller.switchTheme,
|
2020-11-25 20:39:54 +01:00
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
RadioListTile<AdaptiveThemeMode>(
|
2021-04-18 09:18:23 +02:00
|
|
|
groupValue: controller.currentTheme,
|
2021-04-09 18:26:44 +02:00
|
|
|
value: AdaptiveThemeMode.light,
|
|
|
|
title: Text(L10n.of(context).lightTheme),
|
2021-04-18 09:18:23 +02:00
|
|
|
onChanged: controller.switchTheme,
|
2020-11-25 20:39:54 +01:00
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
RadioListTile<AdaptiveThemeMode>(
|
2021-04-18 09:18:23 +02:00
|
|
|
groupValue: controller.currentTheme,
|
2021-04-09 18:26:44 +02:00
|
|
|
value: AdaptiveThemeMode.dark,
|
|
|
|
title: Text(L10n.of(context).darkTheme),
|
2021-04-18 09:18:23 +02:00
|
|
|
onChanged: controller.switchTheme,
|
2021-04-09 18:26:44 +02:00
|
|
|
),
|
2021-10-14 18:09:30 +02:00
|
|
|
const Divider(height: 1),
|
2021-04-09 18:26:44 +02:00
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).wallpaper,
|
|
|
|
style: TextStyle(
|
2021-05-24 10:59:00 +02:00
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
2021-04-09 18:26:44 +02:00
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2021-02-07 08:59:58 +01:00
|
|
|
),
|
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
if (Matrix.of(context).wallpaper != null)
|
|
|
|
ListTile(
|
|
|
|
title: Image.file(
|
|
|
|
Matrix.of(context).wallpaper,
|
|
|
|
height: 38,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
),
|
2021-10-14 18:09:30 +02:00
|
|
|
trailing: const Icon(
|
2021-11-14 13:24:01 +01:00
|
|
|
Icons.delete_outlined,
|
2021-04-09 18:26:44 +02:00
|
|
|
color: Colors.red,
|
|
|
|
),
|
2021-04-18 09:18:23 +02:00
|
|
|
onTap: controller.deleteWallpaperAction,
|
2021-02-07 08:59:58 +01:00
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
Builder(builder: (context) {
|
|
|
|
return ListTile(
|
|
|
|
title: Text(L10n.of(context).changeWallpaper),
|
2021-11-14 13:24:01 +01:00
|
|
|
trailing: Icon(
|
|
|
|
Icons.photo_outlined,
|
|
|
|
color: Theme.of(context).textTheme.bodyText1.color,
|
|
|
|
),
|
2021-04-18 09:18:23 +02:00
|
|
|
onTap: controller.setWallpaperAction,
|
2021-04-09 18:26:44 +02:00
|
|
|
);
|
|
|
|
}),
|
2021-10-14 18:09:30 +02:00
|
|
|
const Divider(height: 1),
|
2021-04-09 18:26:44 +02:00
|
|
|
ListTile(
|
|
|
|
title: Text(
|
|
|
|
L10n.of(context).fontSize,
|
2021-02-07 08:59:58 +01:00
|
|
|
style: TextStyle(
|
2021-05-24 10:59:00 +02:00
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
2021-04-09 18:26:44 +02:00
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
subtitle: Text('(*${AppConfig.fontSizeFactor})'),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
alignment: Alignment.centerLeft,
|
2021-11-13 17:57:55 +01:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
2021-11-13 13:06:36 +01:00
|
|
|
child: Material(
|
2021-11-13 17:57:55 +01:00
|
|
|
color: Theme.of(context).primaryColor,
|
2021-11-13 13:06:36 +01:00
|
|
|
elevation: 6,
|
|
|
|
shadowColor:
|
|
|
|
Theme.of(context).secondaryHeaderColor.withAlpha(100),
|
|
|
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
child: Text(
|
|
|
|
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor',
|
|
|
|
style: TextStyle(
|
2021-11-13 17:57:55 +01:00
|
|
|
color: Colors.white,
|
2021-11-13 13:06:36 +01:00
|
|
|
fontSize:
|
|
|
|
AppConfig.messageFontSize * AppConfig.fontSizeFactor,
|
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
),
|
2021-02-07 08:59:58 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2021-04-09 18:26:44 +02:00
|
|
|
Slider(
|
|
|
|
min: 0.5,
|
|
|
|
max: 2.5,
|
2021-10-10 12:41:43 +02:00
|
|
|
divisions: 8,
|
2021-04-09 18:26:44 +02:00
|
|
|
value: AppConfig.fontSizeFactor,
|
|
|
|
semanticFormatterCallback: (d) => d.toString(),
|
2021-04-18 09:18:23 +02:00
|
|
|
onChanged: controller.changeFontSizeFactor,
|
2021-04-09 18:26:44 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-11-25 20:39:54 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|