mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-17 14:50:12 +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 {
|
Widget get customAppBar {
|
||||||
return StreamBuilder(
|
return StreamBuilder(
|
||||||
stream: _homeController.hideSearchBar
|
stream: _homeController.hideSearchBar
|
||||||
? _homeController.searchBarStream.stream
|
? _mainController.navSearchStreamDebounce
|
||||||
.throttle(const Duration(milliseconds: 500))
|
? _homeController.searchBarStream.stream
|
||||||
|
.throttle(const Duration(milliseconds: 500))
|
||||||
|
: _homeController.searchBarStream.stream
|
||||||
: null,
|
: null,
|
||||||
initialData: true,
|
initialData: true,
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class MainController extends GetxController {
|
|||||||
late int lastCheckUnreadAt = 0;
|
late int lastCheckUnreadAt = 0;
|
||||||
|
|
||||||
late final mainTabBarView = GStorage.mainTabBarView;
|
late final mainTabBarView = GStorage.mainTabBarView;
|
||||||
|
late bool navSearchStreamDebounce = GStorage.navSearchStreamDebounce;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
|
|||||||
@@ -264,8 +264,10 @@ class _MainAppState extends State<MainApp>
|
|||||||
? null
|
? null
|
||||||
: StreamBuilder(
|
: StreamBuilder(
|
||||||
stream: _mainController.hideTabBar
|
stream: _mainController.hideTabBar
|
||||||
? _mainController.bottomBarStream.stream
|
? _mainController.navSearchStreamDebounce
|
||||||
.throttle(const Duration(milliseconds: 500))
|
? _mainController.bottomBarStream.stream
|
||||||
|
.throttle(const Duration(milliseconds: 500))
|
||||||
|
: _mainController.bottomBarStream.stream
|
||||||
: null,
|
: null,
|
||||||
initialData: true,
|
initialData: true,
|
||||||
builder: (context, AsyncSnapshot snapshot) {
|
builder: (context, AsyncSnapshot snapshot) {
|
||||||
|
|||||||
@@ -421,6 +421,19 @@ List<SettingsModel> get styleSettings => [
|
|||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
needReboot: 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(
|
SettingsModel(
|
||||||
settingsType: SettingsType.normal,
|
settingsType: SettingsType.normal,
|
||||||
onTap: (setState) {
|
onTap: (setState) {
|
||||||
|
|||||||
@@ -445,6 +445,9 @@ class GStorage {
|
|||||||
static bool get recordSearchHistory => GStorage.setting
|
static bool get recordSearchHistory => GStorage.setting
|
||||||
.get(SettingBoxKey.recordSearchHistory, defaultValue: true);
|
.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
|
static List<double> get dynamicDetailRatio => List<double>.from(setting
|
||||||
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
|
||||||
|
|
||||||
@@ -728,6 +731,7 @@ class SettingBoxKey {
|
|||||||
enableDragSubtitle = 'enableDragSubtitle',
|
enableDragSubtitle = 'enableDragSubtitle',
|
||||||
fastForBackwardDuration = 'fastForBackwardDuration',
|
fastForBackwardDuration = 'fastForBackwardDuration',
|
||||||
recordSearchHistory = 'recordSearchHistory',
|
recordSearchHistory = 'recordSearchHistory',
|
||||||
|
navSearchStreamDebounce = 'navSearchStreamDebounce',
|
||||||
|
|
||||||
// Sponsor Block
|
// Sponsor Block
|
||||||
enableSponsorBlock = 'enableSponsorBlock',
|
enableSponsorBlock = 'enableSponsorBlock',
|
||||||
|
|||||||
Reference in New Issue
Block a user