opt: search settings

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-30 21:36:06 +08:00
parent b7b3460248
commit 9e50a195a4
2 changed files with 29 additions and 23 deletions

View File

@@ -1,6 +1,7 @@
import 'package:PiliPlus/common/widgets/http_error.dart'; import 'package:PiliPlus/common/widgets/http_error.dart';
import 'package:PiliPlus/pages/setting/widgets/model.dart'; import 'package:PiliPlus/pages/setting/widgets/model.dart';
import 'package:PiliPlus/utils/grid.dart'; import 'package:PiliPlus/utils/grid.dart';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:waterfall_flow/waterfall_flow.dart'; import 'package:waterfall_flow/waterfall_flow.dart';
@@ -15,6 +16,14 @@ class SettingsSearchPage extends StatefulWidget {
class _SettingsSearchPageState extends State<SettingsSearchPage> { class _SettingsSearchPageState extends State<SettingsSearchPage> {
final _textEditingController = TextEditingController(); final _textEditingController = TextEditingController();
final RxList<SettingsModel> _list = <SettingsModel>[].obs; final RxList<SettingsModel> _list = <SettingsModel>[].obs;
late final _settings = [
...extraSettings,
...privacySettings,
...recommendSettings,
...videoSettings,
...playSettings,
...styleSettings,
]..removeWhere((item) => item.settingsType == SettingsType.divider);
@override @override
void dispose() { void dispose() {
@@ -45,28 +54,21 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
controller: _textEditingController, controller: _textEditingController,
textAlignVertical: TextAlignVertical.center, textAlignVertical: TextAlignVertical.center,
onChanged: (value) { onChanged: (value) {
EasyThrottle.throttle(
'searchSettings', const Duration(milliseconds: 200), () {
if (value.isEmpty) { if (value.isEmpty) {
_list.value = <SettingsModel>[]; _list.clear();
} else { } else {
_list.value = [ value = value.toLowerCase();
...extraSettings, _list.value = _settings
...privacySettings,
...recommendSettings,
...videoSettings,
...playSettings,
...styleSettings,
]
.where((item) => .where((item) =>
item.settingsType != SettingsType.divider &&
(item.title ?? item.getTitle?.call()) (item.title ?? item.getTitle?.call())
?.toLowerCase() ?.toLowerCase()
.contains(value.toLowerCase()) || .contains(value) ||
item.subtitle item.subtitle?.toLowerCase().contains(value) == true)
?.toLowerCase()
.contains(value.toLowerCase()) ==
true)
.toList(); .toList();
} }
});
}, },
decoration: InputDecoration( decoration: InputDecoration(
isDense: true, isDense: true,

View File

@@ -280,7 +280,11 @@ class _SettingPageState extends State<SettingPage> {
} }
Widget _buildSearchItem(ThemeData theme) => Padding( Widget _buildSearchItem(ThemeData theme) => Padding(
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 5), padding: EdgeInsets.only(
left: 16 + MediaQuery.paddingOf(context).left,
right: 16,
bottom: 8,
),
child: InkWell( child: InkWell(
onTap: () => Get.toNamed('/settingsSearch'), onTap: () => Get.toNamed('/settingsSearch'),
borderRadius: BorderRadius.circular(50), borderRadius: BorderRadius.circular(50),