mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
* fix: resolve Linux window close handler to prevent app hang - Add delete-event callback that properly quits the application when window is closed * feat: Add desktop scaling and fix linux postinst - Implement desktop interface scaling in main.dart using FittedBox. - Add desktop scaling setting UI. - Add desktopScale to storage preference. - Fix typos and logic in Linux postinst script. - Update piliplus.desktop with StartupWMClass. * update Signed-off-by: dom <githubaccount56556@proton.me> --------- Signed-off-by: Shao Guohao <shao.gh.98@gmail.com> Co-authored-by: dom <githubaccount56556@proton.me>
64 lines
1.7 KiB
Dart
64 lines
1.7 KiB
Dart
import 'package:PiliPlus/common/widgets/flutter/list_tile.dart';
|
|
import 'package:flutter/material.dart' hide ListTile;
|
|
|
|
class NormalItem extends StatefulWidget {
|
|
final String? title;
|
|
final ValueGetter<String>? getTitle;
|
|
final String? subtitle;
|
|
final ValueGetter<String>? getSubtitle;
|
|
final Widget? leading;
|
|
final ValueGetter<Widget?>? getTrailing;
|
|
final void Function(BuildContext context, VoidCallback setState)? onTap;
|
|
final EdgeInsetsGeometry? contentPadding;
|
|
final TextStyle? titleStyle;
|
|
|
|
const NormalItem({
|
|
this.title,
|
|
this.getTitle,
|
|
this.subtitle,
|
|
this.getSubtitle,
|
|
this.leading,
|
|
this.getTrailing,
|
|
this.onTap,
|
|
this.contentPadding,
|
|
this.titleStyle,
|
|
super.key,
|
|
}) : assert(title != null || getTitle != null);
|
|
|
|
@override
|
|
State<NormalItem> createState() => _NormalItemState();
|
|
}
|
|
|
|
class _NormalItemState extends State<NormalItem> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
late final theme = Theme.of(context);
|
|
return ListTile(
|
|
contentPadding: widget.contentPadding,
|
|
onTap: widget.onTap == null
|
|
? null
|
|
: () => widget.onTap!(context, refresh),
|
|
title: Text(
|
|
widget.title ?? widget.getTitle!(),
|
|
style: widget.titleStyle ?? theme.textTheme.titleMedium!,
|
|
),
|
|
subtitle: widget.subtitle != null || widget.getSubtitle != null
|
|
? Text(
|
|
widget.subtitle ?? widget.getSubtitle!(),
|
|
style: theme.textTheme.labelMedium!.copyWith(
|
|
color: theme.colorScheme.outline,
|
|
),
|
|
)
|
|
: null,
|
|
leading: widget.leading,
|
|
trailing: widget.getTrailing?.call(),
|
|
);
|
|
}
|
|
|
|
void refresh() {
|
|
if (mounted) {
|
|
setState(() {});
|
|
}
|
|
}
|
|
}
|