chore: Resort settings and add more description text

This commit is contained in:
krille-chan 2024-01-20 14:45:44 +01:00
commit f7c89ddf9e
No known key found for this signature in database
4 changed files with 31 additions and 21 deletions

View file

@ -6,6 +6,7 @@ class SettingsSwitchListTile extends StatefulWidget {
final bool defaultValue;
final String storeKey;
final String title;
final String? subtitle;
final Function(bool)? onChanged;
const SettingsSwitchListTile.adaptive({
@ -13,6 +14,7 @@ class SettingsSwitchListTile extends StatefulWidget {
this.defaultValue = false,
required this.storeKey,
required this.title,
this.subtitle,
this.onChanged,
});
@ -23,10 +25,12 @@ class SettingsSwitchListTile extends StatefulWidget {
class SettingsSwitchListTileState extends State<SettingsSwitchListTile> {
@override
Widget build(BuildContext context) {
final subtitle = widget.subtitle;
return SwitchListTile.adaptive(
value: Matrix.of(context).store.getBool(widget.storeKey) ??
widget.defaultValue,
title: Text(widget.title),
subtitle: subtitle == null ? null : Text(subtitle),
onChanged: (bool newValue) async {
widget.onChanged?.call(newValue);
await Matrix.of(context).store.setBool(widget.storeKey, newValue);