chore: Resort settings and add more description text
This commit is contained in:
parent
a7a8285a55
commit
f7c89ddf9e
4 changed files with 31 additions and 21 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue