mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
better scrolling
This commit is contained in:
parent
c988342de1
commit
3100702e93
8 changed files with 233 additions and 88 deletions
|
|
@ -1,30 +1,43 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:immich_mobile/widgets/common/transparent_image.dart';
|
||||
|
||||
class FadeInPlaceholderImage extends StatelessWidget {
|
||||
final Widget placeholder;
|
||||
final ImageProvider image;
|
||||
final Duration duration;
|
||||
final BoxFit fit;
|
||||
final double width;
|
||||
final double height;
|
||||
|
||||
const FadeInPlaceholderImage({
|
||||
super.key,
|
||||
required this.placeholder,
|
||||
required this.image,
|
||||
required this.width,
|
||||
required this.height,
|
||||
this.duration = const Duration(milliseconds: 100),
|
||||
this.fit = BoxFit.cover,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox.expand(
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
placeholder,
|
||||
FadeInImage(fadeInDuration: duration, image: image, fit: fit, placeholder: MemoryImage(kTransparentImage)),
|
||||
],
|
||||
),
|
||||
final stopwatch = Stopwatch()..start();
|
||||
return Image(
|
||||
image: image,
|
||||
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
|
||||
if (frame == null) {
|
||||
return AnimatedSwitcher(duration: duration, child: placeholder);
|
||||
}
|
||||
|
||||
stopwatch.stop();
|
||||
if (stopwatch.elapsedMilliseconds < 32) {
|
||||
return child;
|
||||
}
|
||||
return AnimatedSwitcher(duration: duration, child: child);
|
||||
},
|
||||
filterQuality: FilterQuality.low,
|
||||
fit: fit,
|
||||
width: width,
|
||||
height: height,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue