New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live reload possible in some way? #35

Closed
olegam opened this Issue Dec 14, 2013 · 12 comments

Comments

Projects
None yet
5 participants
@olegam
Contributor

olegam commented Dec 14, 2013

After I started using classy.as for my styling I have quickly become addicted to the live reloading feature. I'm thinking if we could somehow do something similar for Masonry it would be awesome. I don't know how this would work thought.

It's mostly my constant numbers I would like to change live. Today I use DCIntrospect (https://github.com/lukaswelte/DCIntrospect-ARC) to adjust frames in the simulator and then I have to remember the new constant values and change them in the code afterwards.

Could we define all constants in a separate file that is watched by Masonry. So that changes in the constant file would be injected into the running simulator?

@cloudkite

This comment has been minimized.

Show comment
Hide comment
@cloudkite

cloudkite Dec 15, 2013

Member

If you are doing your layout in custom UIView subclasses then you can already take advantage of live reload by using Classy to set the constants of your constraints. You would need to turn your constants into properties on your view class.

custom UIView subclass:

@interface MYCustomView : UIView

@property (nonatomic, assign) UIOffset someOffset

@end
@implementation MYCustomView

- (void)setSomeOffset:(UIOffset)someOffset {
   _someOffset = someOffset
   [self setNeedsUpdateConstraints];
}

- (void)updateConstraints {
   [super updateConstraints];

   [self.someView mas_updateConstraints:^(MASConstraintMaker *make) {
      make.top.equalTo(self).with.offset(self.someOffset.vertical);
      make.left.equalTo(self).with.offset(self.someOffset.horizontal);
  }];
}

@end

in classy stylesheet

MYCustomView {
  someOffset 10, 5
}

Let me know how you get on 👍

Member

cloudkite commented Dec 15, 2013

If you are doing your layout in custom UIView subclasses then you can already take advantage of live reload by using Classy to set the constants of your constraints. You would need to turn your constants into properties on your view class.

custom UIView subclass:

@interface MYCustomView : UIView

@property (nonatomic, assign) UIOffset someOffset

@end
@implementation MYCustomView

- (void)setSomeOffset:(UIOffset)someOffset {
   _someOffset = someOffset
   [self setNeedsUpdateConstraints];
}

- (void)updateConstraints {
   [super updateConstraints];

   [self.someView mas_updateConstraints:^(MASConstraintMaker *make) {
      make.top.equalTo(self).with.offset(self.someOffset.vertical);
      make.left.equalTo(self).with.offset(self.someOffset.horizontal);
  }];
}

@end

in classy stylesheet

MYCustomView {
  someOffset 10, 5
}

Let me know how you get on 👍

@olegam

This comment has been minimized.

Show comment
Hide comment
@olegam

olegam Dec 15, 2013

Contributor

Thats a great idea! Would be nice to be able to use it everywhere (also when not doing subclasses) and without the boilerplate. Maybe I can do categories on UIView and UIControl to give them new margin and size properties that will be stored in an ascociated object and in the setter call -setNeedsDisplay on the super view. I'll try to explore this :)

Contributor

olegam commented Dec 15, 2013

Thats a great idea! Would be nice to be able to use it everywhere (also when not doing subclasses) and without the boilerplate. Maybe I can do categories on UIView and UIControl to give them new margin and size properties that will be stored in an ascociated object and in the setter call -setNeedsDisplay on the super view. I'll try to explore this :)

@olegam

This comment has been minimized.

Show comment
Hide comment
@olegam

olegam Dec 15, 2013

Contributor

Seems to work very well with a UIView category to specify optional size and margin that can be referenced from the mas_updateConstraints method. Check out my example here: https://github.com/olegam/LiveLayoutDemo

What do you think of this approach? Something that would be suitable to ship wit Classy?

Contributor

olegam commented Dec 15, 2013

Seems to work very well with a UIView category to specify optional size and margin that can be referenced from the mas_updateConstraints method. Check out my example here: https://github.com/olegam/LiveLayoutDemo

What do you think of this approach? Something that would be suitable to ship wit Classy?

@cloudkite

This comment has been minimized.

Show comment
Hide comment
@cloudkite

cloudkite Dec 16, 2013

Member

Glad it's working for you 👍
In terms of including it in classy I have some reservations, as I would rather not make classy and masonry dependent on each other for people who want to use one and not the other.

Also most of the time I would recommend using a custom UIView subclass so that you keep view logic out of your UIViewControllers.

Member

cloudkite commented Dec 16, 2013

Glad it's working for you 👍
In terms of including it in classy I have some reservations, as I would rather not make classy and masonry dependent on each other for people who want to use one and not the other.

Also most of the time I would recommend using a custom UIView subclass so that you keep view logic out of your UIViewControllers.

@olegam

This comment has been minimized.

Show comment
Hide comment
@olegam

olegam Dec 16, 2013

Contributor

Ok cool. And thanks again for the advice. I think I will then make a small pod with the category and write a blog post about the approach.

Contributor

olegam commented Dec 16, 2013

Ok cool. And thanks again for the advice. I think I will then make a small pod with the category and write a blog post about the approach.

@cloudkite

This comment has been minimized.

Show comment
Hide comment
@cloudkite

cloudkite Dec 16, 2013

Member

Sounds great! Looking forward to it :)

Member

cloudkite commented Dec 16, 2013

Sounds great! Looking forward to it :)

@lluisgerard

This comment has been minimized.

Show comment
Hide comment
@lluisgerard

lluisgerard Dec 16, 2013

Contributor

Looking forward too 👍 please, publish the link here, I love Masonry and is always nice to see how others use it!

Contributor

lluisgerard commented Dec 16, 2013

Looking forward too 👍 please, publish the link here, I love Masonry and is always nice to see how others use it!

@olegam

This comment has been minimized.

Show comment
Hide comment
@cloudkite

This comment has been minimized.

Show comment
Hide comment
@cloudkite

cloudkite Dec 17, 2013

Member

Thanks @olegam!

Member

cloudkite commented Dec 17, 2013

Thanks @olegam!

@lluisgerard

This comment has been minimized.

Show comment
Hide comment
@lluisgerard

lluisgerard Dec 17, 2013

Contributor

Amazing, thanks @olegam! 👍

Contributor

lluisgerard commented Dec 17, 2013

Amazing, thanks @olegam! 👍

@vascoorey

This comment has been minimized.

Show comment
Hide comment
@vascoorey

vascoorey Dec 18, 2013

Contributor

Awesome one, cheers @olegam !

Contributor

vascoorey commented Dec 18, 2013

Awesome one, cheers @olegam !

@twlopes

This comment has been minimized.

Show comment
Hide comment
@twlopes

twlopes commented Dec 20, 2013

Very cool @olegam !

@cloudkite cloudkite closed this Dec 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment