From c499b9a55f7d36878de67701e791614a742bda24 Mon Sep 17 00:00:00 2001 From: Dan Fabulich Date: Mon, 11 May 2026 12:03:19 -0700 Subject: [PATCH] Add a custom `empty` closure variation Tests https://github.com/skiptools/skip-ui/pull/423 --- Sources/Showcase/ImagePlayground.swift | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Sources/Showcase/ImagePlayground.swift b/Sources/Showcase/ImagePlayground.swift index fe892fa..26f936d 100644 --- a/Sources/Showcase/ImagePlayground.swift +++ b/Sources/Showcase/ImagePlayground.swift @@ -321,6 +321,35 @@ struct ImagePlayground: View { .frame(width: 100, height: 100) .border(Color.blue) } + HStack { + Text("Custom empty phase closure") + Spacer() + AsyncImage(url: remoteImageResourceURL) { phase in + switch phase { + case .empty: + ZStack { + if let image = phase.image { + let _ = logger.debug("Custom empty phase closure: .empty image") + ProgressView() + image + } else { + ProgressView() + } + } + case .failure: + Color.red + case .success(let image): + image.resizable() + @unknown default: + EmptyView() + } + } + .frame(width: 100, height: 100) + .border(Color.blue) + } + #if os(Android) + //.subcomposeAsyncImage() + #endif } .padding() }