mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: search video by pubtime
This commit is contained in:
@@ -79,6 +79,8 @@ class SearchHttp {
|
|||||||
int? orderSort,
|
int? orderSort,
|
||||||
int? userType,
|
int? userType,
|
||||||
int? categoryId,
|
int? categoryId,
|
||||||
|
int? pubBegin,
|
||||||
|
int? pubEnd,
|
||||||
}) async {
|
}) async {
|
||||||
var reqData = {
|
var reqData = {
|
||||||
'search_type': searchType.type,
|
'search_type': searchType.type,
|
||||||
@@ -92,6 +94,8 @@ class SearchHttp {
|
|||||||
if (orderSort != null) 'order_sort': orderSort,
|
if (orderSort != null) 'order_sort': orderSort,
|
||||||
if (userType != null) 'user_type': userType,
|
if (userType != null) 'user_type': userType,
|
||||||
if (categoryId != null) 'category_id': categoryId,
|
if (categoryId != null) 'category_id': categoryId,
|
||||||
|
if (pubBegin != null) 'pubtime_begin_s': pubBegin,
|
||||||
|
if (pubEnd != null) 'pubtime_end_s': pubEnd,
|
||||||
};
|
};
|
||||||
var res = await Request().get(Api.searchByType, data: reqData);
|
var res = await Request().get(Api.searchByType, data: reqData);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class SearchText extends StatelessWidget {
|
|||||||
final double? fontSize;
|
final double? fontSize;
|
||||||
final Color? bgColor;
|
final Color? bgColor;
|
||||||
final Color? textColor;
|
final Color? textColor;
|
||||||
|
final TextAlign? textAlign;
|
||||||
const SearchText({
|
const SearchText({
|
||||||
super.key,
|
super.key,
|
||||||
this.searchText,
|
this.searchText,
|
||||||
@@ -17,6 +18,7 @@ class SearchText extends StatelessWidget {
|
|||||||
this.fontSize,
|
this.fontSize,
|
||||||
this.bgColor,
|
this.bgColor,
|
||||||
this.textColor,
|
this.textColor,
|
||||||
|
this.textAlign,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -40,6 +42,7 @@ class SearchText extends StatelessWidget {
|
|||||||
const EdgeInsets.only(top: 5, bottom: 5, left: 11, right: 11),
|
const EdgeInsets.only(top: 5, bottom: 5, left: 11, right: 11),
|
||||||
child: Text(
|
child: Text(
|
||||||
searchText!,
|
searchText!,
|
||||||
|
textAlign: textAlign,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: fontSize,
|
fontSize: fontSize,
|
||||||
color:
|
color:
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class SearchPanelController extends CommonController {
|
|||||||
int? userType;
|
int? userType;
|
||||||
int? categoryId;
|
int? categoryId;
|
||||||
String? tag;
|
String? tag;
|
||||||
|
int? pubBegin;
|
||||||
|
int? pubEnd;
|
||||||
late final searchResultController =
|
late final searchResultController =
|
||||||
Get.find<SearchResultController>(tag: tag);
|
Get.find<SearchResultController>(tag: tag);
|
||||||
|
|
||||||
@@ -103,5 +105,7 @@ class SearchPanelController extends CommonController {
|
|||||||
orderSort: orderSort,
|
orderSort: orderSort,
|
||||||
userType: userType,
|
userType: userType,
|
||||||
categoryId: categoryId,
|
categoryId: categoryId,
|
||||||
|
pubBegin: pubBegin,
|
||||||
|
pubEnd: pubEnd,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:PiliPalaX/common/widgets/video_card_h.dart';
|
import 'package:PiliPalaX/common/widgets/video_card_h.dart';
|
||||||
import 'package:PiliPalaX/models/common/search_type.dart';
|
import 'package:PiliPalaX/models/common/search_type.dart';
|
||||||
import 'package:PiliPalaX/pages/search_panel/index.dart';
|
import 'package:PiliPalaX/pages/search_panel/index.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import '../../../common/constants.dart';
|
import '../../../common/constants.dart';
|
||||||
import '../../../utils/grid.dart';
|
import '../../../utils/grid.dart';
|
||||||
@@ -177,6 +178,12 @@ 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 pubTimeFiltersList = [
|
||||||
|
{'label': '不限', 'value': 0},
|
||||||
|
{'label': '最近一天', 'value': 1},
|
||||||
|
{'label': '最近一周', 'value': 2},
|
||||||
|
{'label': '最近半年', 'value': 3},
|
||||||
|
];
|
||||||
List timeFiltersList = [
|
List timeFiltersList = [
|
||||||
{'label': '全部时长', 'value': 0},
|
{'label': '全部时长', 'value': 0},
|
||||||
{'label': '0-10分钟', 'value': 1},
|
{'label': '0-10分钟', 'value': 1},
|
||||||
@@ -208,11 +215,33 @@ class VideoPanelController extends GetxController {
|
|||||||
{'label': '电影', 'value': 20, 'tids': 23},
|
{'label': '电影', 'value': 20, 'tids': 23},
|
||||||
{'label': '电视', 'value': 21, 'tids': 11},
|
{'label': '电视', 'value': 21, 'tids': 11},
|
||||||
];
|
];
|
||||||
|
int currentPubTimeFilterval = 0;
|
||||||
|
late DateTime pubBegin;
|
||||||
|
late DateTime pubEnd;
|
||||||
|
bool customPubBegin = false;
|
||||||
|
bool customPubEnd = false;
|
||||||
int currentTimeFilterval = 0;
|
int currentTimeFilterval = 0;
|
||||||
int currentZoneFilterval = 0;
|
int currentZoneFilterval = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
pubBegin = DateTime(
|
||||||
|
now.year,
|
||||||
|
now.month,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
pubEnd = DateTime(
|
||||||
|
now.year,
|
||||||
|
now.month,
|
||||||
|
now.day,
|
||||||
|
23,
|
||||||
|
59,
|
||||||
|
59,
|
||||||
|
);
|
||||||
List<Map<String, dynamic>> list = ArchiveFilterType.values
|
List<Map<String, dynamic>> list = ArchiveFilterType.values
|
||||||
.map((type) => {
|
.map((type) => {
|
||||||
'label': type.description,
|
'label': type.description,
|
||||||
@@ -230,90 +259,237 @@ class VideoPanelController extends GetxController {
|
|||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
builder: (_) => SingleChildScrollView(
|
builder: (_) => StatefulBuilder(
|
||||||
child: Container(
|
builder: (context, setState) {
|
||||||
width: double.infinity,
|
Widget dateWidget([bool isFirst = true]) {
|
||||||
padding: EdgeInsets.only(
|
return SearchText(
|
||||||
top: 20,
|
searchText:
|
||||||
left: 16,
|
DateFormat('yyyy-MM-dd').format(isFirst ? pubBegin : pubEnd),
|
||||||
right: 16,
|
textAlign: TextAlign.center,
|
||||||
bottom: 80 + MediaQuery.of(context).padding.bottom,
|
onSelect: (text) {
|
||||||
),
|
showDatePicker(
|
||||||
child: Column(
|
context: context,
|
||||||
mainAxisSize: MainAxisSize.min,
|
initialDate: isFirst ? pubBegin : pubEnd,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
firstDate: isFirst ? DateTime(2009, 6, 26) : pubBegin,
|
||||||
children: [
|
lastDate: isFirst ? pubEnd : DateTime.now(),
|
||||||
const SizedBox(height: 10),
|
).then((selectedDate) async {
|
||||||
const Text('时长', style: TextStyle(fontSize: 16)),
|
if (selectedDate != null) {
|
||||||
const SizedBox(height: 10),
|
if (isFirst) {
|
||||||
Wrap(
|
customPubBegin = true;
|
||||||
spacing: 8,
|
pubBegin = selectedDate;
|
||||||
runSpacing: 8,
|
} else {
|
||||||
children: timeFiltersList
|
customPubEnd = true;
|
||||||
.map(
|
pubEnd = selectedDate;
|
||||||
(item) => SearchText(
|
}
|
||||||
searchText: item['label'],
|
currentPubTimeFilterval = -1;
|
||||||
onSelect: (text) async {
|
SmartDialog.dismiss();
|
||||||
Get.back();
|
// SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||||
currentTimeFilterval = item['value'];
|
SearchPanelController ctr = Get.find<SearchPanelController>(
|
||||||
SmartDialog.dismiss();
|
tag: 'video${searchPanelCtr.keyword!}');
|
||||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
ctr.pubBegin = DateTime(
|
||||||
SearchPanelController ctr =
|
pubBegin.year,
|
||||||
Get.find<SearchPanelController>(
|
pubBegin.month,
|
||||||
tag: 'video${searchPanelCtr.keyword!}');
|
pubBegin.day,
|
||||||
ctr.duration.value = item['value'];
|
0,
|
||||||
SmartDialog.showLoading(msg: 'loading');
|
0,
|
||||||
await ctr.onRefresh();
|
0,
|
||||||
SmartDialog.dismiss();
|
).millisecondsSinceEpoch ~/
|
||||||
},
|
1000;
|
||||||
onLongSelect: (_) {},
|
ctr.pubEnd = DateTime(
|
||||||
bgColor: item['value'] == currentTimeFilterval
|
pubEnd.year,
|
||||||
? Theme.of(context).colorScheme.primaryContainer
|
pubEnd.month,
|
||||||
: null,
|
pubEnd.day,
|
||||||
textColor: item['value'] == currentTimeFilterval
|
23,
|
||||||
? Theme.of(context).colorScheme.onPrimaryContainer
|
59,
|
||||||
: null,
|
59,
|
||||||
),
|
).millisecondsSinceEpoch ~/
|
||||||
)
|
1000;
|
||||||
.toList(),
|
setState(() {});
|
||||||
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
|
await ctr.onRefresh();
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onLongSelect: (_) {},
|
||||||
|
bgColor: currentPubTimeFilterval == -1 &&
|
||||||
|
(isFirst ? customPubBegin : customPubEnd)
|
||||||
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
|
: null,
|
||||||
|
textColor: currentPubTimeFilterval == -1 &&
|
||||||
|
(isFirst ? customPubBegin : customPubEnd)
|
||||||
|
? Theme.of(context).colorScheme.onPrimaryContainer
|
||||||
|
: Theme.of(context).colorScheme.outline.withOpacity(0.8),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: 20,
|
||||||
|
left: 16,
|
||||||
|
right: 16,
|
||||||
|
bottom: 80 + MediaQuery.of(context).padding.bottom,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
child: Column(
|
||||||
const Text('分区', style: TextStyle(fontSize: 16)),
|
mainAxisSize: MainAxisSize.min,
|
||||||
const SizedBox(height: 10),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Wrap(
|
children: [
|
||||||
spacing: 8,
|
const SizedBox(height: 10),
|
||||||
runSpacing: 8,
|
const Text('发布时间', style: TextStyle(fontSize: 16)),
|
||||||
children: zoneFiltersList
|
const SizedBox(height: 10),
|
||||||
.map(
|
Wrap(
|
||||||
(item) => SearchText(
|
spacing: 8,
|
||||||
searchText: item['label'],
|
runSpacing: 8,
|
||||||
onSelect: (text) async {
|
children: pubTimeFiltersList
|
||||||
Get.back();
|
.map(
|
||||||
currentZoneFilterval = item['value'];
|
(item) => SearchText(
|
||||||
SmartDialog.dismiss();
|
searchText: item['label'],
|
||||||
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
onSelect: (text) async {
|
||||||
SearchPanelController ctr =
|
Get.back();
|
||||||
Get.find<SearchPanelController>(
|
currentPubTimeFilterval = item['value'];
|
||||||
tag: 'video${searchPanelCtr.keyword!}');
|
SmartDialog.dismiss();
|
||||||
ctr.tids = item['tids'];
|
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||||
SmartDialog.showLoading(msg: 'loading');
|
SearchPanelController ctr =
|
||||||
await ctr.onRefresh();
|
Get.find<SearchPanelController>(
|
||||||
SmartDialog.dismiss();
|
tag: 'video${searchPanelCtr.keyword!}');
|
||||||
},
|
DateTime now = DateTime.now();
|
||||||
onLongSelect: (_) {},
|
if (item['value'] == 0) {
|
||||||
bgColor: item['value'] == currentZoneFilterval
|
ctr.pubBegin = null;
|
||||||
? Theme.of(context).colorScheme.primaryContainer
|
ctr.pubEnd = null;
|
||||||
: null,
|
} else {
|
||||||
textColor: item['value'] == currentZoneFilterval
|
ctr.pubBegin = DateTime(
|
||||||
? Theme.of(context).colorScheme.onPrimaryContainer
|
now.year,
|
||||||
: null,
|
now.month,
|
||||||
|
now.day -
|
||||||
|
(item['value'] == 0
|
||||||
|
? 0
|
||||||
|
: item['value'] == 1
|
||||||
|
? 6
|
||||||
|
: 179),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
).millisecondsSinceEpoch ~/
|
||||||
|
1000;
|
||||||
|
ctr.pubEnd = DateTime(
|
||||||
|
now.year,
|
||||||
|
now.month,
|
||||||
|
now.day,
|
||||||
|
23,
|
||||||
|
59,
|
||||||
|
59,
|
||||||
|
).millisecondsSinceEpoch ~/
|
||||||
|
1000;
|
||||||
|
}
|
||||||
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
|
await ctr.onRefresh();
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
onLongSelect: (_) {},
|
||||||
|
bgColor: item['value'] == currentPubTimeFilterval
|
||||||
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
|
: null,
|
||||||
|
textColor: item['value'] == currentPubTimeFilterval
|
||||||
|
? Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onPrimaryContainer
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(child: dateWidget()),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
const Text(
|
||||||
|
'至',
|
||||||
|
style: TextStyle(fontSize: 13),
|
||||||
),
|
),
|
||||||
)
|
const SizedBox(width: 8),
|
||||||
.toList(),
|
Expanded(child: dateWidget(false)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
const Text('内容时长', style: TextStyle(fontSize: 16)),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: timeFiltersList
|
||||||
|
.map(
|
||||||
|
(item) => SearchText(
|
||||||
|
searchText: item['label'],
|
||||||
|
onSelect: (text) async {
|
||||||
|
Get.back();
|
||||||
|
currentTimeFilterval = item['value'];
|
||||||
|
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