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

Enhance zoom #859

Merged
merged 13 commits into from
Jan 11, 2024
Merged

Enhance zoom #859

merged 13 commits into from
Jan 11, 2024

Conversation

Niranjan-Dorage
Copy link
Contributor

@Niranjan-Dorage Niranjan-Dorage commented Oct 28, 2023

Pull Request Description

This pull request introduces an enhancement that dynamically adjusts the maximum zoom level based on the resolution of the image. The getImageSize function has been implemented to calculate the image's width and height, and the maxzoomlevel is set according to the larger dimension (width or height). This allows for variable zooming capabilities, improving the user experience, especially for high-resolution images.
also my branch is upto date and ready for merging

Issue Being Fixed

Previously, there was a static maximum zoom level set at 4x the display size in the image viewer. This limitation restricted the ability to zoom in on images, especially high-resolution images, where greater zoom levels might be necessary for detailed viewing.

Issue Number: #754

Screenshots / Recordings

Checklist

  • Did you update CHANGELOG.md?
  • Did you use localized strings where applicable?
  • Did you add semanticLabels where applicable for accessibility?

Copy link
Member

@micahmo micahmo left a comment

Choose a reason for hiding this comment

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

Thanks so much for the contribution, nice work!!

@CTalvio Do you want to review too?

lib/shared/image_viewer.dart Outdated Show resolved Hide resolved
pubspec.lock Outdated Show resolved Hide resolved
lib/shared/image_viewer.dart Outdated Show resolved Hide resolved
lib/shared/image_viewer.dart Show resolved Hide resolved
@Niranjan-Dorage
Copy link
Contributor Author

all suggestions are implemented , you can check code again @micahmo sir .

@CTalvio
Copy link
Collaborator

CTalvio commented Oct 28, 2023

LGTM! Awesome!

Copy link
Member

@hjiangsu hjiangsu left a comment

Choose a reason for hiding this comment

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

Hey @Niranjan-Dorage, thanks for contributing to this project! I just have a couple of comments with regards to the PR, but everything else seems good to me!

I would also remove the changes from pubspec.lock if possible as it seems like its downgrading some packages (unless this was on purpose)

@@ -113,12 +115,30 @@ class _ImageViewerState extends State<ImageViewer> with TickerProviderStateMixin
);
}

Future<void> getImageSize(String imageUrl, context) async {
retrieveImageDimensions(imageUrl);
Copy link
Member

Choose a reason for hiding this comment

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

I believe that all the widgets that depend on ImageViewer have some width/height information already present. Maybe a slightly better solution here is to allow width and height to be passed into ImageViewer as a optional parameters.

If the width and height parameters are passed into ImageViewer, then we'll use that information. Otherwise if width/height are null, we'll fallback to fetching the image dimensions from retrieveImageDimensions

I believe that media_view.dart and image_preview.dart are the only widgets at this time using ImageViewer!

Copy link
Contributor Author

@Niranjan-Dorage Niranjan-Dorage Dec 30, 2023

Choose a reason for hiding this comment

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

Hello @hjiangsu sir,

I sincerely apologize for the delay. I was occupied with exams, but I'm now continuing with the remaining work.

I couldn't find any pre-fetched dimensions in either image_preview.dart or media_view.dart. Please correct me if I'm mistaken.

Thank you.

Copy link
Member

@hjiangsu hjiangsu Jan 4, 2024

Choose a reason for hiding this comment

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

I sincerely apologize for the delay. I was occupied with exams, but I'm now continuing with the remaining work.

No worries!

I couldn't find any pre-fetched dimensions in either image_preview.dart or media_view.dart. Please correct me if I'm mistaken.

I can clarify a bit more on this! MediaView contains postViewMedia parameter which contains information about the post along with the media information (see PostViewMedia class).

PostViewMedia contains a list of Media objects that contain width and height parameters. See Media class to get more information on what parameters the class has.

If you'd like, I can add a commit to this PR which implements this. Let me know!

@override
void initState() {
super.initState();
getImageSize(widget.url!, context);
Copy link
Member

Choose a reason for hiding this comment

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

Since getImageSize is an async function and calls setState(), we should change this to be the following to be safe (we want initState to finish initializing before setState is called)

WidgetsBinding.instance.addPostFrameCallback((_){
  getImageSize(widget.url!, context);
});

Copy link
Contributor Author

@Niranjan-Dorage Niranjan-Dorage Dec 30, 2023

Choose a reason for hiding this comment

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

changes done ✅✅

@Niranjan-Dorage
Copy link
Contributor Author

@CTalvio @micahmo @hjiangsu kindly review the changes

Copy link
Member

@hjiangsu hjiangsu left a comment

Choose a reason for hiding this comment

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

Just a few minor comments!

.env Outdated
@@ -0,0 +1 @@
# Empty Environment File
Copy link
Member

Choose a reason for hiding this comment

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

The .env file was removed from .gitignore since it's no longer relevant. You can go ahead and remove this file.

See #946 for more information!

bool isDownloadingMedia = false;
late double imagewidth = 0;
Copy link
Member

Choose a reason for hiding this comment

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

For conventions, use camel case for the variable names (imageWidth, imageHeight, maxZoomLevel)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hjiangsu changes done

Copy link
Member

@hjiangsu hjiangsu left a comment

Choose a reason for hiding this comment

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

LGTM! I just moved the changelog entry to the proper place

@hjiangsu hjiangsu merged commit fb2f586 into thunder-app:develop Jan 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants