pteasima / VTree

VirtualDOM for Swift (iOS, macOS)
MIT License
0 stars 0 forks source link

Add ViewController support #1

Open pteasima opened 6 years ago

pteasima commented 6 years ago

In order to make this framework relevant, it needs to support UIViewController nodes. Try to make a PoC of this.

The hard thing about view controllers is that you cant just present them at will. There are issues related to parentVC state and animated transitions ("warning, trying to present VC on another VC that is not in window", "warning, unbalanced calls to VC appearance"). Some kind of "locking" mechanism needs to be put in place. Hopefully its possible to do something like "if a child gets added, but cant be presented yet, create it, hold on to it, but dont present. Only start presenting when possible (if it hasnt been removed by then)."

The framework needs to be ready to support different kinds of nodes (UIView, UIViewController nodes for now, but also SpriteKit, SceneKit in the future). I have tried this in the past and it makes the implementation much more complicated. Hopefully basic support can be added without many changes to the framework (even in a unsafe way where adding a VC node as child of a View node would crash). This could later be made safe by only exposing the right stuff in node initializers. Moving to a safe underlying impl is desirable but Im not confident I can do it in one shot (so start with a version that works under ideal circumstances and refactor later).

A VC node might have some props that are passed through to its view property, or it might be forced to have exactly one child View node. Try to delay this decision to keep things simple for now.

pteasima commented 6 years ago

If stuck, ReactNative should provide solutions. By looking at it briefly, its looks like it uses all kinds of different locks for all kinds of animated stuff that requires synchronization. Try to keep it simple if possible (dont try to port ReactNative right away)