-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from simonoppowa/add-image-fullscreen
feat(meal-detail): add meal full screen image view
- Loading branch information
Showing
4 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:cached_network_image/cached_network_image.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_cache_manager/flutter_cache_manager.dart'; | ||
import 'package:opennutritracker/core/utils/locator.dart'; | ||
import 'package:opennutritracker/features/meal_detail/presentation/widgets/meal_placeholder.dart'; | ||
|
||
class ImageFullScreen extends StatefulWidget { | ||
|
||
static const fullScreenHeroTag = 'fullScreenTag'; | ||
|
||
const ImageFullScreen({super.key}); | ||
|
||
@override | ||
State<ImageFullScreen> createState() => _ImageFullScreenState(); | ||
} | ||
|
||
class _ImageFullScreenState extends State<ImageFullScreen> { | ||
late String imageUrl; | ||
|
||
@override | ||
void didChangeDependencies() { | ||
final args = | ||
ModalRoute.of(context)?.settings.arguments as ImageFullScreenArguments; | ||
imageUrl = args.imageUrl; | ||
super.didChangeDependencies(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
extendBodyBehindAppBar: true, | ||
appBar: AppBar( | ||
elevation: 0, | ||
backgroundColor: Colors.transparent, | ||
), | ||
body: InteractiveViewer( | ||
child: Hero( | ||
tag: ImageFullScreen.fullScreenHeroTag, | ||
child: CachedNetworkImage( | ||
width: double.infinity, | ||
height: double.infinity, | ||
cacheManager: locator<CacheManager>(), | ||
imageUrl: imageUrl, | ||
fit: BoxFit.cover, | ||
placeholder: (context, string) => const MealPlaceholder(), | ||
errorWidget: (context, url, error) => const MealPlaceholder(), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class ImageFullScreenArguments { | ||
final String imageUrl; | ||
|
||
ImageFullScreenArguments(this.imageUrl); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters