mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom horizontal preview
Closes #117 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -246,7 +246,9 @@ class VideoDetailController extends GetxController
|
||||
imageStatus = false;
|
||||
}
|
||||
|
||||
// 页面来源 稍后再看 收藏夹
|
||||
late final horizontalPreview = GStorage.horizontalPreview;
|
||||
|
||||
// 页面来源 稍后再看 收藏夹
|
||||
String sourceType = 'normal';
|
||||
late bool _mediaDesc = false;
|
||||
late RxList<MediaVideoItemModel> mediaList = <MediaVideoItemModel>[].obs;
|
||||
|
||||
@@ -24,6 +24,7 @@ class VideoReplyPanel extends StatefulWidget {
|
||||
final Function replyReply;
|
||||
final VoidCallback? onViewImage;
|
||||
final ValueChanged<int>? onDismissed;
|
||||
final Function(List<String>, int)? callback;
|
||||
|
||||
const VideoReplyPanel({
|
||||
super.key,
|
||||
@@ -35,6 +36,7 @@ class VideoReplyPanel extends StatefulWidget {
|
||||
required this.replyReply,
|
||||
this.onViewImage,
|
||||
this.onDismissed,
|
||||
this.callback,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -264,6 +266,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
getTag: () => heroTag,
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: widget.callback,
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
@@ -282,6 +285,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
getTag: () => heroTag,
|
||||
callback: widget.callback,
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -35,6 +35,7 @@ class ReplyItem extends StatelessWidget {
|
||||
this.onViewImage,
|
||||
this.onDismissed,
|
||||
this.getTag,
|
||||
this.callback,
|
||||
});
|
||||
final ReplyItemModel? replyItem;
|
||||
final String? replyLevel;
|
||||
@@ -47,6 +48,7 @@ class ReplyItem extends StatelessWidget {
|
||||
final VoidCallback? onViewImage;
|
||||
final ValueChanged<int>? onDismissed;
|
||||
final Function? getTag;
|
||||
final Function(List<String>, int)? callback;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -975,8 +977,9 @@ class ReplyItem extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onViewImage,
|
||||
onDismissed,
|
||||
onViewImage: onViewImage,
|
||||
onDismissed: onDismissed,
|
||||
callback: callback,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -38,6 +38,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
this.getTag,
|
||||
this.onViewImage,
|
||||
this.onDismissed,
|
||||
this.callback,
|
||||
});
|
||||
final ReplyInfo replyItem;
|
||||
final String? replyLevel;
|
||||
@@ -53,6 +54,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
final Function? getTag;
|
||||
final VoidCallback? onViewImage;
|
||||
final ValueChanged<int>? onDismissed;
|
||||
final Function(List<String>, int)? callback;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -1006,8 +1008,9 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
onViewImage,
|
||||
onDismissed,
|
||||
onViewImage: onViewImage,
|
||||
onDismissed: onDismissed,
|
||||
callback: callback,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models/video/reply/item.dart';
|
||||
import 'package:PiliPlus/pages/common/common_controller.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
@@ -37,11 +38,13 @@ class VideoReplyReplyController extends CommonController
|
||||
RxInt count = (-1).obs;
|
||||
int? upMid;
|
||||
|
||||
dynamic firstFloor;
|
||||
|
||||
int? index;
|
||||
AnimationController? controller;
|
||||
Animation<Color?>? colorAnimation;
|
||||
|
||||
dynamic firstFloor;
|
||||
late final horizontalPreview = GStorage.horizontalPreview;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -58,6 +59,10 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
dynamic get firstFloor =>
|
||||
widget.firstFloor ?? _videoReplyReplyController.firstFloor;
|
||||
|
||||
bool get _horizontalPreview =>
|
||||
context.orientation == Orientation.landscape &&
|
||||
_videoReplyReplyController.horizontalPreview;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -174,6 +179,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
isTop: widget.isTop,
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: firstFloor,
|
||||
@@ -186,6 +192,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
},
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
);
|
||||
} else if (index == 1) {
|
||||
return Divider(
|
||||
@@ -271,6 +278,23 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
),
|
||||
);
|
||||
|
||||
get _getImageCallback => _horizontalPreview
|
||||
? (imgList, index) {
|
||||
_key.currentState?.showBottomSheet(
|
||||
(context) {
|
||||
return InteractiveviewerGallery(
|
||||
sources: imgList,
|
||||
initIndex: index,
|
||||
setStatusBar: false,
|
||||
);
|
||||
},
|
||||
enableDrag: false,
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
);
|
||||
}
|
||||
: null;
|
||||
|
||||
void _onReply(dynamic item, int index) {
|
||||
dynamic oid = item?.oid.toInt();
|
||||
dynamic root = GlobalData().grpcReply ? item?.id.toInt() : item?.rpid;
|
||||
@@ -457,6 +481,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
},
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: replyItem,
|
||||
@@ -477,6 +502,7 @@ class _VideoReplyReplyPanelState extends State<VideoReplyReplyPanel> {
|
||||
},
|
||||
onViewImage: widget.onViewImage,
|
||||
onDismissed: widget.onDismissed,
|
||||
callback: _getImageCallback,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart';
|
||||
import 'package:PiliPlus/common/widgets/list_sheet.dart';
|
||||
import 'package:PiliPlus/common/widgets/segment_progress_bar.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -94,6 +95,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
context.orientation == Orientation.landscape &&
|
||||
videoDetailController.horizontalSeasonPanel;
|
||||
|
||||
bool get _horizontalPreview =>
|
||||
context.orientation == Orientation.landscape &&
|
||||
videoDetailController.horizontalPreview;
|
||||
|
||||
StreamSubscription? _listenerDetail;
|
||||
StreamSubscription? _listenerLoadingState;
|
||||
StreamSubscription? _listenerCid;
|
||||
@@ -1543,6 +1548,22 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
replyReply: replyReply,
|
||||
onViewImage: videoDetailController.onViewImage,
|
||||
onDismissed: videoDetailController.onDismissed,
|
||||
callback: _horizontalPreview
|
||||
? (imgList, index) {
|
||||
videoDetailController.childKey.currentState?.showBottomSheet(
|
||||
(context) {
|
||||
return InteractiveviewerGallery(
|
||||
sources: imgList,
|
||||
initIndex: index,
|
||||
setStatusBar: false,
|
||||
);
|
||||
},
|
||||
enableDrag: false,
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
);
|
||||
}
|
||||
: null,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user