Merge branch 'main' into design

This commit is contained in:
guozhigq
2024-04-18 23:44:01 +08:00
17 changed files with 373 additions and 334 deletions

View File

@ -206,4 +206,4 @@ jobs:
method: sendFile method: sendFile
path: Pilipala-Beta/* path: Pilipala-Beta/*
parse_mode: Markdown parse_mode: Markdown
context: "*Beta版本: v${{ needs.update_version.outputs.new_version }}*\n更新内容: [${{ needs.update_version.outputs.last_commit }}](${{ github.event.head_commit.url }})" context: "*Beta版本: v${{ needs.update_version.outputs.new_version }}*\n更新内容: [${{ needs.update_version.outputs.last_commit }}]"

View File

@ -130,27 +130,10 @@ class MyApp extends StatelessWidget {
); );
} }
final SnackBarThemeData snackBarThemeData = SnackBarThemeData(
actionTextColor: darkColorScheme.primary,
backgroundColor: darkColorScheme.secondaryContainer,
closeIconColor: darkColorScheme.secondary,
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
elevation: 20,
);
ThemeData themeData = ThemeData( ThemeData themeData = ThemeData(
// fontFamily: 'HarmonyOS',
colorScheme: currentThemeValue == ThemeType.dark colorScheme: currentThemeValue == ThemeType.dark
? darkColorScheme ? darkColorScheme
: lightColorScheme, : lightColorScheme,
snackBarTheme: snackBarThemeData,
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder(
allowEnterRouteSnapshotting: false,
),
},
),
); );
// 小白条、导航栏沉浸 // 小白条、导航栏沉浸
@ -171,9 +154,38 @@ class MyApp extends StatelessWidget {
// 图片缓存 // 图片缓存
// PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20; // PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20;
return GetMaterialApp( return GetMaterialApp(
title: 'PiLiPaLa', title: 'PiliPala',
theme: themeData, theme: ThemeData(
darkTheme: themeData, colorScheme: currentThemeValue == ThemeType.dark
? darkColorScheme
: lightColorScheme,
snackBarTheme: SnackBarThemeData(
actionTextColor: lightColorScheme.primary,
backgroundColor: lightColorScheme.secondaryContainer,
closeIconColor: lightColorScheme.secondary,
contentTextStyle: TextStyle(color: lightColorScheme.secondary),
elevation: 20,
),
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder(
allowEnterRouteSnapshotting: false,
),
},
),
),
darkTheme: ThemeData(
colorScheme: currentThemeValue == ThemeType.light
? lightColorScheme
: darkColorScheme,
snackBarTheme: SnackBarThemeData(
actionTextColor: darkColorScheme.primary,
backgroundColor: darkColorScheme.secondaryContainer,
closeIconColor: darkColorScheme.secondary,
contentTextStyle: TextStyle(color: darkColorScheme.secondary),
elevation: 20,
),
),
localizationsDelegates: const [ localizationsDelegates: const [
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/pages/rank/zone/index.dart'; import 'package:pilipala/pages/rank/zone/index.dart';
enum RandType { enum RandType {
@ -74,7 +73,6 @@ List tabsConfig = [
), ),
'label': '全站', 'label': '全站',
'type': RandType.all, 'type': RandType.all,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 0), 'page': const ZonePage(rid: 0),
}, },
{ {
@ -84,7 +82,6 @@ List tabsConfig = [
), ),
'label': '国创相关', 'label': '国创相关',
'type': RandType.creation, 'type': RandType.creation,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 168), 'page': const ZonePage(rid: 168),
}, },
{ {
@ -94,7 +91,6 @@ List tabsConfig = [
), ),
'label': '动画', 'label': '动画',
'type': RandType.animation, 'type': RandType.animation,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 1), 'page': const ZonePage(rid: 1),
}, },
{ {
@ -104,7 +100,6 @@ List tabsConfig = [
), ),
'label': '音乐', 'label': '音乐',
'type': RandType.music, 'type': RandType.music,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 3), 'page': const ZonePage(rid: 3),
}, },
{ {
@ -114,7 +109,6 @@ List tabsConfig = [
), ),
'label': '舞蹈', 'label': '舞蹈',
'type': RandType.dance, 'type': RandType.dance,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 129), 'page': const ZonePage(rid: 129),
}, },
{ {
@ -124,7 +118,6 @@ List tabsConfig = [
), ),
'label': '游戏', 'label': '游戏',
'type': RandType.game, 'type': RandType.game,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 4), 'page': const ZonePage(rid: 4),
}, },
{ {
@ -134,7 +127,6 @@ List tabsConfig = [
), ),
'label': '知识', 'label': '知识',
'type': RandType.knowledge, 'type': RandType.knowledge,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 36), 'page': const ZonePage(rid: 36),
}, },
{ {
@ -144,7 +136,6 @@ List tabsConfig = [
), ),
'label': '科技', 'label': '科技',
'type': RandType.technology, 'type': RandType.technology,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 188), 'page': const ZonePage(rid: 188),
}, },
{ {
@ -154,7 +145,6 @@ List tabsConfig = [
), ),
'label': '运动', 'label': '运动',
'type': RandType.sport, 'type': RandType.sport,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 234), 'page': const ZonePage(rid: 234),
}, },
{ {
@ -164,7 +154,6 @@ List tabsConfig = [
), ),
'label': '汽车', 'label': '汽车',
'type': RandType.car, 'type': RandType.car,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 223), 'page': const ZonePage(rid: 223),
}, },
{ {
@ -174,7 +163,6 @@ List tabsConfig = [
), ),
'label': '生活', 'label': '生活',
'type': RandType.life, 'type': RandType.life,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 160), 'page': const ZonePage(rid: 160),
}, },
{ {
@ -184,7 +172,6 @@ List tabsConfig = [
), ),
'label': '美食', 'label': '美食',
'type': RandType.food, 'type': RandType.food,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 211), 'page': const ZonePage(rid: 211),
}, },
{ {
@ -194,7 +181,6 @@ List tabsConfig = [
), ),
'label': '动物圈', 'label': '动物圈',
'type': RandType.animal, 'type': RandType.animal,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 217), 'page': const ZonePage(rid: 217),
}, },
{ {
@ -204,7 +190,6 @@ List tabsConfig = [
), ),
'label': '鬼畜', 'label': '鬼畜',
'type': RandType.madness, 'type': RandType.madness,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 119), 'page': const ZonePage(rid: 119),
}, },
{ {
@ -214,7 +199,6 @@ List tabsConfig = [
), ),
'label': '时尚', 'label': '时尚',
'type': RandType.fashion, 'type': RandType.fashion,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 155), 'page': const ZonePage(rid: 155),
}, },
{ {
@ -224,7 +208,6 @@ List tabsConfig = [
), ),
'label': '娱乐', 'label': '娱乐',
'type': RandType.entertainment, 'type': RandType.entertainment,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 5), 'page': const ZonePage(rid: 5),
}, },
{ {
@ -234,7 +217,6 @@ List tabsConfig = [
), ),
'label': '影视', 'label': '影视',
'type': RandType.film, 'type': RandType.film,
'ctr': Get.put<ZoneController>,
'page': const ZonePage(rid: 181), 'page': const ZonePage(rid: 181),
} }
]; ];

View File

@ -5,6 +5,10 @@ enum SubtitleType {
aizh, aizh,
// 英语(自动生成) // 英语(自动生成)
aien, aien,
// 中文(简体)
zhHans,
// 英文(美国)
enUS,
} }
extension SubtitleTypeExtension on SubtitleType { extension SubtitleTypeExtension on SubtitleType {
@ -16,6 +20,10 @@ extension SubtitleTypeExtension on SubtitleType {
return '中文(自动翻译)'; return '中文(自动翻译)';
case SubtitleType.aien: case SubtitleType.aien:
return '英语(自动生成)'; return '英语(自动生成)';
case SubtitleType.zhHans:
return '中文(简体)';
case SubtitleType.enUS:
return '英文(美国)';
} }
} }
} }
@ -29,6 +37,10 @@ extension SubtitleIdExtension on SubtitleType {
return 'ai-zh'; return 'ai-zh';
case SubtitleType.aien: case SubtitleType.aien:
return 'ai-en'; return 'ai-en';
case SubtitleType.zhHans:
return 'zh-Hans';
case SubtitleType.enUS:
return 'en-US';
} }
} }
} }
@ -42,6 +54,10 @@ extension SubtitleCodeExtension on SubtitleType {
return 2; return 2;
case SubtitleType.aien: case SubtitleType.aien:
return 3; return 3;
case SubtitleType.zhHans:
return 4;
case SubtitleType.enUS:
return 5;
} }
} }
} }

View File

@ -56,6 +56,7 @@ class BangumiIntroController extends GetxController {
RxMap followStatus = {}.obs; RxMap followStatus = {}.obs;
int _tempThemeValue = -1; int _tempThemeValue = -1;
var userInfo; var userInfo;
PersistentBottomSheetController? bottomSheetController;
@override @override
void onInit() { void onInit() {
@ -320,4 +321,8 @@ class BangumiIntroController extends GetxController {
).buildShowContent(Get.context!), ).buildShowContent(Get.context!),
); );
} }
hiddenEpisodeBottomSheet() {
bottomSheetController?.close();
}
} }

View File

@ -325,6 +325,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
changeFuc: (bvid, cid, aid) => changeFuc: (bvid, cid, aid) =>
bangumiIntroController.changeSeasonOrbangu(bvid, cid, aid), bangumiIntroController.changeSeasonOrbangu(bvid, cid, aid),
bangumiDetail: bangumiIntroController.bangumiDetail.value, bangumiDetail: bangumiIntroController.bangumiDetail.value,
bangumiIntroController: bangumiIntroController,
) )
], ],
], ],

View File

@ -10,6 +10,7 @@ import 'package:pilipala/utils/storage.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../../../common/pages_bottom_sheet.dart'; import '../../../common/pages_bottom_sheet.dart';
import '../../../models/common/video_episode_type.dart'; import '../../../models/common/video_episode_type.dart';
import '../introduction/controller.dart';
class BangumiPanel extends StatefulWidget { class BangumiPanel extends StatefulWidget {
const BangumiPanel({ const BangumiPanel({
@ -19,6 +20,7 @@ class BangumiPanel extends StatefulWidget {
this.sheetHeight, this.sheetHeight,
this.changeFuc, this.changeFuc,
this.bangumiDetail, this.bangumiDetail,
this.bangumiIntroController,
}); });
final List<EpisodeItem> pages; final List<EpisodeItem> pages;
@ -26,6 +28,7 @@ class BangumiPanel extends StatefulWidget {
final double? sheetHeight; final double? sheetHeight;
final Function? changeFuc; final Function? changeFuc;
final BangumiInfoModel? bangumiDetail; final BangumiInfoModel? bangumiDetail;
final BangumiIntroController? bangumiIntroController;
@override @override
State<BangumiPanel> createState() => _BangumiPanelState(); State<BangumiPanel> createState() => _BangumiPanelState();
@ -136,6 +139,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
padding: MaterialStateProperty.all(EdgeInsets.zero), padding: MaterialStateProperty.all(EdgeInsets.zero),
), ),
onPressed: () { onPressed: () {
widget.bangumiIntroController?.bottomSheetController =
_bottomSheetController = EpisodeBottomSheet( _bottomSheetController = EpisodeBottomSheet(
currentCid: cid, currentCid: cid,
episodes: widget.pages, episodes: widget.pages,

View File

@ -16,6 +16,7 @@ import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart'; import 'package:pilipala/utils/id_utils.dart';
import '../../../models/video/reply/item.dart';
import '../widgets/dynamic_panel.dart'; import '../widgets/dynamic_panel.dart';
class DynamicDetailPage extends StatefulWidget { class DynamicDetailPage extends StatefulWidget {
@ -210,9 +211,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
onRefresh: () async { onRefresh: () async {
await _dynamicDetailController.queryReplyList(); await _dynamicDetailController.queryReplyList();
}, },
child: Stack( child: CustomScrollView(
children: [
CustomScrollView(
controller: scrollController, controller: scrollController,
slivers: [ slivers: [
if (action != 'comment') if (action != 'comment')
@ -230,9 +229,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
border: Border( border: Border(
top: BorderSide( top: BorderSide(
width: 0.6, width: 0.6,
color: Theme.of(context) color: Theme.of(context).dividerColor.withOpacity(0.05),
.dividerColor
.withOpacity(0.05),
), ),
), ),
), ),
@ -264,8 +261,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
_dynamicDetailController.queryBySort(), _dynamicDetailController.queryBySort(),
icon: const Icon(Icons.sort, size: 16), icon: const Icon(Icons.sort, size: 16),
label: Obx(() => Text( label: Obx(() => Text(
_dynamicDetailController _dynamicDetailController.sortTypeLabel.value,
.sortTypeLabel.value,
style: const TextStyle(fontSize: 13), style: const TextStyle(fontSize: 13),
)), )),
), ),
@ -282,22 +278,22 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
Map data = snapshot.data as Map; Map data = snapshot.data as Map;
if (snapshot.data['status']) { if (snapshot.data['status']) {
RxList<ReplyItemModel> replyList =
_dynamicDetailController.replyList;
// 请求成功 // 请求成功
return Obx( return Obx(
() => _dynamicDetailController.replyList.isEmpty && () => replyList.isEmpty &&
_dynamicDetailController.isLoadingMore _dynamicDetailController.isLoadingMore
? SliverList( ? SliverList(
delegate: SliverChildBuilderDelegate( delegate:
(context, index) { SliverChildBuilderDelegate((context, index) {
return const VideoReplySkeleton(); return const VideoReplySkeleton();
}, childCount: 8), }, childCount: 8),
) )
: SliverList( : SliverList(
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(context, index) { (context, index) {
if (index == if (index == replyList.length) {
_dynamicDetailController
.replyList.length) {
return Container( return Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.of(context) bottom: MediaQuery.of(context)
@ -324,25 +320,21 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
); );
} else { } else {
return ReplyItem( return ReplyItem(
replyItem: _dynamicDetailController replyItem: replyList[index],
.replyList[index],
showReplyRow: true, showReplyRow: true,
replyLevel: '1', replyLevel: '1',
replyReply: (replyItem) => replyReply: (replyItem) =>
replyReply(replyItem), replyReply(replyItem),
replyType: replyType: ReplyType.values[replyType],
ReplyType.values[replyType],
addReply: (replyItem) { addReply: (replyItem) {
_dynamicDetailController replyList[index]
.replyList[index].replies! .replies!
.add(replyItem); .add(replyItem);
}, },
); );
} }
}, },
childCount: _dynamicDetailController childCount: replyList.length + 1,
.replyList.length +
1,
), ),
), ),
); );
@ -365,17 +357,17 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
) )
], ],
), ),
Positioned( ),
bottom: MediaQuery.of(context).padding.bottom + 14, floatingActionButton: SlideTransition(
right: 14,
child: SlideTransition(
position: Tween<Offset>( position: Tween<Offset>(
begin: const Offset(0, 2), begin: const Offset(0, 2),
end: const Offset(0, 0), end: const Offset(0, 0),
).animate(CurvedAnimation( ).animate(
CurvedAnimation(
parent: fabAnimationCtr, parent: fabAnimationCtr,
curve: Curves.easeInOut, curve: Curves.easeInOut,
)), ),
),
child: FloatingActionButton( child: FloatingActionButton(
heroTag: null, heroTag: null,
onPressed: () { onPressed: () {
@ -397,8 +389,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
// 完成评论,数据添加 // 完成评论,数据添加
if (value != null && value['data'] != null) if (value != null && value['data'] != null)
{ {
_dynamicDetailController.replyList _dynamicDetailController.replyList.add(value['data']),
.add(value['data']),
_dynamicDetailController.acount.value++ _dynamicDetailController.acount.value++
} }
}, },
@ -408,10 +399,6 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
child: const Icon(Icons.reply), child: const Icon(Icons.reply),
), ),
), ),
),
],
),
),
); );
} }
} }

View File

@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:hive/hive.dart'; import 'package:hive/hive.dart';
import 'package:pilipala/models/common/rank_type.dart'; import 'package:pilipala/models/common/rank_type.dart';
import 'package:pilipala/pages/rank/zone/index.dart';
import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/storage.dart';
class RankController extends GetxController with GetTickerProviderStateMixin { class RankController extends GetxController with GetTickerProviderStateMixin {
@ -29,20 +30,22 @@ class RankController extends GetxController with GetTickerProviderStateMixin {
void onRefresh() { void onRefresh() {
int index = tabController.index; int index = tabController.index;
var ctr = tabsCtrList[index]; final ZoneController ctr = tabsCtrList[index];
ctr().onRefresh(); ctr.onRefresh();
} }
void animateToTop() { void animateToTop() {
int index = tabController.index; int index = tabController.index;
var ctr = tabsCtrList[index]; final ZoneController ctr = tabsCtrList[index];
ctr().animateToTop(); ctr.animateToTop();
} }
void setTabConfig() async { void setTabConfig() async {
tabs.value = tabsConfig; tabs.value = tabsConfig;
initialIndex.value = 0; initialIndex.value = 0;
tabsCtrList = tabs.map((e) => e['ctr']).toList(); tabsCtrList = tabs
.map((e) => Get.put(ZoneController(), tag: e['rid'].toString()))
.toList();
tabsPageList = tabs.map<Widget>((e) => e['page']).toList(); tabsPageList = tabs.map<Widget>((e) => e['page']).toList();
tabController = TabController( tabController = TabController(

View File

@ -102,7 +102,7 @@ class _RankPageState extends State<RankPage>
onTap: (value) { onTap: (value) {
feedBack(); feedBack();
if (_rankController.initialIndex.value == value) { if (_rankController.initialIndex.value == value) {
_rankController.tabsCtrList[value]().animateToTop(); _rankController.tabsCtrList[value].animateToTop();
} }
_rankController.initialIndex.value = value; _rankController.initialIndex.value = value;
}, },

View File

@ -42,12 +42,15 @@ class ZoneController extends GetxController {
// 返回顶部并刷新 // 返回顶部并刷新
void animateToTop() async { void animateToTop() async {
if (scrollController.hasClients) {
if (scrollController.offset >= if (scrollController.offset >=
MediaQuery.of(Get.context!).size.height * 5) { MediaQuery.of(Get.context!).size.height * 5) {
scrollController.jumpTo(0); scrollController.jumpTo(0);
} else { } else {
await scrollController.animateTo(0, await scrollController.animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut); duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut);
}
} }
} }
} }

View File

@ -58,6 +58,7 @@ class VideoIntroController extends GetxController {
String heroTag = ''; String heroTag = '';
late ModelResult modelResult; late ModelResult modelResult;
PersistentBottomSheetController? bottomSheetController; PersistentBottomSheetController? bottomSheetController;
late bool enableRelatedVideo;
@override @override
void onInit() { void onInit() {
@ -74,6 +75,8 @@ class VideoIntroController extends GetxController {
queryOnlineTotal(); queryOnlineTotal();
startTimer(); // 在页面加载时启动定时器 startTimer(); // 在页面加载时启动定时器
} }
enableRelatedVideo =
setting.get(SettingBoxKey.enableRelatedVideo, defaultValue: true);
} }
// 获取视频简介&分p // 获取视频简介&分p
@ -447,15 +450,18 @@ class VideoIntroController extends GetxController {
// 重新获取视频资源 // 重新获取视频资源
final VideoDetailController videoDetailCtr = final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag); Get.find<VideoDetailController>(tag: heroTag);
if (enableRelatedVideo) {
final ReleatedController releatedCtr = final ReleatedController releatedCtr =
Get.find<ReleatedController>(tag: heroTag); Get.find<ReleatedController>(tag: heroTag);
releatedCtr.bvid = bvid;
releatedCtr.queryRelatedVideo();
}
videoDetailCtr.bvid = bvid; videoDetailCtr.bvid = bvid;
videoDetailCtr.oid.value = aid ?? IdUtils.bv2av(bvid); videoDetailCtr.oid.value = aid ?? IdUtils.bv2av(bvid);
videoDetailCtr.cid.value = cid; videoDetailCtr.cid.value = cid;
videoDetailCtr.danmakuCid.value = cid; videoDetailCtr.danmakuCid.value = cid;
videoDetailCtr.queryVideoUrl(); videoDetailCtr.queryVideoUrl();
releatedCtr.bvid = bvid;
releatedCtr.queryRelatedVideo();
// 重新请求评论 // 重新请求评论
try { try {
/// 未渲染回复组件时可能异常 /// 未渲染回复组件时可能异常

View File

@ -180,12 +180,21 @@ class _VideoDetailPageState extends State<VideoDetailPage>
plPlayerController?.isFullScreen.listen((bool isFullScreen) { plPlayerController?.isFullScreen.listen((bool isFullScreen) {
if (isFullScreen) { if (isFullScreen) {
vdCtr.hiddenReplyReplyPanel(); vdCtr.hiddenReplyReplyPanel();
if (vdCtr.videoType == SearchType.video) {
videoIntroController.hiddenEpisodeBottomSheet(); videoIntroController.hiddenEpisodeBottomSheet();
if (videoIntroController.videoDetail.value.ugcSeason != null || if (videoIntroController.videoDetail.value.ugcSeason != null ||
(videoIntroController.videoDetail.value.pages != null && (videoIntroController.videoDetail.value.pages != null &&
videoIntroController.videoDetail.value.pages!.length > 1)) { videoIntroController.videoDetail.value.pages!.length > 1)) {
vdCtr.bottomList.insert(3, BottomControlType.episode); vdCtr.bottomList.insert(3, BottomControlType.episode);
} }
}
if (vdCtr.videoType == SearchType.media_bangumi) {
bangumiIntroController.hiddenEpisodeBottomSheet();
if (bangumiIntroController.bangumiDetail.value.episodes != null &&
bangumiIntroController.bangumiDetail.value.episodes!.length > 1) {
vdCtr.bottomList.insert(3, BottomControlType.episode);
}
}
} else { } else {
if (vdCtr.bottomList.contains(BottomControlType.episode)) { if (vdCtr.bottomList.contains(BottomControlType.episode)) {
vdCtr.bottomList.removeAt(3); vdCtr.bottomList.removeAt(3);
@ -395,26 +404,40 @@ class _VideoDetailPageState extends State<VideoDetailPage>
width: 38, width: 38,
height: 38, height: 38,
child: Obx( child: Obx(
() => IconButton( () => !vdCtr.isShowCover.value
? IconButton(
onPressed: () { onPressed: () {
plPlayerController?.isOpenDanmu.value = plPlayerController?.isOpenDanmu.value =
!(plPlayerController?.isOpenDanmu.value ?? !(plPlayerController
?.isOpenDanmu.value ??
false); false);
}, },
icon: !(plPlayerController?.isOpenDanmu.value ?? icon:
!(plPlayerController?.isOpenDanmu.value ??
false) false)
? SvgPicture.asset( ? SvgPicture.asset(
'assets/images/video/danmu_close.svg', 'assets/images/video/danmu_close.svg',
// ignore: deprecated_member_use // ignore: deprecated_member_use
color: color: Theme.of(context)
Theme.of(context).colorScheme.outline, .colorScheme
.outline,
) )
: SvgPicture.asset( : SvgPicture.asset(
'assets/images/video/danmu_open.svg', 'assets/images/video/danmu_open.svg',
// ignore: deprecated_member_use // ignore: deprecated_member_use
color: color: Theme.of(context)
Theme.of(context).colorScheme.primary, .colorScheme
.primary,
), ),
)
: IconButton(
icon: SvgPicture.asset(
'assets/images/video/danmu_close.svg',
// ignore: deprecated_member_use
color:
Theme.of(context).colorScheme.outline,
),
onPressed: () {},
), ),
), ),
), ),

View File

@ -1306,20 +1306,6 @@ class _HeaderControlState extends State<HeaderControl> {
], ],
/// 字幕 /// 字幕
// SizedBox(
// width: 34,
// height: 34,
// child: IconButton(
// style: ButtonStyle(
// padding: MaterialStateProperty.all(EdgeInsets.zero),
// ),
// onPressed: () => showSubtitleDialog(),
// icon: const Icon(
// Icons.closed_caption_off,
// size: 22,
// ),
// ),
// ),
ComBtn( ComBtn(
icon: const Icon( icon: const Icon(
Icons.closed_caption_off, Icons.closed_caption_off,

View File

@ -473,17 +473,17 @@ class PlPlayerController {
} }
// 字幕 // 字幕
if (dataSource.subFiles != '' && dataSource.subFiles != null) { // if (dataSource.subFiles != '' && dataSource.subFiles != null) {
await pp.setProperty( // await pp.setProperty(
'sub-files', // 'sub-files',
UniversalPlatform.isWindows // UniversalPlatform.isWindows
? dataSource.subFiles!.replaceAll(';', '\\;') // ? dataSource.subFiles!.replaceAll(';', '\\;')
: dataSource.subFiles!.replaceAll(':', '\\:'), // : dataSource.subFiles!.replaceAll(':', '\\:'),
); // );
await pp.setProperty("subs-with-matching-audio", "no"); // await pp.setProperty("subs-with-matching-audio", "no");
await pp.setProperty("sub-forced-only", "yes"); // await pp.setProperty("sub-forced-only", "yes");
await pp.setProperty("blend-subtitles", "video"); // await pp.setProperty("blend-subtitles", "video");
} // }
_videoController = _videoController ?? _videoController = _videoController ??
VideoController( VideoController(
@ -522,7 +522,22 @@ class PlPlayerController {
Duration seekTo = Duration.zero, Duration seekTo = Duration.zero,
Duration? duration, Duration? duration,
}) async { }) async {
// 设置倍速 getVideoFit();
// if (_looping) {
// await setLooping(_looping);
// }
/// 跳转播放
if (seekTo != Duration.zero) {
await this.seekTo(seekTo);
}
/// 自动播放
if (_autoPlay) {
await play(duration: duration);
}
/// 设置倍速
if (videoType.value == 'live') { if (videoType.value == 'live') {
await setPlaybackSpeed(1.0); await setPlaybackSpeed(1.0);
} else { } else {
@ -532,20 +547,6 @@ class PlPlayerController {
await setPlaybackSpeed(1.0); await setPlaybackSpeed(1.0);
} }
} }
getVideoFit();
// if (_looping) {
// await setLooping(_looping);
// }
// 跳转播放
if (seekTo != Duration.zero) {
await this.seekTo(seekTo);
}
// 自动播放
if (_autoPlay) {
await play(duration: duration);
}
} }
List<StreamSubscription> subscriptions = []; List<StreamSubscription> subscriptions = [];
@ -603,7 +604,9 @@ class PlPlayerController {
makeHeartBeat(event.inSeconds); makeHeartBeat(event.inSeconds);
}), }),
videoPlayerController!.stream.duration.listen((event) { videoPlayerController!.stream.duration.listen((event) {
if (event > Duration.zero) {
duration.value = event; duration.value = event;
}
}), }),
videoPlayerController!.stream.buffer.listen((event) { videoPlayerController!.stream.buffer.listen((event) {
_buffered.value = event; _buffered.value = event;
@ -646,6 +649,7 @@ class PlPlayerController {
/// 跳转至指定位置 /// 跳转至指定位置
Future<void> seekTo(Duration position, {type = 'seek'}) async { Future<void> seekTo(Duration position, {type = 'seek'}) async {
try {
if (position < Duration.zero) { if (position < Duration.zero) {
position = Duration.zero; position = Duration.zero;
} }
@ -654,14 +658,20 @@ class PlPlayerController {
_heartDuration = position.inSeconds; _heartDuration = position.inSeconds;
if (duration.value.inSeconds != 0) { if (duration.value.inSeconds != 0) {
if (type != 'slider') { if (type != 'slider') {
/// 拖动进度条调节时,不等待第一帧,防止抖动
await _videoPlayerController?.stream.buffer.first; await _videoPlayerController?.stream.buffer.first;
} }
await _videoPlayerController?.seek(position); await _videoPlayerController?.seek(position);
} else { } else {
_timerForSeek?.cancel(); _timerForSeek?.cancel();
_timerForSeek ??= _timerForSeek ??= _startSeekTimer(position);
Timer.periodic(const Duration(milliseconds: 200), (Timer t) async { }
} catch (err) {
print('Error while seeking: $err');
}
}
Timer? _startSeekTimer(Duration position) {
return Timer.periodic(const Duration(milliseconds: 200), (Timer t) async {
if (duration.value.inSeconds != 0) { if (duration.value.inSeconds != 0) {
await _videoPlayerController!.stream.buffer.first; await _videoPlayerController!.stream.buffer.first;
await _videoPlayerController?.seek(position); await _videoPlayerController?.seek(position);
@ -670,7 +680,6 @@ class PlPlayerController {
} }
}); });
} }
}
/// 设置倍速 /// 设置倍速
Future<void> setPlaybackSpeed(double speed) async { Future<void> setPlaybackSpeed(double speed) async {
@ -708,11 +717,10 @@ class PlPlayerController {
await seekTo(Duration.zero); await seekTo(Duration.zero);
} }
await _videoPlayerController?.play(); await _videoPlayerController?.play();
playerStatus.status.value = PlayerStatus.playing;
await getCurrentVolume(); await getCurrentVolume();
await getCurrentBrightness(); await getCurrentBrightness();
playerStatus.status.value = PlayerStatus.playing;
// screenManager.setOverlays(false); // screenManager.setOverlays(false);
/// 临时fix _duration.value丢失 /// 临时fix _duration.value丢失

View File

@ -5,8 +5,8 @@ class SubTitleUtils {
for (int i = 0; i < jsonData.length; i++) { for (int i = 0; i < jsonData.length; i++) {
final item = jsonData[i]; final item = jsonData[i];
double from = item['from'] as double; double from = double.parse(item['from'].toString());
double to = item['to'] as double; double to = double.parse(item['to'].toString());
int sid = (item['sid'] ?? 0) as int; int sid = (item['sid'] ?? 0) as int;
String content = item['content'] as String; String content = item['content'] as String;

View File

@ -210,15 +210,18 @@ class Utils {
int minDiff = 127; int minDiff = 127;
int closestNumber = 0; // 初始化为0表示没有找到比目标值小的整数 int closestNumber = 0; // 初始化为0表示没有找到比目标值小的整数
if (numbers.contains(target)) {
return target;
}
// 向下查找 // 向下查找
try { try {
for (int number in numbers) { for (int number in numbers) {
if (number < target) { if (number < target) {
int diff = target - number; // 计算目标值与当前整数的差值 int diff = target - number; // 计算目标值与当前整数的差值
if (diff < minDiff) { if (diff < minDiff) {
minDiff = diff; minDiff = diff;
closestNumber = number; closestNumber = number;
return closestNumber;
} }
} }
} }