fix: 图片预览放大、取消下滑关闭图片预览
This commit is contained in:
@ -135,25 +135,14 @@ class _ImagePreviewState extends State<ImagePreview>
|
|||||||
),
|
),
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
DismissiblePage(
|
GestureDetector(
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
onDismissed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
// Note that scrollable widget inside DismissiblePage might limit the functionality
|
|
||||||
// If scroll direction matches DismissiblePage direction
|
|
||||||
direction: DismissiblePageDismissDirection.down,
|
|
||||||
disabled: _dismissDisabled,
|
|
||||||
isFullScreen: true,
|
|
||||||
child: GestureDetector(
|
|
||||||
onLongPress: () => onOpenMenu(),
|
onLongPress: () => onOpenMenu(),
|
||||||
child: ExtendedImageGesturePageView.builder(
|
child: ExtendedImageGesturePageView.builder(
|
||||||
controller: ExtendedPageController(
|
controller: ExtendedPageController(
|
||||||
initialPage: _previewController.initialPage.value,
|
initialPage: _previewController.initialPage.value,
|
||||||
pageSpacing: 0,
|
pageSpacing: 0,
|
||||||
),
|
),
|
||||||
onPageChanged: (int index) =>
|
onPageChanged: (int index) => _previewController.onChange(index),
|
||||||
_previewController.onChange(index),
|
|
||||||
canScrollPage: (GestureDetails? gestureDetails) =>
|
canScrollPage: (GestureDetails? gestureDetails) =>
|
||||||
gestureDetails!.totalScale! <= 1.0,
|
gestureDetails!.totalScale! <= 1.0,
|
||||||
itemCount: widget.imgList!.length,
|
itemCount: widget.imgList!.length,
|
||||||
@ -245,13 +234,14 @@ class _ImagePreviewState extends State<ImagePreview>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
|
left: 20,
|
||||||
|
right: 20,
|
||||||
bottom: MediaQuery.of(context).padding.bottom + 30),
|
bottom: MediaQuery.of(context).padding.bottom + 30),
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
@ -264,20 +254,34 @@ class _ImagePreviewState extends State<ImagePreview>
|
|||||||
tileMode: TileMode.mirror,
|
tileMode: TileMode.mirror,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Obx(
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
widget.imgList!.length > 1
|
||||||
|
? Obx(
|
||||||
() => Text.rich(
|
() => Text.rich(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
TextSpan(
|
TextSpan(
|
||||||
style: const TextStyle(color: Colors.white, fontSize: 15),
|
style: const TextStyle(
|
||||||
|
color: Colors.white, fontSize: 16),
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: _previewController.currentPage.toString()),
|
text: _previewController.currentPage
|
||||||
|
.toString()),
|
||||||
const TextSpan(text: ' / '),
|
const TextSpan(text: ' / '),
|
||||||
TextSpan(text: widget.imgList!.length.toString()),
|
TextSpan(
|
||||||
|
text:
|
||||||
|
widget.imgList!.length.toString()),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
icon: const Icon(Icons.close, color: Colors.white),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
|
)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user