Last active
August 29, 2015 14:21
-
-
Save nguyenhuy/ac755a421caab9a19340 to your computer and use it in GitHub Desktop.
ASDK's KittenNode with ComponentLayout. Original code: https://github.com/facebook/AsyncDisplayKit/blob/master/examples/Kittens/Sample/KittenNode.m#L127
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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 | |
} | |
}]]; | |
} |
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
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.