From bb62a3a15970a03f5a67230639f0d1d7cc8096bb Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 25 Apr 2020 15:36:07 +0200 Subject: [PATCH] Create widget for fullscreen image --- lib/ui/routes/full_screen_image.dart | 29 ++++++++++++++++++++++++++++ lib/utils/ui_utils.dart | 12 ++---------- 2 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 lib/ui/routes/full_screen_image.dart diff --git a/lib/ui/routes/full_screen_image.dart b/lib/ui/routes/full_screen_image.dart new file mode 100644 index 0000000..edde6e6 --- /dev/null +++ b/lib/ui/routes/full_screen_image.dart @@ -0,0 +1,29 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:comunic/utils/intl_utils.dart'; +import 'package:flutter/material.dart'; +import 'package:photo_view/photo_view.dart'; + +/// Full screen image details +/// +/// @author Pierre Hubert + +class FullScreenImageRoute extends StatefulWidget { + final String url; + + FullScreenImageRoute(this.url) : assert(url != null); + + @override + _FullScreenImageRouteState createState() => _FullScreenImageRouteState(); +} + +class _FullScreenImageRouteState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(tr("Image")), + ), + body: PhotoView(imageProvider: CachedNetworkImageProvider(widget.url)), + ); + } +} diff --git a/lib/utils/ui_utils.dart b/lib/utils/ui_utils.dart index 934b192..3c2364b 100644 --- a/lib/utils/ui_utils.dart +++ b/lib/utils/ui_utils.dart @@ -1,9 +1,8 @@ -import 'package:cached_network_image/cached_network_image.dart'; import 'package:comunic/helpers/preferences_helper.dart'; +import 'package:comunic/ui/routes/full_screen_image.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; import 'package:html/parser.dart'; -import 'package:photo_view/photo_view.dart'; /// User interface utilities /// @@ -69,14 +68,7 @@ Widget buildErrorCard(String message, /// Show an image with a given [url] in full screen void showImageFullScreen(BuildContext context, String url) { Navigator.of(context).push(MaterialPageRoute(builder: (c) { - return Scaffold( - appBar: AppBar( - title: Text(tr("Image")), - ), - body: PhotoView( - imageProvider: CachedNetworkImageProvider(url), - ), - ); + return FullScreenImageRoute(url); })); }