feat: 我的订阅新增播单支持

This commit is contained in:
orz12
2024-04-26 23:41:29 +08:00
parent c90f75de72
commit 30998611da
6 changed files with 100 additions and 37 deletions

View File

@@ -66,7 +66,8 @@ class SubController extends GetxController {
),
TextButton(
onPressed: () async {
var res = await UserHttp.cancelSub(seasonId: subFolderItem.id!);
var res = await UserHttp.cancelSub(
id: subFolderItem.id!, type: subFolderItem.type!);
if (res['status']) {
subFolderData.value.list!.remove(subFolderItem);
subFolderData.update((val) {});

View File

@@ -24,7 +24,7 @@ class SubItem extends StatelessWidget {
arguments: subFolderItem,
parameters: {
'heroTag': heroTag,
'seasonId': subFolderItem.id.toString(),
'id': subFolderItem.id.toString(),
},
),
child: Padding(
@@ -77,6 +77,14 @@ class VideoContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
// subFolderItem.type == 11播单
// subFolderItem.type == 21合集
// 其它:其它
String typeString = subFolderItem.type == 11
? '播单'
: subFolderItem.type == 21
? '合集'
: '其它:${subFolderItem.type}';
return Expanded(
child: Stack(
children: [
@@ -95,7 +103,7 @@ class VideoContent extends StatelessWidget {
),
const SizedBox(height: 2),
Text(
'合集 UP主${subFolderItem.upper!.name!}',
'[$typeString] UP主${subFolderItem.upper!.name!}',
textAlign: TextAlign.start,
style: TextStyle(
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,

View File

@@ -7,7 +7,7 @@ import '../../models/user/sub_folder.dart';
class SubDetailController extends GetxController {
late SubFolderItemData item;
late int seasonId;
late int id;
late String heroTag;
int currentPage = 1;
bool isLoadingMore = false;
@@ -15,12 +15,14 @@ class SubDetailController extends GetxController {
RxList<SubDetailMediaItem> subList = <SubDetailMediaItem>[].obs;
RxString loadingText = '加载中...'.obs;
int mediaCount = 0;
RxInt playCount = 0.obs;
@override
void onInit() {
item = Get.arguments;
if (playCount.value == 0) playCount.value = item.viewCount!;
if (Get.parameters.keys.isNotEmpty) {
seasonId = int.parse(Get.parameters['seasonId']!);
id = int.parse(Get.parameters['id']!);
heroTag = Get.parameters['heroTag']!;
}
super.onInit();
@@ -32,16 +34,28 @@ class SubDetailController extends GetxController {
return;
}
isLoadingMore = true;
var res = await UserHttp.userSubFolderDetail(
seasonId: seasonId,
ps: 20,
pn: currentPage,
);
late Map<String,dynamic> res;
if (item.type! == 11) {
res = await UserHttp.favResourceList(
id: id,
ps: 20,
pn: currentPage,
);
} else {
res = await UserHttp.favSeasonList(// item.type! == 21
id: id,
ps: 20,
pn: currentPage,
);
}
if (res['status']) {
subInfo.value = res['data'].info;
if (currentPage == 1 && type == 'init') {
subList.value = res['data'].medias;
mediaCount = res['data'].info.mediaCount;
if (item.type == 11) {
playCount.value = res['data'].info.cntInfo!['play'];
}
} else if (type == 'onLoad') {
subList.addAll(res['data'].medias);
}

View File

@@ -26,12 +26,12 @@ class _SubDetailPageState extends State<SubDetailPage> {
Get.put(SubDetailController());
late StreamController<bool> titleStreamC; // a
late Future _futureBuilderFuture;
late String seasonId;
late String id;
@override
void initState() {
super.initState();
seasonId = Get.parameters['seasonId']!;
id = Get.parameters['id']!;
_futureBuilderFuture = _subDetailController.queryUserSubFolderDetail();
titleStreamC = StreamController<bool>();
_controller.addListener(
@@ -162,14 +162,17 @@ class _SubDetailPageState extends State<SubDetailPage> {
),
),
const SizedBox(height: 4),
Text(
'${Utils.numFormat(_subDetailController.item.viewCount)}次播放',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
color: Theme.of(context).colorScheme.outline),
Obx(
() => Text(
'${Utils.numFormat(_subDetailController.playCount.value)}次播放',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelSmall!
.fontSize,
color:
Theme.of(context).colorScheme.outline),
),
),
],
),