Skip to content

Instantly share code, notes, and snippets.

@nguyenhuy
Last active August 29, 2015 14:21
Show Gist options
  • Save nguyenhuy/ac755a421caab9a19340 to your computer and use it in GitHub Desktop.
Save nguyenhuy/ac755a421caab9a19340 to your computer and use it in GitHub Desktop.
- (CKComponent *)layoutComponentThatFits:(CGSize)constrainedSize
{
return [CKInsetComponent
newWithInsets:UIEdgeInsetsMake(kOuterPadding, kOuterPadding, kOuterPadding, kOuterPadding)
component:
[CKStackLayoutComponent
newWithSize:{.maxWidth = constrainedSize.width, .maxHeight = constrainedSize.height}
style:{.direction = CKStackLayoutDirectionHorizontal, .spacing = kInnerPadding} // Change to CKStackLayoutDirectionVertical it will just work!!!
children:{
{
[ASNodeWrappingComponent newWithNode:_imageNode staticSize:CGSizeMake(kImageSize, kImageSize)]
},
{
[ASNodeWrappingComponent newWithNode:_textNode],
.flexShrink = true // Flexbox baby
}
}]];
}
@appleguy
Copy link

This is really cool! To make it more accessible to people, we should probably plan to fork the implementation and rename / refactor to be more consistent with ASDK patterns. Because Components have a very different mental model for development, using CK*Component objects is a bit confusing, even for a fairly experienced developer.

@nguyenhuy
Copy link
Author

yes, this is more like a showcase. The project still needs heavy refactoring. Let's move the discuss to FB group I guess, I didn't get notification here.

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