diff --git a/lib/models/common/account_type.dart b/lib/models/common/account_type.dart index 1401fc9c2..03a1974d1 100644 --- a/lib/models/common/account_type.dart +++ b/lib/models/common/account_type.dart @@ -1,10 +1,9 @@ enum AccountType { - main, - heartbeat, - recommend, - video, -} + main('主账号'), + heartbeat('记录观看'), + recommend('推荐'), + video('视频取流'); -extension AccountTypeExt on AccountType { - String get title => const ['主账号', '记录观看', '推荐', '视频取流'][index]; + final String title; + const AccountType(this.title); } diff --git a/lib/models/common/audio_normalization.dart b/lib/models/common/audio_normalization.dart index 4fb635dff..d4c6b8eb0 100644 --- a/lib/models/common/audio_normalization.dart +++ b/lib/models/common/audio_normalization.dart @@ -1,13 +1,11 @@ -enum AudioNormalization { disable, dynaudnorm, loudnorm, custom } +enum AudioNormalization { + disable('禁用'), + // ref https://github.com/KRTirtho/spotube/commit/da10ab2e291d4ba4d3082b9a6ae535639fb8f1b7 + dynaudnorm('预设 dynaudnorm', 'dynaudnorm=g=5:f=250:r=0.9:p=0.5'), + loudnorm('预设 loudnorm', 'loudnorm=I=-16:LRA=11:TP=-1.5'), + custom('自定义参数'); -extension AudioNormalizationExt on AudioNormalization { - String get title => - const ['禁用', '预设 dynaudnorm', '预设 loudnorm', '自定义参数'][index]; - String get param => const [ - '', - // ref https://github.com/KRTirtho/spotube/commit/da10ab2e291d4ba4d3082b9a6ae535639fb8f1b7 - 'dynaudnorm=g=5:f=250:r=0.9:p=0.5', - 'loudnorm=I=-16:LRA=11:TP=-1.5', - '', - ][index]; + final String title; + final String param; + const AudioNormalization(this.title, [this.param = '']); } diff --git a/lib/models/common/avatar_badge_type.dart b/lib/models/common/avatar_badge_type.dart index 56379c34f..02a1f8ef5 100644 --- a/lib/models/common/avatar_badge_type.dart +++ b/lib/models/common/avatar_badge_type.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; -enum BadgeType { none, vip, person, institution } +enum BadgeType { + none(), + vip('大会员'), + person('认证个人', Color(0xFFFFCC00)), + institution('认证机构', Colors.lightBlueAccent); -extension BadgeTypeExt on BadgeType { - String get desc => const ['', '大会员', '认证个人', '认证机构'][index]; - Color get color => const [ - Colors.transparent, - Color(0xFFFF6699), - Color(0xFFFFCC00), - Colors.lightBlueAccent - ][index]; + final String? desc; + final Color? color; + const BadgeType([this.desc, this.color]); } diff --git a/lib/models/common/episode_panel_type.dart b/lib/models/common/episode_panel_type.dart index 42628a948..713ddb6b2 100644 --- a/lib/models/common/episode_panel_type.dart +++ b/lib/models/common/episode_panel_type.dart @@ -1,5 +1,8 @@ -enum EpisodeType { part, season, bangumi } +enum EpisodeType { + part('分P'), + season('合集'), + bangumi('番剧'); -extension EpisodeTypeExt on EpisodeType { - String get title => const ['分P', '合集', '番剧'][index]; + final String title; + const EpisodeType(this.title); } diff --git a/lib/models/common/fav_type.dart b/lib/models/common/fav_type.dart index 2c8c69148..6c0936833 100644 --- a/lib/models/common/fav_type.dart +++ b/lib/models/common/fav_type.dart @@ -4,16 +4,14 @@ import 'package:PiliPlus/pages/fav/pgc/view.dart'; import 'package:PiliPlus/pages/fav/video/view.dart'; import 'package:flutter/material.dart'; -enum FavTabType { video, bangumi, cinema, article, note } +enum FavTabType { + video('视频', FavVideoPage()), + bangumi('追番', FavPgcPage(type: 1)), + cinema('追剧', FavPgcPage(type: 2)), + article('专栏', FavArticlePage()), + note('笔记', FavNotePage()); -extension FavTabTypeExt on FavTabType { - String get title => const ['视频', '追番', '追剧', '专栏', '笔记'][index]; - - Widget get page => switch (this) { - FavTabType.video => const FavVideoPage(), - FavTabType.bangumi => const FavPgcPage(type: 1), - FavTabType.cinema => const FavPgcPage(type: 2), - FavTabType.article => const FavArticlePage(), - FavTabType.note => const FavNotePage(), - }; + final String title; + final Widget page; + const FavTabType(this.title, this.page); } diff --git a/lib/models/common/follow_order_type.dart b/lib/models/common/follow_order_type.dart index 6184801da..821a0e16a 100644 --- a/lib/models/common/follow_order_type.dart +++ b/lib/models/common/follow_order_type.dart @@ -1,6 +1,9 @@ -enum FollowOrderType { def, attention } +enum FollowOrderType { + def('', '最近关注'), + attention('attention', '最常访问'); -extension FollowOrderTypeExt on FollowOrderType { - String get type => const ['', 'attention'][index]; - String get title => const ['最近关注', '最常访问'][index]; + final String type; + final String title; + + const FollowOrderType(this.type, this.title); } diff --git a/lib/models/common/history_business_type.dart b/lib/models/common/history_business_type.dart index 4dd08d0e4..3493d4adb 100644 --- a/lib/models/common/history_business_type.dart +++ b/lib/models/common/history_business_type.dart @@ -1,23 +1,20 @@ enum HistoryBusinessType { // 普通视频 - archive, + archive('archive'), // 剧集(番剧 / 影视) - pgc, + pgc('pgc'), // 直播 - live, + live('live'), // 文章 - articleList, + articleList('article-list'), // 文章 - article, - hiddenDurationType, - showBadge -} + article('article'); -extension HistoryBusinessTypeExt on HistoryBusinessType { - String get type => - const ['archive', 'pgc', 'live', 'article-list', 'article'][index]; // 隐藏时长 - List get hiddenDurationType => const ['live', 'article-list', 'article']; + static const hiddenDurationType = {'live', 'article-list', 'article'}; // 右上 - List get showBadge => const ['pgc', 'article-list', 'article']; + static const showBadge = {'pgc', 'article-list', 'article'}; + + final String type; + const HistoryBusinessType(this.type); } diff --git a/lib/models/common/home_tab_type.dart b/lib/models/common/home_tab_type.dart index a84b4a837..cd1e5ddc8 100644 --- a/lib/models/common/home_tab_type.dart +++ b/lib/models/common/home_tab_type.dart @@ -12,10 +12,16 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; -enum HomeTabType { live, rcmd, hot, rank, bangumi, cinema } +enum HomeTabType { + live('直播'), + rcmd('推荐'), + hot('热门'), + rank('分区'), + bangumi('番剧'), + cinema('影视'); -extension HomeTabTypeExt on HomeTabType { - String get description => const ['直播', '推荐', '热门', '分区', '番剧', '影视'][index]; + final String description; + const HomeTabType(this.description); } List get homeTabsConfig => [ diff --git a/lib/models/common/later_view_type.dart b/lib/models/common/later_view_type.dart index 3e9c96c5e..43f4da852 100644 --- a/lib/models/common/later_view_type.dart +++ b/lib/models/common/later_view_type.dart @@ -1,12 +1,15 @@ import 'package:PiliPlus/pages/later/child_view.dart'; import 'package:flutter/material.dart'; -enum LaterViewType { all, toView, unfinished, viewed } +enum LaterViewType { + all('全部'), + toView('未看'), + unfinished('未看完'), + viewed('已看完'); -extension LaterViewTypeExt on LaterViewType { int get type => index; - - String get title => const ['全部', '未看', '未看完', '已看完'][index]; - Widget get page => LaterViewChildPage(laterViewType: this); + + final String title; + const LaterViewType(this.title); } diff --git a/lib/models/common/nav_bar_config.dart b/lib/models/common/nav_bar_config.dart index 988b02ced..ef3fea5b2 100644 --- a/lib/models/common/nav_bar_config.dart +++ b/lib/models/common/nav_bar_config.dart @@ -1,5 +1,30 @@ import 'package:flutter/material.dart'; +// enum NavigationBarType { +// home( +// '首页', +// Icon(Icons.home_outlined, size: 23), +// Icon(Icons.home, size: 21), +// ), +// dynamics( +// '动态', +// Icon(Icons.motion_photos_on_outlined, size: 21), +// Icon(Icons.motion_photos_on, size: 21), +// ), +// media( +// '媒体库', +// Icon(Icons.video_collection_outlined, size: 21), +// Icon(Icons.video_collection, size: 21), +// ); + +// final Icon icon; +// final Icon selectIcon; +// final String label; + +// const NavigationBarType(this.label, this.icon, this.selectIcon); +// } + +// TODO enum List defaultNavigationBars = [ { 'id': 0, diff --git a/lib/models/common/rank_type.dart b/lib/models/common/rank_type.dart index 1e646f14b..542de2486 100644 --- a/lib/models/common/rank_type.dart +++ b/lib/models/common/rank_type.dart @@ -1,3 +1,4 @@ +// TODO named record or enum const List rankTabsConfig = [ { 'rid': 0, diff --git a/lib/models/common/search_type.dart b/lib/models/common/search_type.dart index 5e1b4b22e..da82db27f 100644 --- a/lib/models/common/search_type.dart +++ b/lib/models/common/search_type.dart @@ -2,52 +2,41 @@ enum SearchType { // all, // 视频:video - video, + video('视频'), // 番剧:media_bangumi, - media_bangumi, + media_bangumi('番剧'), // 影视:media_ft - media_ft, + media_ft('影视'), // 直播间及主播:live // live, // 直播间:live_room - live_room, + live_room('直播间'), // 主播:live_user // live_user, // 话题:topic // topic, // 用户:bili_user - bili_user, + bili_user('用户'), // 专栏:article - article, + article('专栏'); // 相簿:photo // photo -} -extension SearchTypeExtension on SearchType { - String get label => const [ - // '综合', - '视频', - '番剧', - '影视', - '直播间', - '用户', - '专栏', - ][index]; + final String label; + const SearchType(this.label); } // 搜索类型为视频、专栏及相簿时 enum ArchiveFilterType { - totalrank, - click, - pubdate, - dm, - stow, - scores, + totalrank('默认排序'), + click('播放多'), + pubdate('新发布'), + dm('弹幕多'), + stow('收藏多'), + scores('评论多'); // 专栏 - // attention, -} + // attention('最多喜欢'), -extension ArchiveFilterTypeExtension on ArchiveFilterType { - String get description => - const ['默认排序', '播放多', '新发布', '弹幕多', '收藏多', '评论多', '最多喜欢'][index]; + final String description; + const ArchiveFilterType(this.description); } diff --git a/lib/models/common/super_resolution_type.dart b/lib/models/common/super_resolution_type.dart index 5106c52c1..357a0652d 100644 --- a/lib/models/common/super_resolution_type.dart +++ b/lib/models/common/super_resolution_type.dart @@ -1,5 +1,8 @@ -enum SuperResolutionType { disable, efficiency, quality } +enum SuperResolutionType { + disable('禁用'), + efficiency('效率'), + quality('画质'); -extension SuperResolutionTypeExt on SuperResolutionType { - String get title => const ['禁用', '效率', '画质'][index]; + final String title; + const SuperResolutionType(this.title); } diff --git a/lib/models/common/video/CDN.dart b/lib/models/common/video/CDN.dart deleted file mode 100644 index 8b255279d..000000000 --- a/lib/models/common/video/CDN.dart +++ /dev/null @@ -1,117 +0,0 @@ -// ignore_for_file: constant_identifier_names - -//https://github.com/yujincheng08/BiliRoaming/blob/master/app/src/main/res/values/strings_raw.xml -//https://github.com/yujincheng08/BiliRoaming/blob/master/app/src/main/res/values/arrays.xml - -enum CDNService { - baseUrl, - backupUrl, - ali, - alib, - alio1, - cos, - cosb, - coso1, - hw, - hwb, - hwo1, - hw_08c, - hw_08h, - hw_08ct, - tf_hw, - tf_tx, - akamai, - aliov, - cosov, - hwov, - hk_bcache, -} - -extension CDNServiceDesc on CDNService { - static const List _descList = [ - '基础 URL(不推荐)', - '备用 URL', - 'ali(阿里云)', - 'alib(阿里云)', - 'alio1(阿里云)', - 'cos(腾讯云)', - 'cosb(腾讯云,VOD 加速类型)', - 'coso1(腾讯云)', - 'hw(华为云,融合 CDN)', - 'hwb(华为云,融合 CDN)', - 'hwo1(华为云,融合 CDN)', - '08c(华为云,融合 CDN)', - '08h(华为云,融合 CDN)', - '08ct(华为云,融合 CDN)', - 'tf_hw(华为云)', - 'tf_tx(腾讯云)', - 'akamai(Akamai 海外)', - 'aliov(阿里云海外)', - 'cosov(腾讯云海外)', - 'hwov(华为云海外)', - 'hk_bcache(Bilibili海外)', - ]; - String get description => _descList[index]; -} - -extension CDNServiceHost on CDNService { - static const List _hostList = [ - '', - '', - 'upos-sz-mirrorali.bilivideo.com', - 'upos-sz-mirroralib.bilivideo.com', - 'upos-sz-mirroralio1.bilivideo.com', - 'upos-sz-mirrorcos.bilivideo.com', - 'upos-sz-mirrorcosb.bilivideo.com', - 'upos-sz-mirrorcoso1.bilivideo.com', - 'upos-sz-mirrorhw.bilivideo.com', - 'upos-sz-mirrorhwb.bilivideo.com', - 'upos-sz-mirrorhwo1.bilivideo.com', - 'upos-sz-mirror08c.bilivideo.com', - 'upos-sz-mirror08h.bilivideo.com', - 'upos-sz-mirror08ct.bilivideo.com', - 'upos-tf-all-hw.bilivideo.com', - 'upos-tf-all-tx.bilivideo.com', - 'upos-hz-mirrorakam.akamaized.net', - 'upos-sz-mirroraliov.bilivideo.com', - 'upos-sz-mirrorcosov.bilivideo.com', - 'upos-sz-mirrorhwov.bilivideo.com', - 'cn-hk-eq-bcache-01.bilivideo.com', - ]; - String get host => _hostList[index]; -} - -extension CDNServiceCode on CDNService { - static const List _codeList = [ - 'baseUrl', - 'backupUrl', - 'ali', - 'alib', - 'alio1', - 'cos', - 'cosb', - 'coso1', - 'hw', - 'hwb', - 'hwo1', - 'hw_08c', - 'hw_08h', - 'hw_08ct', - 'tf_hw', - 'tf_tx', - 'akamai', - 'aliov', - 'cosov', - 'hwov', - 'hk_bcache', - ]; - String get code => _codeList[index]; - - static CDNService? fromCode(String code) { - final index = _codeList.indexOf(code); - if (index != -1) { - return CDNService.values[index]; - } - return null; - } -} diff --git a/lib/models/common/video/cdn_type.dart b/lib/models/common/video/cdn_type.dart new file mode 100644 index 000000000..e405bdaac --- /dev/null +++ b/lib/models/common/video/cdn_type.dart @@ -0,0 +1,36 @@ +// ignore_for_file: constant_identifier_names + +//https://github.com/yujincheng08/BiliRoaming/blob/master/app/src/main/res/values/strings_raw.xml +//https://github.com/yujincheng08/BiliRoaming/blob/master/app/src/main/res/values/arrays.xml + +enum CDNService { + baseUrl('基础URL(不推荐)'), + backupUrl('备用URL'), + ali('ali(阿里云)', 'upos-sz-mirrorali.bilivideo.com'), + alib('alib(阿里云)', 'upos-sz-mirroralib.bilivideo.com'), + alio1('alio1(阿里云)', 'upos-sz-mirroralio1.bilivideo.com'), + cos('cos(腾讯云)', 'upos-sz-mirrorcos.bilivideo.com'), + cosb('cosb(腾讯云,VOD加速类型)', 'upos-sz-mirrorcosb.bilivideo.com'), + coso1('coso1(腾讯云)', 'upos-sz-mirrorcoso1.bilivideo.com'), + hw('hw(华为云,融合CDN)', 'upos-sz-mirrorhw.bilivideo.com'), + hwb('hwb(华为云,融合CDN)', 'upos-sz-mirrorhwb.bilivideo.com'), + hwo1('hwo1(华为云,融合CDN)', 'upos-sz-mirrorhwo1.bilivideo.com'), + hw_08c('08c(华为云,融合CDN)', 'upos-sz-mirror08c.bilivideo.com'), + hw_08h('08h(华为云,融合CDN)', 'upos-sz-mirror08h.bilivideo.com'), + hw_08ct('08ct(华为云,融合CDN)', 'upos-sz-mirror08ct.bilivideo.com'), + tf_hw('tf_hw(华为云)', 'upos-tf-all-hw.bilivideo.com'), + tf_tx('tf_tx(腾讯云)', 'upos-tf-all-tx.bilivideo.com'), + akamai('akamai(Akamai海外)', 'upos-hz-mirrorakam.akamaized.net'), + aliov('aliov(阿里云海外)', 'upos-sz-mirroraliov.bilivideo.com'), + cosov('cosov(腾讯云海外)', 'upos-sz-mirrorcosov.bilivideo.com'), + hwov('hwov(华为云海外)', 'upos-sz-mirrorhwov.bilivideo.com'), + hk_bcache('hk_bcache(Bilibili海外)', 'cn-hk-eq-bcache-01.bilivideo.com'); + + String get code => name; + static final fromCode = values.byName; + + final String description; + final String host; + + const CDNService(this.description, [this.host = '']); +} diff --git a/lib/models/common/webview_menu_type.dart b/lib/models/common/webview_menu_type.dart index 026009420..92a9d211a 100644 --- a/lib/models/common/webview_menu_type.dart +++ b/lib/models/common/webview_menu_type.dart @@ -1,19 +1,11 @@ enum WebviewMenuItem { - refresh, - copy, - openInBrowser, - clearCache, - resetCookie, - goBack, -} + refresh('刷新'), + copy('复制链接'), + openInBrowser('浏览器中打开'), + clearCache('清除缓存'), + resetCookie('重新设置Cookie'), + goBack('返回'); -extension WebviewMenuItemExt on WebviewMenuItem { - String get title => const [ - '刷新', - '复制链接', - '浏览器中打开', - '清除缓存', - '重新设置Cookie', - '返回', - ][index]; + final String title; + const WebviewMenuItem(this.title); } diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index 3b5d698d0..7f91aaf0e 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -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) diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index b3093bea9..90c8224e9 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -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 +class MemberController extends CommonDataController with GetTickerProviderStateMixin { MemberController({required this.mid}); int mid; @@ -141,7 +141,7 @@ class MemberController extends CommonDataController ); showUname.value = true; username = errMsg; - loadingState.value = LoadingState.success(null); + loadingState.value = LoadingState.success(null); return true; } diff --git a/lib/pages/member_home/view.dart b/lib/pages/member_home/view.dart index 9c8391d3e..118d6a951 100644 --- a/lib/pages/member_home/view.dart +++ b/lib/pages/member_home/view.dart @@ -40,20 +40,19 @@ class _MemberHomeState extends State return _buildBody(_ctr.loadingState.value); } - Widget _buildBody(LoadingState loadingState) { + Widget _buildBody(LoadingState 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 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 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 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 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), ), ), ), diff --git a/lib/pages/setting/widgets/model.dart b/lib/pages/setting/widgets/model.dart index d9bcce1e5..605079e08 100644 --- a/lib/pages/setting/widgets/model.dart +++ b/lib/pages/setting/widgets/model.dart @@ -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 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!, diff --git a/lib/pages/setting/widgets/select_dialog.dart b/lib/pages/setting/widgets/select_dialog.dart index cb308accd..3de499dd9 100644 --- a/lib/pages/setting/widgets/select_dialog.dart +++ b/lib/pages/setting/widgets/select_dialog.dart @@ -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'; diff --git a/lib/pages/video/widgets/header_control.dart b/lib/pages/video/widgets/header_control.dart index b8a37063e..b9e78754d 100644 --- a/lib/pages/video/widgets/header_control.dart +++ b/lib/pages/video/widgets/header_control.dart @@ -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 { 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 { defaultCDNService = result; setting.put(SettingBoxKey.CDNService, result); SmartDialog.showToast( - '已设置为 ${CDNServiceCode.fromCode(result)!.description},正在重载视频'); + '已设置为 ${CDNService.fromCode(result).description},正在重载视频'); setState(() {}); videoDetailCtr.queryVideoUrl( videoDetailCtr.playedTime, diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 636d45064..5a35ec251 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -15,8 +15,8 @@ import 'package:PiliPlus/models/common/msg/msg_unread_type.dart'; import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart'; import 'package:PiliPlus/models/common/sponsor_block/skip_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'; diff --git a/lib/utils/video_utils.dart b/lib/utils/video_utils.dart index e27ddb8a6..3f0774f18 100644 --- a/lib/utils/video_utils.dart +++ b/lib/utils/video_utils.dart @@ -1,4 +1,4 @@ -import 'package:PiliPlus/models/common/video/CDN.dart'; +import 'package:PiliPlus/models/common/video/cdn_type.dart'; import 'package:PiliPlus/models/live/live_room/room_info.dart'; import 'package:PiliPlus/models/video/play/url.dart'; import 'package:PiliPlus/utils/extension.dart'; @@ -6,11 +6,10 @@ import 'package:PiliPlus/utils/storage.dart'; import 'package:flutter/material.dart'; class VideoUtils { - static String getCdnUrl(dynamic item, [defaultCDNService]) { + static String getCdnUrl(dynamic item, [String? defaultCDNService]) { String? backupUrl; String? videoUrl; - defaultCDNService ??= GStorage.setting - .get(SettingBoxKey.CDNService, defaultValue: CDNService.backupUrl.code); + defaultCDNService ??= GStorage.defaultCDNService; if (item is AudioItem) { if (GStorage.setting .get(SettingBoxKey.disableAudioCDN, defaultValue: true)) { @@ -41,7 +40,7 @@ class VideoUtils { } debugPrint("videoUrl:$videoUrl"); - String defaultCDNHost = CDNServiceCode.fromCode(defaultCDNService)!.host; + String defaultCDNHost = CDNService.fromCode(defaultCDNService).host; debugPrint("defaultCDNHost:$defaultCDNHost"); if (videoUrl!.contains("szbdyd.com")) { final uri = Uri.parse(videoUrl);