Merge branch 'main' into fix

This commit is contained in:
guozhigq
2024-04-14 00:12:51 +08:00
9 changed files with 89 additions and 53 deletions

View File

@ -56,6 +56,7 @@ class BangumiIntroController extends GetxController {
RxMap followStatus = {}.obs;
int _tempThemeValue = -1;
var userInfo;
PersistentBottomSheetController? bottomSheetController;
@override
void onInit() {
@ -320,4 +321,8 @@ class BangumiIntroController extends GetxController {
).buildShowContent(Get.context!),
);
}
hiddenEpisodeBottomSheet() {
bottomSheetController?.close();
}
}

View File

@ -325,6 +325,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
changeFuc: (bvid, cid, aid) =>
bangumiIntroController.changeSeasonOrbangu(bvid, cid, aid),
bangumiDetail: bangumiIntroController.bangumiDetail.value,
bangumiIntroController: bangumiIntroController,
)
],
],

View File

@ -10,6 +10,7 @@ import 'package:pilipala/utils/storage.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../../../common/pages_bottom_sheet.dart';
import '../../../models/common/video_episode_type.dart';
import '../introduction/controller.dart';
class BangumiPanel extends StatefulWidget {
const BangumiPanel({
@ -19,6 +20,7 @@ class BangumiPanel extends StatefulWidget {
this.sheetHeight,
this.changeFuc,
this.bangumiDetail,
this.bangumiIntroController,
});
final List<EpisodeItem> pages;
@ -26,6 +28,7 @@ class BangumiPanel extends StatefulWidget {
final double? sheetHeight;
final Function? changeFuc;
final BangumiInfoModel? bangumiDetail;
final BangumiIntroController? bangumiIntroController;
@override
State<BangumiPanel> createState() => _BangumiPanelState();
@ -92,11 +95,15 @@ class _BangumiPanelState extends State<BangumiPanel> {
// 在回调函数中获取更新后的状态
final double offset = min((currentIndex * 150) - 75,
listViewScrollCtr.position.maxScrollExtent);
if (currentIndex.value == 0) {
listViewScrollCtr.jumpTo(0);
} else {
listViewScrollCtr.animateTo(
offset,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
}
});
}
@ -132,6 +139,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () {
widget.bangumiIntroController?.bottomSheetController =
_bottomSheetController = EpisodeBottomSheet(
currentCid: cid,
episodes: widget.pages,

View File

@ -106,6 +106,7 @@ class VideoDetailController extends GetxController
BottomControlType.fit,
BottomControlType.fullscreen,
].obs;
RxDouble sheetHeight = 0.0.obs;
@override
void onInit() {
@ -172,6 +173,7 @@ class VideoDetailController extends GetxController
firstFloor: firstFloor,
replyType: ReplyType.video,
source: 'videoDetail',
sheetHeight: sheetHeight.value,
);
});
replyReplyBottomSheetCtr?.closed.then((value) {

View File

@ -372,7 +372,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
),
/// 点赞收藏转发
actionGrid(context, videoIntroController),
Material(child: actionGrid(context, videoIntroController)),
// 合集 videoPart 简洁
if (widget.videoDetail!.ugcSeason != null) ...[
Obx(
@ -381,7 +381,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
cid: videoIntroController.lastPlayCid.value != 0
? videoIntroController.lastPlayCid.value
: widget.videoDetail!.pages!.first.cid,
sheetHeight: sheetHeight,
sheetHeight: videoDetailCtr.sheetHeight.value,
changeFuc: (bvid, cid, aid) =>
videoIntroController.changeSeasonOrbangu(
bvid,
@ -399,7 +399,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
() => PagesPanel(
pages: widget.videoDetail!.pages!,
cid: videoIntroController.lastPlayCid.value,
sheetHeight: sheetHeight,
sheetHeight: videoDetailCtr.sheetHeight.value,
changeFuc: (cid) => videoIntroController.changeSeasonOrbangu(
videoIntroController.bvid,
cid,

View File

@ -5,7 +5,6 @@ import 'package:get/get.dart';
import 'package:pilipala/models/video_detail_res.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/pages/video/detail/introduction/index.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../../../../../common/pages_bottom_sheet.dart';
import '../../../../../models/common/video_episode_type.dart';
@ -35,7 +34,6 @@ class _PagesPanelState extends State<PagesPanel> {
final String heroTag = Get.arguments['heroTag'];
late VideoDetailController _videoDetailController;
final ScrollController listViewScrollCtr = ScrollController();
final ItemScrollController itemScrollController = ItemScrollController();
late PersistentBottomSheetController? _bottomSheetController;
@override
@ -60,7 +58,6 @@ class _PagesPanelState extends State<PagesPanel> {
}
void changeFucCall(item, i) async {
print('pages changeFucCall');
widget.changeFuc?.call(item.cid);
currentIndex.value = i;
_bottomSheetController?.close();
@ -72,11 +69,15 @@ class _PagesPanelState extends State<PagesPanel> {
// 在回调函数中获取更新后的状态
final double offset = min((currentIndex * 150) - 75,
listViewScrollCtr.position.maxScrollExtent);
if (currentIndex.value == 0) {
listViewScrollCtr.jumpTo(0);
} else {
listViewScrollCtr.animateTo(
offset,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
}
});
}

View File

@ -4,7 +4,6 @@ import 'package:pilipala/common/pages_bottom_sheet.dart';
import 'package:pilipala/models/video_detail_res.dart';
import 'package:pilipala/pages/video/detail/index.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../../../../../models/common/video_episode_type.dart';
import '../controller.dart';
@ -33,7 +32,6 @@ class _SeasonPanelState extends State<SeasonPanel> {
late RxInt currentIndex = (-1).obs;
final String heroTag = Get.arguments['heroTag'];
late VideoDetailController _videoDetailController;
final ItemScrollController itemScrollController = ItemScrollController();
late PersistentBottomSheetController? _bottomSheetController;
@override

View File

@ -19,6 +19,7 @@ class VideoReplyReplyPanel extends StatefulWidget {
this.firstFloor,
this.source,
this.replyType,
this.sheetHeight,
super.key,
});
final int? oid;
@ -27,6 +28,7 @@ class VideoReplyReplyPanel extends StatefulWidget {
final ReplyItemModel? firstFloor;
final String? source;
final ReplyType? replyType;
final double? sheetHeight;
@override
State<VideoReplyReplyPanel> createState() => _VideoReplyReplyPanelState();
@ -36,7 +38,6 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
late VideoReplyReplyController _videoReplyReplyController;
late AnimationController replyAnimationCtl;
final Box<dynamic> localCache = GStrorage.localCache;
late double sheetHeight;
Future? _futureBuilderFuture;
late ScrollController scrollController;
@ -62,7 +63,6 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
},
);
sheetHeight = localCache.get('sheetHeight');
_futureBuilderFuture = _videoReplyReplyController.queryReplyList();
}
@ -77,18 +77,20 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
@override
Widget build(BuildContext context) {
return Container(
height: widget.source == 'videoDetail' ? sheetHeight : null,
height: widget.source == 'videoDetail' ? widget.sheetHeight : null,
color: Theme.of(context).colorScheme.background,
child: Column(
children: [
if (widget.source == 'videoDetail')
Container(
height: 45,
padding: const EdgeInsets.only(left: 12, right: 2),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
const Text('评论详情'),
AppBar(
toolbarHeight: 45,
automaticallyImplyLeading: false,
centerTitle: false,
title: Text(
'评论详情',
style: Theme.of(context).textTheme.titleSmall,
),
actions: [
IconButton(
icon: const Icon(Icons.close, size: 20),
onPressed: () {
@ -97,13 +99,9 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
Navigator.pop(context);
},
),
const SizedBox(width: 14),
],
),
),
Divider(
height: 1,
color: Theme.of(context).dividerColor.withOpacity(0.1),
),
Expanded(
child: RefreshIndicator(
onRefresh: () async {

View File

@ -47,7 +47,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
late BangumiIntroController bangumiIntroController;
late String heroTag;
PlayerStatus playerStatus = PlayerStatus.playing;
Rx<PlayerStatus> playerStatus = PlayerStatus.playing.obs;
double doubleOffset = 0;
final Box<dynamic> localCache = GStrorage.localCache;
@ -67,6 +67,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
super.initState();
heroTag = Get.arguments['heroTag'];
vdCtr = Get.put(VideoDetailController(), tag: heroTag);
vdCtr.sheetHeight.value = localCache.get('sheetHeight');
videoIntroController = Get.put(
VideoIntroController(bvid: Get.parameters['bvid']!),
tag: heroTag);
@ -112,6 +113,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
_extendNestCtr.addListener(
() {
final double offset = _extendNestCtr.position.pixels;
vdCtr.sheetHeight.value =
Get.size.height - videoHeight - statusBarHeight + offset;
appbarStream.add(offset);
},
);
@ -119,7 +122,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
// 播放器状态监听
void playerListener(PlayerStatus? status) async {
playerStatus = status!;
playerStatus.value = status!;
if (status == PlayerStatus.completed) {
// 结束播放退出全屏
if (autoExitFullcreen) {
@ -177,12 +180,21 @@ class _VideoDetailPageState extends State<VideoDetailPage>
plPlayerController?.isFullScreen.listen((bool isFullScreen) {
if (isFullScreen) {
vdCtr.hiddenReplyReplyPanel();
if (vdCtr.videoType == SearchType.video) {
videoIntroController.hiddenEpisodeBottomSheet();
if (videoIntroController.videoDetail.value.ugcSeason != null ||
(videoIntroController.videoDetail.value.pages != null &&
videoIntroController.videoDetail.value.pages!.length > 1)) {
vdCtr.bottomList.insert(3, BottomControlType.episode);
}
}
if (vdCtr.videoType == SearchType.media_bangumi) {
bangumiIntroController.hiddenEpisodeBottomSheet();
if (bangumiIntroController.bangumiDetail.value.episodes != null &&
bangumiIntroController.bangumiDetail.value.episodes!.length > 1) {
vdCtr.bottomList.insert(3, BottomControlType.episode);
}
}
} else {
if (vdCtr.bottomList.contains(BottomControlType.episode)) {
vdCtr.bottomList.removeAt(3);
@ -271,7 +283,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
@override
Widget build(BuildContext context) {
// final double videoHeight = MediaQuery.sizeOf(context).width * 9 / 16;
final sizeContext = MediaQuery.sizeOf(context);
final _context = MediaQuery.of(context);
late double defaultVideoHeight = sizeContext.width * 9 / 16;
@ -366,6 +377,18 @@ class _VideoDetailPageState extends State<VideoDetailPage>
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Obx(() => AnimatedOpacity(
opacity: playerStatus.value != PlayerStatus.playing
? 1
: 0,
duration: const Duration(milliseconds: 100),
child: const Icon(
Icons.drag_handle_rounded,
size: 20,
color: Colors.grey,
),
)),
const SizedBox(width: 8),
SizedBox(
height: 32,
child: TextButton(
@ -404,7 +427,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
),
),
),
const SizedBox(width: 14),
const SizedBox(width: 18),
],
),
)),
@ -557,7 +580,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
Orientation.landscape ||
plPlayerController?.isFullScreen.value == true
? MediaQuery.sizeOf(context).height
: playerStatus != PlayerStatus.playing
: playerStatus.value != PlayerStatus.playing
? kToolbarHeight
: pinnedHeaderHeight;
},
@ -624,7 +647,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
return ScrollAppBar(
snapshot.data!.toDouble(),
() => continuePlay(),
playerStatus,
playerStatus.value,
null,
);
}),