mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt sort search
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
27
lib/models/common/search/article_search_type.dart
Normal file
27
lib/models/common/search/article_search_type.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
enum ArticleOrderType {
|
||||
totalrank('综合排序'),
|
||||
pubdate('最新发布'),
|
||||
click('最多点击'),
|
||||
attention('最多喜欢'),
|
||||
scores('最多评论');
|
||||
|
||||
String get order => name;
|
||||
final String label;
|
||||
const ArticleOrderType(this.label);
|
||||
}
|
||||
|
||||
enum ArticleZoneType {
|
||||
all('全部分区', 0),
|
||||
douga('动画', 2),
|
||||
game('游戏', 1),
|
||||
cinephile('影视', 28),
|
||||
life('生活', 3),
|
||||
interest('兴趣', 29),
|
||||
novel('轻小说', 16),
|
||||
tech('科技', 17),
|
||||
note('笔记', 41);
|
||||
|
||||
final String label;
|
||||
final int categoryId;
|
||||
const ArticleZoneType(this.label, this.categoryId);
|
||||
}
|
||||
22
lib/models/common/search/user_search_type.dart
Normal file
22
lib/models/common/search/user_search_type.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
enum UserOrderType {
|
||||
def('默认排序', 0, ''),
|
||||
fansDesc('粉丝数由高到低', 0, 'fans'),
|
||||
fansAsc('粉丝数由低到高', 1, 'fans'),
|
||||
levelDesc('Lv等级由高到低', 0, 'level'),
|
||||
levelAsc('Lv等级由低到高', 1, 'level');
|
||||
|
||||
final String label;
|
||||
final int orderSort;
|
||||
final String order;
|
||||
const UserOrderType(this.label, this.orderSort, this.order);
|
||||
}
|
||||
|
||||
enum UserType {
|
||||
all('全部用户'),
|
||||
up('UP主'),
|
||||
common('普通用户'),
|
||||
verified('认证用户');
|
||||
|
||||
final String label;
|
||||
const UserType(this.label);
|
||||
}
|
||||
49
lib/models/common/search/video_search_type.dart
Normal file
49
lib/models/common/search/video_search_type.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
enum VideoPubTimeType {
|
||||
all('不限'),
|
||||
day('最近一天'),
|
||||
week('最近一周'),
|
||||
halfYear('最近半年');
|
||||
|
||||
final String label;
|
||||
const VideoPubTimeType(this.label);
|
||||
}
|
||||
|
||||
enum VideoDurationType {
|
||||
all('全部时长'),
|
||||
tenMins('0-10分钟'),
|
||||
halfHour('0-30分钟'),
|
||||
hour('30-60分钟'),
|
||||
hourPlus('60分钟+');
|
||||
|
||||
final String label;
|
||||
const VideoDurationType(this.label);
|
||||
}
|
||||
|
||||
enum VideoZoneType {
|
||||
all('全部'),
|
||||
douga('动画', tids: 1),
|
||||
anime('番剧', tids: 13),
|
||||
guochuang('国创', tids: 167),
|
||||
music('音乐', tids: 3),
|
||||
dance('舞蹈', tids: 129),
|
||||
game('游戏', tids: 4),
|
||||
knowledge('知识', tids: 36),
|
||||
tech('科技', tids: 188),
|
||||
sports('运动', tids: 234),
|
||||
car('汽车', tids: 223),
|
||||
life('生活', tids: 160),
|
||||
food('美食', tids: 221),
|
||||
animal('动物', tids: 217),
|
||||
kichiku('鬼畜', tids: 119),
|
||||
fashion('时尚', tids: 115),
|
||||
info('资讯', tids: 202),
|
||||
ent('娱乐', tids: 5),
|
||||
cinephile('影视', tids: 181),
|
||||
documentary('记录', tids: 177),
|
||||
movie('电影', tids: 23),
|
||||
tv('电视', tids: 11);
|
||||
|
||||
final String label;
|
||||
final int? tids;
|
||||
const VideoZoneType(this.label, {this.tids});
|
||||
}
|
||||
@@ -42,12 +42,12 @@ class SearchAllController
|
||||
Future<LoadingState<SearchAllData>> customGetData() => SearchHttp.searchAll(
|
||||
keyword: keyword,
|
||||
page: page,
|
||||
order: order.value,
|
||||
duration: searchType == SearchType.video ? duration.value : null,
|
||||
tids: tids,
|
||||
orderSort: orderSort,
|
||||
userType: userType,
|
||||
categoryId: categoryId,
|
||||
order: order,
|
||||
duration: null,
|
||||
tids: videoZoneType?.tids,
|
||||
orderSort: userOrderType?.value.orderSort,
|
||||
userType: userType?.value.index,
|
||||
categoryId: articleZoneType?.value.categoryId,
|
||||
pubBegin: pubBegin,
|
||||
pubEnd: pubEnd,
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/models/common/search/article_search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/pages/search_panel/controller.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
|
||||
class SearchArticleController
|
||||
@@ -19,6 +19,7 @@ class SearchArticleController
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
articleZoneType = ArticleZoneType.all.obs;
|
||||
jump2Article();
|
||||
}
|
||||
|
||||
@@ -40,27 +41,7 @@ class SearchArticleController
|
||||
}
|
||||
}
|
||||
|
||||
// sort
|
||||
late final List orderFiltersList = [
|
||||
{'label': '综合排序', 'value': 0, 'order': 'totalrank'},
|
||||
{'label': '最新发布', 'value': 1, 'order': 'pubdate'},
|
||||
{'label': '最多点击', 'value': 2, 'order': 'click'},
|
||||
{'label': '最多喜欢', 'value': 3, 'order': 'attention'},
|
||||
{'label': '最多评论', 'value': 4, 'order': 'scores'},
|
||||
];
|
||||
late final List zoneFiltersList = [
|
||||
{'label': '全部分区', 'value': 0, 'categoryId': 0},
|
||||
{'label': '动画', 'value': 1, 'categoryId': 2},
|
||||
{'label': '游戏', 'value': 2, 'categoryId': 1},
|
||||
{'label': '影视', 'value': 3, 'categoryId': 28},
|
||||
{'label': '生活', 'value': 4, 'categoryId': 3},
|
||||
{'label': '兴趣', 'value': 5, 'categoryId': 29},
|
||||
{'label': '轻小说', 'value': 6, 'categoryId': 16},
|
||||
{'label': '科技', 'value': 7, 'categoryId': 17},
|
||||
{'label': '笔记', 'value': 8, 'categoryId': 41},
|
||||
];
|
||||
RxInt currentOrderFilterval = 0.obs;
|
||||
RxInt currentZoneFilterval = 0.obs;
|
||||
Rx<ArticleOrderType> articleOrderType = ArticleOrderType.totalrank.obs;
|
||||
|
||||
void onShowFilterDialog(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
@@ -91,30 +72,25 @@ class SearchArticleController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: orderFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (_) async {
|
||||
Get.back();
|
||||
currentOrderFilterval.value = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
order.value = item['order'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
bgColor: item['value'] == currentOrderFilterval.value
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor:
|
||||
item['value'] == currentOrderFilterval.value
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
children: ArticleOrderType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == articleOrderType.value;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
articleOrderType.value = e;
|
||||
order = e.order;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text('分区', style: TextStyle(fontSize: 16)),
|
||||
@@ -122,29 +98,24 @@ class SearchArticleController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: zoneFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (_) async {
|
||||
Get.back();
|
||||
currentZoneFilterval.value = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
categoryId = item['categoryId'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
bgColor: item['value'] == currentZoneFilterval.value
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: item['value'] == currentZoneFilterval.value
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
children: ArticleZoneType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == articleZoneType!.value;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
articleZoneType!.value = e;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -51,7 +51,7 @@ class _SearchArticlePanelState
|
||||
children: [
|
||||
Obx(
|
||||
() => Text(
|
||||
'排序: ${controller.orderFiltersList[controller.currentOrderFilterval.value]['label']}',
|
||||
'排序: ${controller.articleOrderType.value.label}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
@@ -59,7 +59,7 @@ class _SearchArticlePanelState
|
||||
const Spacer(),
|
||||
Obx(
|
||||
() => Text(
|
||||
'分区: ${controller.zoneFiltersList[controller.currentZoneFilterval.value]['label']}',
|
||||
'分区: ${controller.articleZoneType!.value.label}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/search/article_search_type.dart';
|
||||
import 'package:PiliPlus/models/common/search/user_search_type.dart';
|
||||
import 'package:PiliPlus/models/common/search/video_search_type.dart';
|
||||
import 'package:PiliPlus/models/common/search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:PiliPlus/pages/search_result/controller.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class SearchPanelController<R extends SearchNumData<T>, T>
|
||||
@@ -19,17 +23,37 @@ class SearchPanelController<R extends SearchNumData<T>, T>
|
||||
final SearchType searchType;
|
||||
|
||||
// sort
|
||||
final RxString order = ''.obs;
|
||||
late final RxInt duration = 0.obs;
|
||||
int? tids;
|
||||
int? orderSort;
|
||||
int? userType;
|
||||
int? categoryId;
|
||||
// common
|
||||
String order = '';
|
||||
|
||||
// video
|
||||
VideoDurationType? videoDurationType; // int duration
|
||||
VideoZoneType? videoZoneType; // int? tids;
|
||||
int? pubBegin;
|
||||
int? pubEnd;
|
||||
|
||||
// article
|
||||
Rx<UserOrderType>? userOrderType;
|
||||
Rx<UserType>? userType;
|
||||
|
||||
// article
|
||||
Rx<ArticleZoneType>? articleZoneType; // int? categoryId;
|
||||
|
||||
SearchResultController? searchResultController;
|
||||
|
||||
void onSortSearch({
|
||||
bool getBack = true,
|
||||
String? label,
|
||||
}) {
|
||||
if (getBack) Get.back();
|
||||
SmartDialog.dismiss();
|
||||
if (label != null) {
|
||||
SmartDialog.showToast("「$label」的筛选结果");
|
||||
}
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
onReload().whenComplete(SmartDialog.dismiss);
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -55,12 +79,12 @@ class SearchPanelController<R extends SearchNumData<T>, T>
|
||||
searchType: searchType,
|
||||
keyword: keyword,
|
||||
page: page,
|
||||
order: order.value,
|
||||
duration: searchType == SearchType.video ? duration.value : null,
|
||||
tids: tids,
|
||||
orderSort: orderSort,
|
||||
userType: userType,
|
||||
categoryId: categoryId,
|
||||
order: order,
|
||||
duration: videoDurationType?.index,
|
||||
tids: videoZoneType?.tids,
|
||||
orderSort: userOrderType?.value.orderSort,
|
||||
userType: userType?.value.index,
|
||||
categoryId: articleZoneType?.value.categoryId,
|
||||
pubBegin: pubBegin,
|
||||
pubEnd: pubEnd,
|
||||
);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/models/common/search/user_search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/pages/search_panel/controller.dart';
|
||||
import 'package:PiliPlus/utils/context_ext.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart' hide ContextExtensionss;
|
||||
|
||||
class SearchUserController
|
||||
@@ -16,22 +16,12 @@ class SearchUserController
|
||||
required super.tag,
|
||||
});
|
||||
|
||||
// sort
|
||||
late final List orderFiltersList = [
|
||||
{'label': '默认排序', 'value': 0, 'orderSort': 0, 'order': ''},
|
||||
{'label': '粉丝数由高到低', 'value': 1, 'orderSort': 0, 'order': 'fans'},
|
||||
{'label': '粉丝数由低到高', 'value': 2, 'orderSort': 1, 'order': 'fans'},
|
||||
{'label': 'Lv等级由高到低', 'value': 3, 'orderSort': 0, 'order': 'level'},
|
||||
{'label': 'Lv等级由低到高', 'value': 4, 'orderSort': 1, 'order': 'level'},
|
||||
];
|
||||
late final List userTypeFiltersList = [
|
||||
{'label': '全部用户', 'value': 0, 'userType': 0},
|
||||
{'label': 'UP主', 'value': 1, 'userType': 1},
|
||||
{'label': '普通用户', 'value': 2, 'userType': 2},
|
||||
{'label': '认证用户', 'value': 3, 'userType': 3},
|
||||
];
|
||||
RxInt currentOrderFilterval = 0.obs;
|
||||
RxInt currentUserTypeFilterval = 0.obs;
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
userType = UserType.all.obs;
|
||||
userOrderType = UserOrderType.def.obs;
|
||||
}
|
||||
|
||||
void onShowFilterDialog(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
@@ -62,31 +52,25 @@ class SearchUserController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: orderFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (_) async {
|
||||
Get.back();
|
||||
currentOrderFilterval.value = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
orderSort = item['orderSort'];
|
||||
order.value = item['order'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
bgColor: item['value'] == currentOrderFilterval.value
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor:
|
||||
item['value'] == currentOrderFilterval.value
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
children: UserOrderType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == userOrderType!.value;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
userOrderType!.value = e;
|
||||
order = e.order;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text('用户分类', style: TextStyle(fontSize: 16)),
|
||||
@@ -94,31 +78,24 @@ class SearchUserController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: userTypeFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (_) async {
|
||||
Get.back();
|
||||
currentUserTypeFilterval.value = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
userType = item['userType'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
bgColor:
|
||||
item['value'] == currentUserTypeFilterval.value
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor:
|
||||
item['value'] == currentUserTypeFilterval.value
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
children: UserType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == userType!.value;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
userType!.value = e;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -51,7 +51,7 @@ class _SearchUserPanelState
|
||||
children: [
|
||||
Obx(
|
||||
() => Text(
|
||||
'排序: ${controller.orderFiltersList[controller.currentOrderFilterval.value]['label']}',
|
||||
'排序: ${controller.userOrderType!.value.label}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
@@ -59,7 +59,7 @@ class _SearchUserPanelState
|
||||
const Spacer(),
|
||||
Obx(
|
||||
() => Text(
|
||||
'用户类型: ${controller.userTypeFiltersList[controller.currentUserTypeFilterval.value]['label']}',
|
||||
'用户类型: ${controller.userType!.value.label}',
|
||||
maxLines: 1,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/search/video_search_type.dart';
|
||||
import 'package:PiliPlus/models/common/search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
@@ -26,23 +27,11 @@ class SearchVideoController
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
videoDurationType = VideoDurationType.all;
|
||||
videoZoneType = VideoZoneType.all;
|
||||
DateTime now = DateTime.now();
|
||||
pubBeginDate = DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
);
|
||||
pubEndDate = DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
now.day,
|
||||
23,
|
||||
59,
|
||||
59,
|
||||
);
|
||||
pubBeginDate = DateTime(now.year, now.month, 1, 0, 0, 0);
|
||||
pubEndDate = DateTime(now.year, now.month, now.day, 23, 59, 59);
|
||||
|
||||
jump2Video();
|
||||
}
|
||||
@@ -86,61 +75,12 @@ class SearchVideoController
|
||||
}
|
||||
}
|
||||
|
||||
// sort
|
||||
late final List<Map> filterList = ArchiveFilterType.values
|
||||
.map(
|
||||
(type) => {
|
||||
'label': type.desc,
|
||||
'type': type,
|
||||
},
|
||||
)
|
||||
.toList();
|
||||
late final Rx<ArchiveFilterType> selectedType =
|
||||
ArchiveFilterType.values.first.obs;
|
||||
late final List pubTimeFiltersList = [
|
||||
{'label': '不限', 'value': 0},
|
||||
{'label': '最近一天', 'value': 1},
|
||||
{'label': '最近一周', 'value': 2},
|
||||
{'label': '最近半年', 'value': 3},
|
||||
];
|
||||
late final List timeFiltersList = [
|
||||
{'label': '全部时长', 'value': 0},
|
||||
{'label': '0-10分钟', 'value': 1},
|
||||
{'label': '10-30分钟', 'value': 2},
|
||||
{'label': '30-60分钟', 'value': 3},
|
||||
{'label': '60分钟+', 'value': 4},
|
||||
];
|
||||
late final 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 currentPubTimeFilter = 0;
|
||||
final Rx<ArchiveFilterType> selectedType = ArchiveFilterType.totalrank.obs;
|
||||
VideoPubTimeType? pubTimeType = VideoPubTimeType.all;
|
||||
late DateTime pubBeginDate;
|
||||
late DateTime pubEndDate;
|
||||
bool customPubBeginDate = false;
|
||||
bool customPubEndDate = false;
|
||||
int currentTimeFilter = 0;
|
||||
int currentZoneFilter = 0;
|
||||
|
||||
void onShowFilterDialog(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
@@ -154,6 +94,9 @@ class SearchVideoController
|
||||
builder: (context, setState) {
|
||||
final theme = Theme.of(context);
|
||||
Widget dateWidget([bool isFirst = true]) {
|
||||
final enable =
|
||||
pubTimeType == null &&
|
||||
(isFirst ? customPubBeginDate : customPubEndDate);
|
||||
return SearchText(
|
||||
text: DateUtil.longFormat.format(
|
||||
isFirst ? pubBeginDate : pubEndDate,
|
||||
@@ -165,7 +108,7 @@ class SearchVideoController
|
||||
initialDate: isFirst ? pubBeginDate : pubEndDate,
|
||||
firstDate: isFirst ? DateTime(2009, 6, 26) : pubBeginDate,
|
||||
lastDate: isFirst ? pubEndDate : DateTime.now(),
|
||||
).then((selectedDate) async {
|
||||
).then((selectedDate) {
|
||||
if (selectedDate != null) {
|
||||
if (isFirst) {
|
||||
customPubBeginDate = true;
|
||||
@@ -174,7 +117,7 @@ class SearchVideoController
|
||||
customPubEndDate = true;
|
||||
pubEndDate = selectedDate;
|
||||
}
|
||||
currentPubTimeFilter = -1;
|
||||
pubTimeType = null;
|
||||
SmartDialog.dismiss();
|
||||
pubBegin =
|
||||
DateTime(
|
||||
@@ -197,20 +140,14 @@ class SearchVideoController
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000;
|
||||
setState(() {});
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
onSortSearch(getBack: false);
|
||||
}
|
||||
});
|
||||
},
|
||||
bgColor:
|
||||
currentPubTimeFilter == -1 &&
|
||||
(isFirst ? customPubBeginDate : customPubEndDate)
|
||||
bgColor: enable
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: theme.colorScheme.outline.withValues(alpha: 0.1),
|
||||
textColor:
|
||||
currentPubTimeFilter == -1 &&
|
||||
(isFirst ? customPubBeginDate : customPubEndDate)
|
||||
textColor: enable
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: theme.colorScheme.outline.withValues(alpha: 0.8),
|
||||
);
|
||||
@@ -235,59 +172,55 @@ class SearchVideoController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: pubTimeFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (text) async {
|
||||
Get.back();
|
||||
currentPubTimeFilter = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
DateTime now = DateTime.now();
|
||||
if (item['value'] == 0) {
|
||||
pubBegin = null;
|
||||
pubEnd = null;
|
||||
} else {
|
||||
pubBegin =
|
||||
DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
now.day -
|
||||
(item['value'] == 0
|
||||
? 0
|
||||
: item['value'] == 1
|
||||
? 6
|
||||
: 179),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000;
|
||||
pubEnd =
|
||||
DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
now.day,
|
||||
23,
|
||||
59,
|
||||
59,
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000;
|
||||
}
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
bgColor: item['value'] == currentPubTimeFilter
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: item['value'] == currentPubTimeFilter
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
children: VideoPubTimeType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == pubTimeType;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (text) {
|
||||
pubTimeType = e;
|
||||
DateTime now = DateTime.now();
|
||||
if (e == VideoPubTimeType.all) {
|
||||
pubBegin = null;
|
||||
pubEnd = null;
|
||||
} else {
|
||||
pubBegin =
|
||||
DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
now.day -
|
||||
(e == VideoPubTimeType.day
|
||||
? 0
|
||||
: e == VideoPubTimeType.week
|
||||
? 6
|
||||
: 179),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000;
|
||||
pubEnd =
|
||||
DateTime(
|
||||
now.year,
|
||||
now.month,
|
||||
now.day,
|
||||
23,
|
||||
59,
|
||||
59,
|
||||
).millisecondsSinceEpoch ~/
|
||||
1000;
|
||||
}
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
@@ -308,29 +241,24 @@ class SearchVideoController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: timeFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (text) async {
|
||||
Get.back();
|
||||
currentTimeFilter = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
duration.value = item['value'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
bgColor: item['value'] == currentTimeFilter
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: item['value'] == currentTimeFilter
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
children: VideoDurationType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == videoDurationType;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
videoDurationType = e;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Text('内容分区', style: TextStyle(fontSize: 16)),
|
||||
@@ -338,29 +266,24 @@ class SearchVideoController
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: zoneFiltersList
|
||||
.map(
|
||||
(item) => SearchText(
|
||||
text: item['label'],
|
||||
onTap: (text) async {
|
||||
Get.back();
|
||||
currentZoneFilter = item['value'];
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||
tids = item['tids'];
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
bgColor: item['value'] == currentZoneFilter
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: item['value'] == currentZoneFilter
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
children: VideoZoneType.values.map(
|
||||
(e) {
|
||||
final isCurr = e == videoZoneType;
|
||||
return SearchText(
|
||||
text: e.label,
|
||||
onTap: (_) {
|
||||
videoZoneType = e;
|
||||
onSortSearch(label: e.label);
|
||||
},
|
||||
bgColor: isCurr
|
||||
? theme.colorScheme.secondaryContainer
|
||||
: null,
|
||||
textColor: isCurr
|
||||
? theme.colorScheme.onSecondaryContainer
|
||||
: null,
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_card/video_card_h.dart';
|
||||
import 'package:PiliPlus/models/common/search_type.dart';
|
||||
import 'package:PiliPlus/models/search/result.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/pages/search_panel/video/controller.dart';
|
||||
import 'package:PiliPlus/pages/search_panel/view.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class SearchVideoPanel extends CommonSearchPanel {
|
||||
@@ -56,29 +56,21 @@ class _SearchVideoPanelState
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Wrap(
|
||||
children: [
|
||||
for (var i in controller.filterList) ...[
|
||||
for (var e in ArchiveFilterType.values)
|
||||
Obx(
|
||||
() => SearchText(
|
||||
fontSize: 13,
|
||||
text: i['label'],
|
||||
text: e.desc,
|
||||
bgColor: Colors.transparent,
|
||||
textColor:
|
||||
controller.selectedType.value == i['type']
|
||||
textColor: controller.selectedType.value == e
|
||||
? theme.colorScheme.primary
|
||||
: theme.colorScheme.outline,
|
||||
onTap: (value) async {
|
||||
controller.selectedType.value = i['type'];
|
||||
controller.order.value = i['type']
|
||||
.toString()
|
||||
.split('.')
|
||||
.last;
|
||||
SmartDialog.showLoading(msg: 'loading');
|
||||
await controller.onReload();
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
onTap: (_) => controller
|
||||
..order = e.name
|
||||
..selectedType.value = e
|
||||
..onSortSearch(getBack: false),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user