mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 视频简介跳过加载转圈;修复优先展示评论时无分p和连播失效、切换分p后未刷新数据
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -40,7 +42,7 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
|
||||
late String heroTag;
|
||||
late VideoIntroController videoIntroController;
|
||||
VideoDetailData? videoDetail;
|
||||
late Future? _futureBuilderFuture;
|
||||
// late Future? _futureBuilderFuture;
|
||||
|
||||
// 添加页面缓存
|
||||
@override
|
||||
@@ -56,7 +58,7 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
|
||||
// }
|
||||
heroTag = widget.heroTag;
|
||||
videoIntroController = Get.put(VideoIntroController(), tag: heroTag);
|
||||
_futureBuilderFuture = videoIntroController.queryVideoIntro();
|
||||
// _futureBuilderFuture = videoIntroController.queryVideoIntro();
|
||||
videoIntroController.videoDetail.listen((value) {
|
||||
videoDetail = value;
|
||||
});
|
||||
@@ -71,53 +73,19 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return const SliverToBoxAdapter(child: SizedBox());
|
||||
}
|
||||
if (snapshot.data['status']) {
|
||||
// 请求成功
|
||||
return Obx(
|
||||
() => VideoInfo(
|
||||
loadingStatus: false,
|
||||
videoDetail: videoIntroController.videoDetail.value,
|
||||
heroTag: heroTag,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return HttpError(
|
||||
errMsg: snapshot.data['msg'],
|
||||
btnText: snapshot.data['code'] == -404 ||
|
||||
snapshot.data['code'] == 62002
|
||||
? '上一页'
|
||||
: null,
|
||||
fn: () {
|
||||
if (snapshot.data['code'] == -404 ||
|
||||
snapshot.data['code'] == 62002) {
|
||||
Get.back();
|
||||
return;
|
||||
}
|
||||
_futureBuilderFuture = videoIntroController.queryVideoIntro();
|
||||
_futureBuilderFuture!.then((value) {
|
||||
videoIntroController.videoDetail.refresh();
|
||||
setState(() {});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return VideoInfo(
|
||||
return Obx(() => videoIntroController.videoDetail.value.title == null
|
||||
? VideoInfo(
|
||||
loadingStatus: true,
|
||||
videoDetail: videoDetail,
|
||||
heroTag: heroTag,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
)
|
||||
: VideoInfo(
|
||||
//key:herotag
|
||||
key: ValueKey(heroTag),
|
||||
loadingStatus: false,
|
||||
videoDetail: videoIntroController.videoDetail.value,
|
||||
heroTag: heroTag,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +113,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
|
||||
late final bool loadingStatus; // 加载状态
|
||||
|
||||
late final dynamic owner;
|
||||
late final dynamic follower;
|
||||
late final dynamic followStatus;
|
||||
late int mid;
|
||||
late String memberHeroTag;
|
||||
late bool enableAi;
|
||||
@@ -171,11 +136,6 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
videoItem = videoIntroController.videoItem!;
|
||||
|
||||
loadingStatus = widget.loadingStatus;
|
||||
owner = loadingStatus ? videoItem['owner'] : widget.videoDetail!.owner;
|
||||
follower = loadingStatus
|
||||
? '-'
|
||||
: Utils.numFormat(videoIntroController.userStat['follower']);
|
||||
followStatus = videoIntroController.followStatus;
|
||||
enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true);
|
||||
}
|
||||
|
||||
@@ -268,219 +228,227 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
right: StyleString.safeSpace,
|
||||
top: 10),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: !loadingStatus
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(children: [
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(children: [
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: onPushMember,
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 1, horizontal: 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
type: 'avatar',
|
||||
src: loadingStatus
|
||||
? videoItem['owner']?.face ?? ""
|
||||
: widget.videoDetail!.owner!.face,
|
||||
width: 30,
|
||||
height: 30,
|
||||
fadeInDuration: Duration.zero,
|
||||
fadeOutDuration: Duration.zero,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: onPushMember,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 1, horizontal: 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
type: 'avatar',
|
||||
src: loadingStatus
|
||||
? owner.face
|
||||
: widget.videoDetail!.owner!.face,
|
||||
width: 30,
|
||||
height: 30,
|
||||
fadeInDuration: Duration.zero,
|
||||
fadeOutDuration: Duration.zero,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
owner.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.primary),
|
||||
// semanticsLabel: "Up主:${owner.name}",
|
||||
),
|
||||
const SizedBox(height: 0),
|
||||
Text(
|
||||
follower,
|
||||
semanticsLabel: "$follower粉丝",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
loadingStatus
|
||||
? videoItem['owner']?.name ?? ""
|
||||
: widget.videoDetail!.owner!.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: t.colorScheme.primary),
|
||||
// semanticsLabel: "Up主:${owner.name}",
|
||||
),
|
||||
const SizedBox(height: 0),
|
||||
Obx(() => Text(
|
||||
Utils.numFormat(videoIntroController
|
||||
.userStat.value['follower']),
|
||||
semanticsLabel:
|
||||
"${Utils.numFormat(videoIntroController.userStat.value['follower'])}粉丝",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
)),
|
||||
followButton(context, t),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
if (isHorizontal) ...[
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: actionGrid(context, videoIntroController)),
|
||||
]
|
||||
]),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => showIntroDetail(),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
!loadingStatus
|
||||
? widget.videoDetail!.title
|
||||
: videoItem['title'],
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 16,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
]),
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => showIntroDetail(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 7, bottom: 6),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: !loadingStatus
|
||||
? widget.videoDetail!.stat!.view
|
||||
: videoItem['stat'].view,
|
||||
size: 'medium',
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
StatDanMu(
|
||||
theme: 'gray',
|
||||
danmu: !loadingStatus
|
||||
? widget.videoDetail!.stat!.danmu
|
||||
: videoItem['stat'].danmu,
|
||||
size: 'medium',
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
Utils.dateFormat(
|
||||
!loadingStatus
|
||||
? widget.videoDetail!.pubdate
|
||||
: videoItem['pubdate'],
|
||||
formatType: 'detail'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
if (MineController.anonymity) ...<Widget>[
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
MdiIcons.incognito,
|
||||
size: 15,
|
||||
color: t.colorScheme.outline,
|
||||
semanticLabel: '无痕',
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 10),
|
||||
if (videoIntroController.isShowOnlineTotal)
|
||||
Obx(
|
||||
() => Text(
|
||||
'${videoIntroController.total.value}人在看',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (enableAi)
|
||||
Positioned(
|
||||
right: 10,
|
||||
top: 6,
|
||||
child: Semantics(
|
||||
label: 'AI总结',
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
final res = await videoIntroController
|
||||
.aiConclusion();
|
||||
if (res['status']) {
|
||||
showAiBottomSheet();
|
||||
}
|
||||
},
|
||||
child: Image.asset('assets/images/ai.png',
|
||||
height: 22),
|
||||
)),
|
||||
)
|
||||
],
|
||||
),
|
||||
// 点赞收藏转发 布局样式1
|
||||
// SingleChildScrollView(
|
||||
// padding: const EdgeInsets.only(top: 7, bottom: 7),
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: actionRow(
|
||||
// context,
|
||||
// videoIntroController,
|
||||
// videoDetailCtr,
|
||||
// ),
|
||||
// ),
|
||||
// 点赞收藏转发 布局样式2
|
||||
if (!isHorizontal)
|
||||
actionGrid(context, videoIntroController),
|
||||
// 合集
|
||||
if (!loadingStatus &&
|
||||
widget.videoDetail!.ugcSeason != null) ...[
|
||||
Obx(
|
||||
() => SeasonPanel(
|
||||
heroTag: heroTag,
|
||||
ugcSeason: widget.videoDetail!.ugcSeason!,
|
||||
cid: videoIntroController.lastPlayCid.value != 0
|
||||
? videoIntroController.lastPlayCid.value
|
||||
: widget.videoDetail!.pages!.first.cid,
|
||||
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||
),
|
||||
)
|
||||
followButton(context, t),
|
||||
],
|
||||
if (!loadingStatus &&
|
||||
widget.videoDetail!.pages != null &&
|
||||
widget.videoDetail!.pages!.length > 1) ...[
|
||||
Obx(() => PagesPanel(
|
||||
heroTag: heroTag,
|
||||
pages: widget.videoDetail!.pages!,
|
||||
cid: videoIntroController.lastPlayCid.value,
|
||||
bvid: videoIntroController.bvid,
|
||||
changeFuc:
|
||||
videoIntroController.changeSeasonOrbangu,
|
||||
))
|
||||
],
|
||||
],
|
||||
)
|
||||
: const SizedBox(
|
||||
height: 130,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (isHorizontal) ...[
|
||||
const SizedBox(width: 10),
|
||||
Expanded(child: actionGrid(context, videoIntroController)),
|
||||
]
|
||||
]),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => showIntroDetail(),
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.videoDetail?.title ?? videoItem['title'] ?? "",
|
||||
// !loadingStatus
|
||||
// ? "${widget.videoDetail?.title}"
|
||||
// : videoItem['title'] ?? "",
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)),
|
||||
Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 16,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
]),
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => showIntroDetail(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 7, bottom: 6),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
StatView(
|
||||
theme: 'gray',
|
||||
view: !loadingStatus
|
||||
? widget.videoDetail?.stat?.view ?? '-'
|
||||
: videoItem['stat']?.view ?? '-',
|
||||
size: 'medium',
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
StatDanMu(
|
||||
theme: 'gray',
|
||||
danmu: !loadingStatus
|
||||
? widget.videoDetail?.stat?.danmu ?? '-'
|
||||
: videoItem['stat']?.danmu ?? '-',
|
||||
size: 'medium',
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
Utils.dateFormat(
|
||||
!loadingStatus
|
||||
? widget.videoDetail?.pubdate
|
||||
: videoItem['pubdate'],
|
||||
formatType: 'detail'),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
if (MineController.anonymity) ...<Widget>[
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
MdiIcons.incognito,
|
||||
size: 15,
|
||||
color: t.colorScheme.outline,
|
||||
semanticLabel: '无痕',
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 10),
|
||||
if (videoIntroController.isShowOnlineTotal)
|
||||
Obx(
|
||||
() => Text(
|
||||
'${videoIntroController.total.value}人在看',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (enableAi)
|
||||
Positioned(
|
||||
right: 10,
|
||||
top: 6,
|
||||
child: Semantics(
|
||||
label: 'AI总结',
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
final res =
|
||||
await videoIntroController.aiConclusion();
|
||||
if (res['status']) {
|
||||
showAiBottomSheet();
|
||||
}
|
||||
},
|
||||
child:
|
||||
Image.asset('assets/images/ai.png', height: 22),
|
||||
)),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
Obx(
|
||||
() => videoIntroController.queryVideoIntroData.value["status"]
|
||||
? const SizedBox()
|
||||
: Center(
|
||||
child: TextButton.icon(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
videoIntroController
|
||||
.queryVideoIntroData.value["status"] = true;
|
||||
videoIntroController.queryVideoIntro();
|
||||
},
|
||||
label: const Text("点此重新加载"),
|
||||
),
|
||||
),
|
||||
),
|
||||
// 点赞收藏转发 布局样式1
|
||||
// SingleChildScrollView(
|
||||
// padding: const EdgeInsets.only(top: 7, bottom: 7),
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child: actionRow(
|
||||
// context,
|
||||
// videoIntroController,
|
||||
// videoDetailCtr,
|
||||
// ),
|
||||
// ),
|
||||
// 点赞收藏转发 布局样式2
|
||||
if (!isHorizontal) actionGrid(context, videoIntroController),
|
||||
// 合集
|
||||
if (!loadingStatus && widget.videoDetail?.ugcSeason != null) ...[
|
||||
Obx(
|
||||
() => SeasonPanel(
|
||||
heroTag: heroTag,
|
||||
ugcSeason: widget.videoDetail!.ugcSeason!,
|
||||
cid: videoIntroController.lastPlayCid.value != 0
|
||||
? videoIntroController.lastPlayCid.value
|
||||
: widget.videoDetail!.pages!.first.cid,
|
||||
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||
),
|
||||
)
|
||||
],
|
||||
if (!loadingStatus &&
|
||||
widget.videoDetail?.pages != null &&
|
||||
widget.videoDetail!.pages!.length > 1) ...[
|
||||
Obx(() => PagesPanel(
|
||||
heroTag: heroTag,
|
||||
pages: widget.videoDetail!.pages!,
|
||||
cid: videoIntroController.lastPlayCid.value,
|
||||
bvid: videoIntroController.bvid,
|
||||
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||
))
|
||||
],
|
||||
],
|
||||
)),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -494,15 +462,19 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
visualDensity: VisualDensity.compact,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.only(left: 6, right: 6),
|
||||
foregroundColor: (followStatus?['attribute'] ?? 0) != 0
|
||||
? t.colorScheme.outline
|
||||
: t.colorScheme.onPrimary,
|
||||
backgroundColor: (followStatus?['attribute'] ?? 0) != 0
|
||||
? t.colorScheme.onInverseSurface
|
||||
: t.colorScheme.primary, // 设置按钮背景色
|
||||
foregroundColor:
|
||||
(videoIntroController.followStatus['attribute'] ?? 0) != 0
|
||||
? t.colorScheme.outline
|
||||
: t.colorScheme.onPrimary,
|
||||
backgroundColor:
|
||||
(videoIntroController.followStatus['attribute'] ?? 0) != 0
|
||||
? t.colorScheme.onInverseSurface
|
||||
: t.colorScheme.primary, // 设置按钮背景色
|
||||
),
|
||||
child: Text(
|
||||
((followStatus?['attribute'] ?? 0) != 0) ? '已关注' : '关注',
|
||||
((videoIntroController.followStatus['attribute'] ?? 0) != 0)
|
||||
? '已关注'
|
||||
: '关注',
|
||||
style: TextStyle(fontSize: t.textTheme.labelMedium!.fontSize),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user