Add configurable scroll threshold (#910)

* Add configurable scroll threshold

* update

---------

Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
Tong xuewen
2025-07-29 23:02:05 +08:00
committed by GitHub
parent cf403aaf78
commit 3eb9c5b8ba
8 changed files with 191 additions and 103 deletions

View File

@@ -1,4 +1,5 @@
import 'dart:io';
import 'dart:math';
import 'package:PiliPlus/common/widgets/custom_toast.dart';
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
@@ -343,15 +344,61 @@ List<SettingsModel> get styleSettings => [
),
SettingsModel(
settingsType: SettingsType.sw1tch,
title: '降低收起/展开顶/底栏频率',
leading: const Icon(Icons.vertical_distribute),
setKey: SettingBoxKey.navSearchStreamDebounce,
defaultVal: false,
onChanged: (value) {
try {
Get.find<MainController>().navSearchStreamDebounce = value;
Get.forceAppUpdate();
} catch (_) {}
title: '顶/底栏滚动阈值',
subtitle: '滚动多少像素后收起/展开顶底栏默认50像素',
leading: const Icon(Icons.swipe_vertical),
defaultVal: true,
setKey: SettingBoxKey.enableScrollThreshold,
needReboot: true,
onTap: () {
String scrollThreshold = Pref.scrollThreshold.toString();
showDialog(
context: Get.context!,
builder: (context) {
return AlertDialog(
title: const Text('滚动阈值'),
content: TextFormField(
autofocus: true,
initialValue: scrollThreshold,
keyboardType: const TextInputType.numberWithOptions(
decimal: true,
),
onChanged: (value) {
scrollThreshold = value;
},
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'[\d\.]+')),
],
decoration: const InputDecoration(suffixText: 'px'),
),
actions: [
TextButton(
onPressed: Get.back,
child: Text(
'取消',
style: TextStyle(
color: Theme.of(context).colorScheme.outline,
),
),
),
TextButton(
onPressed: () {
Get.back();
GStorage.setting.put(
SettingBoxKey.scrollThreshold,
max(
10.0,
double.tryParse(scrollThreshold) ?? 50.0,
),
);
SmartDialog.showToast('重启生效');
},
child: const Text('确定'),
),
],
);
},
);
},
),
SettingsModel(