robb / Cartography

A declarative Auto Layout DSL for Swift :iphone::triangular_ruler:
Other
7.34k stars 528 forks source link

Add UILayoutSupport support #203

Closed TimothyChilvers closed 8 years ago

TimothyChilvers commented 8 years ago

Hope you don't mind my taking a stab at this. It's based on the examples in https://github.com/robb/Cartography/issues/95 and admittedly it doesn't quite match the framework pattern, but it's here if you want it.

robb commented 8 years ago

Thanks for the pull request! 💖

Would you mind adding some tests that also exercise the new API?

CVertex commented 8 years ago

Where's this at? Would love to see this in my favourite AutoLayout library :)

TimothyChilvers commented 8 years ago

I've been using it for months now and it's been fine, I'd like to add the tests and change the names to match styles that have been discussed elsewhere…. But I haven't done it. I'll see if I can do that by the end of the week.

CVertex commented 8 years ago

great! Can't wait! :)

orta commented 8 years ago

@TimothyChilvers this looks good 👍 - it's worth trying to get this tested and merged

TimothyChilvers commented 8 years ago

All right, all right… I'll pick it up again now.

TimothyChilvers commented 8 years ago

Is my approach preferred over #212 ?

orta commented 8 years ago

@robb that opinion is on you I'm afraid ^

TimothyChilvers commented 8 years ago

I added tests, but I'm not happy with them. The reason being I can't make the UILayoutGuide of the view controller have a non-zero length just using UIKit components straight off. I only spent an hour or so fiddling with it, so I might have missed something. I have another branch which stubs the view controller and layout guide classes, but the compiler warnings for availability are a nightmare.

If the tests are adequate (In my mind they're not the greatest), feel free to merge. If someone wants to have a go at populating the layout guide with a length, also be my guest. I'll put some time aside on Monday if no further action has been taken.

TimothyChilvers commented 8 years ago

So…

Having tried subclassing UIViewController and giving custom UILayoutGuide subclasses to the guides and failed, and failing to populate the UIKit supplied top and bottom layoutGuide objects with properties, and finally with UILayoutSupport not being equatable / internal behaviour and constraint generation being unreliable, I'm calling this as the limit of what I can achieve with the tests.

orta commented 8 years ago

Alright, given the comprehensive docs / tests on this PR, I'm gonna merge it tomorrow unless I hear a good to not

orta commented 8 years ago

Hah - nice. OK, let's get this in.