mod: add nav/search debounce option

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-04 21:52:28 +08:00
parent f1433c6e9b
commit 1c0bae600f
5 changed files with 26 additions and 4 deletions

View File

@@ -154,8 +154,10 @@ class _HomePageState extends State<HomePage>
Widget get customAppBar {
return StreamBuilder(
stream: _homeController.hideSearchBar
? _homeController.searchBarStream.stream
.throttle(const Duration(milliseconds: 500))
? _mainController.navSearchStreamDebounce
? _homeController.searchBarStream.stream
.throttle(const Duration(milliseconds: 500))
: _homeController.searchBarStream.stream
: null,
initialData: true,
builder: (BuildContext context, AsyncSnapshot snapshot) {

View File

@@ -38,6 +38,7 @@ class MainController extends GetxController {
late int lastCheckUnreadAt = 0;
late final mainTabBarView = GStorage.mainTabBarView;
late bool navSearchStreamDebounce = GStorage.navSearchStreamDebounce;
@override
void onInit() {

View File

@@ -264,8 +264,10 @@ class _MainAppState extends State<MainApp>
? null
: StreamBuilder(
stream: _mainController.hideTabBar
? _mainController.bottomBarStream.stream
.throttle(const Duration(milliseconds: 500))
? _mainController.navSearchStreamDebounce
? _mainController.bottomBarStream.stream
.throttle(const Duration(milliseconds: 500))
: _mainController.bottomBarStream.stream
: null,
initialData: true,
builder: (context, AsyncSnapshot snapshot) {

View File

@@ -421,6 +421,19 @@ List<SettingsModel> get styleSettings => [
defaultVal: true,
needReboot: true,
),
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 (_) {}
},
),
SettingsModel(
settingsType: SettingsType.normal,
onTap: (setState) {

View File

@@ -445,6 +445,9 @@ class GStorage {
static bool get recordSearchHistory => GStorage.setting
.get(SettingBoxKey.recordSearchHistory, defaultValue: true);
static bool get navSearchStreamDebounce => GStorage.setting
.get(SettingBoxKey.navSearchStreamDebounce, defaultValue: false);
static List<double> get dynamicDetailRatio => List<double>.from(setting
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
@@ -728,6 +731,7 @@ class SettingBoxKey {
enableDragSubtitle = 'enableDragSubtitle',
fastForBackwardDuration = 'fastForBackwardDuration',
recordSearchHistory = 'recordSearchHistory',
navSearchStreamDebounce = 'navSearchStreamDebounce',
// Sponsor Block
enableSponsorBlock = 'enableSponsorBlock',