mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
opt: search settings
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -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) {
|
||||||
if (value.isEmpty) {
|
EasyThrottle.throttle(
|
||||||
_list.value = <SettingsModel>[];
|
'searchSettings', const Duration(milliseconds: 200), () {
|
||||||
} else {
|
if (value.isEmpty) {
|
||||||
_list.value = [
|
_list.clear();
|
||||||
...extraSettings,
|
} else {
|
||||||
...privacySettings,
|
value = value.toLowerCase();
|
||||||
...recommendSettings,
|
_list.value = _settings
|
||||||
...videoSettings,
|
.where((item) =>
|
||||||
...playSettings,
|
(item.title ?? item.getTitle?.call())
|
||||||
...styleSettings,
|
?.toLowerCase()
|
||||||
]
|
.contains(value) ||
|
||||||
.where((item) =>
|
item.subtitle?.toLowerCase().contains(value) == true)
|
||||||
item.settingsType != SettingsType.divider &&
|
.toList();
|
||||||
(item.title ?? item.getTitle?.call())
|
}
|
||||||
?.toLowerCase()
|
});
|
||||||
.contains(value.toLowerCase()) ||
|
|
||||||
item.subtitle
|
|
||||||
?.toLowerCase()
|
|
||||||
.contains(value.toLowerCase()) ==
|
|
||||||
true)
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: true,
|
isDense: true,
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
Reference in New Issue
Block a user