FurryChat/lib/components/settings_themes.dart

86 lines
2.4 KiB
Dart
Raw Normal View History

2020-02-23 07:49:58 +00:00
import 'package:flutter/material.dart';
import '../components/theme_switcher.dart';
import '../components/matrix.dart';
2020-05-07 05:52:40 +00:00
import '../l10n/l10n.dart';
2020-02-23 07:49:58 +00:00
class ThemesSettings extends StatefulWidget {
@override
ThemesSettingsState createState() => ThemesSettingsState();
}
class ThemesSettingsState extends State<ThemesSettings> {
Themes _selectedTheme;
bool _amoledEnabled;
@override
Widget build(BuildContext context) {
2020-05-13 13:58:59 +00:00
final matrix = Matrix.of(context);
final themeEngine = ThemeSwitcherWidget.of(context);
2020-02-23 07:49:58 +00:00
_selectedTheme = themeEngine.selectedTheme;
_amoledEnabled = themeEngine.amoledEnabled;
return Column(
children: <Widget>[
RadioListTile<Themes>(
title: Text(
2020-05-07 05:52:40 +00:00
L10n.of(context).systemTheme,
2020-02-23 07:49:58 +00:00
),
value: Themes.system,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
RadioListTile<Themes>(
title: Text(
2020-05-07 05:52:40 +00:00
L10n.of(context).lightTheme,
2020-02-23 07:49:58 +00:00
),
value: Themes.light,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
RadioListTile<Themes>(
title: Text(
2020-05-07 05:52:40 +00:00
L10n.of(context).darkTheme,
2020-02-23 07:49:58 +00:00
),
value: Themes.dark,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
ListTile(
title: Text(
2020-05-07 05:52:40 +00:00
L10n.of(context).useAmoledTheme,
2020-02-23 07:49:58 +00:00
),
trailing: Switch(
value: _amoledEnabled,
activeColor: Theme.of(context).primaryColor,
onChanged: (bool value) {
setState(() {
_amoledEnabled = value;
themeEngine.switchTheme(matrix, _selectedTheme, value);
});
},
),
),
],
);
}
}