diff --git a/lib/src/full_screen_media.dart b/lib/src/full_screen_media.dart index a0c4a03f..0857531a 100644 --- a/lib/src/full_screen_media.dart +++ b/lib/src/full_screen_media.dart @@ -169,6 +169,14 @@ class _FullScreenMediaState extends State mediaAttachments: widget.mediaAttachments, message: widget.message, videoPackages: videoPackages, + mediaSelectedCallBack: (val) { + setState(() { + _currentPage = val; + _pageController.animateToPage(val, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut); + }); + }, ), ], ), diff --git a/lib/src/image_footer.dart b/lib/src/image_footer.dart index 9455d8f3..51bb9009 100644 --- a/lib/src/image_footer.dart +++ b/lib/src/image_footer.dart @@ -36,6 +36,7 @@ class ImageFooter extends StatefulWidget { final Message message; final List videoPackages; + final ValueChanged mediaSelectedCallBack; /// Creates a channel header ImageFooter({ @@ -48,6 +49,7 @@ class ImageFooter extends StatefulWidget { this.mediaAttachments, this.message, this.videoPackages, + this.mediaSelectedCallBack, }) : preferredSize = Size.fromHeight(kToolbarHeight), super(key: key); @@ -213,23 +215,33 @@ class _ImageFooterState extends State { videoAttachments .indexOf(widget.mediaAttachments[position])]; - return FittedBox( - child: Chewie( - controller: controllerPackage.chewieController, + return InkWell( + onTap: () { + widget.mediaSelectedCallBack(position); + }, + child: FittedBox( + child: Chewie( + controller: controllerPackage.chewieController, + ), ), ); } else { - return Padding( - padding: const EdgeInsets.all(1.0), - child: AspectRatio( - child: CachedNetworkImage( - imageUrl: - widget.mediaAttachments[position].imageUrl ?? - widget.mediaAttachments[position].assetUrl ?? - widget.mediaAttachments[position].thumbUrl, - fit: BoxFit.cover, + return InkWell( + onTap: () { + widget.mediaSelectedCallBack(position); + }, + child: Padding( + padding: const EdgeInsets.all(1.0), + child: AspectRatio( + child: CachedNetworkImage( + imageUrl: widget + .mediaAttachments[position].imageUrl ?? + widget.mediaAttachments[position].assetUrl ?? + widget.mediaAttachments[position].thumbUrl, + fit: BoxFit.cover, + ), + aspectRatio: 1.0, ), - aspectRatio: 1.0, ), ); }