SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.21k stars 230 forks source link

Feature AnimatedImage placeholder view builder #94

Closed dreampiggy closed 4 years ago

dreampiggy commented 4 years ago

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

codecov[bot] commented 4 years ago

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%) :arrow_up:
Impacted Files Coverage Δ
SDWebImageSwiftUI/Classes/ImageViewWrapper.swift 82.69% <77.77%> (-1.03%) :arrow_down:
SDWebImageSwiftUI/Classes/WebImage.swift 84.51% <80.00%> (+4.51%) :arrow_up:
SDWebImageSwiftUI/Classes/ImageManager.swift 75.71% <83.33%> (+4.44%) :arrow_up:
SDWebImageSwiftUI/Classes/AnimatedImage.swift 73.89% <90.32%> (+1.29%) :arrow_up:

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.