Skip to content

Generated preview much larger than necessary#116

Description

@markst

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
Image

However when generating snapshot, the rendered output is much larger than necessary:

Image Image

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()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions