mod: 侧边栏、动态重构,排行改为首页分区,平板、折叠屏、竖屏视频新适配,播放页可隐藏黑边、截图、点踩,弹幕粗细调整,默认关闭后台播放,弹窗接受返回

This commit is contained in:
orz12
2024-05-20 14:46:31 +08:00
parent fd51cddeca
commit 074bf03946
97 changed files with 4105 additions and 2672 deletions

View File

@@ -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('确认'),
)