freshOS / Stevia

:leaves: Concise Autolayout code
https://freshos.github.io/SteviaDocs/
MIT License
3.38k stars 214 forks source link

Issue of leading(%) trailing (%) in 4.7.0 RTL support #128

Closed mineschan closed 5 years ago

mineschan commented 5 years ago

Firstly, thanks @s4cha a lot for the work on RTL support in 4.7.0 Able to use chainable api and visual formatting (|-10-label-|) in the RTL project I'm working on now!

However the leading trailing with SteviaPercentage is not working properly. This also happened when I try to support it in my fork.

s4cha commented 5 years ago

Hey @mineschan thank you so much for reporting this. Indeed the percent-based api is wrong with leading & trailing attributes at the moment. Turns out using multipliers with leading and trailing attributes doesn't allow us to reach our goal. Thankfully there is a way (there always is!). This is via UILayoutGuide. We can transparently introduce a UILayoutGuide with a percent-based width and then pin constraints on it.

// |-[layoutGuide(== x % width)-[view]

This has the advantage to work gracefully with RTL mode :)

UILayoutGuide is iOS 9.0 only so we'll have to raise our support (from iOS 8.0), but it's not a big deal since iOS 8.0 has been long dead and buried.

Going to update the release and let you know when you can try it out.

s4cha commented 5 years ago

@mineschan the release has been updated with the fix, let me know how this goes :)

https://github.com/freshOS/Stevia/releases/tag/4.7.1

mineschan commented 5 years ago

Thanks @s4cha !!

I tested with leading(%) and trailing(%) mix with leading(x) / trailing (x) / left(x) / right(x), all works perfectly!! You make my life so much easier :D

s4cha commented 5 years ago

@mineschan Very happy to help ๐Ÿ˜ƒ !!! Thanks a ton for your help and reactivity, this is very much appreciated ๐Ÿ™

mineschan commented 5 years ago

Youre welcome! Just, dont mind me that I brought you some coffee๐Ÿ˜Œ

s4cha commented 5 years ago

@mineschan Thank you so much for the donation ๐Ÿ˜. Have a fantastic Day !!!