Add photo view for thumbnails, emotes, and badges (#372)
* Add photo view for emotes and badges * Add photo view to stream thumbnails * Remove dismissable and use close button * Use cached network image provider * Add dismissible
This commit is contained in:
parent
3de9eb8351
commit
a5cc7d8f3f
5 changed files with 74 additions and 2 deletions
43
lib/widgets/photo_view.dart
Normal file
43
lib/widgets/photo_view.dart
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
class FrostyPhotoViewDialog extends StatefulWidget {
|
||||
final String imageUrl;
|
||||
|
||||
const FrostyPhotoViewDialog({super.key, required this.imageUrl});
|
||||
|
||||
@override
|
||||
State<FrostyPhotoViewDialog> createState() => _FrostyPhotoViewDialogState();
|
||||
}
|
||||
|
||||
class _FrostyPhotoViewDialogState extends State<FrostyPhotoViewDialog> {
|
||||
PhotoViewScaleState photoViewScaleState = PhotoViewScaleState.initial;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
Dismissible(
|
||||
key: const Key('photo_view_dismissible'),
|
||||
direction: photoViewScaleState == PhotoViewScaleState.initial
|
||||
? DismissDirection.vertical
|
||||
: DismissDirection.none,
|
||||
onDismissed: Navigator.of(context).pop,
|
||||
child: PhotoView(
|
||||
imageProvider: CachedNetworkImageProvider(widget.imageUrl),
|
||||
scaleStateChangedCallback: (value) =>
|
||||
setState(() => photoViewScaleState = value),
|
||||
backgroundDecoration:
|
||||
const BoxDecoration(color: Colors.transparent),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: Navigator.of(context).pop,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue