Skip to content

Commit

Permalink
Faster image scrolling and fix zoom out issue (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodepanda7 authored Nov 6, 2024
1 parent 9b3f2bc commit 1938537
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/ui/widgets/cached_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ class CachedImage extends CachedNetworkImage {
BoxFit super.fit = BoxFit.cover,
Duration super.fadeOutDuration = const Duration(milliseconds: 200),
super.fadeInDuration = const Duration(milliseconds: 200),
required String placeholder,
String? placeholder,
}) : super(
key: ValueKey(imageUrl),
cacheManager: cache.ThaliaCacheManager(),
cacheKey: _getCacheKey(imageUrl),
placeholder: (_, __) => Image.asset(placeholder, fit: fit),
placeholder: placeholder == null
? null
: (_, __) => Image.asset(placeholder, fit: fit),
);
}

Expand Down
11 changes: 7 additions & 4 deletions lib/ui/widgets/gallery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:reaxit/models.dart';
import 'package:reaxit/ui/theme.dart';
import 'package:share_plus/share_plus.dart';
import 'package:gal/gal.dart';
import 'package:reaxit/ui/widgets/cached_image.dart';

abstract class GalleryCubit<T> extends StateStreamableSource<T> {
Future<void> updateLike({required bool liked, required int index});
Expand Down Expand Up @@ -169,9 +170,11 @@ class _GalleryState<C extends GalleryCubit> extends State<Gallery>
child = GestureDetector(
onDoubleTap: () => _likePhoto(photos, i),
child: RotatedBox(
quarterTurns: photos[i].rotation ~/ 90,
child: Image.network(photos[i].full),
),
quarterTurns: photos[i].rotation ~/ 90,
child: CachedImage(
imageUrl: photos[i].full,
fit: BoxFit.contain,
)),
);
} else {
child = const Center(
Expand All @@ -181,7 +184,7 @@ class _GalleryState<C extends GalleryCubit> extends State<Gallery>

return PhotoViewGalleryPageOptions.customChild(
child: child,
minScale: PhotoViewComputedScale.contained * 0.8,
minScale: PhotoViewComputedScale.contained * 1,
maxScale: PhotoViewComputedScale.covered * 2,
);
},
Expand Down

0 comments on commit 1938537

Please sign in to comment.