Skip to content

Instantly share code, notes, and snippets.

@cesteban
Last active April 5, 2017 23:23
Show Gist options
  • Save cesteban/e5d265989ed319c0f83bfda3bffdcf8c to your computer and use it in GitHub Desktop.
Save cesteban/e5d265989ed319c0f83bfda3bffdcf8c to your computer and use it in GitHub Desktop.
Ideas for ASDKFluentExtensions in Swift
extension ASLayoutElement {
public func withOverlay(_ overlay: ASLayoutElement) -> ASOverlayLayoutSpec {
return ASOverlayLayoutSpec(child: self, overlay: overlay)
}
public func withBackgorund(_ background: ASLayoutElement) -> ASBackgroundLayoutSpec {
return ASBackgroundLayoutSpec(child: self, background: background)
}
public func withRatio(_ ratio: CGFloat) -> ASRatioLayoutSpec {
return ASRatioLayoutSpec(ratio: ratio, child: self)
}
public func withInset(_ insets: UIEdgeInsets) -> ASInsetLayoutSpec {
return ASInsetLayoutSpec(insets: insets, child: self)
}
public func withRelativePosition(horizontal: ASRelativeLayoutSpecPosition = .none, vertical: ASRelativeLayoutSpecPosition = .none, sizing: ASRelativeLayoutSpecSizingOption = []) -> ASRelativeLayoutSpec {
return ASRelativeLayoutSpec(horizontalPosition: horizontal, verticalPosition: vertical, sizingOption: sizing, child: self)
}
public func wrap() -> ASWrapperLayoutSpec {
return ASWrapperLayoutSpec(layoutElement: self)
}
public func center(centeringOptions: ASCenterLayoutSpecCenteringOptions = [], sizingOptions: ASCenterLayoutSpecSizingOptions = []) -> ASCenterLayoutSpec {
return ASCenterLayoutSpec(centeringOptions: centeringOptions, sizingOptions: sizingOptions, child: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment