opt: enum (#824)

* opt: enum

* opt: member page type
This commit is contained in:
My-Responsitories
2025-05-06 00:18:30 +08:00
committed by GitHub
parent 1da30d5d8f
commit a915650bb6
24 changed files with 211 additions and 291 deletions

View File

@@ -145,8 +145,7 @@ class HistoryItem extends StatelessWidget {
width: maxWidth,
height: maxHeight,
),
if (!HistoryBusinessType
.hiddenDurationType.hiddenDurationType
if (!HistoryBusinessType.hiddenDurationType
.contains(videoItem.history.business))
PBadge(
text: videoItem.progress == -1
@@ -157,7 +156,7 @@ class HistoryItem extends StatelessWidget {
type: 'gray',
),
// 右上角
if (HistoryBusinessType.showBadge.showBadge
if (HistoryBusinessType.showBadge
.contains(videoItem.history.business) ||
videoItem.history.business ==
HistoryBusinessType.live.type)

View File

@@ -16,7 +16,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
class MemberController extends CommonDataController<SpaceData, dynamic>
class MemberController extends CommonDataController<SpaceData, SpaceData?>
with GetTickerProviderStateMixin {
MemberController({required this.mid});
int mid;
@@ -141,7 +141,7 @@ class MemberController extends CommonDataController<SpaceData, dynamic>
);
showUname.value = true;
username = errMsg;
loadingState.value = LoadingState.success(null);
loadingState.value = LoadingState<SpaceData?>.success(null);
return true;
}

View File

@@ -40,20 +40,19 @@ class _MemberHomeState extends State<MemberHome>
return _buildBody(_ctr.loadingState.value);
}
Widget _buildBody(LoadingState loadingState) {
Widget _buildBody(LoadingState<SpaceData?> loadingState) {
final isVertical = context.orientation == Orientation.portrait;
return switch (loadingState) {
Loading() => loadingWidget,
Success() => loadingState.response is SpaceData
Success(response: final res) => res != null
? CustomScrollView(
slivers: [
if (loadingState.response?.archive?.item?.isNotEmpty ==
true) ...[
if (res.archive?.item?.isNotEmpty == true) ...[
_videoHeader(
title: '视频',
param: 'contribute',
param1: 'video',
count: loadingState.response.archive.count,
count: res.archive!.count!,
),
SliverPadding(
padding: const EdgeInsets.symmetric(
@@ -71,38 +70,35 @@ class _MemberHomeState extends State<MemberHome>
delegate: SliverChildBuilderDelegate(
(context, index) {
return VideoCardVMemberHome(
videoItem:
loadingState.response.archive.item[index],
videoItem: res.archive!.item![index],
);
},
childCount: min(isVertical ? 4 : 8,
loadingState.response.archive.item.length),
childCount:
min(isVertical ? 4 : 8, res.archive!.item!.length),
),
),
),
],
if (loadingState.response?.favourite2?.item?.isNotEmpty ==
true) ...[
if (res.favourite2?.item?.isNotEmpty == true) ...[
_videoHeader(
title: '收藏',
param: 'favorite',
count: loadingState.response.favourite2.count,
count: res.favourite2!.count!,
),
SliverToBoxAdapter(
child: SizedBox(
height: 98,
child: MemberFavItem(
item: loadingState.response.favourite2.item.first,
item: res.favourite2!.item!.first,
),
),
),
],
if (loadingState.response?.coinArchive?.item?.isNotEmpty ==
true) ...[
if (res.coinArchive?.item?.isNotEmpty == true) ...[
_videoHeader(
title: '最近投币的视频',
param: 'coinArchive',
count: loadingState.response.coinArchive.count,
count: res.coinArchive!.count!,
),
SliverPadding(
padding: const EdgeInsets.symmetric(
@@ -120,22 +116,20 @@ class _MemberHomeState extends State<MemberHome>
delegate: SliverChildBuilderDelegate(
(context, index) {
return VideoCardVMemberHome(
videoItem:
loadingState.response.coinArchive.item[index],
videoItem: res.coinArchive!.item![index],
);
},
childCount: min(isVertical ? 2 : 4,
loadingState.response.coinArchive.item.length),
childCount: min(
isVertical ? 2 : 4, res.coinArchive!.item!.length),
),
),
),
],
if (loadingState.response?.likeArchive?.item?.isNotEmpty ==
true) ...[
if (res.likeArchive?.item?.isNotEmpty == true) ...[
_videoHeader(
title: '最近点赞的视频',
param: 'likeArchive',
count: loadingState.response.likeArchive.count,
count: res.likeArchive!.count!,
),
SliverPadding(
padding: const EdgeInsets.symmetric(
@@ -153,54 +147,48 @@ class _MemberHomeState extends State<MemberHome>
delegate: SliverChildBuilderDelegate(
(context, index) {
return VideoCardVMemberHome(
videoItem:
loadingState.response.likeArchive.item[index],
videoItem: res.likeArchive!.item![index],
);
},
childCount: min(isVertical ? 2 : 4,
loadingState.response.likeArchive.item.length),
childCount: min(
isVertical ? 2 : 4, res.likeArchive!.item!.length),
),
),
),
],
if (loadingState.response?.article?.item?.isNotEmpty ==
true) ...[
if (res.article?.item?.isNotEmpty == true) ...[
_videoHeader(
title: '专栏',
param: 'contribute',
param1: 'article',
count: loadingState.response.article.count,
count: res.article!.count!,
),
SliverGrid(
gridDelegate: Grid.videoCardHDelegate(context),
delegate: SliverChildBuilderDelegate(
(context, index) {
return MemberArticleItem(
item: loadingState.response.article.item[index],
item: res.article!.item![index],
);
},
childCount: isVertical
? 1
: loadingState.response.article.item.length,
childCount: isVertical ? 1 : res.article!.item!.length,
),
),
],
if (loadingState.response?.audios?.item?.isNotEmpty ==
true) ...[
if (res.audios?.item?.isNotEmpty == true) ...[
_videoHeader(
title: '音频',
param: 'contribute',
param1: 'audio',
count: loadingState.response.audios.count,
count: res.audios!.count!,
),
// TODO
],
if (loadingState.response?.season?.item?.isNotEmpty ==
true) ...[
if (res.season?.item?.isNotEmpty == true) ...[
_videoHeader(
title: '追番',
param: 'bangumi',
count: loadingState.response.season.count,
count: res.season!.count!,
),
SliverPadding(
padding: const EdgeInsets.symmetric(
@@ -218,12 +206,11 @@ class _MemberHomeState extends State<MemberHome>
delegate: SliverChildBuilderDelegate(
(context, index) {
return BangumiCardVMemberHome(
bangumiItem:
loadingState.response.season.item[index],
bangumiItem: res.season!.item![index],
);
},
childCount: min(isVertical ? 3 : 6,
loadingState.response.season.item.length),
childCount:
min(isVertical ? 3 : 6, res.season!.item!.length),
),
),
),

View File

@@ -19,8 +19,8 @@ import 'package:PiliPlus/models/common/reply/reply_sort_type.dart';
import 'package:PiliPlus/models/common/settings_type.dart';
import 'package:PiliPlus/models/common/super_resolution_type.dart';
import 'package:PiliPlus/models/common/theme/theme_type.dart';
import 'package:PiliPlus/models/common/video/CDN.dart';
import 'package:PiliPlus/models/common/video/audio_quality.dart';
import 'package:PiliPlus/models/common/video/cdn_type.dart';
import 'package:PiliPlus/models/common/video/live_quality.dart';
import 'package:PiliPlus/models/common/video/subtitle_pref_type.dart';
import 'package:PiliPlus/models/common/video/video_decode_type.dart';
@@ -1029,7 +1029,7 @@ List<SettingsModel> get videoSettings => [
title: 'CDN 设置',
leading: Icon(MdiIcons.cloudPlusOutline),
getSubtitle: () =>
'当前使用:${CDNServiceCode.fromCode(GStorage.defaultCDNService)!.description},部分 CDN 可能失效,如无法播放请尝试切换',
'当前使用:${CDNService.fromCode(GStorage.defaultCDNService).description},部分 CDN 可能失效,如无法播放请尝试切换',
onTap: (setState) async {
String? result = await showDialog(
context: Get.context!,

View File

@@ -2,7 +2,7 @@ import 'dart:async';
import 'package:PiliPlus/http/constants.dart';
import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/models/common/video/CDN.dart';
import 'package:PiliPlus/models/common/video/cdn_type.dart';
import 'package:PiliPlus/models/video/play/url.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/video_utils.dart';

View File

@@ -6,8 +6,8 @@ import 'package:PiliPlus/common/widgets/button/icon_button.dart';
import 'package:PiliPlus/common/widgets/self_sized_horizontal_list.dart';
import 'package:PiliPlus/models/common/search_type.dart';
import 'package:PiliPlus/models/common/super_resolution_type.dart';
import 'package:PiliPlus/models/common/video/CDN.dart';
import 'package:PiliPlus/models/common/video/audio_quality.dart';
import 'package:PiliPlus/models/common/video/cdn_type.dart';
import 'package:PiliPlus/models/common/video/video_decode_type.dart';
import 'package:PiliPlus/models/common/video/video_quality.dart';
import 'package:PiliPlus/models/video/play/url.dart';
@@ -253,7 +253,7 @@ class HeaderControlState extends State<HeaderControl> {
title: const Text('CDN 设置', style: titleStyle),
leading: Icon(MdiIcons.cloudPlusOutline, size: 20),
subtitle: Text(
'当前:${CDNServiceCode.fromCode(defaultCDNService)!.description},无法播放请切换',
'当前:${CDNService.fromCode(defaultCDNService).description},无法播放请切换',
style: subTitleStyle,
),
onTap: () async {
@@ -269,7 +269,7 @@ class HeaderControlState extends State<HeaderControl> {
defaultCDNService = result;
setting.put(SettingBoxKey.CDNService, result);
SmartDialog.showToast(
'已设置为 ${CDNServiceCode.fromCode(result)!.description},正在重载视频');
'已设置为 ${CDNService.fromCode(result).description},正在重载视频');
setState(() {});
videoDetailCtr.queryVideoUrl(
videoDetailCtr.playedTime,