mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-18 08:06:21 +08:00
fix: video toolbar
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -129,6 +129,7 @@ class VideoDetailController extends GetxController
|
|||||||
|
|
||||||
late final scrollKey = GlobalKey<ExtendedNestedScrollViewState>();
|
late final scrollKey = GlobalKey<ExtendedNestedScrollViewState>();
|
||||||
late final RxString direction = 'horizontal'.obs;
|
late final RxString direction = 'horizontal'.obs;
|
||||||
|
late final RxDouble scrollRatio = 0.0.obs;
|
||||||
|
|
||||||
bool imageStatus = false;
|
bool imageStatus = false;
|
||||||
|
|
||||||
@@ -2027,6 +2028,10 @@ class VideoDetailController extends GetxController
|
|||||||
videoUrl = null;
|
videoUrl = null;
|
||||||
audioUrl = null;
|
audioUrl = null;
|
||||||
|
|
||||||
|
if (Get.currentRoute.startsWith('/videoV') && scrollRatio.value != 0) {
|
||||||
|
scrollRatio.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
// danmaku
|
// danmaku
|
||||||
dmTrend = null;
|
dmTrend = null;
|
||||||
savedDanmaku = null;
|
savedDanmaku = null;
|
||||||
|
|||||||
@@ -565,7 +565,6 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
..addListener(scrollListener);
|
..addListener(scrollListener);
|
||||||
late final double defVideoHeight = MediaQuery.sizeOf(context).width * 9 / 16;
|
late final double defVideoHeight = MediaQuery.sizeOf(context).width * 9 / 16;
|
||||||
late double videoHeight = MediaQuery.sizeOf(context).width * 9 / 16;
|
late double videoHeight = MediaQuery.sizeOf(context).width * 9 / 16;
|
||||||
late RxDouble scrollRatio = 0.0.obs;
|
|
||||||
late bool isExpanding = false;
|
late bool isExpanding = false;
|
||||||
|
|
||||||
void animListener() {
|
void animListener() {
|
||||||
@@ -577,19 +576,19 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
void scrollListener() {
|
void scrollListener() {
|
||||||
if (scrollController.hasClients) {
|
if (scrollController.hasClients) {
|
||||||
if (scrollController.offset == 0) {
|
if (scrollController.offset == 0) {
|
||||||
scrollRatio.value = 0;
|
videoDetailController.scrollRatio.value = 0;
|
||||||
} else {
|
} else {
|
||||||
double offset =
|
double offset =
|
||||||
scrollController.offset - (videoHeight - defVideoHeight);
|
scrollController.offset - (videoHeight - defVideoHeight);
|
||||||
if (offset > 0) {
|
if (offset > 0) {
|
||||||
scrollRatio.value = clampDouble(
|
videoDetailController.scrollRatio.value = clampDouble(
|
||||||
offset.toPrecision(2) /
|
offset.toPrecision(2) /
|
||||||
(defVideoHeight - kToolbarHeight).toPrecision(2),
|
(defVideoHeight - kToolbarHeight).toPrecision(2),
|
||||||
0.0,
|
0.0,
|
||||||
1.0,
|
1.0,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
scrollRatio.value = 0;
|
videoDetailController.scrollRatio.value = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -638,13 +637,14 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
toolbarHeight: 0,
|
toolbarHeight: 0,
|
||||||
),
|
),
|
||||||
if (scrollRatio.value != 0 &&
|
if (videoDetailController.scrollRatio.value != 0 &&
|
||||||
scrollController.offset != 0)
|
scrollController.offset != 0)
|
||||||
AppBar(
|
AppBar(
|
||||||
backgroundColor: Theme.of(context)
|
backgroundColor: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.surface
|
.surface
|
||||||
.withOpacity(scrollRatio.value),
|
.withOpacity(
|
||||||
|
videoDetailController.scrollRatio.value),
|
||||||
toolbarHeight: 0,
|
toolbarHeight: 0,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -748,7 +748,8 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
Obx(
|
Obx(
|
||||||
() {
|
() {
|
||||||
Widget toolbar() => Opacity(
|
Widget toolbar() => Opacity(
|
||||||
opacity: scrollRatio.value,
|
opacity:
|
||||||
|
videoDetailController.scrollRatio.value,
|
||||||
child: Container(
|
child: Container(
|
||||||
color:
|
color:
|
||||||
Theme.of(context).colorScheme.surface,
|
Theme.of(context).colorScheme.surface,
|
||||||
@@ -810,7 +811,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
.primary,
|
.primary,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${plPlayerController == null ? '立即' : plPlayerController!.playerStatus.status.value == PlayerStatus.completed ? '重新' : '继续'}播放',
|
'${videoDetailController.playedTime == null ? '立即' : plPlayerController!.playerStatus.status.value == PlayerStatus.completed ? '重新' : '继续'}播放',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
@@ -825,14 +826,31 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return scrollRatio.value == 0 ||
|
return videoDetailController.scrollRatio.value ==
|
||||||
|
0 ||
|
||||||
scrollController.offset == 0
|
scrollController.offset == 0
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: Positioned.fill(
|
: Positioned.fill(
|
||||||
bottom: -2,
|
bottom: -2,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
scrollRatio.value = 0;
|
if (videoDetailController
|
||||||
|
.isQuerying) {
|
||||||
|
debugPrint('handlePlay: querying');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (videoDetailController.videoUrl ==
|
||||||
|
null ||
|
||||||
|
videoDetailController.audioUrl ==
|
||||||
|
null) {
|
||||||
|
debugPrint(
|
||||||
|
'handlePlay: videoUrl/audioUrl not initialized');
|
||||||
|
videoDetailController
|
||||||
|
.queryVideoUrl();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
videoDetailController
|
||||||
|
.scrollRatio.value = 0;
|
||||||
if (plPlayerController == null) {
|
if (plPlayerController == null) {
|
||||||
handlePlay();
|
handlePlay();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user