opt sort search

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-07 12:34:03 +08:00
parent 6d55321699
commit 83e25ec0bf
11 changed files with 336 additions and 351 deletions

View 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);
}

View 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);
}

View 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});
}

View File

@@ -42,12 +42,12 @@ class SearchAllController
Future<LoadingState<SearchAllData>> customGetData() => SearchHttp.searchAll( Future<LoadingState<SearchAllData>> customGetData() => SearchHttp.searchAll(
keyword: keyword, keyword: keyword,
page: page, page: page,
order: order.value, order: order,
duration: searchType == SearchType.video ? duration.value : null, duration: null,
tids: tids, tids: videoZoneType?.tids,
orderSort: orderSort, orderSort: userOrderType?.value.orderSort,
userType: userType, userType: userType?.value.index,
categoryId: categoryId, categoryId: articleZoneType?.value.categoryId,
pubBegin: pubBegin, pubBegin: pubBegin,
pubEnd: pubEnd, pubEnd: pubEnd,
); );

View File

@@ -1,11 +1,11 @@
import 'dart:math'; import 'dart:math';
import 'package:PiliPlus/models/common/search/article_search_type.dart';
import 'package:PiliPlus/models/search/result.dart'; import 'package:PiliPlus/models/search/result.dart';
import 'package:PiliPlus/pages/search/widgets/search_text.dart'; import 'package:PiliPlus/pages/search/widgets/search_text.dart';
import 'package:PiliPlus/pages/search_panel/controller.dart'; import 'package:PiliPlus/pages/search_panel/controller.dart';
import 'package:PiliPlus/utils/context_ext.dart'; import 'package:PiliPlus/utils/context_ext.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart' hide ContextExtensionss; import 'package:get/get.dart' hide ContextExtensionss;
class SearchArticleController class SearchArticleController
@@ -19,6 +19,7 @@ class SearchArticleController
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
articleZoneType = ArticleZoneType.all.obs;
jump2Article(); jump2Article();
} }
@@ -40,27 +41,7 @@ class SearchArticleController
} }
} }
// sort Rx<ArticleOrderType> articleOrderType = ArticleOrderType.totalrank.obs;
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;
void onShowFilterDialog(BuildContext context) { void onShowFilterDialog(BuildContext context) {
showModalBottomSheet( showModalBottomSheet(
@@ -91,30 +72,25 @@ class SearchArticleController
Wrap( Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: orderFiltersList children: ArticleOrderType.values.map(
.map( (e) {
(item) => SearchText( final isCurr = e == articleOrderType.value;
text: item['label'], return SearchText(
onTap: (_) async { text: e.label,
Get.back(); onTap: (_) {
currentOrderFilterval.value = item['value']; articleOrderType.value = e;
SmartDialog.dismiss(); order = e.order;
SmartDialog.showToast("${item['label']}」的筛选结果"); onSortSearch(label: e.label);
order.value = item['order']; },
SmartDialog.showLoading(msg: 'loading'); bgColor: isCurr
await onReload(); ? theme.colorScheme.secondaryContainer
SmartDialog.dismiss(); : null,
}, textColor: isCurr
bgColor: item['value'] == currentOrderFilterval.value ? theme.colorScheme.onSecondaryContainer
? theme.colorScheme.secondaryContainer : null,
: null, );
textColor: },
item['value'] == currentOrderFilterval.value ).toList(),
? theme.colorScheme.onSecondaryContainer
: null,
),
)
.toList(),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
const Text('分区', style: TextStyle(fontSize: 16)), const Text('分区', style: TextStyle(fontSize: 16)),
@@ -122,29 +98,24 @@ class SearchArticleController
Wrap( Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: zoneFiltersList children: ArticleZoneType.values.map(
.map( (e) {
(item) => SearchText( final isCurr = e == articleZoneType!.value;
text: item['label'], return SearchText(
onTap: (_) async { text: e.label,
Get.back(); onTap: (_) {
currentZoneFilterval.value = item['value']; articleZoneType!.value = e;
SmartDialog.dismiss(); onSortSearch(label: e.label);
SmartDialog.showToast("${item['label']}」的筛选结果"); },
categoryId = item['categoryId']; bgColor: isCurr
SmartDialog.showLoading(msg: 'loading'); ? theme.colorScheme.secondaryContainer
await onReload(); : null,
SmartDialog.dismiss(); textColor: isCurr
}, ? theme.colorScheme.onSecondaryContainer
bgColor: item['value'] == currentZoneFilterval.value : null,
? theme.colorScheme.secondaryContainer );
: null, },
textColor: item['value'] == currentZoneFilterval.value ).toList(),
? theme.colorScheme.onSecondaryContainer
: null,
),
)
.toList(),
), ),
], ],
), ),

View File

@@ -51,7 +51,7 @@ class _SearchArticlePanelState
children: [ children: [
Obx( Obx(
() => Text( () => Text(
'排序: ${controller.orderFiltersList[controller.currentOrderFilterval.value]['label']}', '排序: ${controller.articleOrderType.value.label}',
maxLines: 1, maxLines: 1,
style: TextStyle(color: theme.colorScheme.outline), style: TextStyle(color: theme.colorScheme.outline),
), ),
@@ -59,7 +59,7 @@ class _SearchArticlePanelState
const Spacer(), const Spacer(),
Obx( Obx(
() => Text( () => Text(
'分区: ${controller.zoneFiltersList[controller.currentZoneFilterval.value]['label']}', '分区: ${controller.articleZoneType!.value.label}',
maxLines: 1, maxLines: 1,
style: TextStyle(color: theme.colorScheme.outline), style: TextStyle(color: theme.colorScheme.outline),
), ),

View File

@@ -1,10 +1,14 @@
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/search.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/common/search_type.dart';
import 'package:PiliPlus/models/search/result.dart'; import 'package:PiliPlus/models/search/result.dart';
import 'package:PiliPlus/pages/common/common_list_controller.dart'; import 'package:PiliPlus/pages/common/common_list_controller.dart';
import 'package:PiliPlus/pages/search_result/controller.dart'; import 'package:PiliPlus/pages/search_result/controller.dart';
import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/extension.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class SearchPanelController<R extends SearchNumData<T>, T> class SearchPanelController<R extends SearchNumData<T>, T>
@@ -19,17 +23,37 @@ class SearchPanelController<R extends SearchNumData<T>, T>
final SearchType searchType; final SearchType searchType;
// sort // sort
final RxString order = ''.obs; // common
late final RxInt duration = 0.obs; String order = '';
int? tids;
int? orderSort; // video
int? userType; VideoDurationType? videoDurationType; // int duration
int? categoryId; VideoZoneType? videoZoneType; // int? tids;
int? pubBegin; int? pubBegin;
int? pubEnd; int? pubEnd;
// article
Rx<UserOrderType>? userOrderType;
Rx<UserType>? userType;
// article
Rx<ArticleZoneType>? articleZoneType; // int? categoryId;
SearchResultController? searchResultController; 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 @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
@@ -55,12 +79,12 @@ class SearchPanelController<R extends SearchNumData<T>, T>
searchType: searchType, searchType: searchType,
keyword: keyword, keyword: keyword,
page: page, page: page,
order: order.value, order: order,
duration: searchType == SearchType.video ? duration.value : null, duration: videoDurationType?.index,
tids: tids, tids: videoZoneType?.tids,
orderSort: orderSort, orderSort: userOrderType?.value.orderSort,
userType: userType, userType: userType?.value.index,
categoryId: categoryId, categoryId: articleZoneType?.value.categoryId,
pubBegin: pubBegin, pubBegin: pubBegin,
pubEnd: pubEnd, pubEnd: pubEnd,
); );

View File

@@ -1,11 +1,11 @@
import 'dart:math'; import 'dart:math';
import 'package:PiliPlus/models/common/search/user_search_type.dart';
import 'package:PiliPlus/models/search/result.dart'; import 'package:PiliPlus/models/search/result.dart';
import 'package:PiliPlus/pages/search/widgets/search_text.dart'; import 'package:PiliPlus/pages/search/widgets/search_text.dart';
import 'package:PiliPlus/pages/search_panel/controller.dart'; import 'package:PiliPlus/pages/search_panel/controller.dart';
import 'package:PiliPlus/utils/context_ext.dart'; import 'package:PiliPlus/utils/context_ext.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart' hide ContextExtensionss; import 'package:get/get.dart' hide ContextExtensionss;
class SearchUserController class SearchUserController
@@ -16,22 +16,12 @@ class SearchUserController
required super.tag, required super.tag,
}); });
// sort @override
late final List orderFiltersList = [ void onInit() {
{'label': '默认排序', 'value': 0, 'orderSort': 0, 'order': ''}, super.onInit();
{'label': '粉丝数由高到低', 'value': 1, 'orderSort': 0, 'order': 'fans'}, userType = UserType.all.obs;
{'label': '粉丝数由低到高', 'value': 2, 'orderSort': 1, 'order': 'fans'}, userOrderType = UserOrderType.def.obs;
{'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;
void onShowFilterDialog(BuildContext context) { void onShowFilterDialog(BuildContext context) {
showModalBottomSheet( showModalBottomSheet(
@@ -62,31 +52,25 @@ class SearchUserController
Wrap( Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: orderFiltersList children: UserOrderType.values.map(
.map( (e) {
(item) => SearchText( final isCurr = e == userOrderType!.value;
text: item['label'], return SearchText(
onTap: (_) async { text: e.label,
Get.back(); onTap: (_) {
currentOrderFilterval.value = item['value']; userOrderType!.value = e;
SmartDialog.dismiss(); order = e.order;
SmartDialog.showToast("${item['label']}」的筛选结果"); onSortSearch(label: e.label);
orderSort = item['orderSort']; },
order.value = item['order']; bgColor: isCurr
SmartDialog.showLoading(msg: 'loading'); ? theme.colorScheme.secondaryContainer
await onReload(); : null,
SmartDialog.dismiss(); textColor: isCurr
}, ? theme.colorScheme.onSecondaryContainer
bgColor: item['value'] == currentOrderFilterval.value : null,
? theme.colorScheme.secondaryContainer );
: null, },
textColor: ).toList(),
item['value'] == currentOrderFilterval.value
? theme.colorScheme.onSecondaryContainer
: null,
),
)
.toList(),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
const Text('用户分类', style: TextStyle(fontSize: 16)), const Text('用户分类', style: TextStyle(fontSize: 16)),
@@ -94,31 +78,24 @@ class SearchUserController
Wrap( Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: userTypeFiltersList children: UserType.values.map(
.map( (e) {
(item) => SearchText( final isCurr = e == userType!.value;
text: item['label'], return SearchText(
onTap: (_) async { text: e.label,
Get.back(); onTap: (_) {
currentUserTypeFilterval.value = item['value']; userType!.value = e;
SmartDialog.dismiss(); onSortSearch(label: e.label);
SmartDialog.showToast("${item['label']}」的筛选结果"); },
userType = item['userType']; bgColor: isCurr
SmartDialog.showLoading(msg: 'loading'); ? theme.colorScheme.secondaryContainer
await onReload(); : null,
SmartDialog.dismiss(); textColor: isCurr
}, ? theme.colorScheme.onSecondaryContainer
bgColor: : null,
item['value'] == currentUserTypeFilterval.value );
? theme.colorScheme.secondaryContainer },
: null, ).toList(),
textColor:
item['value'] == currentUserTypeFilterval.value
? theme.colorScheme.onSecondaryContainer
: null,
),
)
.toList(),
), ),
], ],
), ),

View File

@@ -51,7 +51,7 @@ class _SearchUserPanelState
children: [ children: [
Obx( Obx(
() => Text( () => Text(
'排序: ${controller.orderFiltersList[controller.currentOrderFilterval.value]['label']}', '排序: ${controller.userOrderType!.value.label}',
maxLines: 1, maxLines: 1,
style: TextStyle(color: theme.colorScheme.outline), style: TextStyle(color: theme.colorScheme.outline),
), ),
@@ -59,7 +59,7 @@ class _SearchUserPanelState
const Spacer(), const Spacer(),
Obx( Obx(
() => Text( () => Text(
'用户类型: ${controller.userTypeFiltersList[controller.currentUserTypeFilterval.value]['label']}', '用户类型: ${controller.userType!.value.label}',
maxLines: 1, maxLines: 1,
style: TextStyle(color: theme.colorScheme.outline), style: TextStyle(color: theme.colorScheme.outline),
), ),

View File

@@ -1,6 +1,7 @@
import 'dart:math'; import 'dart:math';
import 'package:PiliPlus/http/loading_state.dart'; 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/common/search_type.dart';
import 'package:PiliPlus/models/search/result.dart'; import 'package:PiliPlus/models/search/result.dart';
import 'package:PiliPlus/pages/search/widgets/search_text.dart'; import 'package:PiliPlus/pages/search/widgets/search_text.dart';
@@ -26,23 +27,11 @@ class SearchVideoController
@override @override
void onInit() { void onInit() {
super.onInit(); super.onInit();
videoDurationType = VideoDurationType.all;
videoZoneType = VideoZoneType.all;
DateTime now = DateTime.now(); DateTime now = DateTime.now();
pubBeginDate = DateTime( pubBeginDate = DateTime(now.year, now.month, 1, 0, 0, 0);
now.year, pubEndDate = DateTime(now.year, now.month, now.day, 23, 59, 59);
now.month,
1,
0,
0,
0,
);
pubEndDate = DateTime(
now.year,
now.month,
now.day,
23,
59,
59,
);
jump2Video(); jump2Video();
} }
@@ -86,61 +75,12 @@ class SearchVideoController
} }
} }
// sort final Rx<ArchiveFilterType> selectedType = ArchiveFilterType.totalrank.obs;
late final List<Map> filterList = ArchiveFilterType.values VideoPubTimeType? pubTimeType = VideoPubTimeType.all;
.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;
late DateTime pubBeginDate; late DateTime pubBeginDate;
late DateTime pubEndDate; late DateTime pubEndDate;
bool customPubBeginDate = false; bool customPubBeginDate = false;
bool customPubEndDate = false; bool customPubEndDate = false;
int currentTimeFilter = 0;
int currentZoneFilter = 0;
void onShowFilterDialog(BuildContext context) { void onShowFilterDialog(BuildContext context) {
showModalBottomSheet( showModalBottomSheet(
@@ -154,6 +94,9 @@ class SearchVideoController
builder: (context, setState) { builder: (context, setState) {
final theme = Theme.of(context); final theme = Theme.of(context);
Widget dateWidget([bool isFirst = true]) { Widget dateWidget([bool isFirst = true]) {
final enable =
pubTimeType == null &&
(isFirst ? customPubBeginDate : customPubEndDate);
return SearchText( return SearchText(
text: DateUtil.longFormat.format( text: DateUtil.longFormat.format(
isFirst ? pubBeginDate : pubEndDate, isFirst ? pubBeginDate : pubEndDate,
@@ -165,7 +108,7 @@ class SearchVideoController
initialDate: isFirst ? pubBeginDate : pubEndDate, initialDate: isFirst ? pubBeginDate : pubEndDate,
firstDate: isFirst ? DateTime(2009, 6, 26) : pubBeginDate, firstDate: isFirst ? DateTime(2009, 6, 26) : pubBeginDate,
lastDate: isFirst ? pubEndDate : DateTime.now(), lastDate: isFirst ? pubEndDate : DateTime.now(),
).then((selectedDate) async { ).then((selectedDate) {
if (selectedDate != null) { if (selectedDate != null) {
if (isFirst) { if (isFirst) {
customPubBeginDate = true; customPubBeginDate = true;
@@ -174,7 +117,7 @@ class SearchVideoController
customPubEndDate = true; customPubEndDate = true;
pubEndDate = selectedDate; pubEndDate = selectedDate;
} }
currentPubTimeFilter = -1; pubTimeType = null;
SmartDialog.dismiss(); SmartDialog.dismiss();
pubBegin = pubBegin =
DateTime( DateTime(
@@ -197,20 +140,14 @@ class SearchVideoController
).millisecondsSinceEpoch ~/ ).millisecondsSinceEpoch ~/
1000; 1000;
setState(() {}); setState(() {});
SmartDialog.showLoading(msg: 'loading'); onSortSearch(getBack: false);
await onReload();
SmartDialog.dismiss();
} }
}); });
}, },
bgColor: bgColor: enable
currentPubTimeFilter == -1 &&
(isFirst ? customPubBeginDate : customPubEndDate)
? theme.colorScheme.secondaryContainer ? theme.colorScheme.secondaryContainer
: theme.colorScheme.outline.withValues(alpha: 0.1), : theme.colorScheme.outline.withValues(alpha: 0.1),
textColor: textColor: enable
currentPubTimeFilter == -1 &&
(isFirst ? customPubBeginDate : customPubEndDate)
? theme.colorScheme.onSecondaryContainer ? theme.colorScheme.onSecondaryContainer
: theme.colorScheme.outline.withValues(alpha: 0.8), : theme.colorScheme.outline.withValues(alpha: 0.8),
); );
@@ -235,59 +172,55 @@ class SearchVideoController
Wrap( Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: pubTimeFiltersList children: VideoPubTimeType.values.map(
.map( (e) {
(item) => SearchText( final isCurr = e == pubTimeType;
text: item['label'], return SearchText(
onTap: (text) async { text: e.label,
Get.back(); onTap: (text) {
currentPubTimeFilter = item['value']; pubTimeType = e;
SmartDialog.dismiss(); DateTime now = DateTime.now();
SmartDialog.showToast("${item['label']}」的筛选结果"); if (e == VideoPubTimeType.all) {
DateTime now = DateTime.now(); pubBegin = null;
if (item['value'] == 0) { pubEnd = null;
pubBegin = null; } else {
pubEnd = null; pubBegin =
} else { DateTime(
pubBegin = now.year,
DateTime( now.month,
now.year, now.day -
now.month, (e == VideoPubTimeType.day
now.day - ? 0
(item['value'] == 0 : e == VideoPubTimeType.week
? 0 ? 6
: item['value'] == 1 : 179),
? 6 0,
: 179), 0,
0, 0,
0, ).millisecondsSinceEpoch ~/
0, 1000;
).millisecondsSinceEpoch ~/ pubEnd =
1000; DateTime(
pubEnd = now.year,
DateTime( now.month,
now.year, now.day,
now.month, 23,
now.day, 59,
23, 59,
59, ).millisecondsSinceEpoch ~/
59, 1000;
).millisecondsSinceEpoch ~/ }
1000; onSortSearch(label: e.label);
} },
SmartDialog.showLoading(msg: 'loading'); bgColor: isCurr
await onReload(); ? theme.colorScheme.secondaryContainer
SmartDialog.dismiss(); : null,
}, textColor: isCurr
bgColor: item['value'] == currentPubTimeFilter ? theme.colorScheme.onSecondaryContainer
? theme.colorScheme.secondaryContainer : null,
: null, );
textColor: item['value'] == currentPubTimeFilter },
? theme.colorScheme.onSecondaryContainer ).toList(),
: null,
),
)
.toList(),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
Row( Row(
@@ -308,29 +241,24 @@ class SearchVideoController
Wrap( Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: timeFiltersList children: VideoDurationType.values.map(
.map( (e) {
(item) => SearchText( final isCurr = e == videoDurationType;
text: item['label'], return SearchText(
onTap: (text) async { text: e.label,
Get.back(); onTap: (_) {
currentTimeFilter = item['value']; videoDurationType = e;
SmartDialog.dismiss(); onSortSearch(label: e.label);
SmartDialog.showToast("${item['label']}」的筛选结果"); },
duration.value = item['value']; bgColor: isCurr
SmartDialog.showLoading(msg: 'loading'); ? theme.colorScheme.secondaryContainer
await onReload(); : null,
SmartDialog.dismiss(); textColor: isCurr
}, ? theme.colorScheme.onSecondaryContainer
bgColor: item['value'] == currentTimeFilter : null,
? theme.colorScheme.secondaryContainer );
: null, },
textColor: item['value'] == currentTimeFilter ).toList(),
? theme.colorScheme.onSecondaryContainer
: null,
),
)
.toList(),
), ),
const SizedBox(height: 20), const SizedBox(height: 20),
const Text('内容分区', style: TextStyle(fontSize: 16)), const Text('内容分区', style: TextStyle(fontSize: 16)),
@@ -338,29 +266,24 @@ class SearchVideoController
Wrap( Wrap(
spacing: 8, spacing: 8,
runSpacing: 8, runSpacing: 8,
children: zoneFiltersList children: VideoZoneType.values.map(
.map( (e) {
(item) => SearchText( final isCurr = e == videoZoneType;
text: item['label'], return SearchText(
onTap: (text) async { text: e.label,
Get.back(); onTap: (_) {
currentZoneFilter = item['value']; videoZoneType = e;
SmartDialog.dismiss(); onSortSearch(label: e.label);
SmartDialog.showToast("${item['label']}」的筛选结果"); },
tids = item['tids']; bgColor: isCurr
SmartDialog.showLoading(msg: 'loading'); ? theme.colorScheme.secondaryContainer
await onReload(); : null,
SmartDialog.dismiss(); textColor: isCurr
}, ? theme.colorScheme.onSecondaryContainer
bgColor: item['value'] == currentZoneFilter : null,
? theme.colorScheme.secondaryContainer );
: null, },
textColor: item['value'] == currentZoneFilter ).toList(),
? theme.colorScheme.onSecondaryContainer
: null,
),
)
.toList(),
), ),
], ],
), ),

View File

@@ -1,12 +1,12 @@
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart'; 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/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/models/search/result.dart';
import 'package:PiliPlus/pages/search/widgets/search_text.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/video/controller.dart';
import 'package:PiliPlus/pages/search_panel/view.dart'; import 'package:PiliPlus/pages/search_panel/view.dart';
import 'package:PiliPlus/utils/grid.dart'; import 'package:PiliPlus/utils/grid.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class SearchVideoPanel extends CommonSearchPanel { class SearchVideoPanel extends CommonSearchPanel {
@@ -56,29 +56,21 @@ class _SearchVideoPanelState
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
child: Wrap( child: Wrap(
children: [ children: [
for (var i in controller.filterList) ...[ for (var e in ArchiveFilterType.values)
Obx( Obx(
() => SearchText( () => SearchText(
fontSize: 13, fontSize: 13,
text: i['label'], text: e.desc,
bgColor: Colors.transparent, bgColor: Colors.transparent,
textColor: textColor: controller.selectedType.value == e
controller.selectedType.value == i['type']
? theme.colorScheme.primary ? theme.colorScheme.primary
: theme.colorScheme.outline, : theme.colorScheme.outline,
onTap: (value) async { onTap: (_) => controller
controller.selectedType.value = i['type']; ..order = e.name
controller.order.value = i['type'] ..selectedType.value = e
.toString() ..onSortSearch(getBack: false),
.split('.')
.last;
SmartDialog.showLoading(msg: 'loading');
await controller.onReload();
SmartDialog.dismiss();
},
), ),
), ),
],
], ],
), ),
), ),