Add fullscreen image view

Closes #9
This commit is contained in:
Lea 2023-02-04 10:35:54 +01:00
parent c086599396
commit 001666f3e3
Signed by: Lea
GPG key ID: 1BAFFE8347019C42
4 changed files with 39 additions and 0 deletions

View file

@ -1,4 +1,5 @@
import 'package:feet/api/api.dart'; import 'package:feet/api/api.dart';
import 'package:feet/pages/image_view.dart';
import 'package:feet/widgets/homepage_post.dart'; import 'package:feet/widgets/homepage_post.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -112,6 +113,18 @@ class _ArticlePageState extends State<ArticlePage> {
child: SelectionArea( child: SelectionArea(
child: Html( child: Html(
data: widget.article.html, data: widget.article.html,
onImageTap: (url, ctx, attributes, element) => Navigator.of(context).push(
PageRouteBuilder(
opaque: false,
pageBuilder: (context, _, __) => ImageView(url: url!),
transitionsBuilder: (context, animation, _, child) {
return FadeTransition(
opacity: animation,
child: child,
);
},
),
),
), ),
), ),
) )

17
lib/pages/image_view.dart Normal file
View file

@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
class ImageView extends StatelessWidget {
final String url;
const ImageView({super.key, required this.url});
@override
Widget build(BuildContext context) {
return PhotoView(
backgroundDecoration: BoxDecoration(color: Theme.of(context).colorScheme.background.withAlpha(200)),
maxScale: 5.0,
minScale: PhotoViewComputedScale.contained,
imageProvider: NetworkImage(url),
);
}
}

View file

@ -440,6 +440,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.1.0" version: "5.1.0"
photo_view:
dependency: "direct main"
description:
name: photo_view
sha256: "8036802a00bae2a78fc197af8a158e3e2f7b500561ed23b4c458107685e645bb"
url: "https://pub.dev"
source: hosted
version: "0.14.0"
platform: platform:
dependency: transitive dependency: transitive
description: description:

View file

@ -45,6 +45,7 @@ dependencies:
workmanager: ^0.5.1 workmanager: ^0.5.1
flutter_local_notifications: ^9.1.4 flutter_local_notifications: ^9.1.4
permission_handler: ^10.2.0 permission_handler: ^10.2.0
photo_view: ^0.14.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: