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

Feature progressiveJPEG for SwiftUI #2366

Merged
merged 2 commits into from
Mar 4, 2025
Merged

Conversation

onevcat
Copy link
Owner

@onevcat onevcat commented Mar 3, 2025

This allows SwiftUI uses the progressive JPEG modifier to display an image with progressive support.

Solve #1554

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-03-04.at.01.08.10.mp4

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @onevcat, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request introduces progressive JPEG support for SwiftUI in Kingfisher. It adds a new ProgressiveJPEGDemo view to the demo app, showcasing the progressive loading of a JPEG image. The progressiveJPEG modifier is now available as a KFOptionSetter, and the KingfisherManager is updated to handle progressive image setting during image retrieval. This resolves issue #1554.

Highlights

  • Feature: Adds progressive JPEG support to SwiftUI's KFImage, allowing images to load progressively.
  • Demo: Introduces a new ProgressiveJPEGDemo view in the demo app to demonstrate the progressive JPEG loading feature.
  • API: The progressiveJPEG modifier is now available as a KFOptionSetter, providing a convenient way to enable progressive loading.

Changelog

Click here to see the changelog
  • Demo/Demo/Kingfisher-Demo/SwiftUIViews/MainView.swift
    • Added a NavigationLink to the new ProgressiveJPEGDemo view.
  • Demo/Demo/Kingfisher-Demo/SwiftUIViews/ProgressiveJPEGDemo.swift
    • Created a new SwiftUI view ProgressiveJPEGDemo to display a progressive JPEG image using KFImage.
    • Uses KFImage with the progressiveJPEG() modifier.
    • Displays the received and total image sizes during loading using the onProgress callback.
  • Demo/Kingfisher-Demo.xcodeproj/project.pbxproj
    • Added ProgressiveJPEGDemo.swift to the project.
    • Added ProgressiveJPEGDemo.swift to the build file.
    • Added ProgressiveJPEGDemo.swift to the sources build phase.
  • Sources/General/KF.swift
    • Removed the progressiveJPEG function from the KF.Builder extension.
  • Sources/General/KFOptionsSetter.swift
    • Added the progressiveJPEG function to the KFOptionSetter extension, allowing it to be used with SwiftUI.
  • Sources/General/KingfisherManager.swift
    • Modified retrieveImage to accept a progressiveImageSetter closure.
    • The progressiveImageSetter closure is called when a progressively loaded image is available.
  • Sources/SwiftUI/ImageBinder.swift
    • Added progressiveImageSetter to the retrieveImage call, which updates the loadedImage property with the progressively loaded image.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Trivia time!

What does JPEG stand for?

Click here for the answer
JPEG stands for Joint Photographic Experts Group.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces progressive JPEG support to SwiftUI views in Kingfisher. The changes involve adding a new demo view, modifying the KFImage and KingfisherManager to handle progressive images, and updating project files. Overall, the implementation seems reasonable, but there are a few areas that could be improved for clarity and maintainability.

Merge Readiness

The pull request introduces a new feature and seems generally well-implemented. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging. Given the absence of any CRITICAL or HIGH severity issues, the pull request is a good candidate for merging after addressing the MEDIUM and LOW severity issues. I recommend that the pull request not be merged until those are addressed (at a minimum).

@onevcat onevcat merged commit 4d947c4 into master Mar 4, 2025
48 checks passed
@onevcat onevcat deleted the feature/progressive-jpeg-swiftui branch March 4, 2025 11:45
@onevcat onevcat mentioned this pull request Mar 4, 2025
3 tasks
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.

1 participant