mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: sort user search
This commit is contained in:
@@ -76,6 +76,8 @@ class SearchHttp {
|
|||||||
String? order,
|
String? order,
|
||||||
int? duration,
|
int? duration,
|
||||||
int? tids,
|
int? tids,
|
||||||
|
int? orderSort,
|
||||||
|
int? userType,
|
||||||
}) async {
|
}) async {
|
||||||
var reqData = {
|
var reqData = {
|
||||||
'search_type': searchType.type,
|
'search_type': searchType.type,
|
||||||
@@ -83,9 +85,11 @@ class SearchHttp {
|
|||||||
// 'order_sort': 0,
|
// 'order_sort': 0,
|
||||||
// 'user_type': 0,
|
// 'user_type': 0,
|
||||||
'page': page,
|
'page': page,
|
||||||
if (order != null) 'order': order,
|
if (order != null && order.isNotEmpty) 'order': order,
|
||||||
if (duration != null) 'duration': duration,
|
if (duration != null) 'duration': duration,
|
||||||
if (tids != null) 'tids': tids,
|
if (tids != null) 'tids': tids,
|
||||||
|
if (orderSort != null) 'order_sort': orderSort,
|
||||||
|
if (userType != null) 'user_type': userType,
|
||||||
};
|
};
|
||||||
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) {
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ class SearchPanelController extends CommonController {
|
|||||||
// 视频时长筛选 仅用于搜索视频
|
// 视频时长筛选 仅用于搜索视频
|
||||||
RxInt duration = 0.obs;
|
RxInt duration = 0.obs;
|
||||||
int? tids;
|
int? tids;
|
||||||
|
int? orderSort;
|
||||||
|
int? userType;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@@ -68,8 +70,10 @@ class SearchPanelController extends CommonController {
|
|||||||
searchType: searchType!,
|
searchType: searchType!,
|
||||||
keyword: keyword!,
|
keyword: keyword!,
|
||||||
page: currentPage,
|
page: currentPage,
|
||||||
order: searchType!.type != 'video' ? null : order.value,
|
order: order.value,
|
||||||
duration: searchType!.type != 'video' ? null : duration.value,
|
duration: searchType!.type != 'video' ? null : duration.value,
|
||||||
tids: tids,
|
tids: tids,
|
||||||
|
orderSort: orderSort,
|
||||||
|
userType: userType,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
|
import 'package:PiliPalaX/pages/search/widgets/search_text.dart';
|
||||||
|
import 'package:PiliPalaX/pages/search_panel/controller.dart';
|
||||||
|
import 'package:PiliPalaX/pages/video/detail/reply/view.dart'
|
||||||
|
show MySliverPersistentHeaderDelegate;
|
||||||
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';
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
@@ -6,13 +11,67 @@ import 'package:PiliPalaX/utils/utils.dart';
|
|||||||
import '../../../common/constants.dart';
|
import '../../../common/constants.dart';
|
||||||
import '../../../utils/grid.dart';
|
import '../../../utils/grid.dart';
|
||||||
|
|
||||||
Widget searchUserPanel(BuildContext context, ctr, list) {
|
Widget searchUserPanel(BuildContext context, searchPanelCtr, list) {
|
||||||
TextStyle style = TextStyle(
|
TextStyle style = TextStyle(
|
||||||
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
fontSize: Theme.of(context).textTheme.labelSmall!.fontSize,
|
||||||
color: Theme.of(context).colorScheme.outline);
|
color: Theme.of(context).colorScheme.outline);
|
||||||
|
final ctr = Get.put(UserPanelController());
|
||||||
|
|
||||||
return CustomScrollView(controller: ctr.scrollController, slivers: [
|
return CustomScrollView(
|
||||||
SliverGrid(
|
controller: searchPanelCtr.scrollController,
|
||||||
|
slivers: [
|
||||||
|
SliverPersistentHeader(
|
||||||
|
pinned: false,
|
||||||
|
floating: true,
|
||||||
|
delegate: MySliverPersistentHeaderDelegate(
|
||||||
|
child: Container(
|
||||||
|
height: 40,
|
||||||
|
color: Theme.of(context).colorScheme.surface,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Obx(
|
||||||
|
() => Text(
|
||||||
|
'排序: ${ctr.orderFiltersList[ctr.currentOrderFilterval.value]['label']}',
|
||||||
|
maxLines: 1,
|
||||||
|
style:
|
||||||
|
TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Obx(
|
||||||
|
() => Text(
|
||||||
|
'用户类型: ${ctr.userTypeFiltersList[ctr.currentUserTypeFilterval.value]['label']}',
|
||||||
|
maxLines: 1,
|
||||||
|
style:
|
||||||
|
TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
SizedBox(
|
||||||
|
width: 32,
|
||||||
|
height: 32,
|
||||||
|
child: IconButton(
|
||||||
|
tooltip: '筛选',
|
||||||
|
style: ButtonStyle(
|
||||||
|
padding: WidgetStateProperty.all(EdgeInsets.zero),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
ctr.onShowFilterDialog(context, searchPanelCtr);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.filter_list_outlined,
|
||||||
|
size: 18,
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SliverGrid(
|
||||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||||
mainAxisSpacing: StyleString.cardSpace,
|
mainAxisSpacing: StyleString.cardSpace,
|
||||||
crossAxisSpacing: StyleString.safeSpace,
|
crossAxisSpacing: StyleString.safeSpace,
|
||||||
@@ -77,6 +136,123 @@ Widget searchUserPanel(BuildContext context, ctr, list) {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount: list!.length,
|
childCount: list!.length,
|
||||||
))
|
),
|
||||||
]);
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class UserPanelController extends GetxController {
|
||||||
|
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'},
|
||||||
|
];
|
||||||
|
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;
|
||||||
|
|
||||||
|
onShowFilterDialog(
|
||||||
|
BuildContext context,
|
||||||
|
SearchPanelController searchPanelCtr,
|
||||||
|
) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
isScrollControlled: true,
|
||||||
|
builder: (_) => SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: 20,
|
||||||
|
left: 16,
|
||||||
|
right: 16,
|
||||||
|
bottom: 80 + MediaQuery.of(context).padding.bottom,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Text('用户粉丝数及等级排序顺序', style: TextStyle(fontSize: 16)),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: orderFiltersList
|
||||||
|
.map(
|
||||||
|
(item) => SearchText(
|
||||||
|
searchText: item['label'],
|
||||||
|
onSelect: (_) async {
|
||||||
|
Get.back();
|
||||||
|
currentOrderFilterval.value = item['value'];
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||||
|
SearchPanelController ctr =
|
||||||
|
Get.find<SearchPanelController>(
|
||||||
|
tag: 'bili_user${searchPanelCtr.keyword!}');
|
||||||
|
ctr.orderSort = item['orderSort'];
|
||||||
|
ctr.order.value = item['order'];
|
||||||
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
|
await ctr.onRefresh();
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
onLongSelect: (_) {},
|
||||||
|
bgColor: item['value'] == currentOrderFilterval.value
|
||||||
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
|
: null,
|
||||||
|
textColor: item['value'] == currentOrderFilterval.value
|
||||||
|
? 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: userTypeFiltersList
|
||||||
|
.map(
|
||||||
|
(item) => SearchText(
|
||||||
|
searchText: item['label'],
|
||||||
|
onSelect: (_) async {
|
||||||
|
Get.back();
|
||||||
|
currentUserTypeFilterval.value = item['value'];
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
SmartDialog.showToast("「${item['label']}」的筛选结果");
|
||||||
|
SearchPanelController ctr =
|
||||||
|
Get.find<SearchPanelController>(
|
||||||
|
tag: 'bili_user${searchPanelCtr.keyword!}');
|
||||||
|
ctr.userType = item['userType'];
|
||||||
|
SmartDialog.showLoading(msg: 'loading');
|
||||||
|
await ctr.onRefresh();
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
onLongSelect: (_) {},
|
||||||
|
bgColor: item['value'] == currentUserTypeFilterval.value
|
||||||
|
? Theme.of(context).colorScheme.primaryContainer
|
||||||
|
: null,
|
||||||
|
textColor: item['value'] ==
|
||||||
|
currentUserTypeFilterval.value
|
||||||
|
? Theme.of(context).colorScheme.onPrimaryContainer
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
SliverPersistentHeader(
|
SliverPersistentHeader(
|
||||||
pinned: false,
|
pinned: false,
|
||||||
floating: true,
|
floating: true,
|
||||||
delegate: _MySliverPersistentHeaderDelegate(
|
delegate: MySliverPersistentHeaderDelegate(
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 40,
|
height: 40,
|
||||||
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
|
padding: const EdgeInsets.fromLTRB(12, 0, 6, 0),
|
||||||
@@ -257,8 +257,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
|
class MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
|
||||||
_MySliverPersistentHeaderDelegate({required this.child});
|
MySliverPersistentHeaderDelegate({required this.child});
|
||||||
final double _minExtent = 45;
|
final double _minExtent = 45;
|
||||||
final double _maxExtent = 45;
|
final double _maxExtent = 45;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@@ -281,7 +281,7 @@ class _MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate {
|
|||||||
double get minExtent => _minExtent;
|
double get minExtent => _minExtent;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRebuild(covariant _MySliverPersistentHeaderDelegate oldDelegate) {
|
bool shouldRebuild(covariant MySliverPersistentHeaderDelegate oldDelegate) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user