mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -267,6 +267,11 @@ class MyApp extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Get.isDialogOpen ?? Get.isBottomSheetOpen ?? false) {
|
||||
Get.back();
|
||||
return;
|
||||
}
|
||||
|
||||
final plCtr = PlPlayerController.instance;
|
||||
if (plCtr != null) {
|
||||
if (plCtr.isFullScreen.value == true) {
|
||||
@@ -274,10 +279,10 @@ class MyApp extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plCtr.isDesktopPip) {
|
||||
plCtr.exitDesktopPip();
|
||||
return;
|
||||
}
|
||||
// if (plCtr.isDesktopPip) {
|
||||
// plCtr.exitDesktopPip();
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
Get.back();
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/models/common/image_type.dart';
|
||||
import 'package:PiliPlus/models_new/live/live_superchat/item.dart';
|
||||
import 'package:PiliPlus/pages/video/introduction/ugc/widgets/selectable_text.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -140,7 +141,7 @@ class _SuperChatCardState extends State<SuperChatCard> {
|
||||
color: bottomColor,
|
||||
),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: SelectableText(
|
||||
child: selectableText(
|
||||
item.message,
|
||||
style: TextStyle(color: Utils.parseColor(item.messageFontColor)),
|
||||
),
|
||||
|
||||
@@ -118,17 +118,11 @@ class LiveHeaderControl extends StatelessWidget {
|
||||
plPlayerController.toggleDesktopPip();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var floating = Floating();
|
||||
if ((await floating.isPipAvailable) == true) {
|
||||
plPlayerController.hiddenControls(false);
|
||||
floating.enable(
|
||||
plPlayerController.isVertical
|
||||
? const EnableManual(aspectRatio: Rational.vertical())
|
||||
: const EnableManual(),
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
if (await Floating().isPipAvailable) {
|
||||
plPlayerController
|
||||
..hiddenControls(false)
|
||||
..enterPip();
|
||||
}
|
||||
},
|
||||
icon: const Icon(
|
||||
size: 18,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
@@ -16,7 +17,6 @@ import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart';
|
||||
import 'package:PiliPlus/pages/video/member/controller.dart';
|
||||
import 'package:PiliPlus/services/account_service.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:PiliPlus/utils/num_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/request_utils.dart';
|
||||
@@ -41,11 +41,10 @@ class HorizontalMemberPage extends StatefulWidget {
|
||||
State<HorizontalMemberPage> createState() => _HorizontalMemberPageState();
|
||||
}
|
||||
|
||||
class _HorizontalMemberPageState extends State<HorizontalMemberPage>
|
||||
with GridMixin {
|
||||
class _HorizontalMemberPageState extends State<HorizontalMemberPage> {
|
||||
late final HorizontalMemberPageController _controller;
|
||||
AccountService accountService = Get.find<AccountService>();
|
||||
dynamic _bvid;
|
||||
late final String _bvid;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -58,6 +57,15 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage>
|
||||
tag: widget.videoDetailController.heroTag,
|
||||
);
|
||||
_bvid = widget.videoDetailController.bvid;
|
||||
if (_controller.loadingState.value
|
||||
case Success<List<SpaceArchiveItem>?> res) {
|
||||
final index = res.response?.indexWhere((e) => e.bvid == _bvid) ?? -1;
|
||||
if (index != -1) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_controller.scrollController.jumpTo(100.0 * index + 40);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -180,32 +188,39 @@ class _HorizontalMemberPageState extends State<HorizontalMemberPage>
|
||||
LoadingState<List<SpaceArchiveItem>?> loadingState,
|
||||
) {
|
||||
return switch (loadingState) {
|
||||
Loading() => gridSkeleton,
|
||||
Loading() => SliverPrototypeExtentList.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (_, _) => const VideoCardHSkeleton(),
|
||||
prototypeItem: const VideoCardHSkeleton(),
|
||||
),
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid.builder(
|
||||
gridDelegate: gridDelegate,
|
||||
? SliverFixedExtentList.builder(
|
||||
itemBuilder: (context, index) {
|
||||
if (index == response.length - 1 && _controller.hasNext) {
|
||||
_controller.onLoadMore();
|
||||
}
|
||||
final SpaceArchiveItem videoItem = response[index];
|
||||
return VideoCardHMemberVideo(
|
||||
videoItem: videoItem,
|
||||
bvid: _bvid,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
widget.ugcIntroController.onChangeEpisode(
|
||||
BaseEpisodeItem(
|
||||
bvid: videoItem.bvid,
|
||||
cid: videoItem.cid,
|
||||
cover: videoItem.cover,
|
||||
),
|
||||
);
|
||||
},
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 2),
|
||||
child: VideoCardHMemberVideo(
|
||||
videoItem: videoItem,
|
||||
bvid: _bvid,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
widget.ugcIntroController.onChangeEpisode(
|
||||
BaseEpisodeItem(
|
||||
bvid: videoItem.bvid,
|
||||
cid: videoItem.cid,
|
||||
cover: videoItem.cover,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: response!.length,
|
||||
itemExtent: 100,
|
||||
)
|
||||
: HttpError(onReload: _controller.onReload),
|
||||
Error(:var errMsg) => HttpError(
|
||||
|
||||
@@ -2158,9 +2158,8 @@ class HeaderControlState extends State<HeaderControl> {
|
||||
plPlayerController.toggleDesktopPip();
|
||||
return;
|
||||
}
|
||||
bool canUsePiP = await Floating().isPipAvailable;
|
||||
plPlayerController.hiddenControls(false);
|
||||
if (canUsePiP) {
|
||||
if (await Floating().isPipAvailable) {
|
||||
plPlayerController.hiddenControls(false);
|
||||
if (context.mounted &&
|
||||
!videoPlayerServiceHandler!.enableBackgroundPlay) {
|
||||
final theme = Theme.of(context);
|
||||
@@ -2236,10 +2235,7 @@ class HeaderControlState extends State<HeaderControl> {
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
}
|
||||
if (!context.mounted) return;
|
||||
PageUtils.enterPip(
|
||||
width: widget.videoDetailCtr.firstVideo.width,
|
||||
height: widget.videoDetailCtr.firstVideo.height,
|
||||
);
|
||||
plPlayerController.enterPip();
|
||||
}
|
||||
},
|
||||
icon: const Icon(
|
||||
|
||||
@@ -29,12 +29,12 @@ class PlayerFocus extends StatelessWidget {
|
||||
final VoidCallback onSendDanmaku;
|
||||
final bool Function()? canPlay;
|
||||
|
||||
static bool _shouldHandled(KeyEvent event) {
|
||||
return event.logicalKey == LogicalKeyboardKey.tab ||
|
||||
event.logicalKey == LogicalKeyboardKey.arrowLeft ||
|
||||
event.logicalKey == LogicalKeyboardKey.arrowRight ||
|
||||
event.logicalKey == LogicalKeyboardKey.arrowUp ||
|
||||
event.logicalKey == LogicalKeyboardKey.arrowDown;
|
||||
static bool _shouldHandle(LogicalKeyboardKey logicalKey) {
|
||||
return logicalKey == LogicalKeyboardKey.tab ||
|
||||
logicalKey == LogicalKeyboardKey.arrowLeft ||
|
||||
logicalKey == LogicalKeyboardKey.arrowRight ||
|
||||
logicalKey == LogicalKeyboardKey.arrowUp ||
|
||||
logicalKey == LogicalKeyboardKey.arrowDown;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -43,7 +43,7 @@ class PlayerFocus extends StatelessWidget {
|
||||
autofocus: true,
|
||||
onKeyEvent: (node, event) {
|
||||
final handled = _handleKey(event);
|
||||
if (handled || _shouldHandled(event)) {
|
||||
if (handled || _shouldHandle(event.logicalKey)) {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
|
||||
@@ -304,8 +304,12 @@ class PlPlayerController {
|
||||
}
|
||||
|
||||
void enterPip() {
|
||||
if (Get.currentRoute.startsWith('/video')) {
|
||||
PageUtils.enterPip(width: width, height: height);
|
||||
if (videoController != null) {
|
||||
final state = videoController!.player.state;
|
||||
PageUtils.enterPip(
|
||||
width: state.width ?? width,
|
||||
height: state.height ?? height,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,7 +551,8 @@ class PlPlayerController {
|
||||
if (Platform.isAndroid && autoPiP) {
|
||||
Utils.channel.setMethodCallHandler((call) async {
|
||||
if (call.method == 'onUserLeaveHint') {
|
||||
if (playerStatus.status.value == PlayerStatus.playing) {
|
||||
if (playerStatus.status.value == PlayerStatus.playing &&
|
||||
Get.currentRoute.startsWith('/video')) {
|
||||
enterPip();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user