It was more of a general question about if the API is working correctly for others which of course can be very useful information - pretty common for Apple APIs, especially SwiftUI, to behave in strange ways and sometimes just not work at all.
So that was the purpose - knowing it works fine for everyone else would be useful. That's what the 'just me' question means.
But sure, here's the code. It's basically the same as the sample in the documentation and since this modifier just uses a Bool state for presentation it didn't seem useful.
With the below:
- When button pressed, sheet presents as expected.
- Sheet is blank, i.e. totally white.
- Wait a little bit to see what happens (nothing).
- Dismiss sheet with interactive pull dismissal.
- Tap button again.
- Sheet appears, Image Playgrounds content loads.
Code is as follows in case something does jump out. Maybe you'll see something that I do not.
import SwiftUI
#if canImport(ImagePlayground)
import ImagePlayground
#endif
@available(iOS 18.2, *)
struct TripCustomImageGenerationView: View {
@Environment(\.supportsImagePlayground) private var supportsImagePlayground
@State private var showImagePlayground: Bool = false
@State private var data: Data?
var body: some View {
if supportsImagePlayground {
Button("Generate Custom Image") {
showImagePlayground = true
}
.imagePlaygroundSheet(isPresented: $showImagePlayground, concept: "Test Image Concept") { url in
self.data = try? Data(contentsOf: url)
}
} else {
EmptyView()
}
}
}