Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster image scrolling and fix zoom out issue #519

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 9 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,13 @@ 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,
// placeholder:
// 'assets/img/photo_placeholder_${(360 - photos[i].rotation) % 360}.png'),
Comment on lines +177 to +178
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can go

)),
);
} else {
child = const Center(
Expand All @@ -181,7 +186,7 @@ class _GalleryState<C extends GalleryCubit> extends State<Gallery>

return PhotoViewGalleryPageOptions.customChild(
child: child,
minScale: PhotoViewComputedScale.contained * 0.8,
minScale: PhotoViewComputedScale.contained * 1,
Comment on lines -184 to +189
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this was changed? I cannot test this atm, I will test next week

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With 0.8, you can zoom out the image from its default position. Not just 'pinch' it, but after that it will suddenly not take the full width up anymore, which we thought was pretty cursed. Putting it at 1 instead solves that so fully zoomed out is still the full screen width.

maxScale: PhotoViewComputedScale.covered * 2,
);
},
Expand Down
Loading