Skip to content

Feature AnimatedImage placeholder view builder #94

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

Merged
merged 4 commits into from
Apr 5, 2020

Conversation

dreampiggy
Copy link
Collaborator

This PR supports the @ViewBuilder API to create placeholder on AnimatedImage.

The channlege is that AnimatedImage use UIViewRepresentable, which the body func is override by SwiftUI internel logic. So we can not use the same design as WebImage (which return different Image based on loading status)

So, instead, we use the HostingView, to inject the View Hierarchy. The placeholder is above the original SDAnimatedImageView, and controls its isHidden property during loading.

Note the placeholder and indicator can be used at the same time, we need to considerate this case and adjust the View Hierarchy level

@dreampiggy dreampiggy added animated image AnimatedImage struct API API changes feature labels Apr 5, 2020
@dreampiggy dreampiggy force-pushed the feature_animated_placeholder_view_builder branch from c82ffce to eb6c7f1 Compare April 5, 2020 06:24
@dreampiggy dreampiggy force-pushed the feature_animated_placeholder_view_builder branch from eb6c7f1 to 1e1ddcc Compare April 5, 2020 06:25
@codecov
Copy link

codecov bot commented Apr 5, 2020

Codecov Report

Merging #94 into master will increase coverage by 2.03%.
The diff coverage is 85.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #94      +/-   ##
==========================================
+ Coverage   73.49%   75.53%   +2.03%     
==========================================
  Files           9        9              
  Lines         732      748      +16     
==========================================
+ Hits          538      565      +27     
+ Misses        194      183      -11     
Flag Coverage Δ
#ios 75.53% <85.96%> (+2.03%) ⬆️
Impacted Files Coverage Δ
SDWebImageSwiftUI/Classes/ImageViewWrapper.swift 82.69% <77.77%> (-1.03%) ⬇️
SDWebImageSwiftUI/Classes/WebImage.swift 84.51% <80.00%> (+4.51%) ⬆️
SDWebImageSwiftUI/Classes/ImageManager.swift 75.71% <83.33%> (+4.44%) ⬆️
SDWebImageSwiftUI/Classes/AnimatedImage.swift 73.89% <90.32%> (+1.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7458f13...63201c7. Read the comment docs.

@dreampiggy dreampiggy changed the title Feature animated placeholder view builder Feature AnimatedImage placeholder view builder Apr 5, 2020
@dreampiggy dreampiggy merged commit c6e4400 into master Apr 5, 2020
@dreampiggy dreampiggy deleted the feature_animated_placeholder_view_builder branch April 5, 2020 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
animated image AnimatedImage struct API API changes feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant