refa: settings model (#1773)

* opt: MediaQuery

* refa: settings model
This commit is contained in:
My-Responsitories
2025-12-10 16:41:31 +08:00
committed by GitHub
parent b12bdf2eb8
commit 890dc58dc3
13 changed files with 406 additions and 579 deletions

View File

@@ -8,10 +8,9 @@ class NormalItem extends StatefulWidget {
final StringGetter? getTitle;
final String? subtitle;
final StringGetter? getSubtitle;
final String? setKey;
final Widget? leading;
final Widget Function()? getTrailing;
final Function? onTap;
final void Function(BuildContext context, void Function() setState)? onTap;
final EdgeInsetsGeometry? contentPadding;
final TextStyle? titleStyle;
@@ -20,7 +19,6 @@ class NormalItem extends StatefulWidget {
this.getTitle,
this.subtitle,
this.getSubtitle,
this.setKey,
this.leading,
this.getTrailing,
this.onTap,
@@ -36,22 +34,21 @@ class NormalItem extends StatefulWidget {
class _NormalItemState extends State<NormalItem> {
@override
Widget build(BuildContext context) {
late final theme = Theme.of(context);
return ListTile(
contentPadding: widget.contentPadding,
onTap: () => widget.onTap?.call(() {
if (mounted) {
setState(() {});
}
}),
onTap: widget.onTap == null
? null
: () => widget.onTap!(context, refresh),
title: Text(
widget.title ?? widget.getTitle!(),
style: widget.titleStyle ?? Theme.of(context).textTheme.titleMedium!,
style: widget.titleStyle ?? theme.textTheme.titleMedium!,
),
subtitle: widget.subtitle != null || widget.getSubtitle != null
? Text(
widget.subtitle ?? widget.getSubtitle!(),
style: Theme.of(context).textTheme.labelMedium!.copyWith(
color: Theme.of(context).colorScheme.outline,
style: theme.textTheme.labelMedium!.copyWith(
color: theme.colorScheme.outline,
),
)
: null,
@@ -59,4 +56,10 @@ class _NormalItemState extends State<NormalItem> {
trailing: widget.getTrailing?.call(),
);
}
void refresh() {
if (mounted) {
setState(() {});
}
}
}