opt: enum

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-05 15:06:19 +08:00
parent 4e68c765c5
commit 2f4c739f0b
116 changed files with 577 additions and 554 deletions

View File

@@ -0,0 +1,10 @@
enum AccountType {
main,
heartbeat,
recommend,
video,
}
extension AccountTypeExt on AccountType {
String get title => const ['主账号', '记录观看', '推荐', '视频取流'][index];
}

View File

@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
enum BadgeType { none, vip, person, institution }
extension BadgeTypeExt on BadgeType {
String get desc => const ['', '大会员', '认证个人', '认证机构'][index];
Color get color => const [
Colors.transparent,
Color(0xFFFF6699),
Color(0xFFFFCC00),
Colors.lightBlueAccent
][index];
}

View File

@@ -0,0 +1,5 @@
enum DynamicBadgeMode { hidden, point, number }
extension DynamicBadgeModeExt on DynamicBadgeMode {
String get description => const ['隐藏', '红点', '数字'][index];
}

View File

@@ -1,4 +1,4 @@
enum DynamicsType {
enum DynamicsTabType {
all,
video,
pgc,
@@ -6,7 +6,7 @@ enum DynamicsType {
up,
}
extension BusinessTypeExtension on DynamicsType {
extension DynamicsTabTypeExt on DynamicsTabType {
String get values => const ['all', 'video', 'pgc', 'article', 'up'][index];
String get labels => const ['全部', '投稿', '番剧', '专栏', 'UP'][index];
}
@@ -14,31 +14,31 @@ extension BusinessTypeExtension on DynamicsType {
const List tabsConfig = [
{
'tag': 'all',
'value': DynamicsType.all,
'value': DynamicsTabType.all,
'label': '全部',
'enabled': true,
},
{
'tag': 'video',
'value': DynamicsType.video,
'value': DynamicsTabType.video,
'label': '投稿',
'enabled': true,
},
{
'tag': 'pgc',
'value': DynamicsType.pgc,
'value': DynamicsTabType.pgc,
'label': '番剧',
'enabled': true,
},
{
'tag': 'article',
'value': DynamicsType.article,
'value': DynamicsTabType.article,
'label': '专栏',
'enabled': true,
},
{
'tag': 'up',
'value': DynamicsType.up,
'value': DynamicsTabType.up,
'label': 'UP',
'enabled': true,
},

View File

@@ -5,6 +5,6 @@ enum UpPanelPosition {
rightDrawer,
}
extension UpPanelPositionDesc on UpPanelPosition {
extension UpPanelPositionExt on UpPanelPosition {
String get labels => const ['左侧常驻', '右侧常驻', '左侧抽屉', '右侧抽屉'][index];
}

View File

@@ -0,0 +1,5 @@
enum EpisodeType { part, season, bangumi }
extension EpisodeTypeExt on EpisodeType {
String get title => const ['分P', '合集', '番剧'][index];
}

View File

@@ -0,0 +1,19 @@
import 'package:PiliPlus/pages/fav/article/view.dart';
import 'package:PiliPlus/pages/fav/note/view.dart';
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 }
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(),
};
}

View File

@@ -0,0 +1,6 @@
enum FollowOrderType { def, attention }
extension FollowOrderTypeExt on FollowOrderType {
String get type => const ['', 'attention'][index];
String get title => const ['最近关注', '最常访问'][index];
}

View File

@@ -1,4 +1,4 @@
enum BusinessType {
enum HistoryBusinessType {
//
archive,
// /
@@ -13,7 +13,7 @@ enum BusinessType {
showBadge
}
extension BusinessTypeExtension on BusinessType {
extension HistoryBusinessTypeExt on HistoryBusinessType {
String get type =>
const ['archive', 'pgc', 'live', 'article-list', 'article'][index];
//

View File

@@ -12,9 +12,9 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
enum TabType { live, rcmd, hot, rank, bangumi, cinema }
enum HomeTabType { live, rcmd, hot, rank, bangumi, cinema }
extension TabTypeDesc on TabType {
extension HomeTabTypeExt on HomeTabType {
String get description => const ['直播', '推荐', '热门', '分区', '番剧', '影视'][index];
}
@@ -25,7 +25,7 @@ List get tabsConfig => [
size: 15,
),
'label': '直播',
'type': TabType.live,
'type': HomeTabType.live,
'ctr': Get.find<LiveController>,
'page': const LivePage(),
},
@@ -35,7 +35,7 @@ List get tabsConfig => [
size: 15,
),
'label': '推荐',
'type': TabType.rcmd,
'type': HomeTabType.rcmd,
'ctr': Get.find<RcmdController>,
'page': const RcmdPage(),
},
@@ -45,7 +45,7 @@ List get tabsConfig => [
size: 15,
),
'label': '热门',
'type': TabType.hot,
'type': HomeTabType.hot,
'ctr': Get.find<HotController>,
'page': const HotPage(),
},
@@ -55,7 +55,7 @@ List get tabsConfig => [
size: 15,
),
'label': '分区',
'type': TabType.rank,
'type': HomeTabType.rank,
'ctr': Get.find<RankController>,
'page': const RankPage(),
},
@@ -65,9 +65,9 @@ List get tabsConfig => [
size: 15,
),
'label': '番剧',
'type': TabType.bangumi,
'type': HomeTabType.bangumi,
'ctr': Get.find<BangumiController>,
'page': const BangumiPage(tabType: TabType.bangumi),
'page': const BangumiPage(tabType: HomeTabType.bangumi),
},
{
'icon': Icon(
@@ -75,8 +75,8 @@ List get tabsConfig => [
size: 15,
),
'label': '影视',
'type': TabType.cinema,
'type': HomeTabType.cinema,
'ctr': Get.find<BangumiController>,
'page': const BangumiPage(tabType: TabType.cinema),
'page': const BangumiPage(tabType: HomeTabType.cinema),
},
];

View File

@@ -0,0 +1,17 @@
enum SourceType { fileImage, networkImage, livePhoto }
class SourceModel {
final SourceType sourceType;
final String url;
final String? liveUrl;
final int? width;
final int? height;
const SourceModel({
this.sourceType = SourceType.networkImage,
required this.url,
this.liveUrl,
this.width,
this.height,
});
}

View File

@@ -0,0 +1,12 @@
import 'package:PiliPlus/pages/later/child_view.dart';
import 'package:flutter/material.dart';
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);
}

View File

@@ -0,0 +1 @@
enum ContributeType { video, charging, season, series, bangumi }

View File

@@ -0,0 +1 @@
enum ProfileType { uname, sign, sex, birthday }

View File

@@ -0,0 +1,5 @@
enum MemberTabType { none, home, dynamic, contribute, favorite, bangumi }
extension MemberTabTypeExt on MemberTabType {
String get title => const ['默认', '主页', '动态', '投稿', '收藏', '番剧'][index];
}

View File

@@ -0,0 +1,27 @@
enum MsgType {
invalid(value: 0, label: "空空的~"),
text(value: 1, label: "文本消息"),
pic(value: 2, label: "图片消息"),
audio(value: 3, label: "语音消息"),
share(value: 4, label: "分享消息"),
revoke(value: 5, label: "撤回消息"),
customFace(value: 6, label: "自定义表情"),
shareV2(value: 7, label: "分享v2消息"),
sysCancel(value: 8, label: "系统撤销"),
miniProgram(value: 9, label: "小程序"),
notifyMsg(value: 10, label: "业务通知"),
archiveCard(value: 11, label: "投稿卡片"),
articleCard(value: 12, label: "专栏卡片"),
picCard(value: 13, label: "图片卡片"),
commonShare(value: 14, label: "异形卡片"),
autoReplyPush(value: 16, label: "自动回复推送"),
notifyText(value: 18, label: "文本提示");
final int value;
final String label;
const MsgType({required this.value, required this.label});
static MsgType parse(int value) {
return MsgType.values
.firstWhere((e) => e.value == value, orElse: () => MsgType.invalid);
}
}

View File

@@ -1,9 +1,3 @@
enum DynamicBadgeMode { hidden, point, number }
extension DynamicBadgeModeDesc on DynamicBadgeMode {
String get description => const ['隐藏', '红点', '数字'][index];
}
enum MsgUnReadType { pm, reply, at, like, sysMsg }
extension MsgUnReadTypeExt on MsgUnReadType {

View File

@@ -0,0 +1 @@
enum PanelType { none, keyboard, emoji }

View File

@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
enum ReplyOptionType { allow, close, choose }
extension ReplyOptionTypeExt on ReplyOptionType {
String get title => const ['允许评论', '关闭评论', '精选评论'][index];
IconData get iconData => switch (this) {
ReplyOptionType.allow => MdiIcons.commentTextOutline,
ReplyOptionType.close => MdiIcons.commentOffOutline,
ReplyOptionType.choose => MdiIcons.commentProcessingOutline
};
}

View File

@@ -1,6 +1,6 @@
enum ReplySortType { time, like }
extension ReplySortTypeExtension on ReplySortType {
extension ReplySortTypeExt on ReplySortType {
String get title => const ['最新评论', '最热评论'][index];
String get label => const ['最新', '最热'][index];
}

View File

@@ -0,0 +1 @@
enum SettingsType { normal, sw1tch, divider }

View File

@@ -1,17 +1,17 @@
// ignore_for_file: non_constant_identifier_names
import 'package:PiliPlus/common/widgets/pair.dart';
import 'package:PiliPlus/models/common/sponsor_block/segment_type.dart';
import 'package:PiliPlus/models/common/sponsor_block/skip_type.dart';
class SegmentModel {
SegmentModel({
// ignore: non_constant_identifier_names
required this.UUID,
required this.segmentType,
required this.segment,
required this.skipType,
this.hasSkipped,
});
// ignore: non_constant_identifier_names
String UUID;
SegmentType segmentType;
Pair<int, int> segment;

View File

@@ -1,3 +1,5 @@
// ignore_for_file: constant_identifier_names
import 'dart:ui';
import 'package:PiliPlus/models/common/sponsor_block/action_type.dart';
@@ -9,12 +11,9 @@ enum SegmentType {
intro,
outro,
preview,
// ignore: constant_identifier_names
music_offtopic,
// ignore: constant_identifier_names
poi_highlight,
filler,
// ignore: constant_identifier_names
exclusive_access
}

View File

@@ -0,0 +1,117 @@
// 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<String> _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腾讯云',
'akamaiAkamai 海外)',
'aliov阿里云海外',
'cosov腾讯云海外',
'hwov华为云海外',
'hk_bcacheBilibili海外',
];
String get description => _descList[index];
}
extension CDNServiceHost on CDNService {
static const List<String> _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<String> _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;
}
}

View File

@@ -0,0 +1,30 @@
// ignore_for_file: constant_identifier_names
enum AudioQuality { k64, k132, k192, dolby, hiRes }
extension AudioQualityExt on AudioQuality {
static const List<int> _codeList = [
30216,
30232,
30280,
30250,
30251,
];
int get code => _codeList[index];
static AudioQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return AudioQuality.values[index];
}
return null;
}
String get description => const [
'64K',
'132K',
'192K',
'杜比全景声',
'Hi-Res无损',
][index];
}

View File

@@ -0,0 +1,40 @@
enum LiveQuality {
dolby,
super4K,
origin,
bluRay,
superHD,
smooth,
flunt,
}
extension LiveQualityExt on LiveQuality {
static const List<int> _codeList = [
30000,
20000,
10000,
400,
250,
150,
80,
];
int get code => _codeList[index];
static LiveQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return LiveQuality.values[index];
}
return null;
}
String get description => const [
'杜比',
'4K',
'原画',
'蓝光',
'超清',
'高清',
'流畅',
][index];
}

View File

@@ -0,0 +1,21 @@
enum SubtitlePrefType { off, on, withoutAi, auto }
extension SubtitlePrefTypeExt on SubtitlePrefType {
String get description => const [
'默认不显示字幕',
'优先选择非自动生成(ai)字幕',
'跳过自动生成(ai)字幕,选择第一个可用字幕',
'静音时等同第二项,非静音时等同第三项'
][index];
static const List<String> _codeList = ['off', 'on', 'withoutAi', 'auto'];
String get code => _codeList[index];
static SubtitlePrefType? fromCode(String code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return SubtitlePrefType.values[index];
}
return null;
}
}

View File

@@ -0,0 +1,34 @@
// ignore_for_file: constant_identifier_names
enum VideoDecodeFormatType {
DVH1,
AV1,
HEVC,
AVC,
}
extension VideoDecodeFormatTypeExt on VideoDecodeFormatType {
String get description => const ['DVH1', 'AV1', 'HEVC', 'AVC'][index];
static const List<String> _codeList = ['dvh1', 'av01', 'hev1', 'avc1'];
String get code => _codeList[index];
static VideoDecodeFormatType? fromCode(String code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return VideoDecodeFormatType.values[index];
}
return null;
}
static VideoDecodeFormatType? fromString(String val) {
var result = VideoDecodeFormatType.values.first;
for (var i in _codeList) {
if (val.startsWith(i)) {
result = VideoDecodeFormatType.values[_codeList.indexOf(i)];
break;
}
}
return result;
}
}

View File

@@ -0,0 +1,55 @@
enum VideoQuality {
speed240,
fluent360,
clear480,
high720,
high72060,
high1080,
high1080plus,
high108060,
super4K,
hdr,
dolbyVision,
super8k
}
extension VideoQualityExt on VideoQuality {
static const List<int> _codeList = [
6,
16,
32,
64,
74,
80,
112,
116,
120,
125,
126,
127,
];
int get code => _codeList[index];
static VideoQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return VideoQuality.values[index];
}
return null;
}
String get description => const [
'240P 极速',
'360P 流畅',
'480P 清晰',
'720P 高清',
'720P60 高帧率',
'1080P 高清',
'1080P+ 高码率',
'1080P60 高帧率',
'4K 超清',
'HDR 真彩色',
'杜比视界',
'8K 超高清'
][index];
}

View File

@@ -0,0 +1,19 @@
enum WebviewMenuItem {
refresh,
copy,
openInBrowser,
clearCache,
resetCookie,
goBack,
}
extension WebviewMenuItemExt on WebviewMenuItem {
String get title => const [
'刷新',
'复制链接',
'浏览器中打开',
'清除缓存',
'重新设置Cookie',
'返回',
][index];
}