mamaral / Neon

A powerful Swift programmatic UI layout framework.
MIT License
4.58k stars 389 forks source link

Add right to left layout support #56

Closed Moonko closed 6 years ago

Moonko commented 7 years ago

Respect right to left interface layout.

mamaral commented 7 years ago

This has been on my TODO list for a while, thanks for doing this! 👍

Taking a quick look on my phone it looks good, although I see/understand the new values but don't see where these new values are consumed. I'll try to get another look when I'm in front of a computer.

MontakOleg commented 7 years ago

This is implementation of https://github.com/mamaral/Neon/issues/55, great job! 👍

The only thing is different views can have different layout directions in the same app. For example playback control don't flipped on right-to-left systems. Apple uses semanticContentAttribute to specify view layout behaviour. Recommended way to get layout direction on iOS 10 is call myView.effectiveUserInterfaceLayoutDirection which internally depends on semanticContentAttribute.

Looks like we should take view in new leading an trailing factory functions to correct determine layout direction :(

On the other hand we can just ignore semanticContentAttribute . The only issue I can think is subclassing of existing UIKit views which uses non-unspecified semanticContentAttribute. In that case app code cannot use .leading() and .trailing() and must consult view of layout direction and manually use .left and .right values.

mamaral commented 7 years ago

Hmm I'm considering adapting this change in with a larger change in a new major version that would involve breaking changes. I'd think we want to change left and right to leading and trailing, in order to better facilitate RTL.

mamaral commented 6 years ago

I have my own set of changes I've been working on to support this that is a bit more extensive, that I hope to get to finishing/merging soon. Thanks for the effort nonetheless.