opt intro controller

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-02 14:07:29 +08:00
parent 199ddc0e7e
commit 3c964787df
19 changed files with 507 additions and 446 deletions

View File

@@ -10,14 +10,15 @@ import 'package:PiliPlus/models/pgc_lcf.dart';
import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart';
import 'package:PiliPlus/models_new/pgc/pgc_info_model/result.dart';
import 'package:PiliPlus/models_new/triple/pgc_triple.dart';
import 'package:PiliPlus/models_new/video/video_detail/data.dart';
import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart';
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
import 'package:PiliPlus/pages/video/controller.dart';
import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
import 'package:PiliPlus/pages/video/pay_coins/view.dart';
import 'package:PiliPlus/pages/video/reply/controller.dart';
import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
import 'package:PiliPlus/services/service_locator.dart';
import 'package:PiliPlus/utils/feed_back.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/page_utils.dart';
@@ -257,7 +258,7 @@ class PgcIntroController extends CommonIntroController {
}
// 修改分P或番剧分集
void changeSeasonOrbangu(dynamic epId, bvid, cid, aid, cover) {
void onChangeEpisode(dynamic epId, bvid, cid, aid, cover) {
// 重新获取视频资源
this.epId = epId;
this.bvid = bvid;
@@ -270,7 +271,6 @@ class PgcIntroController extends CommonIntroController {
..epId = epId
..bvid = bvid
..cid.value = cid
..danmakuCid.value = cid
..queryVideoUrl();
if (cover is String && cover.isNotEmpty) {
videoDetailCtr.cover.value = cover;
@@ -289,13 +289,9 @@ class PgcIntroController extends CommonIntroController {
queryPgcLikeCoinFav();
}
try {
Get.find<VideoIntroController>(tag: Get.arguments['heroTag'])
..bvid = bvid
..lastPlayCid.value = cid
..queryVideoIntro()
..queryOnlineTotal();
} catch (_) {}
this.cid.value = cid;
queryVideoIntro();
queryOnlineTotal();
}
// 追番
@@ -328,6 +324,7 @@ class PgcIntroController extends CommonIntroController {
SmartDialog.showToast(result['msg']);
}
@override
bool prevPlay() {
final episodes = pgcItem.episodes!;
VideoDetailController videoDetailCtr = Get.find<VideoDetailController>(
@@ -346,7 +343,7 @@ class PgcIntroController extends CommonIntroController {
}
}
final episode = episodes[prevIndex];
changeSeasonOrbangu(
onChangeEpisode(
episode.epId,
episode.bvid,
episode.cid,
@@ -357,6 +354,7 @@ class PgcIntroController extends CommonIntroController {
}
/// 列表循环或者顺序播放时,自动播放下一个;自动连播时,播放相关视频
@override
bool nextPlay() {
try {
final episodes = pgcItem.episodes!;
@@ -380,7 +378,7 @@ class PgcIntroController extends CommonIntroController {
}
}
final episode = episodes[nextIndex];
changeSeasonOrbangu(
onChangeEpisode(
episode.epId,
episode.bvid,
episode.cid,
@@ -456,4 +454,14 @@ class PgcIntroController extends CommonIntroController {
}
});
}
@override
Future<void> queryVideoIntro() async {
var res = await VideoHttp.videoIntro(bvid: bvid);
if (res.isSuccess) {
VideoDetailData data = res.data;
videoPlayerServiceHandler.onVideoDetailChange(data, data.cid!, heroTag);
videoDetail.value = data;
}
}
}

View File

@@ -252,7 +252,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
heroTag: widget.heroTag,
pages: item.episodes!,
cid: videoDetailCtr.cid.value,
changeFuc: pgcIntroController.changeSeasonOrbangu,
onChangeEpisode: pgcIntroController.onChangeEpisode,
showEpisodes: widget.showEpisodes,
newEp: item.newEp,
),
@@ -326,13 +326,15 @@ class _PgcIntroPageState extends State<PgcIntroPage>
needAnim: true,
),
),
ActionItem(
icon: const Icon(FontAwesomeIcons.comment),
selectIcon: const Icon(FontAwesomeIcons.reply),
onTap: () => videoDetailCtr.tabCtr.animateTo(1),
selectStatus: false,
semanticsLabel: '评论',
text: NumUtil.numFormat(item.stat!.reply),
Obx(
() => ActionItem(
icon: const Icon(FontAwesomeIcons.clock),
selectIcon: const Icon(FontAwesomeIcons.solidClock),
onTap: () => handleState(pgcIntroController.viewLater),
selectStatus: pgcIntroController.hasLater.value,
semanticsLabel: '再看',
text: '再看',
),
),
ActionItem(
icon: const Icon(FontAwesomeIcons.shareFromSquare),

View File

@@ -94,94 +94,99 @@ class _IntroDetailState extends CommonCollapseSlidePageState<PgcIntroPanel> {
fontSize: 12,
color: theme.colorScheme.onSurface,
);
return ListView(
controller: _controller,
physics: const AlwaysScrollableScrollPhysics(),
padding: EdgeInsets.only(
left: 14,
right: 14,
top: 14,
bottom: MediaQuery.paddingOf(context).bottom + 80,
),
children: [
SelectableText(
widget.item.title!,
style: const TextStyle(fontSize: 16),
final TextStyle textStyle = TextStyle(
color: theme.colorScheme.onSurfaceVariant,
);
return SelectionArea(
child: ListView(
controller: _controller,
physics: const AlwaysScrollableScrollPhysics(),
padding: EdgeInsets.only(
left: 14,
right: 14,
top: 14,
bottom: MediaQuery.paddingOf(context).bottom + 80,
),
const SizedBox(height: 4),
Row(
spacing: 6,
children: [
StatWidget(
type: StatType.play,
value: widget.item.stat!.view,
),
StatWidget(
type: StatType.danmaku,
value: widget.item.stat!.danmaku,
),
],
),
const SizedBox(height: 4),
Row(
children: [
Text(
widget.item.areas!.first.name!,
style: smallTitle,
),
const SizedBox(width: 6),
Text(
widget.item.publish!.pubTimeShow!,
style: smallTitle,
),
const SizedBox(width: 6),
Text(
widget.item.newEp!.desc!,
style: smallTitle,
),
],
),
const SizedBox(height: 20),
Text(
'简介:',
style: theme.textTheme.titleMedium,
),
const SizedBox(height: 4),
SelectableText(
widget.item.evaluate!,
style: smallTitle.copyWith(fontSize: 14),
),
const SizedBox(height: 20),
Text(
'声优:',
style: theme.textTheme.titleMedium,
),
const SizedBox(height: 4),
SelectableText(
widget.item.actors!,
style: smallTitle.copyWith(fontSize: 14),
),
if (widget.videoTags?.isNotEmpty == true) ...[
const SizedBox(height: 10),
Wrap(
spacing: 8,
runSpacing: 8,
children: widget.videoTags!
.map(
(item) => SearchText(
fontSize: 13,
text: item.tagName!,
onTap: (tagName) => Get.toNamed(
'/searchResult',
parameters: {'keyword': tagName},
),
onLongPress: Utils.copyText,
),
)
.toList(),
children: [
Text(
widget.item.title!,
style: const TextStyle(fontSize: 16),
),
const SizedBox(height: 4),
Row(
spacing: 6,
children: [
StatWidget(
type: StatType.play,
value: widget.item.stat!.view,
),
StatWidget(
type: StatType.danmaku,
value: widget.item.stat!.danmaku,
),
],
),
const SizedBox(height: 4),
Row(
children: [
Text(
widget.item.areas!.first.name!,
style: smallTitle,
),
const SizedBox(width: 6),
Text(
widget.item.publish!.pubTimeShow!,
style: smallTitle,
),
const SizedBox(width: 6),
Text(
widget.item.newEp!.desc!,
style: smallTitle,
),
],
),
const SizedBox(height: 20),
Text(
'简介:',
style: theme.textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(
widget.item.evaluate!,
style: textStyle,
),
const SizedBox(height: 20),
Text(
'演职人员:',
style: theme.textTheme.titleMedium,
),
const SizedBox(height: 4),
Text(
widget.item.actors!,
style: textStyle,
),
if (widget.videoTags?.isNotEmpty == true) ...[
const SizedBox(height: 10),
Wrap(
spacing: 8,
runSpacing: 8,
children: widget.videoTags!
.map(
(item) => SearchText(
fontSize: 13,
text: item.tagName!,
onTap: (tagName) => Get.toNamed(
'/searchResult',
parameters: {'keyword': tagName},
),
onLongPress: Utils.copyText,
),
)
.toList(),
),
],
],
],
),
);
}
}

View File

@@ -15,7 +15,7 @@ class PgcPanel extends StatefulWidget {
super.key,
required this.pages,
this.cid,
required this.changeFuc,
required this.onChangeEpisode,
required this.showEpisodes,
required this.heroTag,
this.newEp,
@@ -23,7 +23,7 @@ class PgcPanel extends StatefulWidget {
final List<EpisodeItem> pages;
final int? cid;
final Function changeFuc;
final Function onChangeEpisode;
final Function showEpisodes;
final String heroTag;
final NewEp? newEp;
@@ -154,7 +154,7 @@ class _PgcPanelState extends State<PgcPanel> {
vipStatus != 1) {
SmartDialog.showToast('需要大会员');
}
widget.changeFuc(
widget.onChangeEpisode(
item.epId,
item.bvid,
item.cid,