Merge branch 'main' into design

This commit is contained in:
guozhigq
2024-11-26 00:02:44 +08:00
20 changed files with 496 additions and 98 deletions

View File

@ -21,6 +21,7 @@ import 'package:pilipala/models/video/play/url.dart';
import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/utils/global_data_cache.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:pilipala/utils/utils.dart';
import 'package:pilipala/utils/video_utils.dart';
@ -140,8 +141,16 @@ class VideoDetailController extends GetxController
} else if (argMap.containsKey('pic')) {
updateCover(argMap['pic']);
}
tabCtr = TabController(length: 2, vsync: this);
tabs.value = <String>[
'简介',
if (videoType == SearchType.video &&
GlobalDataCache.enableComment.contains('video'))
'评论',
if (videoType == SearchType.media_bangumi &&
GlobalDataCache.enableComment.contains('bangumi'))
'评论'
];
tabCtr = TabController(length: tabs.length, vsync: this);
autoPlay.value =
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: false);
@ -198,7 +207,7 @@ class VideoDetailController extends GetxController
});
/// 仅投稿视频skip
if (videoType == SearchType.video) {
if (videoType == SearchType.video && GlobalDataCache.enableSponsorBlock) {
querySkipSegments();
}
}

View File

@ -17,6 +17,7 @@ import 'package:pilipala/pages/video/detail/controller.dart';
import 'package:pilipala/pages/video/detail/reply/index.dart';
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/global_data_cache.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:share_plus/share_plus.dart';
@ -87,19 +88,22 @@ class VideoIntroController extends GetxController {
}
// 获取视频简介&分p
Future queryVideoIntro({cover}) async {
Future queryVideoIntro({String? cover, String? type, int? cid}) async {
var result = await VideoHttp.videoIntro(bvid: bvid);
if (result['status']) {
videoDetail.value = result['data']!;
ugcSeason = result['data']!.ugcSeason;
pages.value = result['data']!.pages!;
lastPlayCid.value = videoDetail.value.cid!;
if (pages.isNotEmpty) {
lastPlayCid.value = pages.first.cid!;
if (type == null) {
lastPlayCid.value = cid ?? videoDetail.value.cid!;
}
final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag);
videoDetailCtr.tabs.value = ['简介', '评论 ${result['data']?.stat?.reply}'];
videoDetailCtr.tabs.value = [
'简介',
if (GlobalDataCache.enableComment.contains('video'))
'评论 ${result['data']?.stat?.reply}'
];
videoDetailCtr.cover.value = cover ?? result['data'].pic ?? '';
// 获取到粉丝数再返回
await queryUserStat();
@ -469,13 +473,16 @@ class VideoIntroController extends GetxController {
// 重新请求评论
try {
/// 未渲染回复组件时可能异常
final VideoReplyController videoReplyCtr =
Get.find<VideoReplyController>(tag: heroTag);
videoReplyCtr.aid = aid;
videoReplyCtr.queryReplyList(type: 'init');
if (GlobalDataCache.enableComment.contains('video')) {
final VideoReplyController videoReplyCtr =
Get.find<VideoReplyController>(tag: heroTag);
videoReplyCtr.aid = aid;
videoReplyCtr.queryReplyList(type: 'init');
}
} catch (_) {}
this.bvid = bvid;
await queryVideoIntro(cover: cover);
// 点击切换时优先取当前cid
await queryVideoIntro(cover: cover, cid: cid);
}
void startTimer() {

View File

@ -57,7 +57,7 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
heroTag = Get.arguments['heroTag'];
videoIntroController =
Get.put(VideoIntroController(bvid: widget.bvid), tag: heroTag);
_futureBuilderFuture = videoIntroController.queryVideoIntro();
_futureBuilderFuture = videoIntroController.queryVideoIntro(type: 'init');
videoIntroController.videoDetail.listen((value) {
videoDetail = value;
});

View File

@ -27,7 +27,7 @@ class SeasonPanel extends StatefulWidget {
}
class _SeasonPanelState extends State<SeasonPanel> {
late List<EpisodeItem> episodes;
List<EpisodeItem>? episodes;
late int cid;
late RxInt currentIndex = (-1).obs;
final String heroTag = Get.arguments['heroTag'];
@ -75,7 +75,10 @@ class _SeasonPanelState extends State<SeasonPanel> {
// 获取currentIndex
void getCurrentIndex() {
currentIndex.value = episodes.indexWhere((EpisodeItem e) => e.cid == cid);
if (episodes != null) {
currentIndex.value =
episodes!.indexWhere((EpisodeItem e) => e.cid == cid);
}
final List<SectionItem> sections = widget.ugcSeason.sections!;
if (sections.length == 1 && sections.first.type == 1) {
final List<EpisodeItem> episodesList = sections.first.episodes!;
@ -83,6 +86,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
for (int j = 0; j < episodesList[i].pages!.length; j++) {
if (episodesList[i].pages![j].cid == cid) {
currentIndex.value = i;
episodes = episodesList;
continue;
}
}
@ -137,7 +141,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
widget.videoIntroCtr.bottomSheetController =
_bottomSheetController = EpisodeBottomSheet(
currentCid: cid,
episodes: episodes,
episodes: episodes!,
changeFucCall: changeFucCall,
sheetHeight: widget.sheetHeight,
dataType: VideoEpidoesType.videoEpisode,
@ -165,7 +169,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
),
const SizedBox(width: 10),
Obx(() => Text(
'${currentIndex.value + 1}/${episodes.length}',
'${currentIndex.value + 1}/${episodes!.length}',
style: Theme.of(context).textTheme.labelMedium,
)),
const SizedBox(width: 6),

View File

@ -24,6 +24,7 @@ import 'package:pilipala/pages/video/detail/related/index.dart';
import 'package:pilipala/plugin/pl_player/index.dart';
import 'package:pilipala/plugin/pl_player/models/play_repeat.dart';
import 'package:pilipala/services/service_locator.dart';
import 'package:pilipala/utils/global_data_cache.dart';
import 'package:pilipala/utils/storage.dart';
import 'package:status_bar_control/status_bar_control.dart';
@ -779,13 +780,20 @@ class _VideoDetailPageState extends State<VideoDetailPage>
);
},
),
Obx(
() => VideoReplyPanel(
bvid: vdCtr.bvid,
oid: vdCtr.oid.value,
onControllerCreated: vdCtr.onControllerCreated,
),
)
if ((vdCtr.videoType == SearchType.media_bangumi &&
GlobalDataCache.enableComment
.contains('bangumi')) ||
(vdCtr.videoType == SearchType.video &&
GlobalDataCache.enableComment
.contains('video'))) ...[
Obx(
() => VideoReplyPanel(
bvid: vdCtr.bvid,
oid: vdCtr.oid.value,
onControllerCreated: vdCtr.onControllerCreated,
),
)
],
],
),
),