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

@@ -266,7 +266,7 @@ class VideoDetailController extends GetxController
type: DataSourceType.network,
httpHeaders: {
'user-agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
'referer': HttpString.baseUrl
},
),
@@ -329,7 +329,7 @@ class VideoDetailController extends GetxController
return result;
}
final List<VideoItem> allVideosList = data.dash!.video!;
print("allVideosList:${allVideosList}");
// print("allVideosList:${allVideosList}");
// 当前可播放的最高质量视频
int currentHighVideoQa = allVideosList.first.quality!.code;
// 预设的画质为null则当前可用的最高质量
@@ -426,6 +426,7 @@ class VideoDetailController extends GetxController
} else {
if (result['code'] == -404) {
isShowCover.value = false;
SmartDialog.showToast('视频不存在或已被删除');
}
if (result['code'] == 87008) {
SmartDialog.showToast("当前视频可能是专属视频,可能需包月充电观看(${result['msg']})");

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

View File

@@ -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: '评论',

View File

@@ -104,6 +104,7 @@ class IntroDetail extends StatelessWidget {
),
),
),
const SizedBox(height: 100),
],
),
),

View File

@@ -5,6 +5,8 @@ import 'package:PiliPalaX/common/widgets/animated_dialog.dart';
import 'package:PiliPalaX/common/widgets/http_error.dart';
import 'package:PiliPalaX/common/widgets/overlay_pop.dart';
import 'package:PiliPalaX/common/widgets/video_card_h.dart';
import '../../../../common/constants.dart';
import '../../../../utils/grid.dart';
import './controller.dart';
class RelatedVideoPanel extends StatefulWidget {
@@ -33,61 +35,75 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
@override
Widget build(BuildContext context) {
super.build(context);
return FutureBuilder(
future: _futureBuilder,
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == null) {
return const SliverToBoxAdapter(child: SizedBox());
}
if (snapshot.data!['status'] && snapshot.data != null) {
RxList relatedVideoList = _releatedController.relatedVideoList;
// 请求成功
return Obx(
() => SliverList(
return SliverPadding(
padding: const EdgeInsets.all(StyleString.safeSpace),
sliver: FutureBuilder(
future: _futureBuilder,
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
if (snapshot.data == null) {
return const SliverToBoxAdapter(child: SizedBox());
}
if (snapshot.data!['status'] && snapshot.hasData) {
RxList relatedVideoList = _releatedController.relatedVideoList;
// 请求成功
return Obx(
() => SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: StyleString.safeSpace,
crossAxisSpacing: StyleString.safeSpace,
maxCrossAxisExtent: Grid.maxRowWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.3,
mainAxisExtent: 0),
delegate: SliverChildBuilderDelegate((context, index) {
if (index == relatedVideoList.length) {
return SizedBox(
height: MediaQuery.of(context).padding.bottom);
} else {
return Material(
child: VideoCardH(
videoItem: relatedVideoList[index],
showPubdate: true,
longPress: () {
try {
_releatedController.popupDialog =
_createPopupDialog(_releatedController
.relatedVideoList[index]);
Overlay.of(context)
.insert(_releatedController.popupDialog!);
} catch (err) {
return {};
}
},
longPressEnd: () {
_releatedController.popupDialog?.remove();
},
),
);
}
}, childCount: relatedVideoList.length + 1),
),
);
} else {
// 请求错误
return HttpError(errMsg: '出错了', fn: () {});
}
} else {
// 骨架屏
return SliverGrid(
gridDelegate: SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: StyleString.safeSpace,
crossAxisSpacing: StyleString.safeSpace,
maxCrossAxisExtent: Grid.maxRowWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.3,
mainAxisExtent: 0),
delegate: SliverChildBuilderDelegate((context, index) {
if (index == relatedVideoList.length) {
return SizedBox(
height: MediaQuery.of(context).padding.bottom);
} else {
return Material(
child: VideoCardH(
videoItem: relatedVideoList[index],
showPubdate: true,
longPress: () {
try {
_releatedController.popupDialog =
_createPopupDialog(_releatedController
.relatedVideoList[index]);
Overlay.of(context)
.insert(_releatedController.popupDialog!);
} catch (err) {
return {};
}
},
longPressEnd: () {
_releatedController.popupDialog?.remove();
},
),
);
}
}, childCount: relatedVideoList.length + 1),
),
);
} else {
// 请求错误
return HttpError(errMsg: '出错了', fn: () {});
}
} else {
// 骨架屏
return SliverList(
delegate: SliverChildBuilderDelegate((context, index) {
return const VideoCardHSkeleton();
}, childCount: 5),
);
}
},
);
return const VideoCardHSkeleton();
}, childCount: 5),
);
}
},
));
}
OverlayEntry _createPopupDialog(videoItem) {

View File

@@ -59,6 +59,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
late bool enableVerticalExpand;
late bool autoPiP;
late bool pipNoDanmaku;
late bool removeSafeArea;
final Floating floating = Floating();
// 生命周期监听
// late final AppLifecycleListener _lifecycleListener;
@@ -66,7 +67,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
RxBool isFullScreen = false.obs;
late StreamSubscription<bool> fullScreenStatusListener;
late final MethodChannel onUserLeaveHintListener;
StreamSubscription<Duration>? _bufferedListener;
// StreamSubscription<Duration>? _bufferedListener;
@override
void initState() {
@@ -97,6 +98,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
pipNoDanmaku = setting.get(SettingBoxKey.pipNoDanmaku, defaultValue: true);
enableVerticalExpand =
setting.get(SettingBoxKey.enableVerticalExpand, defaultValue: false);
removeSafeArea = setting.get(SettingBoxKey.videoPlayerRemoveSafeArea,
defaultValue: false);
if (removeSafeArea) hideStatusBar();
videoSourceInit();
appbarStreamListen();
// lifecycleListener();
@@ -146,6 +150,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (status == PlayerStatus.completed) {
shutdownTimerService.handleWaitingFinished();
bool notExitFlag = false;
/// 顺序播放 列表循环
if (plPlayerController!.playRepeat != PlayRepeat.pause &&
plPlayerController!.playRepeat != PlayRepeat.singleCycle) {
@@ -246,7 +251,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
AutoOrientation.portraitUpMode();
}
shutdownTimerService.handleWaitingFinished();
_bufferedListener?.cancel();
// _bufferedListener?.cancel();
if (plPlayerController != null) {
plPlayerController!.removeStatusLister(playerListener);
fullScreenStatusListener.cancel();
@@ -262,7 +267,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
@override
// 离开当前页面时
void didPushNext() async {
_bufferedListener?.cancel();
// _bufferedListener?.cancel();
/// 开启
if (setting.get(SettingBoxKey.enableAutoBrightness, defaultValue: false)
@@ -392,10 +397,57 @@ class _VideoDetailPageState extends State<VideoDetailPage>
return const SizedBox();
}
});
Widget manualPlayerWidget = Obx(
() => Visibility(
visible: videoDetailController.isShowCover.value &&
videoDetailController.isEffective.value,
child: Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
child: AppBar(
primary: false,
foregroundColor: Colors.white,
elevation: 0,
scrolledUnderElevation: 0,
backgroundColor: Colors.transparent,
actions: [
IconButton(
tooltip: '稍后再看',
onPressed: () async {
var res = await UserHttp.toViewLater(
bvid: videoDetailController.bvid);
SmartDialog.showToast(res['msg']);
},
icon: const Icon(Icons.history_outlined),
),
const SizedBox(width: 14)
],
),
),
Positioned(
right: 12,
bottom: 10,
child: IconButton(
tooltip: '播放',
onPressed: () => handlePlay(),
icon: Image.asset(
'assets/images/play.png',
width: 60,
height: 60,
)),
),
],
)),
);
Widget childWhenDisabled = SafeArea(
top: MediaQuery.of(context).orientation == Orientation.portrait &&
top: !removeSafeArea &&
MediaQuery.of(context).orientation == Orientation.portrait &&
isFullScreen.value == true,
bottom: MediaQuery.of(context).orientation == Orientation.portrait &&
bottom: !removeSafeArea &&
MediaQuery.of(context).orientation == Orientation.portrait &&
isFullScreen.value == true,
left: false, //isFullScreen != true,
right: false, //isFullScreen != true,
@@ -404,17 +456,26 @@ class _VideoDetailPageState extends State<VideoDetailPage>
Scaffold(
resizeToAvoidBottomInset: false,
key: videoDetailController.scaffoldKey,
backgroundColor: Colors.black,
appBar: PreferredSize(
preferredSize: const Size.fromHeight(0),
child: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
// systemOverlayStyle: const SystemUiOverlayStyle(
// statusBarColor: Colors.transparent,
// statusBarIconBrightness: Brightness.light),
),
),
// backgroundColor: Colors.black,
appBar: removeSafeArea
? null
: AppBar(
backgroundColor: Colors.black,
elevation: 0,
toolbarHeight: 0,
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light),
),
// appBar: PreferredSize(
// preferredSize: const Size.fromHeight(0),
// child: AppBar(
// backgroundColor: Colors.transparent,
// elevation: 0,
// systemOverlayStyle: const SystemUiOverlayStyle(
// statusBarColor: Colors.transparent,
// statusBarIconBrightness: Brightness.light),
// ),
// ),
body: Column(
children: [
Obx(
@@ -424,7 +485,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
// print(videoDetailController.tabCtr.index);
if (enableVerticalExpand &&
plPlayerController?.direction.value == 'vertical') {
videoheight = context.width * 5 / 4;
videoheight = context.width;
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
@@ -439,15 +500,17 @@ class _VideoDetailPageState extends State<VideoDetailPage>
!isFullScreen.value &&
isShowing &&
mounted) {
showStatusBar();
if (!removeSafeArea) showStatusBar();
}
return SizedBox(
return Container(
color: Colors.black,
height: MediaQuery.of(context).orientation ==
Orientation.landscape ||
isFullScreen.value == true
? MediaQuery.sizeOf(context).height -
(MediaQuery.of(context).orientation ==
Orientation.landscape
Orientation.landscape ||
removeSafeArea
? 0
: MediaQuery.of(context).padding.top)
: videoheight,
@@ -498,59 +561,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
),
),
),
Obx(
() => Visibility(
visible: videoDetailController
.isShowCover.value &&
videoDetailController
.isEffective.value,
child: Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
child: AppBar(
primary: false,
foregroundColor: Colors.white,
elevation: 0,
scrolledUnderElevation: 0,
backgroundColor:
Colors.transparent,
actions: [
IconButton(
tooltip: '稍后再看',
onPressed: () async {
var res = await UserHttp
.toViewLater(
bvid:
videoDetailController
.bvid);
SmartDialog.showToast(
res['msg']);
},
icon: const Icon(
Icons.history_outlined),
),
const SizedBox(width: 14)
],
),
),
Positioned(
right: 12,
bottom: 10,
child: IconButton(
tooltip: '播放',
onPressed: () => handlePlay(),
icon: Image.asset(
'assets/images/play.png',
width: 60,
height: 60,
)),
),
],
)),
),
manualPlayerWidget,
]
],
)),
@@ -629,15 +640,308 @@ class _VideoDetailPageState extends State<VideoDetailPage>
],
),
);
Widget childWhenDisabledAlmostSquareInner = Obx(() {
if (enableVerticalExpand &&
plPlayerController?.direction.value == 'vertical') {
final double videoheight = context.height -
(removeSafeArea
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom));
final double videowidth = videoheight * 9 / 16;
return Row(children: [
SizedBox(
height: videoheight,
width: isFullScreen.value == true ? context.width : videowidth,
child: PopScope(
canPop: isFullScreen.value != true,
onPopInvoked: (bool didPop) {
if (isFullScreen.value == true) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
},
child: Stack(children: <Widget>[
if (isShowing) plPlayer,
/// 关闭自动播放时 手动播放
if (!videoDetailController.autoPlay.value) ...<Widget>[
Obx(
() => Visibility(
visible: videoDetailController.isShowCover.value,
child: Positioned(
top: 0,
left: 0,
right: 0,
child: GestureDetector(
onTap: () {
handlePlay();
},
child: NetworkImgLayer(
type: 'emote',
src: videoDetailController.videoItem['pic'],
width: videowidth,
height: videoheight,
),
),
),
),
),
manualPlayerWidget,
]
]),
),
),
Expanded(
child: TabBarView(
physics: const BouncingScrollPhysics(),
controller: videoDetailController.tabCtr,
children: <Widget>[
CustomScrollView(
key: const PageStorageKey<String>('简介'),
slivers: <Widget>[
if (videoDetailController.videoType ==
SearchType.video) ...[
const VideoIntroPanel(),
] else if (videoDetailController.videoType ==
SearchType.media_bangumi) ...[
Obx(() => BangumiIntroPanel(
cid: videoDetailController.cid.value)),
],
SliverToBoxAdapter(
child: Divider(
indent: 12,
endIndent: 12,
color: Theme.of(context).dividerColor.withOpacity(0.06),
),
),
const RelatedVideoPanel(),
],
),
Obx(
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
),
)
],
),
),
]);
}
final double videoheight = context.height / 2.5;
final double videowidth = context.width;
return Column(
children: [
SizedBox(
width: videowidth,
height: isFullScreen.value == true
? context.height -
(removeSafeArea
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom))
: videoheight,
child: PopScope(
canPop: isFullScreen.value != true,
onPopInvoked: (bool didPop) {
if (isFullScreen.value == true) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
},
child: Stack(children: <Widget>[
if (isShowing) plPlayer,
/// 关闭自动播放时 手动播放
if (!videoDetailController.autoPlay.value) ...<Widget>[
Obx(
() => Visibility(
visible: videoDetailController.isShowCover.value,
child: Positioned(
top: 0,
left: 0,
right: 0,
child: GestureDetector(
onTap: () {
handlePlay();
},
child: NetworkImgLayer(
type: 'emote',
src: videoDetailController.videoItem['pic'],
width: videowidth,
height: videoheight,
),
),
),
),
),
manualPlayerWidget,
]
]),
),
),
Expanded(
child: Row(children: [
Expanded(
child: CustomScrollView(
key: PageStorageKey<String>('简介${videoDetailController.bvid}'),
slivers: <Widget>[
if (videoDetailController.videoType == SearchType.video) ...[
const VideoIntroPanel(),
const RelatedVideoPanel(),
] else if (videoDetailController.videoType ==
SearchType.media_bangumi) ...[
Obx(() =>
BangumiIntroPanel(cid: videoDetailController.cid.value)),
]
],
)),
Expanded(
child: Obx(
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
),
),
)
]))
],
);
});
Widget childWhenDisabledLandscapeInner = Obx(() {
// 系数是以下三个方程(分别代表特定平板、折叠屏内屏、普通手机横屏尺寸)的近似解
// 820x+1180y+983.67z=450
// 1812x+2176y+1985.68z=680
// 1080x+2340y+1589.72z=560
final double videoheight = sqrt(context.height * context.width) * 12.555 -
context.height * 7.690 -
context.width * 4.741;
final double videowidth = videoheight * 16 / 9;
if (enableVerticalExpand &&
plPlayerController?.direction.value == 'vertical') {
final double videoheight = context.height -
(removeSafeArea
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom));
final double videowidth = videoheight * 9 / 16;
return Row(
children: [
SizedBox(
height: videoheight,
width: isFullScreen.value == true ? context.width : videowidth,
child: PopScope(
canPop: isFullScreen.value != true,
onPopInvoked: (bool didPop) {
if (isFullScreen.value == true) {
plPlayerController!.triggerFullScreen(status: false);
}
if (MediaQuery.of(context).orientation ==
Orientation.landscape &&
!horizontalScreen) {
verticalScreenForTwoSeconds();
}
},
child: Stack(
children: <Widget>[
if (isShowing) plPlayer,
/// 关闭自动播放时 手动播放
if (!videoDetailController.autoPlay.value) ...<Widget>[
Obx(
() => Visibility(
visible: videoDetailController.isShowCover.value,
child: Positioned(
top: 0,
left: 0,
right: 0,
child: GestureDetector(
onTap: () {
handlePlay();
},
child: NetworkImgLayer(
type: 'emote',
src: videoDetailController.videoItem['pic'],
width: videowidth,
height: videoheight,
),
),
),
),
),
manualPlayerWidget,
]
],
),
),
),
Expanded(
child: Row(children: [
Expanded(
child: CustomScrollView(
key: PageStorageKey<String>('简介${videoDetailController.bvid}'),
slivers: <Widget>[
if (videoDetailController.videoType == SearchType.video) ...[
const VideoIntroPanel(),
const RelatedVideoPanel(),
] else if (videoDetailController.videoType ==
SearchType.media_bangumi) ...[
Obx(() => BangumiIntroPanel(
cid: videoDetailController.cid.value)),
]
],
)),
Expanded(
child: Obx(
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
),
),
)
]))
// Expanded(
// child: TabBarView(
// physics: const BouncingScrollPhysics(),
// controller: videoDetailController.tabCtr,
// children: <Widget>[
// CustomScrollView(
// key: const PageStorageKey<String>('简介'),
// slivers: <Widget>[
// if (videoDetailController.videoType ==
// SearchType.video) ...[
// const VideoIntroPanel(),
// ] else if (videoDetailController.videoType ==
// SearchType.media_bangumi) ...[
// Obx(() => BangumiIntroPanel(
// cid: videoDetailController.cid.value)),
// ],
// SliverToBoxAdapter(
// child: Divider(
// indent: 12,
// endIndent: 12,
// color: Theme.of(context).dividerColor.withOpacity(0.06),
// ),
// ),
// const RelatedVideoPanel(),
// ],
// ),
// Obx(
// () => VideoReplyPanel(
// bvid: videoDetailController.bvid,
// oid: videoDetailController.oid.value,
// ),
// )
// ],
// ),
// ),
],
);
}
final double videowidth =
max(context.height / context.width * 1.04, 1 / 2) * context.width;
final double videoheight = videowidth * 9 / 16;
return Row(
children: [
Column(
@@ -689,57 +993,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
),
),
),
Obx(
() => Visibility(
visible: videoDetailController
.isShowCover.value &&
videoDetailController.isEffective.value,
child: Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
child: AppBar(
primary: false,
foregroundColor: Colors.white,
elevation: 0,
scrolledUnderElevation: 0,
backgroundColor: Colors.transparent,
actions: [
IconButton(
tooltip: '稍后再看',
onPressed: () async {
var res =
await UserHttp.toViewLater(
bvid:
videoDetailController
.bvid);
SmartDialog.showToast(
res['msg']);
},
icon: const Icon(
Icons.history_outlined),
),
const SizedBox(width: 14)
],
),
),
Positioned(
right: 12,
bottom: 10,
child: IconButton(
tooltip: '播放',
onPressed: () => handlePlay(),
icon: Image.asset(
'assets/images/play.png',
width: 60,
height: 60,
)),
),
],
)),
),
manualPlayerWidget,
]
],
))),
@@ -750,8 +1004,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
? 0
: context.height -
videoheight -
MediaQuery.of(context).padding.top -
MediaQuery.of(context).padding.bottom,
(removeSafeArea
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom)),
child: CustomScrollView(
key: PageStorageKey<String>(
'简介${videoDetailController.bvid}'),
@@ -759,6 +1015,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (videoDetailController.videoType ==
SearchType.video) ...[
const VideoIntroPanel(),
const RelatedVideoPanel(),
] else if (videoDetailController.videoType ==
SearchType.media_bangumi) ...[
Obx(() => BangumiIntroPanel(
@@ -769,59 +1026,88 @@ class _VideoDetailPageState extends State<VideoDetailPage>
],
),
SizedBox(
width: isFullScreen.value == true
? 0
: (context.width -
MediaQuery.of(context).padding.left -
MediaQuery.of(context).padding.right -
videowidth),
height: context.height -
MediaQuery.of(context).padding.top -
MediaQuery.of(context).padding.bottom,
child: TabBarView(
physics: const BouncingScrollPhysics(),
controller: videoDetailController.tabCtr,
children: <Widget>[
if (videoDetailController.videoType == SearchType.video)
const CustomScrollView(
slivers: [
RelatedVideoPanel(),
],
),
Obx(
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
),
)
],
),
)
width: isFullScreen.value == true
? 0
: (context.width -
videowidth -
(removeSafeArea
? 0
: (MediaQuery.of(context).padding.left +
MediaQuery.of(context).padding.right))),
height: context.height -
(removeSafeArea
? 0
: (MediaQuery.of(context).padding.top +
MediaQuery.of(context).padding.bottom)),
child:
// TabBarView(
// physics: const BouncingScrollPhysics(),
// controller: videoDetailController.tabCtr,
// children: <Widget>[
// if (videoDetailController.videoType == SearchType.video)
// const CustomScrollView(
// slivers: [
// RelatedVideoPanel(),
// ],
// ),
Obx(
() => VideoReplyPanel(
bvid: videoDetailController.bvid,
oid: videoDetailController.oid.value,
),
)
// ],
// ),
)
],
);
});
Widget childWhenDisabledLandscape = Container(
color: Theme.of(context).colorScheme.background,
child: SafeArea(
left: isFullScreen.value != true,
right: isFullScreen.value != true,
child: Stack(children: [
Scaffold(
resizeToAvoidBottomInset: false,
key: videoDetailController.scaffoldKey,
backgroundColor: Theme.of(context).colorScheme.background,
appBar: PreferredSize(
preferredSize: const Size.fromHeight(0),
child: AppBar(
backgroundColor: Colors.transparent,
Widget childWhenDisabledLandscape = SafeArea(
left: !removeSafeArea && isFullScreen.value != true,
right: !removeSafeArea && isFullScreen.value != true,
top: !removeSafeArea,
bottom: !removeSafeArea,
child: Stack(children: [
Scaffold(
resizeToAvoidBottomInset: false,
key: videoDetailController.scaffoldKey,
backgroundColor: Colors.black,
appBar: removeSafeArea
? null
: AppBar(
backgroundColor: Colors.black,
elevation: 0,
// systemOverlayStyle: const SystemUiOverlayStyle(
// statusBarColor: Colors.transparent,
// statusBarIconBrightness: Brightness.dark),
toolbarHeight: 0,
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light),
),
),
body: childWhenDisabledLandscapeInner)
])));
body: Container(
color: Theme.of(context).colorScheme.background,
child: childWhenDisabledLandscapeInner))
]));
Widget childWhenDisabledAlmostSquare = SafeArea(
left: !removeSafeArea && isFullScreen.value != true,
right: !removeSafeArea && isFullScreen.value != true,
top: !removeSafeArea,
bottom: !removeSafeArea,
child: Stack(children: [
Scaffold(
resizeToAvoidBottomInset: false,
key: videoDetailController.scaffoldKey,
backgroundColor: Colors.black,
appBar: removeSafeArea
? null
: AppBar(
backgroundColor: Colors.black,
elevation: 0,
toolbarHeight: 0,
systemOverlayStyle: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light),
),
body: Container(
color: Theme.of(context).colorScheme.background,
child: childWhenDisabledAlmostSquareInner))
]));
Widget childWhenEnabled = Obx(
() => !videoDetailController.autoPlay.value
? const SizedBox()
@@ -851,7 +1137,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
),
),
);
if (!horizontalScreen) {
Widget autoChoose(Widget childWhenDisabled) {
if (Platform.isAndroid) {
return PiPSwitcher(
childWhenDisabled: childWhenDisabled,
@@ -862,34 +1148,59 @@ class _VideoDetailPageState extends State<VideoDetailPage>
return childWhenDisabled;
}
return OrientationBuilder(
builder: (BuildContext context, Orientation orientation) {
if (!horizontalScreen) {
return autoChoose(childWhenDisabled);
}
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (!isShowing) {
return ColoredBox(color: Theme.of(context).colorScheme.background);
}
if (orientation == Orientation.landscape) {
if (!horizontalScreen) {
hideStatusBar();
videoDetailController.hiddenReplyReplyPanel();
if (constraints.maxWidth > constraints.maxHeight * 1.25) {
// hideStatusBar();
// videoDetailController.hiddenReplyReplyPanel();
return autoChoose(childWhenDisabledLandscape);
} else if (constraints.maxWidth * (9 / 16) <
(2 / 5) * constraints.maxHeight) {
if (!isFullScreen.value) {
if (!removeSafeArea) showStatusBar();
}
return autoChoose(childWhenDisabled);
} else {
if (!isFullScreen.value) {
showStatusBar();
if (!removeSafeArea) showStatusBar();
}
return autoChoose(childWhenDisabledAlmostSquare);
}
if (Platform.isAndroid) {
return PiPSwitcher(
childWhenDisabled:
!horizontalScreen || orientation == Orientation.portrait
? childWhenDisabled
: childWhenDisabledLandscape,
childWhenEnabled: childWhenEnabled,
floating: floating,
);
}
return !horizontalScreen || orientation == Orientation.portrait
? childWhenDisabled
: childWhenDisabledLandscape;
//
// final Orientation orientation =
// constraints.maxWidth > constraints.maxHeight * 1.25
// ? Orientation.landscape
// : Orientation.portrait;
// if (orientation == Orientation.landscape) {
// if (!horizontalScreen) {
// hideStatusBar();
// videoDetailController.hiddenReplyReplyPanel();
// }
// } else {
// if (!isFullScreen.value) {
// showStatusBar();
// }
// }
// if (Platform.isAndroid) {
// return PiPSwitcher(
// childWhenDisabled:
// !horizontalScreen || orientation == Orientation.portrait
// ? childWhenDisabled
// : childWhenDisabledLandscape,
// childWhenEnabled: childWhenEnabled,
// floating: floating,
// );
// }
// return !horizontalScreen || orientation == Orientation.portrait
// ? childWhenDisabled
// : childWhenDisabledLandscape;
});
}
}

View File

@@ -237,7 +237,7 @@ class _HeaderControlState extends State<HeaderControl> {
builder: (BuildContext context) {
// TODO: 支持更多类型和颜色的弹幕
return AlertDialog(
title: const Text('发送弹幕(测试)'),
title: const Text('发送弹幕'),
content: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextField(
@@ -733,6 +733,8 @@ class _HeaderControlState extends State<HeaderControl> {
double danmakuDurationVal = widget.controller!.danmakuDurationVal;
// 弹幕描边
double strokeWidth = widget.controller!.strokeWidth;
// 字体粗细
int fontWeight = widget.controller!.fontWeight;
final DanmakuController danmakuController =
widget.controller!.danmakuController!;
@@ -762,7 +764,20 @@ class _HeaderControlState extends State<HeaderControl> {
child: Center(child: Text('弹幕设置', style: titleStyle)),
),
const SizedBox(height: 10),
Text('智能云屏蔽 $danmakuWeight'),
Row(
children: [
Text('智能云屏蔽 $danmakuWeight'),
const Spacer(),
TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
minimumSize: Size.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
onPressed: () => Get.toNamed('/danmakuBlock'),
child: const Text("屏蔽管理"))
],
),
Padding(
padding: const EdgeInsets.only(
top: 0,
@@ -909,6 +924,45 @@ class _HeaderControlState extends State<HeaderControl> {
),
),
),
Text('字体粗细 ${fontWeight + 1}(可能无法精确调节)'),
Padding(
padding: const EdgeInsets.only(
top: 0,
bottom: 6,
left: 10,
right: 10,
),
child: SliderTheme(
data: SliderThemeData(
trackShape: MSliderTrackShape(),
thumbColor: Theme.of(context).colorScheme.primary,
activeTrackColor: Theme.of(context).colorScheme.primary,
trackHeight: 10,
thumbShape: const RoundSliderThumbShape(
enabledThumbRadius: 6.0),
),
child: Slider(
min: 0,
max: 8,
value: fontWeight.toDouble(),
divisions: 9,
label: '${fontWeight + 1}',
onChanged: (double val) {
fontWeight = val.toInt();
widget.controller!.fontWeight = fontWeight;
widget.controller?.putDanmakuSettings();
setState(() {});
try {
final DanmakuOption currentOption =
danmakuController.option;
final DanmakuOption updatedOption =
currentOption.copyWith(fontWeight: fontWeight);
danmakuController.updateOption(updatedOption);
} catch (_) {}
},
),
),
),
Text('描边粗细 $strokeWidth'),
Padding(
padding: const EdgeInsets.only(