mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-01-18 23:27:34 +00:00
feat(mobile): image caching & viewer improvements (#4095)
This commit is contained in:
committed by
GitHub
parent
63b6a71ebd
commit
1c02e1dadf
@@ -235,6 +235,7 @@ class PhotoView extends StatefulWidget {
|
||||
const PhotoView({
|
||||
Key? key,
|
||||
required this.imageProvider,
|
||||
required this.index,
|
||||
this.loadingBuilder,
|
||||
this.backgroundDecoration,
|
||||
this.wantKeepAlive = false,
|
||||
@@ -304,6 +305,7 @@ class PhotoView extends StatefulWidget {
|
||||
imageProvider = null,
|
||||
gaplessPlayback = false,
|
||||
loadingBuilder = null,
|
||||
index = 0,
|
||||
super(key: key);
|
||||
|
||||
/// Given a [imageProvider] it resolves into an zoomable image widget using. It
|
||||
@@ -419,6 +421,8 @@ class PhotoView extends StatefulWidget {
|
||||
/// Useful when you want to drag a widget without restrictions.
|
||||
final bool? enablePanAlways;
|
||||
|
||||
final int index;
|
||||
|
||||
bool get _isCustomChild {
|
||||
return child != null;
|
||||
}
|
||||
@@ -571,6 +575,7 @@ class _PhotoViewState extends State<PhotoView>
|
||||
disableGestures: widget.disableGestures,
|
||||
errorBuilder: widget.errorBuilder,
|
||||
enablePanAlways: widget.enablePanAlways,
|
||||
index: widget.index,
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -625,7 +630,7 @@ typedef PhotoViewImageDragStartCallback = Function(
|
||||
PhotoViewControllerValue controllerValue,
|
||||
);
|
||||
|
||||
/// A type definition for a callback when the user drags
|
||||
/// A type definition for a callback when the user drags
|
||||
typedef PhotoViewImageDragUpdateCallback = Function(
|
||||
BuildContext context,
|
||||
DragUpdateDetails details,
|
||||
@@ -650,4 +655,5 @@ typedef PhotoViewImageScaleEndCallback = Function(
|
||||
typedef LoadingBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
ImageChunkEvent? event,
|
||||
int index,
|
||||
);
|
||||
|
||||
@@ -281,6 +281,7 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
|
||||
)
|
||||
: PhotoView(
|
||||
key: ObjectKey(index),
|
||||
index: index,
|
||||
imageProvider: pageOption.imageProvider,
|
||||
loadingBuilder: widget.loadingBuilder,
|
||||
backgroundDecoration: widget.backgroundDecoration,
|
||||
@@ -315,7 +316,10 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
|
||||
);
|
||||
}
|
||||
|
||||
PhotoViewGalleryPageOptions _buildPageOption(BuildContext context, int index) {
|
||||
PhotoViewGalleryPageOptions _buildPageOption(
|
||||
BuildContext context,
|
||||
int index,
|
||||
) {
|
||||
if (widget._isBuilder) {
|
||||
return widget.builder!(context, index);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ class ImageWrapper extends StatefulWidget {
|
||||
required this.disableGestures,
|
||||
required this.errorBuilder,
|
||||
required this.enablePanAlways,
|
||||
required this.index,
|
||||
}) : super(key: key);
|
||||
|
||||
final ImageProvider imageProvider;
|
||||
@@ -64,6 +65,7 @@ class ImageWrapper extends StatefulWidget {
|
||||
final FilterQuality? filterQuality;
|
||||
final bool? disableGestures;
|
||||
final bool? enablePanAlways;
|
||||
final int index;
|
||||
|
||||
@override
|
||||
createState() => _ImageWrapperState();
|
||||
@@ -128,6 +130,7 @@ class _ImageWrapperState extends State<ImageWrapper> {
|
||||
_lastException = null;
|
||||
_lastStack = null;
|
||||
}
|
||||
|
||||
synchronousCall ? setupCB() : setState(setupCB);
|
||||
}
|
||||
|
||||
@@ -212,7 +215,7 @@ class _ImageWrapperState extends State<ImageWrapper> {
|
||||
|
||||
Widget _buildLoading(BuildContext context) {
|
||||
if (widget.loadingBuilder != null) {
|
||||
return widget.loadingBuilder!(context, _loadingProgress);
|
||||
return widget.loadingBuilder!(context, _loadingProgress, widget.index);
|
||||
}
|
||||
|
||||
return PhotoViewDefaultLoading(
|
||||
|
||||
Reference in New Issue
Block a user