Skip to content
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

Add Forbearance #358

Closed
wants to merge 7 commits into from
Closed

Add Forbearance #358

wants to merge 7 commits into from

Conversation

iStarEternal
Copy link

@iStarEternal iStarEternal commented Jul 5, 2016

It fix the issues #344
It's able to write elegant syntax: make.horizontal.hugging.priorityRequired() to replace the redundant syntax [view setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal].
Hope you like it.

@iStarEternal
Copy link
Author

Excuse me, I don't know how to add it to you example😋, Not found file "MASConstraintMaker+Forbearance.h"

@robertjpayne
Copy link
Member

@iStarEternal looks good, I'm on holiday until August so I'll try and merge it up then if that's ok with you.

@iStarEternal
Copy link
Author

iStarEternal commented Jul 6, 2016

@robertjpayne The Citizen have never been such a long holiday in China🙊🙊🙊

@iStarEternal
Copy link
Author

@robertjpayne
I'm add three method in NSArray+MASAdditions.
- (void)mas_distributeSudokuViewsWithFixedItemWidth:(CGFloat)fixedItemWidth fixedItemHeight:(CGFloat)fixedItemHeight warpCount:(NSInteger)warpCount topSpacing:(CGFloat)topSpacing bottomSpacing:(CGFloat)bottomSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
- (void)mas_distributeSudokuViewsWithFixedLineSpacing:(CGFloat)fixedLineSpacing fixedInteritemSpacing:(CGFloat)fixedInteritemSpacing warpCount:(NSInteger)warpCount topSpacing:(CGFloat)topSpacing bottomSpacing:(CGFloat)bottomSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
- (void)mas_distributeSudokuViewsWithFixedItemWidth:(CGFloat)fixedItemWidth fixedItemHeight:(CGFloat)fixedItemHeight fixedLineSpacing:(CGFloat)fixedLineSpacing fixedInteritemSpacing:(CGFloat)fixedInteritemSpacing warpCount:(NSInteger)warpCount topSpacing:(CGFloat)topSpacing bottomSpacing:(CGFloat)bottomSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing

Yes! It's Sudoku! Now, You just need to write a method that can layout Sudoku~~~

@iStarEternal
Copy link
Author

I want my outcome is used by people all over the world. 😄

@robertjpayne
Copy link
Member

@iStarEternal I've looked at this again, I think we've overthought this a lot and as per #88 I think there are some valid points about not including this API in the maker.

In saying that I do think that it's a bit annoying right now to set, even more so in Objective-C but I think the API should still come from the view itself rather than the constraint maker.

We really only need four properties:

  • Hugging vertical priority
  • Hugging horizontal priority
  • Compression Resistance vertical priority
  • Compression Resistance horizontal priority

I don't think we gain much by splitting the API up too much, we currently don't split margins into make.margins.left.equalTo(100) we instead do make.leftMargin.equalTo(100) so I also think we could easily just add dynamic properties like:

view.mas_contentHuggingVerticalPriority = 50.0

This simplifies the code a lot and reduces a ton of user errors that may crop up if someone tries something silly like make.horizontal.center.equalTo(100)

I know you've put a lot of work into this and I appreciate it, but I'm just mindful it adds an API that can result in a lot of undefined behaviour.

@iStarEternal
Copy link
Author

iStarEternal commented Aug 8, 2016

Very simple implementation, but this didn't realize I expected style unification.

Look at the NSArray+MASAdditions.m, I wrote two very good Sudoku layout
/**

  • 九宫格布局 固定ItemSize 固定ItemSpacing
  • 可由九宫格的内容控制SuperView的大小
  • 如果warpCount > self.count,该方法将会用空白的View填充到superview中
  • Sudoku Layout, has fixed item size, and fix item space
  • If warp count greater than self.count, It's fill empty view to superview
  • @param fixedItemWidth 固定宽度,如果设置成0,则表示自适应,If set it to zero, indicates the adaptive.
  • @param fixedItemHeight 固定高度,如果设置成0,则表示自适应,If set it to zero, indicates the adaptive.
  • @param fixedLineSpacing 行间距
  • @param fixedInteritemSpacing 列间距
  • @param warpCount 折行点
  • @param topSpacing 顶间距
  • @param bottomSpacing 底间距
  • @param leadSpacing 左间距
  • @param tailSpacing 右间距
  • @return 一般情况下会return self.copy 但是如果warpCount大于self.count,将会return一个填充过的数组,让你可以循环调用removeFromSuperview或者干一些其他的事情;
  • @return Normal will return to the [self copy], If warpCount bigger than [self count] , It will return a empty views filled array, you could enumerate [subview removeFromSuperview] or do other things;
    */
  • (NSArray *)mas_distributeSudokuViewsWithFixedItemWidth:(CGFloat)fixedItemWidth
    fixedItemHeight:(CGFloat)fixedItemHeight
    fixedLineSpacing:(CGFloat)fixedLineSpacing
    fixedInteritemSpacing:(CGFloat)fixedInteritemSpacing
    warpCount:(NSInteger)warpCount
    topSpacing:(CGFloat)topSpacing
    bottomSpacing:(CGFloat)bottomSpacing
    leadSpacing:(CGFloat)leadSpacing
    tailSpacing:(CGFloat)tailSpacing;

@robertjpayne
Copy link
Member

Closing this, feel free to open a new PR updated against my recommendations, Again mostly do not feel this API is appropriate in the maker API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants