mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-24 10:08:41 +00:00
@@ -43,6 +43,8 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
|
||||
|
||||
bool? hasSeasonOrSeries;
|
||||
|
||||
late bool hasCharge = false;
|
||||
|
||||
final fromViewAid = Get.parameters['from_view_aid'];
|
||||
|
||||
final key = GlobalKey<ExtendedNestedScrollViewState>();
|
||||
@@ -58,6 +60,7 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
|
||||
final data = response.response;
|
||||
username = data.card?.name ?? '';
|
||||
isFollowed = data.card?.relation?.isFollowed;
|
||||
hasCharge = (data.elec?.total ?? 0) > 0;
|
||||
if (data.relation == -1) {
|
||||
relation.value = 128;
|
||||
} else {
|
||||
|
||||
@@ -17,12 +17,15 @@ import 'package:PiliPlus/pages/member/controller.dart';
|
||||
import 'package:PiliPlus/pages/member/widget/medal_wall.dart';
|
||||
import 'package:PiliPlus/pages/member/widget/user_info_card.dart';
|
||||
import 'package:PiliPlus/pages/member_cheese/view.dart';
|
||||
import 'package:PiliPlus/pages/member_contribute/controller.dart';
|
||||
import 'package:PiliPlus/pages/member_contribute/view.dart';
|
||||
import 'package:PiliPlus/pages/member_dynamics/view.dart';
|
||||
import 'package:PiliPlus/pages/member_favorite/view.dart';
|
||||
import 'package:PiliPlus/pages/member_home/view.dart';
|
||||
import 'package:PiliPlus/pages/member_pgc/view.dart';
|
||||
import 'package:PiliPlus/pages/member_shop/view.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/archive/view.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/season_series/view.dart';
|
||||
import 'package:PiliPlus/utils/date_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
@@ -215,22 +218,35 @@ class _MemberPageState extends State<MemberPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () => Get.toNamed(
|
||||
'/upowerRank',
|
||||
parameters: {
|
||||
'mid': _userController.mid.toString(),
|
||||
},
|
||||
if (_userController.hasCharge)
|
||||
PopupMenuItem(
|
||||
onTap: () => Get.toNamed(
|
||||
'/upowerRank',
|
||||
parameters: {
|
||||
'mid': _userController.mid.toString(),
|
||||
},
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.electric_bolt, size: 19),
|
||||
SizedBox(width: 10),
|
||||
Text('充电排行榜'),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.electric_bolt, size: 19),
|
||||
SizedBox(width: 10),
|
||||
Text('充电排行榜'),
|
||||
],
|
||||
if (Get.isRegistered<MemberContributeCtr>(tag: _heroTag))
|
||||
PopupMenuItem(
|
||||
onTap: _toWebArchive,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.extension_outlined, size: 19),
|
||||
SizedBox(width: 10),
|
||||
Text('网页投稿'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_userController.account.isLogin)
|
||||
if (_userController.mid == _userController.account.mid) ...[
|
||||
if ((_userController
|
||||
@@ -456,4 +472,29 @@ class _MemberPageState extends State<MemberPage> {
|
||||
res.toast();
|
||||
}
|
||||
}
|
||||
|
||||
void _toWebArchive() {
|
||||
try {
|
||||
final ctr = Get.find<MemberContributeCtr>(tag: _heroTag);
|
||||
final item = ctr.items?[ctr.tabController?.index ?? 0];
|
||||
if (item != null) {
|
||||
final id = item.seasonId ?? item.seriesId;
|
||||
if (id != null) {
|
||||
MemberSSWeb.toMemberSSWeb(
|
||||
type: item.seasonId != null ? .season : .series,
|
||||
id: id,
|
||||
mid: _mid,
|
||||
name: _userController.username ?? '',
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
MemberVideoWeb.toMemberVideoWeb(
|
||||
mid: _mid,
|
||||
name: _userController.username ?? '',
|
||||
);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ class MemberSearchChildController extends CommonListController {
|
||||
mid: controller.mid,
|
||||
pn: page,
|
||||
keyword: controller.editingController.text,
|
||||
order: 'pubdate',
|
||||
),
|
||||
MemberSearchType.dynamic => MemberHttp.dynSearch(
|
||||
mid: controller.mid,
|
||||
|
||||
@@ -71,47 +71,43 @@ class _MemberSearchChildPageState extends State<MemberSearchChildPage>
|
||||
Loading() => _buildLoading,
|
||||
Success(:final response) =>
|
||||
response != null && response.isNotEmpty
|
||||
? Builder(
|
||||
builder: (context) {
|
||||
return switch (widget.searchType) {
|
||||
MemberSearchType.archive => SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
return VideoCardH(
|
||||
videoItem: response[index],
|
||||
);
|
||||
},
|
||||
itemCount: response.length,
|
||||
),
|
||||
MemberSearchType.dynamic =>
|
||||
GlobalData().dynamicsWaterfallFlow
|
||||
? SliverWaterfallFlow(
|
||||
gridDelegate: dynGridDelegate,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
return DynamicPanel(item: response[index]);
|
||||
},
|
||||
childCount: response.length,
|
||||
),
|
||||
)
|
||||
: SliverList.builder(
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
return DynamicPanel(item: response[index]);
|
||||
},
|
||||
itemCount: response.length,
|
||||
),
|
||||
};
|
||||
},
|
||||
)
|
||||
? switch (widget.searchType) {
|
||||
MemberSearchType.archive => SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
return VideoCardH(
|
||||
videoItem: response[index],
|
||||
);
|
||||
},
|
||||
itemCount: response.length,
|
||||
),
|
||||
MemberSearchType.dynamic =>
|
||||
GlobalData().dynamicsWaterfallFlow
|
||||
? SliverWaterfallFlow(
|
||||
gridDelegate: dynGridDelegate,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(_, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
return DynamicPanel(item: response[index]);
|
||||
},
|
||||
childCount: response.length,
|
||||
),
|
||||
)
|
||||
: SliverList.builder(
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
return DynamicPanel(item: response[index]);
|
||||
},
|
||||
itemCount: response.length,
|
||||
),
|
||||
}
|
||||
: HttpError(onReload: _controller.onReload),
|
||||
Error(:final errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
63
lib/pages/member_video_web/archive/controller.dart
Normal file
63
lib/pages/member_video_web/archive/controller.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/member.dart';
|
||||
import 'package:PiliPlus/models/common/member/archive_order_type_web.dart';
|
||||
import 'package:PiliPlus/models_new/member/search_archive/data.dart';
|
||||
import 'package:PiliPlus/models_new/member/search_archive/slist.dart';
|
||||
import 'package:PiliPlus/models_new/member/search_archive/vlist.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/base/controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MemberVideoWebCtr
|
||||
extends
|
||||
BaseVideoWebCtr<
|
||||
SearchArchiveData,
|
||||
VListItemModel,
|
||||
ArchiveOrderTypeWeb
|
||||
> {
|
||||
int? _totalCount;
|
||||
@override
|
||||
final Rx<ArchiveOrderTypeWeb> order = Rx(.pubdate);
|
||||
|
||||
int tid = 0;
|
||||
String? specialType;
|
||||
List<ListTag>? tags;
|
||||
|
||||
@override
|
||||
List<VListItemModel>? getDataList(SearchArchiveData response) {
|
||||
return response.list?.vlist;
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(
|
||||
bool isRefresh,
|
||||
Success<SearchArchiveData> response,
|
||||
) {
|
||||
if (isRefresh) {
|
||||
final data = response.response;
|
||||
if (data.page?.count case final count?) {
|
||||
if (tid == 0 && specialType == null) {
|
||||
_totalCount = count;
|
||||
}
|
||||
this.count = count;
|
||||
totalPage = (count / ps).ceil();
|
||||
}
|
||||
final tags = data.list?.tags;
|
||||
if (tags?.isNotEmpty ?? false) {
|
||||
this.tags = tags!
|
||||
..insert(0, ListTag(tid: 0, name: '全部类型', count: _totalCount));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<SearchArchiveData>> customGetData() =>
|
||||
MemberHttp.searchArchive(
|
||||
mid: mid,
|
||||
ps: ps,
|
||||
pn: page,
|
||||
order: order.value,
|
||||
tid: tid,
|
||||
specialType: specialType,
|
||||
);
|
||||
}
|
||||
87
lib/pages/member_video_web/archive/view.dart
Normal file
87
lib/pages/member_video_web/archive/view.dart
Normal file
@@ -0,0 +1,87 @@
|
||||
import 'package:PiliPlus/common/widgets/self_sized_horizontal_list.dart';
|
||||
import 'package:PiliPlus/common/widgets/sliver/sliver_pinned_header.dart';
|
||||
import 'package:PiliPlus/models/common/member/archive_order_type_web.dart';
|
||||
import 'package:PiliPlus/models_new/member/search_archive/data.dart';
|
||||
import 'package:PiliPlus/models_new/member/search_archive/vlist.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/archive/controller.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/base/view.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MemberVideoWeb extends StatefulWidget {
|
||||
const MemberVideoWeb({super.key});
|
||||
|
||||
@override
|
||||
State<MemberVideoWeb> createState() => _MemberVideoWebState();
|
||||
|
||||
static Future<void>? toMemberVideoWeb({
|
||||
required Object mid,
|
||||
required String name,
|
||||
}) {
|
||||
return Get.toNamed(
|
||||
'/videoWeb',
|
||||
arguments: {
|
||||
'mid': mid,
|
||||
'name': name,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MemberVideoWebState
|
||||
extends
|
||||
BaseVideoWebState<
|
||||
MemberVideoWeb,
|
||||
SearchArchiveData,
|
||||
VListItemModel,
|
||||
ArchiveOrderTypeWeb
|
||||
>
|
||||
with GridMixin {
|
||||
@override
|
||||
late final MemberVideoWebCtr controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = Get.put(MemberVideoWebCtr(), tag: name);
|
||||
}
|
||||
|
||||
@override
|
||||
List<ArchiveOrderTypeWeb> get values => ArchiveOrderTypeWeb.values;
|
||||
|
||||
@override
|
||||
Widget? buildTags(ColorScheme colorScheme) {
|
||||
if (controller.tags case final tags?) {
|
||||
return SliverPinnedHeader(
|
||||
backgroundColor: colorScheme.surface,
|
||||
child: SelfSizedHorizontalList(
|
||||
itemCount: tags.length,
|
||||
padding: const .fromLTRB(10, 0, 10, 8),
|
||||
itemBuilder: (context, index) {
|
||||
final item = tags[index];
|
||||
final isCurr = controller.specialType != null
|
||||
? item.specialType == controller.specialType
|
||||
: item.tid == controller.tid;
|
||||
return SearchText(
|
||||
padding: const .symmetric(horizontal: 8, vertical: 4),
|
||||
text: '${item.name!} ${item.count}',
|
||||
bgColor: isCurr ? colorScheme.secondaryContainer : null,
|
||||
textColor: isCurr ? colorScheme.onSecondaryContainer : null,
|
||||
onTap: (_) {
|
||||
if (isCurr) return;
|
||||
controller
|
||||
..tid = item.tid ?? 0
|
||||
..specialType = item.specialType
|
||||
..onReload();
|
||||
},
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, _) => const SizedBox(width: 10),
|
||||
),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
50
lib/pages/member_video_web/base/controller.dart
Normal file
50
lib/pages/member_video_web/base/controller.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart' show ReloadMixin;
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/common/common_list_controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
const int ps = 30;
|
||||
|
||||
abstract class BaseVideoWebCtr<R, T, V> extends CommonListController<R, T>
|
||||
with ReloadMixin {
|
||||
final Object mid = Get.arguments['mid'];
|
||||
|
||||
int? totalPage;
|
||||
int? count;
|
||||
Rx<V> get order;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
void checkIsEnd(int length) {
|
||||
if (totalPage != null && page >= totalPage!) {
|
||||
isEnd = true;
|
||||
} else if (count != null && length >= count!) {
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
|
||||
void queryBySort(V value) {
|
||||
if (isLoading) return;
|
||||
order.value = value;
|
||||
onReload();
|
||||
}
|
||||
|
||||
void jumpToPage(int page) {
|
||||
isEnd = false;
|
||||
reload = true;
|
||||
this.page = page;
|
||||
loadingState.value = LoadingState.loading();
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onReload() {
|
||||
reload = true;
|
||||
return super.onReload();
|
||||
}
|
||||
}
|
||||
217
lib/pages/member_video_web/base/view.dart
Normal file
217
lib/pages/member_video_web/base/view.dart
Normal file
@@ -0,0 +1,217 @@
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||
import 'package:PiliPlus/common/widgets/sliver/sliver_pinned_header.dart';
|
||||
import 'package:PiliPlus/common/widgets/video_card/video_card_h.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/common/enum_with_label.dart';
|
||||
import 'package:PiliPlus/models/model_video.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/base/controller.dart';
|
||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
abstract class BaseVideoWebState<
|
||||
S extends StatefulWidget,
|
||||
R,
|
||||
T extends BaseVideoItemModel,
|
||||
V extends EnumWithLabel
|
||||
>
|
||||
extends State<S>
|
||||
with GridMixin {
|
||||
late final String name;
|
||||
BaseVideoWebCtr<R, T, V> get controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final args = Get.arguments;
|
||||
name = args['name'];
|
||||
}
|
||||
|
||||
List<V> get values;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = ColorScheme.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(name),
|
||||
actions: [
|
||||
Obx(
|
||||
() {
|
||||
final order = controller.order.value;
|
||||
return PopupMenuButton<V>(
|
||||
tooltip: '排序',
|
||||
icon: const Icon(Icons.sort),
|
||||
initialValue: order,
|
||||
onSelected: controller.queryBySort,
|
||||
itemBuilder: (_) => values
|
||||
.map((e) => PopupMenuItem(value: e, child: Text(e.label)))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
body: refreshIndicator(
|
||||
onRefresh: controller.onRefresh,
|
||||
child: CustomScrollView(
|
||||
physics: ReloadScrollPhysics(controller: controller),
|
||||
slivers: [
|
||||
SliverPadding(
|
||||
padding: .only(
|
||||
bottom: MediaQuery.viewPaddingOf(context).bottom + 100,
|
||||
),
|
||||
sliver: Obx(
|
||||
() => buildBody(colorScheme, controller.loadingState.value),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildBody(
|
||||
ColorScheme colorScheme,
|
||||
LoadingState<List<T>?> loadingState,
|
||||
) {
|
||||
return switch (loadingState) {
|
||||
Loading() => gridSkeleton,
|
||||
Success(:final response) =>
|
||||
response != null && response.isNotEmpty
|
||||
? SliverMainAxisGroup(
|
||||
slivers: [
|
||||
buildHeader(colorScheme),
|
||||
?buildTags(colorScheme),
|
||||
SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
itemCount: response.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1) {
|
||||
controller.onLoadMore();
|
||||
}
|
||||
return VideoCardH(videoItem: response[index]);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: HttpError(onReload: controller.onReload),
|
||||
Error(:final errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: controller.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
Widget? buildTags(ColorScheme colorScheme) => null;
|
||||
|
||||
Widget buildHeader(ColorScheme colorScheme) {
|
||||
return SliverPinnedHeader(
|
||||
backgroundColor: colorScheme.surface,
|
||||
child: Padding(
|
||||
padding: const .fromLTRB(14, 0, 8, 4),
|
||||
child: Stack(
|
||||
alignment: .centerLeft,
|
||||
children: [
|
||||
?buildCount(),
|
||||
Center(child: buildPageBtn(colorScheme)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget? buildCount() {
|
||||
final count = controller.count;
|
||||
if (count == null) return null;
|
||||
return Text(
|
||||
'共 $count 视频',
|
||||
style: const TextStyle(height: 1),
|
||||
strutStyle: const StrutStyle(leading: 0, height: 1),
|
||||
);
|
||||
}
|
||||
|
||||
Widget? buildPageBtn(ColorScheme colorScheme) {
|
||||
final totalPage = controller.totalPage;
|
||||
if (totalPage == null) return null;
|
||||
final page = controller.page - 1;
|
||||
final canBackward = page > 1;
|
||||
final canForward = page < totalPage;
|
||||
const size = 30.0;
|
||||
const iconSize = 24.0;
|
||||
|
||||
final backwardBtn = iconButton(
|
||||
size: size,
|
||||
iconSize: iconSize,
|
||||
tooltip: canBackward ? '上一页' : null,
|
||||
icon: const Icon(Icons.keyboard_arrow_left),
|
||||
onPressed: canBackward ? () => controller.jumpToPage(page - 1) : null,
|
||||
);
|
||||
|
||||
final forwardBtn = iconButton(
|
||||
size: size,
|
||||
iconSize: iconSize,
|
||||
tooltip: canForward ? '下一页' : null,
|
||||
icon: const Icon(Icons.keyboard_arrow_right),
|
||||
onPressed: canForward ? () => controller.jumpToPage(page + 1) : null,
|
||||
);
|
||||
|
||||
final pageIndicator = SearchText(
|
||||
height: 1,
|
||||
text: '$page / $totalPage',
|
||||
borderRadius: const .all(.circular(4)),
|
||||
padding: const .symmetric(horizontal: 10, vertical: 5),
|
||||
onTap: (_) => showJumpDialog(page),
|
||||
);
|
||||
|
||||
return Row(
|
||||
spacing: 6,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
backwardBtn,
|
||||
pageIndicator,
|
||||
forwardBtn,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void showJumpDialog(int page) {
|
||||
var pageStr = page.toString();
|
||||
|
||||
void onSubmit([_]) {
|
||||
try {
|
||||
controller.jumpToPage(int.parse(pageStr));
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
showConfirmDialog(
|
||||
context: context,
|
||||
title: const Text('跳至: '),
|
||||
content: TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: pageStr,
|
||||
onChanged: (value) => pageStr = value,
|
||||
decoration: const InputDecoration(
|
||||
labelText: '页数',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
onFieldSubmitted: (_) {
|
||||
Get.back();
|
||||
onSubmit();
|
||||
},
|
||||
),
|
||||
onConfirm: onSubmit,
|
||||
);
|
||||
}
|
||||
}
|
||||
55
lib/pages/member_video_web/season_series/controller.dart
Normal file
55
lib/pages/member_video_web/season_series/controller.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/member.dart';
|
||||
import 'package:PiliPlus/models/common/member/archive_sort_type_app.dart';
|
||||
import 'package:PiliPlus/models/common/member/web_ss_type.dart';
|
||||
import 'package:PiliPlus/models_new/member/season_web/archive.dart';
|
||||
import 'package:PiliPlus/models_new/member/season_web/data.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/base/controller.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MemberSSWebCtr
|
||||
extends BaseVideoWebCtr<SeasonWebData, SeasonArchive, ArchiveSortTypeApp> {
|
||||
@override
|
||||
final Rx<ArchiveSortTypeApp> order = Rx(.desc);
|
||||
late final WebSsType _type;
|
||||
late final Object _id;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
final args = Get.arguments;
|
||||
_type = args['type'];
|
||||
_id = args['id'];
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
List<SeasonArchive>? getDataList(SeasonWebData response) {
|
||||
return response.archives;
|
||||
}
|
||||
|
||||
@override
|
||||
bool customHandleResponse(
|
||||
bool isRefresh,
|
||||
Success<SeasonWebData> response,
|
||||
) {
|
||||
if (isRefresh) {
|
||||
final data = response.response;
|
||||
if (data.page?.total case final total?) {
|
||||
count = total;
|
||||
totalPage = (total / ps).ceil();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState<SeasonWebData>> customGetData() =>
|
||||
MemberHttp.seasonSeriesWeb(
|
||||
type: _type,
|
||||
mid: mid,
|
||||
id: _id,
|
||||
ps: ps,
|
||||
pn: page,
|
||||
sort: order.value,
|
||||
);
|
||||
}
|
||||
55
lib/pages/member_video_web/season_series/view.dart
Normal file
55
lib/pages/member_video_web/season_series/view.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import 'package:PiliPlus/models/common/member/archive_sort_type_app.dart';
|
||||
import 'package:PiliPlus/models/common/member/web_ss_type.dart';
|
||||
import 'package:PiliPlus/models_new/member/season_web/archive.dart';
|
||||
import 'package:PiliPlus/models_new/member/season_web/data.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/base/view.dart';
|
||||
import 'package:PiliPlus/pages/member_video_web/season_series/controller.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MemberSSWeb extends StatefulWidget {
|
||||
const MemberSSWeb({super.key});
|
||||
|
||||
@override
|
||||
State<MemberSSWeb> createState() => _MemberSSWebState();
|
||||
|
||||
static Future<void>? toMemberSSWeb({
|
||||
required WebSsType type,
|
||||
required Object id,
|
||||
required Object mid,
|
||||
required String name,
|
||||
}) {
|
||||
return Get.toNamed(
|
||||
'/ssWeb',
|
||||
arguments: {
|
||||
'type': type,
|
||||
'id': id,
|
||||
'mid': mid,
|
||||
'name': name,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MemberSSWebState
|
||||
extends
|
||||
BaseVideoWebState<
|
||||
MemberSSWeb,
|
||||
SeasonWebData,
|
||||
SeasonArchive,
|
||||
ArchiveSortTypeApp
|
||||
>
|
||||
with GridMixin {
|
||||
@override
|
||||
late final MemberSSWebCtr controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = Get.put(MemberSSWebCtr(), tag: name);
|
||||
}
|
||||
|
||||
@override
|
||||
List<ArchiveSortTypeApp> get values => ArchiveSortTypeApp.values;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/member.dart';
|
||||
import 'package:PiliPlus/models/common/member/contribute_type.dart';
|
||||
import 'package:PiliPlus/models/common/member/archive_order_type_app.dart';
|
||||
import 'package:PiliPlus/models/member/info.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_archive/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_archive/item.dart';
|
||||
@@ -55,7 +55,7 @@ class HorizontalMemberPageController
|
||||
@override
|
||||
bool customHandleResponse(bool isRefresh, Success response) {
|
||||
SpaceArchiveData data = response.response;
|
||||
count.value = data.count ?? -1;
|
||||
count = data.count;
|
||||
if (isRefresh) {
|
||||
if (isLoadPrevious) {
|
||||
hasPrev = data.hasPrev ?? false;
|
||||
@@ -83,8 +83,8 @@ class HorizontalMemberPageController
|
||||
String? currAid;
|
||||
String? firstAid;
|
||||
String? lastAid;
|
||||
RxString order = 'pubdate'.obs;
|
||||
RxInt count = (-1).obs;
|
||||
ArchiveOrderTypeApp order = .pubdate;
|
||||
int? count;
|
||||
bool isLoadPrevious = false;
|
||||
bool hasPrev = true;
|
||||
bool hasNext = true;
|
||||
@@ -92,15 +92,15 @@ class HorizontalMemberPageController
|
||||
@override
|
||||
Future<LoadingState<SpaceArchiveData>> customGetData() =>
|
||||
MemberHttp.spaceArchive(
|
||||
type: ContributeType.video,
|
||||
type: .video,
|
||||
mid: mid,
|
||||
aid: page == 1
|
||||
? currAid
|
||||
: isLoadPrevious
|
||||
? firstAid
|
||||
: lastAid,
|
||||
order: order.value,
|
||||
sort: page != 1 && isLoadPrevious ? 'asc' : null,
|
||||
order: order,
|
||||
sort: page != 1 && isLoadPrevious ? .asc : null,
|
||||
pn: null,
|
||||
next: null,
|
||||
seasonId: null,
|
||||
@@ -131,7 +131,7 @@ class HorizontalMemberPageController
|
||||
|
||||
void queryBySort() {
|
||||
if (isLoading) return;
|
||||
order.value = order.value == 'pubdate' ? 'click' : 'pubdate';
|
||||
order = order == .pubdate ? .click : .pubdate;
|
||||
onReload();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,40 +128,45 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Obx(
|
||||
() {
|
||||
final count = _controller.count.value;
|
||||
return Text(
|
||||
count != -1 ? '共$count视频' : '',
|
||||
style: const TextStyle(fontSize: 13),
|
||||
);
|
||||
},
|
||||
),
|
||||
TextButton.icon(
|
||||
style: Style.buttonStyle,
|
||||
onPressed: () => _controller
|
||||
..lastAid = widget.videoDetailController.aid.toString()
|
||||
..queryBySort(),
|
||||
icon: Icon(
|
||||
Icons.sort,
|
||||
size: 16,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
label: Obx(
|
||||
() => Text(
|
||||
_controller.order.value == 'pubdate' ? '最新发布' : '最多播放',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
?_buildCount(),
|
||||
_buildSortBtn(theme),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget? _buildCount() {
|
||||
final count = _controller.count;
|
||||
if (count != null) {
|
||||
return Text(
|
||||
'共$count视频',
|
||||
style: const TextStyle(fontSize: 13),
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Widget _buildSortBtn(ThemeData theme) {
|
||||
return TextButton.icon(
|
||||
style: Style.buttonStyle,
|
||||
onPressed: () => _controller
|
||||
..lastAid = widget.videoDetailController.aid.toString()
|
||||
..queryBySort(),
|
||||
icon: Icon(
|
||||
Icons.sort,
|
||||
size: 16,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
label: Text(
|
||||
_controller.order.label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildVideoList(
|
||||
ThemeData theme,
|
||||
LoadingState<List<SpaceArchiveItem>?> loadingState,
|
||||
|
||||
Reference in New Issue
Block a user