mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: add nav/search debounce option
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user