SDWebImage / SDWebImageSwiftUI

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

Refactor WebImage/AnimatedImage using SwiftUIBackports and StateObject #227

Closed dreampiggy closed 1 year ago

dreampiggy commented 1 year ago

This PR close #225 #222

Note

This is the Last Version which support iOS 13. The back port is really pain

Changes

WebImage

  1. Use SwiftUIBackport to use StateObject/OnChange/Overlay
  2. Change the Indicator API to match the transform for ImageManager
  3. Remove the unused PlatformApear hack

AnimatedImage

  1. Use context.coordinator to store loading status because it's exclusive unlike normal SwiftUI.View

API Break

  1. The IndicatorReportable design is wrong. And removed with IndicatorStatus ObservableObject class. You can migrate using a self-created @ObservedObject var status = IndicatorStatus(), then use onReceive(myLoadingStatus) to trigger update on that IndicatorStatus (I don't think anyone beside me use this API, actually this does not effect the user-level .indicator(.progress) API...)

Warnings

  1. Fix Xcode 14's warinng

    Publishing changes from within view updates is not allowed, this will cause undefined behavior.

@garrettrayj

dreampiggy commented 1 year ago

The test cases failed because the ViewInspector no longer can find the group.image(0). However, I check the real demo and it works as expected.

May fix later, currently I just merge and release v2.1