my goal is to have a custom AsyncImage View because I need to authenticate my request. Therefore I have created a custom struct which implements this. Now my only problem is that I want to add modifiers to my loaded Image.
Something like this:
CustomAsyncImageView(dataKey: dataKey) { image in
image
.resizable()
} placeholder: {
Rectangle()
}
What I tried:
struct CustomAsyncImageView<Content> : View where Content : View {
var content: Content
var image: Image?
// I left out the Image loading
public init<I, P>(dataKey: String, @ViewBuilder content: @escaping (Image) -> I, @ViewBuilder placeholder: @escaping () -> P) {
// I have this init from AsyncImage, but I have no idea how to initialize my properties
}
var body: some View {
if let image = image {
image
} else {
// show placeholder
}
}
}
Is this type of initialization possible to implement or should I pass the viewModifier as a parameter?