mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 视频简介与相关视频实现方式微调
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -17,6 +18,7 @@ import 'package:PiliPalaX/pages/video/detail/widgets/ai_detail.dart';
|
||||
import 'package:PiliPalaX/utils/feed_back.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
||||
import 'widgets/action_item.dart';
|
||||
import 'widgets/action_row_item.dart';
|
||||
@@ -93,7 +95,18 @@ class _VideoIntroPanelState extends State<VideoIntroPanel>
|
||||
snapshot.data['code'] == 62002
|
||||
? '上一页'
|
||||
: null,
|
||||
fn: () => Get.back(),
|
||||
fn: () {
|
||||
if (snapshot.data['code'] == -404 ||
|
||||
snapshot.data['code'] == 62002) {
|
||||
Get.back();
|
||||
return;
|
||||
}
|
||||
_futureBuilderFuture = videoIntroController.queryVideoIntro();
|
||||
_futureBuilderFuture!.then((value) {
|
||||
videoIntroController.videoDetail.refresh();
|
||||
setState(() {});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -245,11 +258,15 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData t = Theme.of(context);
|
||||
final Color outline = t.colorScheme.outline;
|
||||
bool isHorizontal = context.width > context.height * 1.25;
|
||||
return SliverLayoutBuilder(
|
||||
builder: (BuildContext context, SliverConstraints constraints) {
|
||||
bool isHorizontal = constraints.crossAxisExtent >
|
||||
constraints.viewportMainAxisExtent * 1.25;
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: StyleString.safeSpace, right: StyleString.safeSpace, top: 10),
|
||||
left: StyleString.safeSpace,
|
||||
right: StyleString.safeSpace,
|
||||
top: 10),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: !loadingStatus
|
||||
? Column(
|
||||
@@ -264,6 +281,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
vertical: 1, horizontal: 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
type: 'avatar',
|
||||
@@ -276,11 +294,14 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
fadeOutDuration: Duration.zero,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
owner.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.primary),
|
||||
@@ -292,71 +313,21 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
semanticsLabel: "$follower粉丝",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: outline,
|
||||
),
|
||||
),
|
||||
]),
|
||||
const Spacer(),
|
||||
Obx(() => AnimatedOpacity(
|
||||
opacity: loadingStatus ||
|
||||
videoIntroController
|
||||
.followStatus.isEmpty
|
||||
? 0
|
||||
: 1,
|
||||
duration: const Duration(milliseconds: 50),
|
||||
child: SizedBox(
|
||||
height: 32,
|
||||
child: Obx(
|
||||
() => videoIntroController
|
||||
.followStatus.isNotEmpty
|
||||
? TextButton(
|
||||
onPressed: () =>
|
||||
videoIntroController
|
||||
.actionRelationMod(
|
||||
context),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 8, right: 8),
|
||||
foregroundColor:
|
||||
followStatus['attribute'] !=
|
||||
0
|
||||
? outline
|
||||
: t.colorScheme
|
||||
.onPrimary,
|
||||
backgroundColor:
|
||||
followStatus['attribute'] !=
|
||||
0
|
||||
? t.colorScheme
|
||||
.onInverseSurface
|
||||
: t.colorScheme
|
||||
.primary, // 设置按钮背景色
|
||||
),
|
||||
child: Text(
|
||||
followStatus['attribute'] != 0
|
||||
? '已关注'
|
||||
: '关注',
|
||||
style: TextStyle(
|
||||
fontSize: t.textTheme
|
||||
.labelMedium!.fontSize),
|
||||
),
|
||||
)
|
||||
: ElevatedButton(
|
||||
onPressed: () =>
|
||||
videoIntroController
|
||||
.actionRelationMod(
|
||||
context),
|
||||
child: const Text('关注'),
|
||||
),
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
)),
|
||||
followButton(context, t),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (isHorizontal)
|
||||
if (isHorizontal) ...[
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: actionGrid(context, videoIntroController)),
|
||||
]
|
||||
]),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
@@ -421,15 +392,10 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
if (MineController.anonymity) ...<Widget>[
|
||||
const SizedBox(width: 10),
|
||||
Icon(
|
||||
CupertinoIcons.checkmark_shield,
|
||||
MdiIcons.incognito,
|
||||
size: 15,
|
||||
color: t.colorScheme.outline,
|
||||
),
|
||||
Text(
|
||||
'无痕',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: t.colorScheme.outline),
|
||||
semanticLabel: '无痕',
|
||||
),
|
||||
],
|
||||
const SizedBox(width: 10),
|
||||
@@ -455,8 +421,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
label: 'AI总结',
|
||||
child: GestureDetector(
|
||||
onTap: () async {
|
||||
final res =
|
||||
await videoIntroController.aiConclusion();
|
||||
final res = await videoIntroController
|
||||
.aiConclusion();
|
||||
if (res['status']) {
|
||||
showAiBottomSheet();
|
||||
}
|
||||
@@ -478,7 +444,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
// ),
|
||||
// ),
|
||||
// 点赞收藏转发 布局样式2
|
||||
if (!isHorizontal) actionGrid(context, videoIntroController),
|
||||
if (!isHorizontal)
|
||||
actionGrid(context, videoIntroController),
|
||||
// 合集
|
||||
if (!loadingStatus &&
|
||||
widget.videoDetail!.ugcSeason != null) ...[
|
||||
@@ -501,7 +468,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
pages: widget.videoDetail!.pages!,
|
||||
cid: videoIntroController.lastPlayCid.value,
|
||||
bvid: videoIntroController.bvid,
|
||||
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||
changeFuc:
|
||||
videoIntroController.changeSeasonOrbangu,
|
||||
))
|
||||
],
|
||||
],
|
||||
@@ -514,6 +482,31 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Obx followButton(BuildContext context, ThemeData t) {
|
||||
return Obx(
|
||||
() => TextButton(
|
||||
onPressed: () => videoIntroController.actionRelationMod(context),
|
||||
style: TextButton.styleFrom(
|
||||
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, // 设置按钮背景色
|
||||
),
|
||||
child: Text(
|
||||
((followStatus?['attribute'] ?? 0) != 0) ? '已关注' : '关注',
|
||||
style: TextStyle(fontSize: t.textTheme.labelMedium!.fontSize),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget actionGrid(BuildContext context, videoIntroController) {
|
||||
@@ -530,6 +523,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||
onTap: handleState(videoIntroController.actionLikeVideo),
|
||||
onLongPress: handleState(videoIntroController.actionOneThree),
|
||||
selectStatus: videoIntroController.hasLike.value,
|
||||
loadingStatus: loadingStatus,
|
||||
semanticsLabel: '点赞',
|
||||
|
||||
@@ -85,7 +85,10 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
|
||||
);
|
||||
} else {
|
||||
// 请求错误
|
||||
return HttpError(errMsg: '出错了', fn: () {});
|
||||
return HttpError(errMsg: '出错了', fn: () {
|
||||
_futureBuilder = _relatedController.queryRelatedVideo();
|
||||
_futureBuilder.then((value) => setState(() {}));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// 骨架屏
|
||||
|
||||
Reference in New Issue
Block a user