mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-19 16:46:22 +08:00
@@ -2,6 +2,7 @@ import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_article/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/data.dart';
|
||||
@@ -48,13 +49,14 @@ class FavHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState<FavDetailData>> userFavFolderDetail(
|
||||
{required int mediaId,
|
||||
required int pn,
|
||||
required int ps,
|
||||
String keyword = '',
|
||||
String order = 'mtime',
|
||||
int type = 0}) async {
|
||||
static Future<LoadingState<FavDetailData>> userFavFolderDetail({
|
||||
required int mediaId,
|
||||
required int pn,
|
||||
required int ps,
|
||||
String keyword = '',
|
||||
FavOrderType order = FavOrderType.mtime,
|
||||
int type = 0,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.favResourceList,
|
||||
queryParameters: {
|
||||
@@ -62,7 +64,7 @@ class FavHttp {
|
||||
'pn': pn,
|
||||
'ps': ps,
|
||||
'keyword': keyword,
|
||||
'order': order,
|
||||
'order': order.name,
|
||||
'type': type,
|
||||
'tid': 0,
|
||||
'platform': 'web'
|
||||
|
||||
10
lib/models/common/fav_order_type.dart
Normal file
10
lib/models/common/fav_order_type.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
enum FavOrderType {
|
||||
mtime('最近收藏'),
|
||||
view('最多播放'),
|
||||
pubtime('最近投稿'),
|
||||
;
|
||||
|
||||
final String label;
|
||||
|
||||
const FavOrderType(this.label);
|
||||
}
|
||||
@@ -12,6 +12,8 @@ abstract class CommonSearchPageState<S extends CommonSearchPage, R, T>
|
||||
extends State<S> {
|
||||
CommonSearchController<R, T> get controller;
|
||||
|
||||
List<Widget>? extraActions;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -23,7 +25,8 @@ abstract class CommonSearchPageState<S extends CommonSearchPage, R, T>
|
||||
onPressed: controller.onRefresh,
|
||||
icon: const Icon(Icons.search_outlined, size: 22),
|
||||
),
|
||||
const SizedBox(width: 10)
|
||||
...?extraActions,
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
title: TextField(
|
||||
autofocus: true,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
||||
@@ -19,6 +20,7 @@ class FavDetailController
|
||||
late String heroTag;
|
||||
final Rx<FavFolderInfo> folderInfo = FavFolderInfo().obs;
|
||||
final Rx<bool?> isOwner = Rx<bool?>(null);
|
||||
final Rx<FavOrderType> order = FavOrderType.mtime.obs;
|
||||
|
||||
AccountService accountService = Get.find<AccountService>();
|
||||
|
||||
@@ -84,6 +86,7 @@ class FavDetailController
|
||||
pn: page,
|
||||
ps: 20,
|
||||
mediaId: mediaId,
|
||||
order: order.value,
|
||||
);
|
||||
|
||||
void onDelChecked(BuildContext context) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
||||
@@ -160,6 +161,24 @@ class _FavDetailPageState extends State<FavDetailPage> {
|
||||
icon: const Icon(Icons.share),
|
||||
);
|
||||
}),
|
||||
Obx(
|
||||
() {
|
||||
return PopupMenuButton<FavOrderType>(
|
||||
icon: const Icon(Icons.sort),
|
||||
initialValue: _favDetailController.order.value,
|
||||
tooltip: '排序方式',
|
||||
onSelected: (value) => _favDetailController
|
||||
..order.value = value
|
||||
..onReload(),
|
||||
itemBuilder: (context) => FavOrderType.values
|
||||
.map((e) => PopupMenuItem(
|
||||
value: e,
|
||||
child: Text(e.label),
|
||||
))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
PopupMenuButton(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
itemBuilder: (context) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:PiliPlus/http/fav.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
||||
import 'package:PiliPlus/pages/common/common_search_controller.dart';
|
||||
@@ -14,6 +15,8 @@ class FavSearchController
|
||||
dynamic count = Get.arguments['count'];
|
||||
dynamic title = Get.arguments['title'];
|
||||
|
||||
final Rx<FavOrderType> order = FavOrderType.mtime.obs;
|
||||
|
||||
@override
|
||||
Future<LoadingState<FavDetailData>> customGetData() =>
|
||||
FavHttp.userFavFolderDetail(
|
||||
@@ -22,6 +25,7 @@ class FavSearchController
|
||||
mediaId: mediaId,
|
||||
keyword: editController.text,
|
||||
type: type,
|
||||
order: order.value,
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/models/common/fav_order_type.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/data.dart';
|
||||
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
|
||||
import 'package:PiliPlus/pages/common/common_search_page.dart';
|
||||
@@ -24,6 +25,29 @@ class _FavSearchPageState extends CommonSearchPageState<FavSearchPage,
|
||||
tag: Utils.generateRandomString(8),
|
||||
);
|
||||
|
||||
@override
|
||||
List<Widget>? get extraActions => [
|
||||
Obx(
|
||||
() {
|
||||
return PopupMenuButton<FavOrderType>(
|
||||
icon: const Icon(Icons.sort),
|
||||
requestFocus: false,
|
||||
initialValue: controller.order.value,
|
||||
tooltip: '排序方式',
|
||||
onSelected: (value) => controller
|
||||
..order.value = value
|
||||
..onReload(),
|
||||
itemBuilder: (context) => FavOrderType.values
|
||||
.map((e) => PopupMenuItem(
|
||||
value: e,
|
||||
child: Text(e.label),
|
||||
))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget buildList(List<FavDetailItemModel> list) {
|
||||
return SliverGrid(
|
||||
|
||||
Reference in New Issue
Block a user