What 馃尡
Using new macro with .sizeThatFitsLayout renders preview with the correct size of the view:
#if compiler(>=5.9) && DEBUG
@available(iOS 17.0, *)
#Preview(traits: .sizeThatFitsLayout) {
EpisodeShareLabel()
.preferredColorScheme(.dark)
.background(ShowScreen.Constants.previewBackground)
}
#endif
However when generating snapshot, the rendered output is much larger than necessary:
Proposal 馃帀
I'd need to dig into the code to refresh my memory on how the sizing works.
Possibly it's a trouble with UIHostingController and the swift-snapshot-testing framework.
If getting the traits from the Preview macro is difficult, we could introduce another extension on View in order to mark views as explicitly size that fits:
EpisodeShareLabel()
.preferredColorScheme(.dark)
.background(ShowScreen.Constants.previewBackground)
.prefireIgnored()
.prefireSizeThatFits()
What 馃尡
Using new macro with
.sizeThatFitsLayoutrenders preview with the correct size of the view:However when generating snapshot, the rendered output is much larger than necessary:
Proposal 馃帀
I'd need to dig into the code to refresh my memory on how the sizing works.
Possibly it's a trouble with
UIHostingControllerand the swift-snapshot-testing framework.If getting the
traitsfrom the Preview macro is difficult, we could introduce another extension onViewin order to mark views as explicitly size that fits: