mlemgroup / mlem

Mlem for Lemmy
https://lemmy.ml/c/mlemapp
GNU General Public License v3.0
162 stars 34 forks source link

MultiplatformView #1091

Closed EricBAndrews closed 2 weeks ago

EricBAndrews commented 2 weeks ago

This PR introduces the MultiplatformView, a construct designed to streamline creating different views for different platforms. Its operation is very simple: it takes in two View closures, one to render for iPhone and one to render for iPad, and renders the one appropriate for the current platform.

var body: some View {
  MultiplatformView {
    contentForPhone
  } pad: {
    contentForPad
  }
}

Ideally we would do this with compile-time checks to avoid the runtime conditional, but I can't seem to find a good way to check for iPadOS at compile time.