lorenzofiamingo / swiftui-cached-async-image

CachedAsyncImage is the simplest way to add cache to your AsyncImage.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transaction doesn't work

polkandra opened this issue · comments

Good work, thanks, Lorenzo!
Im using library to fetch and cache images like this:

       CachedAsyncImage(
        url: URL(string: path),
        urlCache: .imageCache,
        transaction: Transaction(animation: .easeInOut)) { phase in
            
            switch phase {
            case .empty:
                ProgressView()
                    .progressViewStyle(.circular)
            case .success(let image):
                image
                    .resizable()
                    .aspectRatio(contentMode: .fill)
            case .failure:
                Image("")
            @unknown default:
                Image("")
            }
        }
        .frame(
            width: frameForBaseImage().0,
            height: frameForBaseImage().1
        )
        .cornerRadius(filesGroupingSelection == .yearGrouping ? 4 : 8)

But transaction doesn't work at all(

I need a reproducible example.
However the animation specified in transaction only takes effect when there is a change in the phase. If the image comes from the cache, the phase is initialized directly with the image so there is no animation (as it should be). If you want to animate this case you just need to apply .animation () outside the CachedAsyncImage.