mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-23 04:00:28 +08:00
tweaks (#1826)
* opt: dataStatus * tweaks * opt: ui * update Signed-off-by: dom <githubaccount56556@proton.me> --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
32386bf146
commit
7ab2cf973f
@@ -33,7 +33,6 @@ sealed class SettingsModel {
|
||||
class PopupModel<T extends EnumWithLabel> extends SettingsModel {
|
||||
const PopupModel({
|
||||
required this.title,
|
||||
super.subtitle,
|
||||
super.leading,
|
||||
super.contentPadding,
|
||||
super.titleStyle,
|
||||
|
||||
@@ -42,6 +42,23 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
final ctr = Get.put(_ColorSelectController());
|
||||
FlexSchemeVariant _dynamicSchemeVariant = Pref.schemeVariant;
|
||||
|
||||
Future<void> _onChanged([bool? val]) async {
|
||||
val ??= !ctr.dynamicColor.value;
|
||||
if (val) {
|
||||
if (await MyApp.initPlatformState()) {
|
||||
Get.forceAppUpdate();
|
||||
} else {
|
||||
SmartDialog.showToast('该设备可能不支持动态取色');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Get.forceAppUpdate();
|
||||
}
|
||||
ctr
|
||||
..dynamicColor.value = val
|
||||
..setting.put(SettingBoxKey.dynamicColor, val);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
@@ -107,37 +124,21 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
),
|
||||
if (!Platform.isIOS)
|
||||
Obx(
|
||||
() {
|
||||
final dynamicColor = ctr.dynamicColor.value;
|
||||
return ListTile(
|
||||
title: const Text('动态取色'),
|
||||
leading: Checkbox(
|
||||
value: dynamicColor,
|
||||
onChanged: (value) {},
|
||||
() => ListTile(
|
||||
title: const Text('动态取色'),
|
||||
leading: ExcludeFocus(
|
||||
child: Checkbox(
|
||||
value: ctr.dynamicColor.value,
|
||||
onChanged: _onChanged,
|
||||
materialTapTargetSize: .shrinkWrap,
|
||||
visualDensity: const VisualDensity(
|
||||
horizontal: -4,
|
||||
vertical: -4,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
final val = !dynamicColor;
|
||||
if (val) {
|
||||
if (await MyApp.initPlatformState()) {
|
||||
Get.forceAppUpdate();
|
||||
} else {
|
||||
SmartDialog.showToast('该设备可能不支持动态取色');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Get.forceAppUpdate();
|
||||
}
|
||||
ctr
|
||||
..dynamicColor.value = val
|
||||
..setting.put(SettingBoxKey.dynamicColor, val);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
onTap: _onChanged,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: padding,
|
||||
@@ -147,9 +148,8 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
duration: const Duration(milliseconds: 200),
|
||||
child: Obx(
|
||||
() => ctr.dynamicColor.value
|
||||
? const SizedBox.shrink(key: ValueKey(false))
|
||||
? const SizedBox.shrink()
|
||||
: Padding(
|
||||
key: const ValueKey(true),
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
@@ -201,25 +201,29 @@ class _ColorSelectPageState extends State<ColorSelectPage> {
|
||||
),
|
||||
Padding(
|
||||
padding: padding,
|
||||
child: IgnorePointer(
|
||||
child: Container(
|
||||
height: size.height / 2,
|
||||
width: size.width,
|
||||
color: theme.colorScheme.surface,
|
||||
child: const HomePage(),
|
||||
child: ExcludeFocus(
|
||||
child: IgnorePointer(
|
||||
child: Container(
|
||||
height: size.height / 2,
|
||||
width: size.width,
|
||||
color: theme.colorScheme.surface,
|
||||
child: const HomePage(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
IgnorePointer(
|
||||
child: NavigationBar(
|
||||
destinations: NavigationBarType.values
|
||||
.map(
|
||||
(item) => NavigationDestination(
|
||||
icon: item.icon,
|
||||
label: item.label,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
ExcludeFocus(
|
||||
child: IgnorePointer(
|
||||
child: NavigationBar(
|
||||
destinations: NavigationBarType.values
|
||||
.map(
|
||||
(item) => NavigationDestination(
|
||||
icon: item.icon,
|
||||
label: item.label,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -42,7 +42,7 @@ class PopupListTile<T> extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PopupListTileState<T> extends State<PopupListTile<T>> {
|
||||
final _key = GlobalKey();
|
||||
final _key = PlatformUtils.isDesktop ? null : GlobalKey();
|
||||
|
||||
void _showButtonMenu(TapUpDetails details, T value) {
|
||||
final box = context.findRenderObject() as RenderBox;
|
||||
@@ -51,7 +51,7 @@ class _PopupListTileState<T> extends State<PopupListTile<T>> {
|
||||
if (PlatformUtils.isDesktop) {
|
||||
dx = details.globalPosition.dx + 1;
|
||||
} else {
|
||||
final box = _key.currentContext!.findRenderObject() as RenderBox;
|
||||
final box = _key!.currentContext!.findRenderObject() as RenderBox;
|
||||
final offset = box.localToGlobal(box.size.topLeft(.zero));
|
||||
dx = offset.dx;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class _PopupListTileState<T> extends State<PopupListTile<T>> {
|
||||
position: RelativeRect.fromLTRB(dx, offset.dy + 5, dx, 0),
|
||||
items: widget.itemBuilder(context),
|
||||
initialValue: value,
|
||||
requestFocus: false,
|
||||
requestFocus: true,
|
||||
).then<void>((T? newValue) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
@@ -82,7 +82,7 @@ class _PopupListTileState<T> extends State<PopupListTile<T>> {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final (value, descStr) = widget.value();
|
||||
Widget title = Builder(key: _key, builder: (_) => widget.title);
|
||||
Widget title = KeyedSubtree(key: _key, child: widget.title);
|
||||
Widget? subtitle;
|
||||
Widget? trailing;
|
||||
final desc = Text(
|
||||
|
||||
Reference in New Issue
Block a user