Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onLongPress on SIngle Image Item #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/gallery_item_thumbnail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'gallery_item_model.dart';
// to show image in Row
class GalleryItemThumbnail extends StatelessWidget {
final GalleryItemModel galleryItem;
final GestureTapCallback? onLongPress;
final GestureTapCallback? onTap;
final Widget? loadingWidget;
final Widget? errorWidget;
Expand All @@ -14,6 +15,7 @@ class GalleryItemThumbnail extends StatelessWidget {
const GalleryItemThumbnail(
{Key? key,
required this.galleryItem,
required this.onLongPress,
required this.onTap,
required this.radius,
required this.loadingWidget,
Expand All @@ -23,6 +25,7 @@ class GalleryItemThumbnail extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onLongPress: onLongPress,
onTap: onTap,
child: Hero(
tag: galleryItem.id,
Expand Down
11 changes: 10 additions & 1 deletion lib/galleryimage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class GalleryImage extends StatefulWidget {
final bool showAppBar;
final bool closeWhenSwipeUp;
final bool closeWhenSwipeDown;

final void Function(int)? onImagePress;

const GalleryImage({
Key? key,
required this.imageUrls,
Expand All @@ -53,6 +54,7 @@ class GalleryImage extends StatefulWidget {
this.showAppBar = true,
this.closeWhenSwipeUp = false,
this.closeWhenSwipeDown = false,
this.onImagePress,
}) : assert(numOfShowImages <= imageUrls.length),
super(key: key);
@override
Expand Down Expand Up @@ -89,6 +91,9 @@ class _GalleryImageState extends State<GalleryImage> {
? _buildImageNumbers(index)
: GalleryItemThumbnail(
galleryItem: galleryItems[index],
onLongPress: () {
widget.onImagePress?.call(index);
},
onTap: () {
_openImageFullScreen(index);
},
Expand All @@ -102,6 +107,9 @@ class _GalleryImageState extends State<GalleryImage> {
// build image with number for other images
Widget _buildImageNumbers(int index) {
return GestureDetector(
onLongPress: () {
widget.onImagePress?.call(index);
},
onTap: () {
_openImageFullScreen(index);
},
Expand All @@ -114,6 +122,7 @@ class _GalleryImageState extends State<GalleryImage> {
loadingWidget: widget.loadingWidget,
errorWidget: widget.errorWidget,
onTap: null,
onLongPress: null,
radius: widget.imageRadius,
),
ClipRRect(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: galleryimage
description: Flutter plugin that list of images from URLs allows you to display
and zoomable multi image on iOS and Android.
version: 2.0.1
version: 2.0.2
homepage: https://github.com/BeshoyMelika/flutter-gallery-package

environment:
Expand Down