From 2dfec9ee629b3a6b115438da2ec926b9067955af Mon Sep 17 00:00:00 2001 From: John Wesley Date: Wed, 27 Dec 2023 17:32:06 -0500 Subject: [PATCH] Implement thread image view with scaling and panning --- lib/src/screens/entries/entry_item.dart | 46 +++++++++++++++++++++---- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/lib/src/screens/entries/entry_item.dart b/lib/src/screens/entries/entry_item.dart index 961228d..09b3c13 100644 --- a/lib/src/screens/entries/entry_item.dart +++ b/lib/src/screens/entries/entry_item.dart @@ -25,6 +25,32 @@ class EntryItem extends StatelessWidget { final Future Function(String)? onReply; final bool isPreview; + _onImageClick(BuildContext context) { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => Scaffold( + extendBodyBehindAppBar: true, + appBar: AppBar( + title: Text(item.title), + backgroundColor: const Color(0x66000000), + ), + body: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: InteractiveViewer( + child: Image.network( + item.image!.storageUrl, + ), + ), + ) + ], + ), + ), + ), + ); + } + @override Widget build(BuildContext context) { return Column( @@ -32,18 +58,24 @@ class EntryItem extends StatelessWidget { children: [ if (item.image?.storageUrl != null) isPreview - ? Image.network( - item.image!.storageUrl, - height: 160, - width: double.infinity, - fit: BoxFit.cover, + ? InkWell( + onTap: () => _onImageClick(context), + child: Image.network( + item.image!.storageUrl, + height: 160, + width: double.infinity, + fit: BoxFit.cover, + ), ) : Container( constraints: BoxConstraints( maxHeight: MediaQuery.of(context).size.height / 2, ), - child: Image.network( - item.image!.storageUrl, + child: InkWell( + onTap: () => _onImageClick(context), + child: Image.network( + item.image!.storageUrl, + ), )), Container( padding: const EdgeInsets.all(16),