mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-29 20:48:40 +00:00
@@ -2,6 +2,8 @@ import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/member.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/member/archive_order_type_app.dart';
|
||||
import 'package:PiliPlus/models/common/member/archive_sort_type_app.dart';
|
||||
import 'package:PiliPlus/models/common/member/contribute_type.dart';
|
||||
import 'package:PiliPlus/models/common/video/source_type.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_archive/data.dart';
|
||||
@@ -23,17 +25,18 @@ class MemberVideoCtr
|
||||
required this.seriesId,
|
||||
this.username,
|
||||
this.title,
|
||||
});
|
||||
}) : isVideo = type == .video;
|
||||
|
||||
ContributeType type;
|
||||
final ContributeType type;
|
||||
final bool isVideo;
|
||||
int? seasonId;
|
||||
int? seriesId;
|
||||
final int mid;
|
||||
late RxString order = 'pubdate'.obs;
|
||||
late RxString sort = 'desc'.obs;
|
||||
RxInt count = (-1).obs;
|
||||
late ArchiveOrderTypeApp order = .pubdate;
|
||||
late ArchiveSortTypeApp sort = .desc;
|
||||
int? count;
|
||||
int? next;
|
||||
Rx<EpisodicButton> episodicButton = EpisodicButton().obs;
|
||||
EpisodicButton? episodicButton;
|
||||
final String? username;
|
||||
final String? title;
|
||||
|
||||
@@ -65,7 +68,7 @@ class MemberVideoCtr
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
if (type == ContributeType.video) {
|
||||
if (isVideo) {
|
||||
fromViewAid = Get.parameters['from_view_aid'];
|
||||
}
|
||||
page = 0;
|
||||
@@ -78,24 +81,18 @@ class MemberVideoCtr
|
||||
Success<SpaceArchiveData> response,
|
||||
) {
|
||||
final data = response.response;
|
||||
episodicButton
|
||||
..value = data.episodicButton ?? EpisodicButton()
|
||||
..refresh();
|
||||
episodicButton = data.episodicButton;
|
||||
next = data.next;
|
||||
if (page == 0 || isLoadPrevious) {
|
||||
hasPrev = data.hasPrev;
|
||||
}
|
||||
if (page == 0 || !isLoadPrevious) {
|
||||
if ((type == ContributeType.video
|
||||
? data.hasNext == false
|
||||
: data.next == 0) ||
|
||||
if ((isVideo ? data.hasNext == false : data.next == 0) ||
|
||||
data.item.isNullOrEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
count.value = type == ContributeType.season
|
||||
? (data.item?.length ?? -1)
|
||||
: (data.count ?? -1);
|
||||
count = type == .season ? data.item?.length : data.count;
|
||||
if (page != 0) {
|
||||
if (loadingState.value case Success(:final response)) {
|
||||
data.item ??= <SpaceArchiveItem>[];
|
||||
@@ -118,18 +115,18 @@ class MemberVideoCtr
|
||||
MemberHttp.spaceArchive(
|
||||
type: type,
|
||||
mid: mid,
|
||||
aid: type == ContributeType.video
|
||||
aid: isVideo
|
||||
? isLoadPrevious
|
||||
? firstAid
|
||||
: lastAid
|
||||
: null,
|
||||
order: type == ContributeType.video ? order.value : null,
|
||||
sort: type == ContributeType.video
|
||||
order: isVideo ? order : null,
|
||||
sort: isVideo
|
||||
? isLoadPrevious
|
||||
? 'asc'
|
||||
? .asc
|
||||
: null
|
||||
: sort.value,
|
||||
pn: type == ContributeType.charging ? page : null,
|
||||
: sort,
|
||||
pn: type == .charging ? page : null,
|
||||
next: next,
|
||||
seasonId: seasonId,
|
||||
seriesId: seriesId,
|
||||
@@ -138,17 +135,17 @@ class MemberVideoCtr
|
||||
|
||||
void queryBySort() {
|
||||
if (isLoading) return;
|
||||
if (type == ContributeType.video) {
|
||||
if (isVideo) {
|
||||
isLocating.value = false;
|
||||
order.value = order.value == 'pubdate' ? 'click' : 'pubdate';
|
||||
order = order == .pubdate ? .click : .pubdate;
|
||||
} else {
|
||||
sort.value = sort.value == 'desc' ? 'asc' : 'desc';
|
||||
sort = sort == .desc ? .asc : .desc;
|
||||
}
|
||||
onReload();
|
||||
}
|
||||
|
||||
Future<void> toViewPlayAll() async {
|
||||
final episodicButton = this.episodicButton.value;
|
||||
final episodicButton = this.episodicButton!;
|
||||
if (episodicButton.text == '继续播放' &&
|
||||
episodicButton.uri?.isNotEmpty == true) {
|
||||
final params = Uri.parse(episodicButton.uri!).queryParameters;
|
||||
@@ -167,7 +164,7 @@ class MemberVideoCtr
|
||||
'oid': oid,
|
||||
'favTitle':
|
||||
'$username: ${title ?? episodicButton.text ?? '播放全部'}',
|
||||
if (seriesId == null) 'count': count.value,
|
||||
if (seriesId == null) 'count': ?count,
|
||||
if (seasonId != null || seriesId != null)
|
||||
'mediaType': params['page_type'],
|
||||
'desc': params['desc'] == '1',
|
||||
@@ -190,9 +187,7 @@ class MemberVideoCtr
|
||||
bool desc = seasonId != null ? false : true;
|
||||
desc =
|
||||
(seasonId != null || seriesId != null) &&
|
||||
(type == ContributeType.video
|
||||
? order.value == 'click'
|
||||
: sort.value == 'asc')
|
||||
(isVideo ? order == .click : sort == .asc)
|
||||
? !desc
|
||||
: desc;
|
||||
PageUtils.toVideoPage(
|
||||
@@ -206,14 +201,13 @@ class MemberVideoCtr
|
||||
'oid': IdUtils.bv2av(element.bvid!),
|
||||
'favTitle':
|
||||
'$username: ${title ?? episodicButton.text ?? '播放全部'}',
|
||||
if (seriesId == null) 'count': count.value,
|
||||
if (seriesId == null) 'count': ?count,
|
||||
if (seasonId != null || seriesId != null)
|
||||
'mediaType': Uri.parse(
|
||||
episodicButton.uri!,
|
||||
).queryParameters['page_type'],
|
||||
'desc': desc,
|
||||
if (type == ContributeType.video)
|
||||
'sortField': order.value == 'click' ? 2 : 1,
|
||||
if (isVideo) 'sortField': order == .click ? 2 : 1,
|
||||
},
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -111,8 +111,7 @@ class _MemberVideoState extends State<MemberVideo>
|
||||
],
|
||||
),
|
||||
);
|
||||
if (widget.type == ContributeType.video &&
|
||||
_controller.fromViewAid?.isNotEmpty == true) {
|
||||
if (_controller.isVideo && _controller.fromViewAid?.isNotEmpty == true) {
|
||||
if (_index == null) {
|
||||
_scrollController =
|
||||
PrimaryScrollController.of(this.context)
|
||||
@@ -174,85 +173,11 @@ class _MemberVideoState extends State<MemberVideo>
|
||||
response != null && response.isNotEmpty
|
||||
? SliverMainAxisGroup(
|
||||
slivers: [
|
||||
SliverFloatingHeaderWidget(
|
||||
backgroundColor: theme.colorScheme.surface,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 2.5, 8, 2.5),
|
||||
child: Row(
|
||||
children: [
|
||||
Obx(
|
||||
() {
|
||||
final count = _controller.count.value;
|
||||
return Text(
|
||||
count != -1 ? '共$count视频' : '',
|
||||
style: const TextStyle(fontSize: 13),
|
||||
);
|
||||
},
|
||||
),
|
||||
Obx(
|
||||
() {
|
||||
final episodicButton =
|
||||
_controller.episodicButton.value;
|
||||
return episodicButton.uri?.isNotEmpty == true
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: _controller.count.value != -1
|
||||
? 6
|
||||
: 0,
|
||||
),
|
||||
child: TextButton.icon(
|
||||
style: Style.buttonStyle,
|
||||
onPressed: _controller.toViewPlayAll,
|
||||
icon: Icon(
|
||||
Icons.play_circle_outline_rounded,
|
||||
size: 16,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
label: Text(
|
||||
episodicButton.text ?? '播放全部',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
const Spacer(),
|
||||
TextButton.icon(
|
||||
style: Style.buttonStyle,
|
||||
onPressed: _controller.queryBySort,
|
||||
icon: Icon(
|
||||
Icons.sort,
|
||||
size: 16,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
label: Obx(
|
||||
() => Text(
|
||||
widget.type == ContributeType.video
|
||||
? _controller.order.value == 'pubdate'
|
||||
? '最新发布'
|
||||
: '最多播放'
|
||||
: _controller.sort.value == 'desc'
|
||||
? '默认'
|
||||
: '倒序',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildHeader(theme),
|
||||
SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
if (widget.type != ContributeType.season &&
|
||||
if (widget.type != .season &&
|
||||
index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
@@ -272,4 +197,79 @@ class _MemberVideoState extends State<MemberVideo>
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
Widget _buildHeader(ThemeData theme) {
|
||||
return SliverFloatingHeaderWidget(
|
||||
backgroundColor: theme.colorScheme.surface,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 2.5, 8, 2.5),
|
||||
child: Row(
|
||||
children: [
|
||||
?_buildCount(),
|
||||
?_buildEpisodeBtn(theme),
|
||||
const Spacer(),
|
||||
_buildSortBtn(theme),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget? _buildCount() {
|
||||
final count = _controller.count;
|
||||
if (count != null) {
|
||||
return Text(
|
||||
'共$count视频',
|
||||
style: const TextStyle(fontSize: 13),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Widget? _buildEpisodeBtn(ThemeData theme) {
|
||||
final episodicButton = _controller.episodicButton;
|
||||
if (episodicButton?.uri?.isNotEmpty ?? false) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: _controller.count != null ? 6 : 0,
|
||||
),
|
||||
child: TextButton.icon(
|
||||
style: Style.buttonStyle,
|
||||
onPressed: _controller.toViewPlayAll,
|
||||
icon: Icon(
|
||||
Icons.play_circle_outline_rounded,
|
||||
size: 16,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
label: Text(
|
||||
episodicButton?.text ?? '播放全部',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Widget _buildSortBtn(ThemeData theme) {
|
||||
return TextButton.icon(
|
||||
style: Style.buttonStyle,
|
||||
onPressed: _controller.queryBySort,
|
||||
icon: Icon(
|
||||
Icons.sort,
|
||||
size: 16,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
label: Text(
|
||||
_controller.isVideo ? _controller.order.label : _controller.sort.label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user