-
Notifications
You must be signed in to change notification settings - Fork 34
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
Create ViewDistributionBuilder #117
Create ViewDistributionBuilder #117
Conversation
Example/ParalayoutSnapshotTests/ViewDistributionSnapshotTests.swift
Outdated
Show resolved
Hide resolved
public static func buildExpression(_ component: CGFloat) -> [ViewDistributionSpecifying] { | ||
return [ViewDistributionItem.fixed(component)] | ||
} | ||
public static func buildExpression(_ component: Double) -> [ViewDistributionSpecifying] { | ||
return [ViewDistributionItem.fixed(component)] | ||
} | ||
public static func buildExpression(_ component: Int) -> [ViewDistributionSpecifying] { | ||
return [ViewDistributionItem.fixed(CGFloat(component))] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three methods enable treating raw numbers as fixed positions in the build expression. So instead of 8.fixed
you could just write 8
.
Happy to delete these for explicit parity with existing APIs. Also happy to add this functionality to existing APIs if folk would like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I agree if we support unspecified numbers they should be fixed, but I think it would be better to keep it explicit. I could see it being very confusing to open a file and see
applyVerticalSubviewDistribution {
oneView
1
twoView
}
Not having this context, I'd probably assume that's a flexible spacer. For now I think probably best to keep it explicit.
public static func buildExpression(_ component: CGFloat) -> [ViewDistributionSpecifying] { | ||
return [ViewDistributionItem.fixed(component)] | ||
} | ||
public static func buildExpression(_ component: Double) -> [ViewDistributionSpecifying] { | ||
return [ViewDistributionItem.fixed(component)] | ||
} | ||
public static func buildExpression(_ component: Int) -> [ViewDistributionSpecifying] { | ||
return [ViewDistributionItem.fixed(CGFloat(component))] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 I agree if we support unspecified numbers they should be fixed, but I think it would be better to keep it explicit. I could see it being very confusing to open a file and see
applyVerticalSubviewDistribution {
oneView
1
twoView
}
Not having this context, I'd probably assume that's a flexible spacer. For now I think probably best to keep it explicit.
c5ba8b5
to
143dafe
Compare
@NickEntin wrote result builder tests you might enjoy, and removed more of the duplicative tests. Ready for a proper review (and CI run)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for adding this!
Resolves #116