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

Code Style #5

Open
dillidon opened this issue Feb 10, 2019 · 2 comments
Open

Code Style #5

dillidon opened this issue Feb 10, 2019 · 2 comments

Comments

@dillidon
Copy link

Hi,

Do you think it would be easier to write code like this:

// instead of
stackView.direction(.row).justifyContent(.spaceBetween).define { (stackView) in
   stackView.addItem(button1).shrink(1).aspectRatio(imageRatio)
   stackView.addItem(button2).marginLeft(10).shrink(1).aspectRatio(imageRatio)
   stackView.addItem(button3).marginLeft(10).shrink(1).aspectRatio(imageRatio)
   stackView.addItem(button4).marginLeft(10).shrink(1).aspectRatio(imageRatio)
}

// use this
stackView
   .direction(.row)
   .align(content: .center)
   .justify(content: .spaceBetween)
   .space(between: 10)
   
stackView.add(button1, button2, button3...)

// using
func add(_ subviews: UIView...) {
   subviews.forEach(addItem)
}

I do not know of such cases when it would be necessary to set margins between objects in a stack.

@lucdion
Copy link
Member

lucdion commented Feb 11, 2019

Hi, it could be an addition to the API.
It is often required to add spacing. Add top or bottom margin to items in a vertical stackview, or left and right margin in an horizontal statckviews.

@dillidon
Copy link
Author

I mean, set different margins between each objects in a stack)

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

No branches or pull requests

2 participants