mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: sort zone of video search
This commit is contained in:
@@ -75,6 +75,7 @@ class SearchHttp {
|
|||||||
required page,
|
required page,
|
||||||
String? order,
|
String? order,
|
||||||
int? duration,
|
int? duration,
|
||||||
|
int? tids,
|
||||||
}) async {
|
}) async {
|
||||||
var reqData = {
|
var reqData = {
|
||||||
'search_type': searchType.type,
|
'search_type': searchType.type,
|
||||||
@@ -84,6 +85,7 @@ class SearchHttp {
|
|||||||
'page': page,
|
'page': page,
|
||||||
if (order != null) 'order': order,
|
if (order != null) 'order': order,
|
||||||
if (duration != null) 'duration': duration,
|
if (duration != null) 'duration': duration,
|
||||||
|
if (tids != null) 'tids': tids,
|
||||||
};
|
};
|
||||||
var res = await Request().get(Api.searchByType, data: reqData);
|
var res = await Request().get(Api.searchByType, data: reqData);
|
||||||
if (res.data['code'] == 0 && res.data['data']['numPages'] > 0) {
|
if (res.data['code'] == 0 && res.data['data']['numPages'] > 0) {
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class SearchText extends StatelessWidget {
|
|||||||
final int? searchTextIdx;
|
final int? searchTextIdx;
|
||||||
final Function? onLongSelect;
|
final Function? onLongSelect;
|
||||||
final double? fontSize;
|
final double? fontSize;
|
||||||
|
final Color? bgColor;
|
||||||
|
final Color? textColor;
|
||||||
const SearchText({
|
const SearchText({
|
||||||
super.key,
|
super.key,
|
||||||
this.searchText,
|
this.searchText,
|
||||||
@@ -13,12 +15,15 @@ class SearchText extends StatelessWidget {
|
|||||||
this.searchTextIdx,
|
this.searchTextIdx,
|
||||||
this.onLongSelect,
|
this.onLongSelect,
|
||||||
this.fontSize,
|
this.fontSize,
|
||||||
|
this.bgColor,
|
||||||
|
this.textColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Material(
|
return Material(
|
||||||
color: Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
|
color: bgColor ??
|
||||||
|
Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@@ -36,8 +41,10 @@ class SearchText extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
searchText!,
|
searchText!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: fontSize,
|
fontSize: fontSize,
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant),
|
color:
|
||||||
|
textColor ?? Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class SearchPanelController extends CommonController {
|
|||||||
RxString order = ''.obs;
|
RxString order = ''.obs;
|
||||||
// 视频时长筛选 仅用于搜索视频
|
// 视频时长筛选 仅用于搜索视频
|
||||||
RxInt duration = 0.obs;
|
RxInt duration = 0.obs;
|
||||||
|
int? tids;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -69,5 +70,6 @@ class SearchPanelController extends CommonController {
|
|||||||
page: currentPage,
|
page: currentPage,
|
||||||
order: searchType!.type != 'video' ? null : order.value,
|
order: searchType!.type != 'video' ? null : order.value,
|
||||||
duration: searchType!.type != 'video' ? null : duration.value,
|
duration: searchType!.type != 'video' ? null : duration.value,
|
||||||
|
tids: tids,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPalaX/pages/search/widgets/search_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -157,14 +158,39 @@ class CustomFilterChip extends StatelessWidget {
|
|||||||
class VideoPanelController extends GetxController {
|
class VideoPanelController extends GetxController {
|
||||||
RxList<Map> filterList = [{}].obs;
|
RxList<Map> filterList = [{}].obs;
|
||||||
Rx<ArchiveFilterType> selectedType = ArchiveFilterType.values.first.obs;
|
Rx<ArchiveFilterType> selectedType = ArchiveFilterType.values.first.obs;
|
||||||
List<Map<String, dynamic>> timeFiltersList = [
|
List timeFiltersList = [
|
||||||
{'label': '全部时长', 'value': 0},
|
{'label': '全部时长', 'value': 0},
|
||||||
{'label': '0-10分钟', 'value': 1},
|
{'label': '0-10分钟', 'value': 1},
|
||||||
{'label': '10-30分钟', 'value': 2},
|
{'label': '10-30分钟', 'value': 2},
|
||||||
{'label': '30-60分钟', 'value': 3},
|
{'label': '30-60分钟', 'value': 3},
|
||||||
{'label': '60分钟+', 'value': 4},
|
{'label': '60分钟+', 'value': 4},
|
||||||
];
|
];
|
||||||
RxInt currentTimeFilterval = 0.obs;
|
List zoneFiltersList = [
|
||||||
|
{'label': '全部', 'value': 0},
|
||||||
|
{'label': '动画', 'value': 1, 'tids': 1},
|
||||||
|
{'label': '番剧', 'value': 2, 'tids': 13},
|
||||||
|
{'label': '国创', 'value': 3, 'tids': 167},
|
||||||
|
{'label': '音乐', 'value': 4, 'tids': 3},
|
||||||
|
{'label': '舞蹈', 'value': 5, 'tids': 129},
|
||||||
|
{'label': '游戏', 'value': 6, 'tids': 4},
|
||||||
|
{'label': '知识', 'value': 7, 'tids': 36},
|
||||||
|
{'label': '科技', 'value': 8, 'tids': 188},
|
||||||
|
{'label': '运动', 'value': 9, 'tids': 234},
|
||||||
|
{'label': '汽车', 'value': 10, 'tids': 223},
|
||||||
|
{'label': '生活', 'value': 11, 'tids': 160},
|
||||||
|
{'label': '美食', 'value': 12, 'tids': 221},
|
||||||
|
{'label': '动物', 'value': 13, 'tids': 217},
|
||||||
|
{'label': '鬼畜', 'value': 14, 'tids': 119},
|
||||||
|
{'label': '时尚', 'value': 15, 'tids': 155},
|
||||||
|
{'label': '资讯', 'value': 16, 'tids': 202},
|
||||||
|
{'label': '娱乐', 'value': 17, 'tids': 5},
|
||||||
|
{'label': '影视', 'value': 18, 'tids': 181},
|
||||||
|
{'label': '记录', 'value': 19, 'tids': 177},
|
||||||
|
{'label': '电影', 'value': 20, 'tids': 23},
|
||||||
|
{'label': '电视', 'value': 21, 'tids': 11},
|
||||||
|
];
|
||||||
|
int currentTimeFilterval = 0;
|
||||||
|
int currentZoneFilterval = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -179,45 +205,97 @@ class VideoPanelController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onShowFilterDialog(
|
onShowFilterDialog(
|
||||||
BuildContext context, SearchPanelController searchPanelCtr) {
|
BuildContext context,
|
||||||
showDialog(
|
SearchPanelController searchPanelCtr,
|
||||||
|
) {
|
||||||
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
isScrollControlled: true,
|
||||||
TextStyle textStyle = Theme.of(context).textTheme.titleMedium!;
|
builder: (_) => SingleChildScrollView(
|
||||||
return AlertDialog(
|
child: Container(
|
||||||
title: const Text('时长筛选'),
|
width: double.infinity,
|
||||||
contentPadding: const EdgeInsets.fromLTRB(0, 15, 0, 20),
|
padding: EdgeInsets.only(
|
||||||
content: StatefulBuilder(builder: (context, StateSetter setState) {
|
top: 20,
|
||||||
return Column(
|
left: 16,
|
||||||
mainAxisSize: MainAxisSize.min,
|
right: 16,
|
||||||
children: [
|
bottom: 80 + MediaQuery.of(context).padding.bottom,
|
||||||
for (var i in timeFiltersList) ...[
|
),
|
||||||
RadioListTile(
|
child: Column(
|
||||||
value: i['value'],
|
mainAxisSize: MainAxisSize.min,
|
||||||
autofocus: true,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
title: Text(i['label'], style: textStyle),
|
children: [
|
||||||
groupValue: currentTimeFilterval.value,
|
const SizedBox(height: 10),
|
||||||
onChanged: (value) async {
|
const Text('时长', style: TextStyle(fontSize: 16)),
|
||||||
Get.back();
|
const SizedBox(height: 10),
|
||||||
currentTimeFilterval.value = value!;
|
Wrap(
|
||||||
setState(() {});
|
spacing: 8,
|
||||||
SmartDialog.dismiss();
|
runSpacing: 8,
|
||||||
SmartDialog.showToast("「${i['label']}」的筛选结果");
|
children: timeFiltersList
|
||||||
SearchPanelController ctr =
|
.map(
|
||||||
Get.find<SearchPanelController>(
|
(item) => SearchText(
|
||||||
tag: 'video${searchPanelCtr.keyword!}');
|
searchText: item['label'],
|
||||||
ctr.duration.value = i['value'];
|
onSelect: (text) async {
|
||||||
SmartDialog.showLoading(msg: 'loading');
|
Get.back();
|
||||||
await ctr.onRefresh();
|
currentTimeFilterval = item['value'];
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
},
|
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||||
),
|
SearchPanelController ctr =
|
||||||
],
|
Get.find<SearchPanelController>(
|
||||||
],
|
tag: 'video${searchPanelCtr.keyword!}');
|
||||||
);
|
ctr.duration.value = item['value'];
|
||||||
}),
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
);
|
await ctr.onRefresh();
|
||||||
},
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
onLongSelect: (_) {},
|
||||||
|
bgColor: item['value'] == currentTimeFilterval
|
||||||
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
|
: null,
|
||||||
|
textColor: item['value'] == currentTimeFilterval
|
||||||
|
? Theme.of(context).colorScheme.onPrimaryContainer
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
const Text('分区', style: TextStyle(fontSize: 16)),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: zoneFiltersList
|
||||||
|
.map(
|
||||||
|
(item) => SearchText(
|
||||||
|
searchText: item['label'],
|
||||||
|
onSelect: (text) async {
|
||||||
|
Get.back();
|
||||||
|
currentZoneFilterval = item['value'];
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||||
|
SearchPanelController ctr =
|
||||||
|
Get.find<SearchPanelController>(
|
||||||
|
tag: 'video${searchPanelCtr.keyword!}');
|
||||||
|
ctr.tids = item['tids'];
|
||||||
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
|
await ctr.onRefresh();
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
onLongSelect: (_) {},
|
||||||
|
bgColor: item['value'] == currentZoneFilterval
|
||||||
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
|
: null,
|
||||||
|
textColor: item['value'] == currentZoneFilterval
|
||||||
|
? Theme.of(context).colorScheme.onPrimaryContainer
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user