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

UI/PhotoPreview #330

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open

UI/PhotoPreview #330

wants to merge 30 commits into from

Conversation

nagavcindriqim
Copy link
Contributor

@nagavcindriqim nagavcindriqim commented Sep 9, 2024

A UI component you can use to present an image or set of images in full-screen mode.

Requirements

  • you should be able to inject an array of images
  • image preview is presented full-screen
  • you can zoom and pan the image
  • you can rotate the screen vertically and/or horizontally
  • you can navigate to the next screen (if multiple are supplied)
  • swipe down to dismiss it interactively
  • written in SwiftUI

Closes #206

@nagavcindriqim nagavcindriqim self-assigned this Sep 9, 2024
@nagavcindriqim nagavcindriqim requested a review from a team September 9, 2024 13:20
Copy link
Collaborator

@borut-t borut-t left a comment

Choose a reason for hiding this comment

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

I like it. I would also like to see a preview of it in the Storbybook app. Can you do that within this PR please.

@borut-t
Copy link
Collaborator

borut-t commented Sep 23, 2024

I've previewed the component in the Storybook app. Here is my observation:

  • there is some flickering going on and it appears to be happening only for the remote images
  • remote image aspect ratio is not respected
  • could we go with a TabView and PageTabViewStyle() instead?
Screen.Recording.2024-09-23.at.08.45.45.mov

@nagavcindriqim
Copy link
Contributor Author

I've previewed the component in the Storybook app. Here is my observation:

  • there is some flickering going on and it appears to be happening only for the remote images
  • remote image aspect ratio is not respected
  • could we go with a TabView and PageTabViewStyle() instead?

Screen.Recording.2024-09-23.at.08.45.45.mov

@borut-t I've made some changes to loading remote images. The issue persisted only when Kingfisher was not available.
Unfortunately we can not use TabView since it limits us on the scrolling functionality.

@borut-t
Copy link
Collaborator

borut-t commented Sep 23, 2024

I've previewed the component in the Storybook app. Here is my observation:

  • there is some flickering going on and it appears to be happening only for the remote images
  • remote image aspect ratio is not respected
  • could we go with a TabView and PageTabViewStyle() instead?

Screen.Recording.2024-09-23.at.08.45.45.mov

@borut-t I've made some changes to loading remote images. The issue persisted only when Kingfisher was not available. Unfortunately we can not use TabView since it limits us on the scrolling functionality.

There is still some glitching going on...
https://github.com/user-attachments/assets/3b516597-0d31-42bf-a181-f149d4b0ff20

Regards to the TabView, I think this can be done with it.

@nagavcindriqim
Copy link
Contributor Author

I've previewed the component in the Storybook app. Here is my observation:

  • there is some flickering going on and it appears to be happening only for the remote images
  • remote image aspect ratio is not respected
  • could we go with a TabView and PageTabViewStyle() instead?

Screen.Recording.2024-09-23.at.08.45.45.mov

@borut-t I've made some changes to loading remote images. The issue persisted only when Kingfisher was not available. Unfortunately we can not use TabView since it limits us on the scrolling functionality.

There is still some glitching going on... https://github.com/user-attachments/assets/3b516597-0d31-42bf-a181-f149d4b0ff20

Regards to the TabView, I think this can be done with it.

@borut-t the glitch should now be fixed 🙏

@borut-t
Copy link
Collaborator

borut-t commented Sep 23, 2024

I've previewed the component in the Storybook app. Here is my observation:

  • there is some flickering going on and it appears to be happening only for the remote images
  • remote image aspect ratio is not respected
  • could we go with a TabView and PageTabViewStyle() instead?

Screen.Recording.2024-09-23.at.08.45.45.mov

@borut-t I've made some changes to loading remote images. The issue persisted only when Kingfisher was not available. Unfortunately we can not use TabView since it limits us on the scrolling functionality.

There is still some glitching going on... https://github.com/user-attachments/assets/3b516597-0d31-42bf-a181-f149d4b0ff20
Regards to the TabView, I think this can be done with it.

@borut-t the glitch should now be fixed 🙏

And they truly are. Two things:

  • progress loader looks a bit funny, can we use the default one?
  • i can zoom out the image too far. Can we limit until the image fit's the screen? (e.g., it should not be smaller than the screen width/height)

@nagavcindriqim
Copy link
Contributor Author

I've previewed the component in the Storybook app. Here is my observation:

  • there is some flickering going on and it appears to be happening only for the remote images
  • remote image aspect ratio is not respected
  • could we go with a TabView and PageTabViewStyle() instead?

Screen.Recording.2024-09-23.at.08.45.45.mov

@borut-t I've made some changes to loading remote images. The issue persisted only when Kingfisher was not available. Unfortunately we can not use TabView since it limits us on the scrolling functionality.

There is still some glitching going on... https://github.com/user-attachments/assets/3b516597-0d31-42bf-a181-f149d4b0ff20
Regards to the TabView, I think this can be done with it.

@borut-t the glitch should now be fixed 🙏

And they truly are. Two things:

  • progress loader looks a bit funny, can we use the default one?
  • i can zoom out the image too far. Can we limit until the image fit's the screen? (e.g., it should not be smaller than the screen width/height)

@borut-t we can't use the default one since we are using .drawingGroup() modifier.
zooming out is now limited to fit the screen 👌

@nagavcindriqim nagavcindriqim force-pushed the feature/photo-preview branch 2 times, most recently from 6f1017f to 960df31 Compare September 26, 2024 11:04
@dejanskledar
Copy link
Collaborator

@nagavcindriqim @borut-t can we wrap this up? Any major issues still present?

Copy link
Contributor

@markom-povio markom-povio left a comment

Choose a reason for hiding this comment

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

Looking good! Can you add some more documentation in the code (in the Configuration, for example)?

@nagavcindriqim
Copy link
Contributor Author

@nagavcindriqim @borut-t can we wrap this up? Any major issues still present?

@dejanskledar major issues should be fixed with this commit 👌

Copy link
Collaborator

@borut-t borut-t left a comment

Choose a reason for hiding this comment

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

Really nice progress 👌

I've added a few comments about the code itself.
And have also tested out the implementation on the real device and it still feels a bit clunky when zooming in. Especially when you zoom-in and out and want to continue scrolling.

I would de-prioritise this ticket for now and we can come back latter...


// MARK: - ViewBuilders
@available(iOS 16.0, *)
extension PhotoPreview {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't want builders to be exposed, do we?


// MARK: - Helpers
@available(iOS 16.0, *)
extension PhotoPreview {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we tighten access?


// MARK: - Gestures
@available(iOS 16.0, *)
extension PhotoPreview {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Private access?

Comment on lines +9 to +11
#if canImport(Kingfisher)
import Kingfisher
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's remove this in favour or RemoteImage.

Comment on lines +80 to +100
var remoteImageView: some View {
#if canImport(Kingfisher)
KFImage(item.url)
.resizable()
.placeholder {
(item.placeholder ?? Image(uiImage: UIImage()))
.resizable()
}
.scaledToFit()
#else
AsyncImage(url: item.url) { image in
image
.resizable()
.scaledToFit()
} placeholder: {
ProgressView()
.tint(.white)
.controlSize(.large)
}
#endif
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we replace with RemoteImage?


// MARK: - Helper methods
@available(iOS 16.0, *)
extension PhotoPreview.ItemView {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Private access?


// MARK: - Gestures
@available(iOS 16.0, *)
extension PhotoPreview.ItemView {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Private access?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UI] PhotoPreview
5 participants