Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalUiConfiguration API to check if the viewInsets are valid #2521

Open
squarejesse opened this issue Jan 4, 2025 · 1 comment
Open

LocalUiConfiguration API to check if the viewInsets are valid #2521

squarejesse opened this issue Jan 4, 2025 · 1 comment

Comments

@squarejesse
Copy link
Contributor

We default UiConfiguration.viewInsets to Margin.zero when the host TreehouseUIView is not attached to the view hierarchy. When it is eventually attached, it takes a frame or two to render with the actual insets.

I’d like the ability for guest code to detect if these insets are invalid so it can choose to not render, rather than rendering with the incorrect value.

@squarejesse
Copy link
Contributor Author

Current work-around:

  /**
   * Returns true if this model is attached to a view hierarchy in the host application.
   *
   * The safe area insets will be wrong until the view is attached, and we don't want to display
   * the UI until we have correct values, otherwise it'll draw an ugly first frame.
   */
  @Composable
  private fun isAttachedToScreen(): Boolean =
    (LocalUiConfiguration.current.viewportSize?.width?.value ?: 0.0) > 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant