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:
@@ -2,6 +2,7 @@ import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/common/reply_controller.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPlus/http/html.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
@@ -14,6 +15,8 @@ class DynamicDetailController extends ReplyController {
|
||||
dynamic item;
|
||||
int? floor;
|
||||
|
||||
late final horizontalPreview = GStorage.horizontalPreview;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/custom_sliver_persistent_header_delegate.dart';
|
||||
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply/widgets/reply_item.dart';
|
||||
@@ -51,6 +52,29 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
|
||||
late final List<double> _ratio = GStorage.dynamicDetailRatio;
|
||||
|
||||
bool get _horizontalPreview =>
|
||||
context.orientation == Orientation.landscape &&
|
||||
_dynamicDetailController.horizontalPreview;
|
||||
|
||||
late final _key = GlobalKey<ScaffoldState>();
|
||||
|
||||
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;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -299,6 +323,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
child: DynamicPanel(
|
||||
item: _dynamicDetailController.item,
|
||||
source: 'detail',
|
||||
callback: _getImageCallback,
|
||||
),
|
||||
),
|
||||
replyPersistentHeader(context),
|
||||
@@ -326,6 +351,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
child: DynamicPanel(
|
||||
item: _dynamicDetailController.item,
|
||||
source: 'detail',
|
||||
callback: _getImageCallback,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -335,6 +361,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
Expanded(
|
||||
flex: _ratio[1].toInt(),
|
||||
child: Scaffold(
|
||||
key: _key,
|
||||
body: refreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _dynamicDetailController.onRefresh();
|
||||
@@ -499,6 +526,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
isTop:
|
||||
_dynamicDetailController.hasUpTop && index == 0,
|
||||
upMid: loadingState.response.subjectControl.upMid,
|
||||
callback: _getImageCallback,
|
||||
)
|
||||
: ReplyItem(
|
||||
replyItem: loadingState.response.replies[index],
|
||||
@@ -515,6 +543,7 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
|
||||
);
|
||||
},
|
||||
onDelete: _dynamicDetailController.onMDelete,
|
||||
callback: _getImageCallback,
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user