facebook / yoga

Yoga is an embeddable layout engine targeting web standards.
https://yogalayout.dev/
MIT License
17.35k stars 1.44k forks source link

Yoga Swift interface #620

Open lucdion opened 7 years ago

lucdion commented 7 years ago

Report

Issues and Steps to Reproduce

This is not an issue, but more a proposition.

YogaKit should have an official Swift interface, and not just a Objective-C interface. Swift has been around for more than 3 years now, and it is now the defacto iOS languages for new applications.

I've developed a nice Swift Yoga interface (at least from my point of view :-)) that gently wraps the Yoga flexbox implementation. I would be really happy to share it and integrate it with the Yoga's repo. You can find my project at https://github.com/lucdion/FlexLayout

Regards

Link to Code

https://github.com/lucdion/FlexLayout

alickbass commented 6 years ago

Any news here?

lucdion commented 6 years ago

No @alickbass, but in the meantime, you can use it: https://github.com/layoutBox/FlexLayout

NickGerleman commented 2 years ago

At this point FlexLayout has grown to be its own mature project. I think it is more likely that we should point to it in Yoga documentation instead of bringing into the repo.

iainsmith commented 3 months ago

Hey all, I started prototyping out an implementation in a standalone package at iainsmith/YogaSwift that uses Swift Macros to minimise the boilerplate code for wrapping the calls to YGNodeStyleGetXXX.

The next thing I am looking at is updating the gentest script to generate the swift tests.

If there’s interest in upstreaming some of this work into the main yoga Swift package, down the line, I’d be happy to move this to a new module in my yoga fork and PR it up.


The upcoming release of swift 6 has support for noncopyable generics & type (~Copyable) which facilitate building a more ergonomic Swift API, so users don’t have to manually call YGNodeFree, which is what my current implementation is targetting.