Is your feature request related to a problem? Please describe.
Since the initial release of URLImage package, ViewBuilder attribute gone public, and there are some benefits for using it. Using it will allow conditionally return views of different types.
In this example if the image is wider than 100px we make it resizable.
URLImage(url: url) { image, info in
Group {
if info.size.width > 100.0 {
image
.resizable()
.aspectRatio(contentMode: .fit)
}
else {
image
}
}
}
Using ViewBuilder attribute will allow to return different views:
URLImage(url: url) { image, info in
if info.size.width > 100.0 {
image
.resizable()
.aspectRatio(contentMode: .fit)
}
else {
image
}
}
Describe the solution you'd like
Add @ViewBuilder to URLImage initializers.
Describe alternatives you've considered
Keep it as is.
Additional contextViewBuilder attribute actually allows to provide multiple child views. It is unclear what should be expected behaviour when this is the case. Simply ignore it, wrap in a Group, or a ZStack, etc. Let me know what you think.
Is your feature request related to a problem? Please describe. Since the initial release of URLImage package,
ViewBuilder
attribute gone public, and there are some benefits for using it. Using it will allow conditionally return views of different types.In this example if the image is wider than 100px we make it resizable.
Using ViewBuilder attribute will allow to return different views:
Describe the solution you'd like Add
@ViewBuilder
toURLImage
initializers.Current:
New:
Describe alternatives you've considered Keep it as is.
Additional context
ViewBuilder
attribute actually allows to provide multiple child views. It is unclear what should be expected behaviour when this is the case. Simply ignore it, wrap in aGroup
, or aZStack
, etc. Let me know what you think.