Skip to content

Conversation

@bbrk24
Copy link
Contributor

@bbrk24 bbrk24 commented Jan 18, 2025

This PR contains a significant restructuring to allow widgets to be UIViews or UIViewControllers. I used this to implement two features: UIViewControllerRepresentable, and split views. While implementing UIViewControllerRepresentable I discovered a way to improve the sizing algorithm for UIViewRepresentable so that is also in this PR.

Split views are currently only supported on iPad, where they actually work.

  • On Apple TV and landscape-orientation iPhones, the sidebar has an additional safe area inset on the left. Since we haven't figured out how to make the layout engine aware of safe area insets, this meant that the sidebar was pushed to the right and covered some content of the main view.
  • On portait-orientation iPhones and iPod touch in all orientations, it is broken for almost exactly the reason you would expect -- iOS refuses to render a sidebar on a screen that narrow. Instead, the sidebar takes up the entire screen, and the main view is hidden.

To avoid these issues for now, createSplitView crashes if it detects it's running on an unsupported system. We may revisit split views on mobile & TV in the future.

Since the scroll widget is now a view controller, I debated making it the UIScollView's delegate, but I decided against that as we wouldn't have any need to implement any of the delegate methods yet.

Copy link
Owner

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few smallish things to change, but overall looking great!

@bbrk24 bbrk24 requested a review from stackotter February 3, 2025 04:54
Copy link
Owner

@stackotter stackotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making those changes 🙏 I'll just test them quickly them locally and then merge if they work

@stackotter stackotter merged commit 810cc92 into stackotter:main Feb 27, 2025
4 checks passed
@bbrk24 bbrk24 deleted the UIViewControllers branch November 1, 2025 04:06
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

Successfully merging this pull request may close these issues.

2 participants