You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fluffychat/lib/components/settings_themes.dart

84 lines
2.4 KiB
Dart

5 years ago
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
5 years ago
import '../components/matrix.dart';
import '../components/theme_switcher.dart';
5 years ago
class ThemesSettings extends StatefulWidget {
@override
ThemesSettingsState createState() => ThemesSettingsState();
}
class ThemesSettingsState extends State<ThemesSettings> {
Themes _selectedTheme;
bool _amoledEnabled;
@override
Widget build(BuildContext context) {
5 years ago
final matrix = Matrix.of(context);
final themeEngine = ThemeSwitcherWidget.of(context);
5 years ago
_selectedTheme = themeEngine.selectedTheme;
_amoledEnabled = themeEngine.amoledEnabled;
return Column(
children: <Widget>[
RadioListTile<Themes>(
title: Text(
5 years ago
L10n.of(context).systemTheme,
5 years ago
),
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(
5 years ago
L10n.of(context).lightTheme,
5 years ago
),
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(
5 years ago
L10n.of(context).darkTheme,
5 years ago
),
value: Themes.dark,
groupValue: _selectedTheme,
activeColor: Theme.of(context).primaryColor,
onChanged: (Themes value) {
setState(() {
_selectedTheme = value;
themeEngine.switchTheme(matrix, value, _amoledEnabled);
});
},
),
SwitchListTile(
5 years ago
title: Text(
5 years ago
L10n.of(context).useAmoledTheme,
5 years ago
),
value: _amoledEnabled,
activeColor: Theme.of(context).primaryColor,
onChanged: (bool value) {
setState(() {
_amoledEnabled = value;
themeEngine.switchTheme(matrix, _selectedTheme, value);
});
},
5 years ago
),
],
);
}
}