Merge branch 'feature-search'
This commit is contained in:
@ -189,7 +189,7 @@ class Api {
|
|||||||
'https://s.search.bilibili.com/main/suggest';
|
'https://s.search.bilibili.com/main/suggest';
|
||||||
|
|
||||||
// 分类搜索
|
// 分类搜索
|
||||||
static const String searchByType = '/x/web-interface/search/type';
|
static const String searchByType = '/x/web-interface/wbi/search/type';
|
||||||
|
|
||||||
// 记录视频播放进度
|
// 记录视频播放进度
|
||||||
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/report.md
|
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/report.md
|
||||||
|
|||||||
@ -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 != -1) '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) {
|
||||||
|
|||||||
@ -5,21 +5,25 @@ class SearchText extends StatelessWidget {
|
|||||||
final Function? onSelect;
|
final Function? onSelect;
|
||||||
final int? searchTextIdx;
|
final int? searchTextIdx;
|
||||||
final Function? onLongSelect;
|
final Function? onLongSelect;
|
||||||
|
final bool isSelect;
|
||||||
const SearchText({
|
const SearchText({
|
||||||
super.key,
|
super.key,
|
||||||
this.searchText,
|
this.searchText,
|
||||||
this.onSelect,
|
this.onSelect,
|
||||||
this.searchTextIdx,
|
this.searchTextIdx,
|
||||||
this.onLongSelect,
|
this.onLongSelect,
|
||||||
|
this.isSelect = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Material(
|
return Material(
|
||||||
color: Theme.of(context)
|
color: isSelect
|
||||||
.colorScheme
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
.surfaceContainerHighest
|
: Theme.of(context)
|
||||||
.withOpacity(0.5),
|
.colorScheme
|
||||||
|
.surfaceContainerHighest
|
||||||
|
.withOpacity(0.5),
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
@ -37,7 +41,10 @@ class SearchText extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
searchText!,
|
searchText!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant),
|
color: isSelect
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -16,14 +16,18 @@ class SearchPanelController extends GetxController {
|
|||||||
RxString order = ''.obs;
|
RxString order = ''.obs;
|
||||||
// 视频时长筛选 仅用于搜索视频
|
// 视频时长筛选 仅用于搜索视频
|
||||||
RxInt duration = 0.obs;
|
RxInt duration = 0.obs;
|
||||||
|
// 视频分区筛选 仅用于搜索视频 -1时不传
|
||||||
|
RxInt tids = (-1).obs;
|
||||||
|
|
||||||
Future onSearch({type = 'init'}) async {
|
Future onSearch({type = 'init'}) async {
|
||||||
var result = await SearchHttp.searchByType(
|
var result = await SearchHttp.searchByType(
|
||||||
searchType: searchType!,
|
searchType: searchType!,
|
||||||
keyword: keyword!,
|
keyword: keyword!,
|
||||||
page: page.value,
|
page: page.value,
|
||||||
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: searchType!.type != 'video' ? null : tids.value,
|
||||||
|
);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
if (type == 'onRefresh') {
|
if (type == 'onRefresh') {
|
||||||
resultList.value = result['data'].list;
|
resultList.value = result['data'].list;
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pilipala/common/widgets/video_card_h.dart';
|
import 'package:pilipala/common/widgets/video_card_h.dart';
|
||||||
import 'package:pilipala/models/common/search_type.dart';
|
import 'package:pilipala/models/common/search_type.dart';
|
||||||
|
import 'package:pilipala/pages/search/widgets/search_text.dart';
|
||||||
import 'package:pilipala/pages/search_panel/index.dart';
|
import 'package:pilipala/pages/search_panel/index.dart';
|
||||||
|
|
||||||
class SearchVideoPanel extends StatelessWidget {
|
class SearchVideoPanel extends StatelessWidget {
|
||||||
@ -94,7 +95,7 @@ class SearchVideoPanel extends StatelessWidget {
|
|||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
padding: MaterialStateProperty.all(EdgeInsets.zero),
|
||||||
),
|
),
|
||||||
onPressed: () => controller.onShowFilterDialog(ctr),
|
onPressed: () => controller.onShowFilterSheet(ctr),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.filter_list_outlined,
|
Icons.filter_list_outlined,
|
||||||
size: 18,
|
size: 18,
|
||||||
@ -165,7 +166,33 @@ class VideoPanelController extends GetxController {
|
|||||||
{'label': '30-60分钟', 'value': 3},
|
{'label': '30-60分钟', 'value': 3},
|
||||||
{'label': '60分钟+', 'value': 4},
|
{'label': '60分钟+', 'value': 4},
|
||||||
];
|
];
|
||||||
|
List<Map<String, dynamic>> partFiltersList = [
|
||||||
|
{'label': '全部', 'value': -1},
|
||||||
|
{'label': '动画', 'value': 1},
|
||||||
|
{'label': '番剧', 'value': 13},
|
||||||
|
{'label': '国创', 'value': 167},
|
||||||
|
{'label': '音乐', 'value': 3},
|
||||||
|
{'label': '舞蹈', 'value': 129},
|
||||||
|
{'label': '游戏', 'value': 4},
|
||||||
|
{'label': '知识', 'value': 36},
|
||||||
|
{'label': '科技', 'value': 188},
|
||||||
|
{'label': '运动', 'value': 234},
|
||||||
|
{'label': '汽车', 'value': 223},
|
||||||
|
{'label': '生活', 'value': 160},
|
||||||
|
{'label': '美食', 'value': 211},
|
||||||
|
{'label': '动物', 'value': 217},
|
||||||
|
{'label': '鬼畜', 'value': 119},
|
||||||
|
{'label': '时尚', 'value': 155},
|
||||||
|
{'label': '资讯', 'value': 202},
|
||||||
|
{'label': '娱乐', 'value': 5},
|
||||||
|
{'label': '影视', 'value': 181},
|
||||||
|
{'label': '记录', 'value': 177},
|
||||||
|
{'label': '电影', 'value': 23},
|
||||||
|
{'label': '电视', 'value': 11},
|
||||||
|
];
|
||||||
|
|
||||||
RxInt currentTimeFilterval = 0.obs;
|
RxInt currentTimeFilterval = 0.obs;
|
||||||
|
RxInt currentPartFilterval = (-1).obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -219,4 +246,100 @@ class VideoPanelController extends GetxController {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onShowFilterSheet(searchPanelCtr) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: Get.context!,
|
||||||
|
builder: (context) {
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder: (context, StateSetter setState) {
|
||||||
|
return Container(
|
||||||
|
color: Theme.of(Get.context!).colorScheme.surface,
|
||||||
|
padding: const EdgeInsets.only(top: 12),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const ListTile(
|
||||||
|
title: Text('内容时长'),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 14,
|
||||||
|
right: 14,
|
||||||
|
bottom: 14,
|
||||||
|
),
|
||||||
|
child: Wrap(
|
||||||
|
spacing: 10,
|
||||||
|
runSpacing: 10,
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
children: [
|
||||||
|
for (var i in timeFiltersList)
|
||||||
|
Obx(
|
||||||
|
() => SearchText(
|
||||||
|
searchText: i['label'],
|
||||||
|
searchTextIdx: i['value'],
|
||||||
|
isSelect:
|
||||||
|
currentTimeFilterval.value == i['value'],
|
||||||
|
onSelect: (value) async {
|
||||||
|
currentTimeFilterval.value = i['value'];
|
||||||
|
setState(() {});
|
||||||
|
SmartDialog.showToast("「${i['label']}」的筛选结果");
|
||||||
|
SearchPanelController ctr =
|
||||||
|
Get.find<SearchPanelController>(
|
||||||
|
tag: 'video${searchPanelCtr.keyword!}');
|
||||||
|
ctr.duration.value = i['value'];
|
||||||
|
Get.back();
|
||||||
|
SmartDialog.showLoading(msg: '获取中');
|
||||||
|
await ctr.onRefresh();
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
onLongSelect: (value) => {},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const ListTile(
|
||||||
|
title: Text('内容分区'),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 14, right: 14),
|
||||||
|
child: Wrap(
|
||||||
|
spacing: 10,
|
||||||
|
runSpacing: 10,
|
||||||
|
direction: Axis.horizontal,
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
children: [
|
||||||
|
for (var i in partFiltersList)
|
||||||
|
SearchText(
|
||||||
|
searchText: i['label'],
|
||||||
|
searchTextIdx: i['value'],
|
||||||
|
isSelect: currentPartFilterval.value == i['value'],
|
||||||
|
onSelect: (value) async {
|
||||||
|
currentPartFilterval.value = i['value'];
|
||||||
|
setState(() {});
|
||||||
|
SmartDialog.showToast("「${i['label']}」的筛选结果");
|
||||||
|
SearchPanelController ctr =
|
||||||
|
Get.find<SearchPanelController>(
|
||||||
|
tag: 'video${searchPanelCtr.keyword!}');
|
||||||
|
ctr.tids.value = i['value'];
|
||||||
|
Get.back();
|
||||||
|
SmartDialog.showLoading(msg: '获取中');
|
||||||
|
await ctr.onRefresh();
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
onLongSelect: (value) => {},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user