mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 侧边栏、动态重构,排行改为首页分区,平板、折叠屏、竖屏视频新适配,播放页可隐藏黑边、截图、点踩,弹幕粗细调整,默认关闭后台播放,弹窗接受返回
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
@@ -42,6 +43,8 @@ class VideoIntroController extends GetxController {
|
||||
|
||||
// 是否点赞
|
||||
RxBool hasLike = false.obs;
|
||||
// 是否点踩
|
||||
RxBool hasDislike = false.obs;
|
||||
// 是否投币
|
||||
RxBool hasCoin = false.obs;
|
||||
// 是否收藏
|
||||
@@ -145,15 +148,16 @@ class VideoIntroController extends GetxController {
|
||||
// 获取点赞状态
|
||||
Future queryHasLikeVideo() async {
|
||||
var result = await VideoHttp.hasLikeVideo(bvid: bvid);
|
||||
// data num 被点赞标志 0:未点赞 1:已点赞
|
||||
hasLike.value = result["data"] == 1 ? true : false;
|
||||
// data num 被点赞标志 0:未点赞 1:已点赞 2:已点踩
|
||||
hasLike.value = result["data"] == 1;
|
||||
hasDislike.value = result["data"] == 2;
|
||||
}
|
||||
|
||||
// 获取投币状态
|
||||
Future queryHasCoinVideo() async {
|
||||
var result = await VideoHttp.hasCoinVideo(bvid: bvid);
|
||||
if (result['status']) {
|
||||
hasCoin.value = result["data"]['multiply'] == 0 ? false : true;
|
||||
hasCoin.value = result["data"]['multiply'] != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +174,7 @@ class VideoIntroController extends GetxController {
|
||||
}
|
||||
|
||||
// 一键三连
|
||||
Future actionOneThree() async {
|
||||
Future actionOneThree(BuildContext context) async {
|
||||
if (userInfo == null) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
@@ -180,19 +184,19 @@ class VideoIntroController extends GetxController {
|
||||
SmartDialog.showToast('🙏 UP已经收到了~');
|
||||
return false;
|
||||
}
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||
builder: (BuildContext context) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content: const Text('一键三连 给UP送温暖'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => SmartDialog.dismiss(),
|
||||
onPressed: () => Get.back(),
|
||||
child: const Text('点错了')),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
var result = await VideoHttp.oneThree(bvid: bvid);
|
||||
if (result['status']) {
|
||||
hasLike.value = result["data"]["like"];
|
||||
@@ -202,7 +206,6 @@ class VideoIntroController extends GetxController {
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
child: const Text('确认'),
|
||||
)
|
||||
@@ -224,6 +227,7 @@ class VideoIntroController extends GetxController {
|
||||
if (!hasLike.value) {
|
||||
SmartDialog.showToast('点赞成功');
|
||||
hasLike.value = true;
|
||||
hasDislike.value = false;
|
||||
videoDetail.value.stat!.like = videoDetail.value.stat!.like! + 1;
|
||||
} else if (hasLike.value) {
|
||||
SmartDialog.showToast('取消赞');
|
||||
@@ -236,6 +240,29 @@ class VideoIntroController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future actionDislikeVideo() async {
|
||||
if (userInfo == null) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
return;
|
||||
}
|
||||
var result =
|
||||
await VideoHttp.dislikeVideo(bvid: bvid, type: !hasDislike.value);
|
||||
if (result['status']) {
|
||||
// hasLike.value = result["data"] == 1 ? true : false;
|
||||
if (!hasDislike.value) {
|
||||
SmartDialog.showToast('点踩成功');
|
||||
hasDislike.value = true;
|
||||
hasLike.value = false;
|
||||
} else {
|
||||
SmartDialog.showToast('取消踩');
|
||||
hasDislike.value = false;
|
||||
}
|
||||
// hasDislike.refresh();
|
||||
} else {
|
||||
SmartDialog.showToast(result['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
// 投币
|
||||
Future actionCoinVideo() async {
|
||||
if (userInfo == null) {
|
||||
@@ -350,10 +377,33 @@ class VideoIntroController extends GetxController {
|
||||
|
||||
// 分享视频
|
||||
Future actionShareVideo() async {
|
||||
var result = await Share.share(
|
||||
'${videoDetail.value.title} UP主: ${videoDetail.value.owner!.name!} - ${HttpString.baseUrl}/video/$bvid')
|
||||
.whenComplete(() {});
|
||||
return result;
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
String videoUrl = '${HttpString.baseUrl}/video/$bvid';
|
||||
return AlertDialog(
|
||||
title: const Text('分享方式'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: videoUrl));
|
||||
SmartDialog.showToast('已复制');
|
||||
Get.back();
|
||||
},
|
||||
child: const Text('复制链接')),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
var result = await Share.share('${videoDetail.value.title} '
|
||||
'UP主: ${videoDetail.value.owner!.name!}'
|
||||
' - $videoUrl')
|
||||
.whenComplete(() {});
|
||||
Get.back();
|
||||
return result;
|
||||
},
|
||||
child: const Text('分享视频')),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Future queryVideoInFolder() async {
|
||||
@@ -394,7 +444,7 @@ class VideoIntroController extends GetxController {
|
||||
}
|
||||
|
||||
// 关注/取关up
|
||||
Future actionRelationMod() async {
|
||||
Future actionRelationMod(BuildContext context) async {
|
||||
feedBack();
|
||||
if (userInfo == null) {
|
||||
SmartDialog.showToast('账号未登录');
|
||||
@@ -413,16 +463,15 @@ class VideoIntroController extends GetxController {
|
||||
actionStatus = 0;
|
||||
break;
|
||||
}
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||
builder: (BuildContext context) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('提示'),
|
||||
content: Text(currentStatus == 0 ? '关注UP主?' : '取消关注UP主?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => SmartDialog.dismiss(),
|
||||
onPressed: () => Get.back(),
|
||||
child: Text(
|
||||
'点错了',
|
||||
style: TextStyle(color: Theme.of(context).colorScheme.outline),
|
||||
@@ -465,7 +514,7 @@ class VideoIntroController extends GetxController {
|
||||
}
|
||||
}
|
||||
}
|
||||
SmartDialog.dismiss();
|
||||
Get.back();
|
||||
},
|
||||
child: const Text('确认'),
|
||||
)
|
||||
|
||||
@@ -244,6 +244,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
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 SliverPadding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: StyleString.safeSpace, right: StyleString.safeSpace, top: 10),
|
||||
@@ -252,20 +253,132 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
? 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,
|
||||
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),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
owner.name,
|
||||
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: 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('关注'),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (isHorizontal)
|
||||
Expanded(
|
||||
child: actionGrid(context, videoIntroController)),
|
||||
]),
|
||||
const SizedBox(height: 8),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () => showIntroDetail(),
|
||||
child: Text(
|
||||
!loadingStatus
|
||||
? widget.videoDetail!.title
|
||||
: videoItem['title'],
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
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,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
]),
|
||||
),
|
||||
Stack(
|
||||
children: [
|
||||
@@ -363,7 +476,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
// ),
|
||||
// ),
|
||||
// 点赞收藏转发 布局样式2
|
||||
actionGrid(context, videoIntroController),
|
||||
if (!isHorizontal) actionGrid(context, videoIntroController),
|
||||
// 合集
|
||||
if (!loadingStatus &&
|
||||
widget.videoDetail!.ugcSeason != null) ...[
|
||||
@@ -387,93 +500,10 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
changeFuc: videoIntroController.changeSeasonOrbangu,
|
||||
))
|
||||
],
|
||||
GestureDetector(
|
||||
onTap: onPushMember,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8, horizontal: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
type: 'avatar',
|
||||
src: loadingStatus
|
||||
? owner.face
|
||||
: widget.videoDetail!.owner!.face,
|
||||
width: 34,
|
||||
height: 34,
|
||||
fadeInDuration: Duration.zero,
|
||||
fadeOutDuration: Duration.zero,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
owner.name,
|
||||
style: const TextStyle(fontSize: 13),
|
||||
// semanticsLabel: "Up主:${owner.name}",
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
follower,
|
||||
semanticsLabel: "粉丝数:$follower",
|
||||
style: TextStyle(
|
||||
fontSize: t.textTheme.labelSmall!.fontSize,
|
||||
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,
|
||||
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,
|
||||
child: const Text('关注'),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: const SizedBox(
|
||||
height: 100,
|
||||
height: 130,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
@@ -503,6 +533,16 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
? Utils.numFormat(widget.videoDetail!.stat!.like!)
|
||||
: '-'),
|
||||
),
|
||||
Obx(
|
||||
() => ActionItem(
|
||||
icon: const Icon(FontAwesomeIcons.thumbsDown),
|
||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsDown),
|
||||
onTap: handleState(videoIntroController.actionDislikeVideo),
|
||||
selectStatus: videoIntroController.hasDislike.value,
|
||||
loadingStatus: loadingStatus,
|
||||
semanticsLabel: '点踩',
|
||||
text: "点踩"),
|
||||
),
|
||||
// ActionItem(
|
||||
// icon: const Icon(FontAwesomeIcons.clock),
|
||||
// onTap: () => videoIntroController.actionShareVideo(),
|
||||
@@ -536,7 +576,8 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
||||
),
|
||||
ActionItem(
|
||||
icon: const Icon(FontAwesomeIcons.comment),
|
||||
onTap: () => videoDetailCtr.tabCtr.animateTo(1),
|
||||
onTap: () => videoDetailCtr.tabCtr
|
||||
.animateTo(videoDetailCtr.tabCtr.index == 1 ? 0 : 1),
|
||||
selectStatus: false,
|
||||
loadingStatus: loadingStatus,
|
||||
semanticsLabel: '评论',
|
||||
|
||||
@@ -104,6 +104,7 @@ class IntroDetail extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 100),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user