mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
[Debug] Remove not used code around visualizing layout specs (#2991)
* Remove not used code around visualizing layout specs * This is sad to see but let’s remove the LayoutSpecPlayground for now
This commit is contained in:
committed by
GitHub
parent
77f29a8b7b
commit
2dca7a0c8d
@@ -352,12 +352,6 @@
|
||||
DE7EF4F81DFF77720082B84A /* ASDisplayNode+FrameworkSubclasses.h in Headers */ = {isa = PBXBuildFile; fileRef = DE7EF4F71DFF77720082B84A /* ASDisplayNode+FrameworkSubclasses.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
DE84918D1C8FFF2B003D89E9 /* ASRunLoopQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 81EE384D1C8E94F000456208 /* ASRunLoopQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
DE84918E1C8FFF9F003D89E9 /* ASRunLoopQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 81EE384E1C8E94F000456208 /* ASRunLoopQueue.mm */; };
|
||||
DE89C1701DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.h in Headers */ = {isa = PBXBuildFile; fileRef = DE89C16A1DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
DE89C1731DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DE89C16B1DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.m */; };
|
||||
DE89C1741DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DE89C16C1DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
DE89C1771DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.m in Sources */ = {isa = PBXBuildFile; fileRef = DE89C16D1DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.m */; };
|
||||
DE89C1781DCEB9CC00D49D74 /* ASLayoutSpec+Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = DE89C16E1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
DE89C17B1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = DE89C16F1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.m */; };
|
||||
DE8BEAC21C2DF3FC00D57C12 /* ASDelegateProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = DE8BEABF1C2DF3FC00D57C12 /* ASDelegateProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
|
||||
DE8BEAC41C2DF3FC00D57C12 /* ASDelegateProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = DE8BEAC01C2DF3FC00D57C12 /* ASDelegateProxy.m */; };
|
||||
DEB8ED7C1DD003D300DBDE55 /* ASLayoutTransition.mm in Sources */ = {isa = PBXBuildFile; fileRef = E52405B21C8FEF03004DC8E7 /* ASLayoutTransition.mm */; };
|
||||
@@ -749,12 +743,6 @@
|
||||
DBDB83931C6E879900D0098C /* ASPagerFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPagerFlowLayout.m; sourceTree = "<group>"; };
|
||||
DE6EA3211C14000600183B10 /* ASDisplayNode+FrameworkPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASDisplayNode+FrameworkPrivate.h"; sourceTree = "<group>"; };
|
||||
DE7EF4F71DFF77720082B84A /* ASDisplayNode+FrameworkSubclasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASDisplayNode+FrameworkSubclasses.h"; sourceTree = "<group>"; };
|
||||
DE89C16A1DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutElementInspectorCell.h; sourceTree = "<group>"; };
|
||||
DE89C16B1DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASLayoutElementInspectorCell.m; sourceTree = "<group>"; };
|
||||
DE89C16C1DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutElementInspectorNode.h; sourceTree = "<group>"; };
|
||||
DE89C16D1DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASLayoutElementInspectorNode.m; sourceTree = "<group>"; };
|
||||
DE89C16E1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASLayoutSpec+Debug.h"; sourceTree = "<group>"; };
|
||||
DE89C16F1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ASLayoutSpec+Debug.m"; sourceTree = "<group>"; };
|
||||
DE8BEABF1C2DF3FC00D57C12 /* ASDelegateProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDelegateProxy.h; sourceTree = "<group>"; };
|
||||
DE8BEAC01C2DF3FC00D57C12 /* ASDelegateProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASDelegateProxy.m; sourceTree = "<group>"; };
|
||||
DEC146B41C37A16A004A0EE7 /* ASCollectionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASCollectionInternal.h; path = Details/ASCollectionInternal.h; sourceTree = "<group>"; };
|
||||
@@ -1356,12 +1344,6 @@
|
||||
DE89C1691DCEB9CC00D49D74 /* Debug */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DE89C16A1DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.h */,
|
||||
DE89C16B1DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.m */,
|
||||
DE89C16C1DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.h */,
|
||||
DE89C16D1DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.m */,
|
||||
DE89C16E1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.h */,
|
||||
DE89C16F1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.m */,
|
||||
764D83D21C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h */,
|
||||
764D83D31C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m */,
|
||||
);
|
||||
@@ -1449,7 +1431,6 @@
|
||||
698DFF471E36B7E9002891F1 /* ASLayoutSpecUtilities.h in Headers */,
|
||||
9C70F20D1CDBE9CB007D6C76 /* ASDefaultPlayButton.h in Headers */,
|
||||
DE7EF4F81DFF77720082B84A /* ASDisplayNode+FrameworkSubclasses.h in Headers */,
|
||||
DE89C1741DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.h in Headers */,
|
||||
254C6B7E1BF94DF4003EC431 /* ASTextKitTailTruncater.h in Headers */,
|
||||
B35062491B010EFD0018CF92 /* _ASCoreAnimationExtras.h in Headers */,
|
||||
68EE0DBE1C1B4ED300BA1B99 /* ASMainSerialQueue.h in Headers */,
|
||||
@@ -1501,7 +1482,6 @@
|
||||
690ED5991E36D118000627C0 /* ASImageNode+tvOS.h in Headers */,
|
||||
254C6B741BF94DF4003EC431 /* ASTextNodeWordKerner.h in Headers */,
|
||||
698DFF441E36B6C9002891F1 /* ASStackLayoutSpecUtilities.h in Headers */,
|
||||
DE89C1781DCEB9CC00D49D74 /* ASLayoutSpec+Debug.h in Headers */,
|
||||
CCF18FF41D2575E300DF5895 /* NSIndexSet+ASHelpers.h in Headers */,
|
||||
83A7D95C1D44548100BF333E /* ASWeakMap.h in Headers */,
|
||||
69708BA61D76386D005C3CF9 /* ASEqualityHashHelpers.h in Headers */,
|
||||
@@ -1511,7 +1491,6 @@
|
||||
254C6B7B1BF94DF4003EC431 /* ASTextKitRenderer+Positioning.h in Headers */,
|
||||
DE4843DC1C93EAC100A1F33B /* ASLayoutTransition.h in Headers */,
|
||||
CC57EAF81E3939450034C595 /* ASTableView+Undeprecated.h in Headers */,
|
||||
DE89C1701DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.h in Headers */,
|
||||
254C6B781BF94DF4003EC431 /* ASTextKitContext.h in Headers */,
|
||||
9CDC18CD1B910E12004965E2 /* ASLayoutElementPrivate.h in Headers */,
|
||||
B35062201B010EFD0018CF92 /* ASLayoutController.h in Headers */,
|
||||
@@ -1875,7 +1854,6 @@
|
||||
B350621C1B010EFD0018CF92 /* ASTableLayoutController.m in Sources */,
|
||||
B350621E1B010EFD0018CF92 /* ASHighlightOverlayLayer.mm in Sources */,
|
||||
9CC606651D24DF9E006581A0 /* NSIndexSet+ASHelpers.m in Sources */,
|
||||
DE89C17B1DCEB9CC00D49D74 /* ASLayoutSpec+Debug.m in Sources */,
|
||||
CC0F885F1E4280B800576FED /* _ASCollectionViewCell.m in Sources */,
|
||||
B35062541B010EFD0018CF92 /* ASImageNode+CGExtras.m in Sources */,
|
||||
6947B0C01E36B4E30007C478 /* ASStackUnpositionedLayout.mm in Sources */,
|
||||
@@ -1897,7 +1875,6 @@
|
||||
B35062071B010EFD0018CF92 /* ASNetworkImageNode.mm in Sources */,
|
||||
34EFC76D1B701CF100AD841F /* ASOverlayLayoutSpec.mm in Sources */,
|
||||
044285101BAA64EC00D16268 /* ASMultidimensionalArrayUtils.mm in Sources */,
|
||||
DE89C1731DCEB9CC00D49D74 /* ASLayoutElementInspectorCell.m in Sources */,
|
||||
B35062271B010EFD0018CF92 /* ASRangeController.mm in Sources */,
|
||||
0442850A1BAA63FE00D16268 /* ASBatchFetching.m in Sources */,
|
||||
68FC85E61CE29B9400EDD713 /* ASNavigationController.m in Sources */,
|
||||
@@ -1933,7 +1910,6 @@
|
||||
044284FD1BAA365100D16268 /* UICollectionViewLayout+ASConvenience.m in Sources */,
|
||||
CC0F885B1E42807F00576FED /* ASCollectionViewFlowLayoutInspector.m in Sources */,
|
||||
690ED5981E36D118000627C0 /* ASControlNode+tvOS.m in Sources */,
|
||||
DE89C1771DCEB9CC00D49D74 /* ASLayoutElementInspectorNode.m in Sources */,
|
||||
254C6B8A1BF94F8A003EC431 /* ASTextKitRenderer+TextChecking.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#import <AsyncDisplayKit/ASInternalHelpers.h>
|
||||
#import <AsyncDisplayKit/ASControlTargetAction.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
|
||||
#import <AsyncDisplayKit/ASLayoutElementInspectorNode.h>
|
||||
#import <AsyncDisplayKit/ASThread.h>
|
||||
|
||||
// UIControl allows dragging some distance outside of the control itself during
|
||||
@@ -465,22 +464,4 @@ CGRect _ASControlNodeGetExpandedBounds(ASControlNode *controlNode) {
|
||||
{
|
||||
return _debugHighlightOverlay;
|
||||
}
|
||||
|
||||
// methods for visualizing ASLayoutSpecs
|
||||
- (void)setHierarchyState:(ASHierarchyState)hierarchyState
|
||||
{
|
||||
[super setHierarchyState:hierarchyState];
|
||||
|
||||
if (self.shouldVisualizeLayoutSpecs) {
|
||||
[self addTarget:self action:@selector(inspectElement) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
} else {
|
||||
[self removeTarget:self action:@selector(inspectElement) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)inspectElement
|
||||
{
|
||||
[ASLayoutElementInspectorNode sharedInstance].layoutElementToEdit = self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -972,19 +972,11 @@ ASLayoutElementFinalLayoutElementDefault
|
||||
[self cancelLayoutTransition];
|
||||
|
||||
BOOL didCreateNewContext = NO;
|
||||
BOOL didOverrideExistingContext = NO;
|
||||
BOOL shouldVisualizeLayout = ASHierarchyStateIncludesVisualizeLayout(_hierarchyState);
|
||||
ASLayoutElementContext context = ASLayoutElementGetCurrentContext();
|
||||
if (ASLayoutElementContextIsNull(context)) {
|
||||
context = ASLayoutElementContextMake(ASLayoutElementContextDefaultTransitionID, shouldVisualizeLayout);
|
||||
context = ASLayoutElementContextMake(ASLayoutElementContextDefaultTransitionID);
|
||||
ASLayoutElementSetCurrentContext(context);
|
||||
didCreateNewContext = YES;
|
||||
} else {
|
||||
if (context.needsVisualizeNode != shouldVisualizeLayout) {
|
||||
context.needsVisualizeNode = shouldVisualizeLayout;
|
||||
ASLayoutElementSetCurrentContext(context);
|
||||
didOverrideExistingContext = YES;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out previous and pending layouts for layout transition
|
||||
@@ -1005,9 +997,6 @@ ASLayoutElementFinalLayoutElementDefault
|
||||
|
||||
if (didCreateNewContext) {
|
||||
ASLayoutElementClearCurrentContext();
|
||||
} else if (didOverrideExistingContext) {
|
||||
context.needsVisualizeNode = !context.needsVisualizeNode;
|
||||
ASLayoutElementSetCurrentContext(context);
|
||||
}
|
||||
|
||||
// If our new layout's desired size for self doesn't match current size, ask our parent to update it.
|
||||
@@ -1125,11 +1114,7 @@ ASLayoutElementFinalLayoutElementDefault
|
||||
}
|
||||
#endif
|
||||
|
||||
if (_shouldCacheLayoutSpec) {
|
||||
_layoutSpec = layoutSpec;
|
||||
} else {
|
||||
ASDisplayNodeAssert(layoutSpec.isMutable, @"Node %@ returned layout spec %@ that has already been used. Layout specs should always be regenerated.", self, layoutSpec);
|
||||
}
|
||||
|
||||
layoutSpec.isMutable = NO;
|
||||
}
|
||||
@@ -1183,9 +1168,7 @@ ASLayoutElementFinalLayoutElementDefault
|
||||
|
||||
BOOL measureLayoutSpec = _measurementOptions & ASDisplayNodePerformanceMeasurementOptionLayoutSpec;
|
||||
|
||||
if (_shouldCacheLayoutSpec && _layoutSpec != nil) {
|
||||
return _layoutSpec;
|
||||
} else if (_layoutSpecBlock != NULL) {
|
||||
if (_layoutSpecBlock != NULL) {
|
||||
return ({
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
ASDN::SumScopeTimer t(_layoutSpecTotalTime, measureLayoutSpec);
|
||||
@@ -1418,8 +1401,7 @@ ASLayoutElementFinalLayoutElementDefault
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
|
||||
BOOL shouldVisualizeLayout = ASHierarchyStateIncludesVisualizeLayout(_hierarchyState);
|
||||
ASLayoutElementSetCurrentContext(ASLayoutElementContextMake(transitionID, shouldVisualizeLayout));
|
||||
ASLayoutElementSetCurrentContext(ASLayoutElementContextMake(transitionID));
|
||||
|
||||
BOOL automaticallyManagesSubnodesDisabled = (self.automaticallyManagesSubnodes == NO);
|
||||
self.automaticallyManagesSubnodes = YES; // Temporary flag for 1.9.x
|
||||
@@ -4004,44 +3986,6 @@ ASLayoutElementStyleExtensibilityForwarding
|
||||
return string;
|
||||
}
|
||||
|
||||
#pragma mark - ASDisplayNode (Visualization)
|
||||
|
||||
- (void)setShouldVisualizeLayoutSpecs:(BOOL)shouldVisualizeLayoutSpecs
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
if (shouldVisualizeLayoutSpecs != [self shouldVisualizeLayoutSpecs]) {
|
||||
if (shouldVisualizeLayoutSpecs) {
|
||||
[self enterHierarchyState:ASHierarchyStateVisualizeLayout];
|
||||
} else {
|
||||
[self exitHierarchyState:ASHierarchyStateVisualizeLayout];
|
||||
}
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldVisualizeLayoutSpecs
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
return ASHierarchyStateIncludesVisualizeLayout(_hierarchyState);
|
||||
}
|
||||
|
||||
- (void)setShouldCacheLayoutSpec:(BOOL)shouldCacheLayoutSpec
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
if (_shouldCacheLayoutSpec != shouldCacheLayoutSpec) {
|
||||
_shouldCacheLayoutSpec = shouldCacheLayoutSpec;
|
||||
if (_shouldCacheLayoutSpec == NO) {
|
||||
_layoutSpec = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldCacheLayoutSpec
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
return _shouldCacheLayoutSpec;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - ASDisplayNode UIKit / CA Categories
|
||||
|
||||
@@ -17,12 +17,6 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface ASDisplayNode (Visualization)
|
||||
@property (nonatomic, assign) BOOL shouldVisualizeLayoutSpecs;
|
||||
@property (nonatomic, assign) BOOL shouldCacheLayoutSpec;
|
||||
|
||||
@end
|
||||
|
||||
@interface ASImageNode (Debugging)
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// ASLayoutElementInspectorCell.h
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Hannah Troisi on 3/27/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/ASCellNode.h>
|
||||
|
||||
typedef NS_ENUM(NSInteger, ASLayoutElementPropertyType) {
|
||||
ASLayoutElementPropertyFlexGrow = 0,
|
||||
ASLayoutElementPropertyFlexShrink,
|
||||
ASLayoutElementPropertyAlignSelf,
|
||||
ASLayoutElementPropertyFlexBasis,
|
||||
ASLayoutElementPropertySpacingBefore,
|
||||
ASLayoutElementPropertySpacingAfter,
|
||||
ASLayoutElementPropertyAscender,
|
||||
ASLayoutElementPropertyDescender,
|
||||
ASLayoutElementPropertyCount
|
||||
};
|
||||
|
||||
@interface ASLayoutElementInspectorCell : ASCellNode
|
||||
|
||||
- (instancetype)initWithProperty:(ASLayoutElementPropertyType)property layoutElementToEdit:(id<ASLayoutElement>)layoutable NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,569 +0,0 @@
|
||||
//
|
||||
// ASLayoutElementInspectorCell.m
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Hannah Troisi on 3/27/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/ASLayoutElementInspectorCell.h>
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||
|
||||
typedef NS_ENUM(NSInteger, CellDataType) {
|
||||
CellDataTypeBool,
|
||||
CellDataTypeFloat,
|
||||
};
|
||||
|
||||
__weak static ASLayoutElementInspectorCell *__currentlyOpenedCell = nil;
|
||||
|
||||
@protocol InspectorCellEditingBubbleProtocol <NSObject>
|
||||
- (void)valueChangedToIndex:(NSUInteger)index;
|
||||
@end
|
||||
|
||||
@interface ASLayoutElementInspectorCellEditingBubble : ASDisplayNode
|
||||
@property (nonatomic, strong, readwrite) id<InspectorCellEditingBubbleProtocol> delegate;
|
||||
- (instancetype)initWithEnumOptions:(BOOL)yes enumStrings:(NSArray<NSString *> *)options currentOptionIndex:(NSUInteger)currentOption;
|
||||
- (instancetype)initWithSliderMinValue:(CGFloat)min maxValue:(CGFloat)max currentValue:(CGFloat)current
|
||||
;@end
|
||||
|
||||
@interface ASLayoutElementInspectorCell () <InspectorCellEditingBubbleProtocol>
|
||||
@end
|
||||
|
||||
@implementation ASLayoutElementInspectorCell
|
||||
{
|
||||
ASLayoutElementPropertyType _propertyType;
|
||||
CellDataType _dataType;
|
||||
id<ASLayoutElement> _layoutElementToEdit;
|
||||
|
||||
ASButtonNode *_buttonNode;
|
||||
ASTextNode *_textNode;
|
||||
ASTextNode *_textNode2;
|
||||
|
||||
ASLayoutElementInspectorCellEditingBubble *_textBubble;
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
- (instancetype)initWithProperty:(ASLayoutElementPropertyType)property layoutElementToEdit:(id<ASLayoutElement>)layoutElement
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
|
||||
_propertyType = property;
|
||||
_dataType = [ASLayoutElementInspectorCell dataTypeForProperty:property];
|
||||
_layoutElementToEdit = layoutElement;
|
||||
|
||||
self.automaticallyManagesSubnodes = YES;
|
||||
|
||||
_buttonNode = [self makeBtnNodeWithTitle:[ASLayoutElementInspectorCell propertyStringForPropertyType:property]];
|
||||
[_buttonNode addTarget:self action:@selector(buttonTapped:) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
|
||||
_textNode = [[ASTextNode alloc] init];
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell propertyValueAttributedStringForProperty:property withLayoutElement:layoutElement];
|
||||
|
||||
[self updateButtonStateForProperty:property withLayoutElement:layoutElement];
|
||||
|
||||
_textNode2 = [[ASTextNode alloc] init];
|
||||
_textNode2.attributedText = [ASLayoutElementInspectorCell propertyValueDetailAttributedStringForProperty:property withLayoutElement:layoutElement];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)updateButtonStateForProperty:(ASLayoutElementPropertyType)property withLayoutElement:(id<ASLayoutElement>)layoutElement
|
||||
{
|
||||
if (property == ASLayoutElementPropertyFlexGrow) {
|
||||
_buttonNode.selected = layoutElement.style.flexGrow;
|
||||
}
|
||||
else if (property == ASLayoutElementPropertyFlexShrink) {
|
||||
_buttonNode.selected = layoutElement.style.flexShrink;
|
||||
}
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
ASStackLayoutSpec *horizontalSpec = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
horizontalSpec.children = @[_buttonNode, _textNode];
|
||||
horizontalSpec.style.flexGrow = 1.0;
|
||||
horizontalSpec.alignItems = ASStackLayoutAlignItemsCenter;
|
||||
horizontalSpec.justifyContent = ASStackLayoutJustifyContentSpaceBetween;
|
||||
|
||||
ASLayoutSpec *childSpec;
|
||||
if (_textBubble) {
|
||||
ASStackLayoutSpec *verticalSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
verticalSpec.children = @[horizontalSpec, _textBubble];
|
||||
verticalSpec.spacing = 8;
|
||||
verticalSpec.style.flexGrow = 1.0;
|
||||
_textBubble.style.flexGrow = 1.0;
|
||||
childSpec = verticalSpec;
|
||||
} else {
|
||||
childSpec = horizontalSpec;
|
||||
}
|
||||
ASInsetLayoutSpec *insetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(2, 4, 2, 4) child:childSpec];
|
||||
insetSpec.style.flexGrow =1.0;
|
||||
|
||||
return insetSpec;
|
||||
}
|
||||
|
||||
+ (NSAttributedString *)propertyValueAttributedStringForProperty:(ASLayoutElementPropertyType)property withLayoutElement:(id<ASLayoutElement>)layoutElement
|
||||
{
|
||||
NSString *valueString;
|
||||
|
||||
switch (property) {
|
||||
case ASLayoutElementPropertyFlexGrow:
|
||||
valueString = layoutElement.style.flexGrow ? @"YES" : @"NO";
|
||||
break;
|
||||
case ASLayoutElementPropertyFlexShrink:
|
||||
valueString = layoutElement.style.flexShrink ? @"YES" : @"NO";
|
||||
break;
|
||||
case ASLayoutElementPropertyAlignSelf:
|
||||
valueString = [ASLayoutElementInspectorCell alignSelfEnumValueString:layoutElement.style.alignSelf];
|
||||
break;
|
||||
case ASLayoutElementPropertyFlexBasis:
|
||||
if (layoutElement.style.flexBasis.unit && layoutElement.style.flexBasis.value) { // ENUM TYPE
|
||||
valueString = [NSString stringWithFormat:@"%0.0f %@", layoutElement.style.flexBasis.value,
|
||||
[ASLayoutElementInspectorCell ASRelativeDimensionEnumString:layoutElement.style.alignSelf]];
|
||||
} else {
|
||||
valueString = @"0 pts";
|
||||
}
|
||||
break;
|
||||
case ASLayoutElementPropertySpacingBefore:
|
||||
valueString = [NSString stringWithFormat:@"%0.0f", layoutElement.style.spacingBefore];
|
||||
break;
|
||||
case ASLayoutElementPropertySpacingAfter:
|
||||
valueString = [NSString stringWithFormat:@"%0.0f", layoutElement.style.spacingAfter];
|
||||
break;
|
||||
case ASLayoutElementPropertyAscender:
|
||||
valueString = [NSString stringWithFormat:@"%0.0f", layoutElement.style.ascender];
|
||||
break;
|
||||
case ASLayoutElementPropertyDescender:
|
||||
valueString = [NSString stringWithFormat:@"%0.0f", layoutElement.style.descender];
|
||||
break;
|
||||
default:
|
||||
valueString = @"?";
|
||||
break;
|
||||
}
|
||||
return [ASLayoutElementInspectorCell attributedStringFromString:valueString];
|
||||
}
|
||||
|
||||
+ (NSAttributedString *)propertyValueDetailAttributedStringForProperty:(ASLayoutElementPropertyType)property withLayoutElement:(id<ASLayoutElement>)layoutElement
|
||||
{
|
||||
NSString *valueString;
|
||||
|
||||
switch (property) {
|
||||
case ASLayoutElementPropertyFlexGrow:
|
||||
case ASLayoutElementPropertyFlexShrink:
|
||||
case ASLayoutElementPropertyAlignSelf:
|
||||
case ASLayoutElementPropertyFlexBasis:
|
||||
case ASLayoutElementPropertySpacingBefore:
|
||||
case ASLayoutElementPropertySpacingAfter:
|
||||
case ASLayoutElementPropertyAscender:
|
||||
case ASLayoutElementPropertyDescender:
|
||||
default:
|
||||
return nil;
|
||||
}
|
||||
return [ASLayoutElementInspectorCell attributedStringFromString:valueString];
|
||||
}
|
||||
|
||||
- (void)endEditingValue
|
||||
{
|
||||
_textBubble = nil;
|
||||
__currentlyOpenedCell = nil;
|
||||
_buttonNode.selected = NO;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)beginEditingValue
|
||||
{
|
||||
_textBubble.delegate = self;
|
||||
__currentlyOpenedCell = self;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)valueChangedToIndex:(NSUInteger)index
|
||||
{
|
||||
switch (_propertyType) {
|
||||
|
||||
case ASLayoutElementPropertyAlignSelf:
|
||||
_layoutElementToEdit.style.alignSelf = (ASStackLayoutAlignSelf)index;
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[ASLayoutElementInspectorCell alignSelfEnumValueString:index]];
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertySpacingBefore:
|
||||
_layoutElementToEdit.style.spacingBefore = (CGFloat)index;
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[NSString stringWithFormat:@"%0.0f", _layoutElementToEdit.style.spacingBefore]];
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertySpacingAfter:
|
||||
_layoutElementToEdit.style.spacingAfter = (CGFloat)index;
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[NSString stringWithFormat:@"%0.0f", _layoutElementToEdit.style.spacingAfter]];
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertyAscender:
|
||||
_layoutElementToEdit.style.ascender = (CGFloat)index;
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[NSString stringWithFormat:@"%0.0f", _layoutElementToEdit.style.ascender]];
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertyDescender:
|
||||
_layoutElementToEdit.style.descender = (CGFloat)index;
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[NSString stringWithFormat:@"%0.0f", _layoutElementToEdit.style.descender]];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
#pragma mark - gesture handling
|
||||
|
||||
- (void)buttonTapped:(ASButtonNode *)sender
|
||||
{
|
||||
BOOL selfIsEditing = (self == __currentlyOpenedCell);
|
||||
[__currentlyOpenedCell endEditingValue];
|
||||
if (selfIsEditing) {
|
||||
sender.selected = NO;
|
||||
return;
|
||||
}
|
||||
|
||||
// NSUInteger currentAlignSelfValue;
|
||||
// NSUInteger nextAlignSelfValue;
|
||||
// CGFloat newValue;
|
||||
|
||||
sender.selected = !sender.selected;
|
||||
switch (_propertyType) {
|
||||
|
||||
case ASLayoutElementPropertyFlexGrow:
|
||||
_layoutElementToEdit.style.flexGrow = sender.isSelected ? 1.0 : 0.0;
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:sender.selected ? @"YES" : @"NO"];
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertyFlexShrink:
|
||||
_layoutElementToEdit.style.flexShrink = sender.isSelected ? 1.0 : 0.0;
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:sender.selected ? @"YES" : @"NO"];
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertyAlignSelf:
|
||||
_textBubble = [[ASLayoutElementInspectorCellEditingBubble alloc] initWithEnumOptions:YES
|
||||
enumStrings:[ASLayoutElementInspectorCell alignSelfEnumStringArray]
|
||||
currentOptionIndex:_layoutElementToEdit.style.alignSelf];
|
||||
|
||||
[self beginEditingValue];
|
||||
// if ([self layoutSpec]) {
|
||||
// currentAlignSelfValue = [[self layoutSpec] alignSelf];
|
||||
// nextAlignSelfValue = (currentAlignSelfValue + 1 <= ASStackLayoutAlignSelfStretch) ? currentAlignSelfValue + 1 : 0;
|
||||
// [[self layoutSpec] setAlignSelf:nextAlignSelfValue];
|
||||
//
|
||||
// } else if ([self node]) {
|
||||
// currentAlignSelfValue = [[self node] alignSelf];
|
||||
// nextAlignSelfValue = (currentAlignSelfValue + 1 <= ASStackLayoutAlignSelfStretch) ? currentAlignSelfValue + 1 : 0;
|
||||
// [[self node] setAlignSelf:nextAlignSelfValue];
|
||||
// }
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertySpacingBefore:
|
||||
_textBubble = [[ASLayoutElementInspectorCellEditingBubble alloc] initWithSliderMinValue:0 maxValue:100 currentValue:_layoutElementToEdit.style.spacingBefore];
|
||||
[self beginEditingValue];
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[NSString stringWithFormat:@"%0.0f", _layoutElementToEdit.style.spacingBefore]];
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertySpacingAfter:
|
||||
_textBubble = [[ASLayoutElementInspectorCellEditingBubble alloc] initWithSliderMinValue:0 maxValue:100 currentValue:_layoutElementToEdit.style.spacingAfter];
|
||||
[self beginEditingValue];
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[NSString stringWithFormat:@"%0.0f", _layoutElementToEdit.style.spacingAfter]];
|
||||
break;
|
||||
|
||||
|
||||
case ASLayoutElementPropertyAscender:
|
||||
_textBubble = [[ASLayoutElementInspectorCellEditingBubble alloc] initWithSliderMinValue:0 maxValue:100 currentValue:_layoutElementToEdit.style.ascender];
|
||||
[self beginEditingValue];
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[NSString stringWithFormat:@"%0.0f", _layoutElementToEdit.style.ascender]];
|
||||
break;
|
||||
|
||||
case ASLayoutElementPropertyDescender:
|
||||
_textBubble = [[ASLayoutElementInspectorCellEditingBubble alloc] initWithSliderMinValue:0 maxValue:100 currentValue:_layoutElementToEdit.style.descender];
|
||||
[self beginEditingValue];
|
||||
_textNode.attributedText = [ASLayoutElementInspectorCell attributedStringFromString:[NSString stringWithFormat:@"%0.0f", _layoutElementToEdit.style.descender]];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
#pragma mark - cast layoutElementToEdit
|
||||
|
||||
- (ASDisplayNode *)node
|
||||
{
|
||||
if (_layoutElementToEdit.layoutElementType == ASLayoutElementTypeDisplayNode) {
|
||||
return (ASDisplayNode *)_layoutElementToEdit;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpec
|
||||
{
|
||||
if (_layoutElementToEdit.layoutElementType == ASLayoutElementTypeLayoutSpec) {
|
||||
return (ASLayoutSpec *)_layoutElementToEdit;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - data / property type helper methods
|
||||
|
||||
+ (CellDataType)dataTypeForProperty:(ASLayoutElementPropertyType)property
|
||||
{
|
||||
switch (property) {
|
||||
|
||||
case ASLayoutElementPropertyFlexGrow:
|
||||
case ASLayoutElementPropertyFlexShrink:
|
||||
return CellDataTypeBool;
|
||||
|
||||
case ASLayoutElementPropertySpacingBefore:
|
||||
case ASLayoutElementPropertySpacingAfter:
|
||||
case ASLayoutElementPropertyAscender:
|
||||
case ASLayoutElementPropertyDescender:
|
||||
return CellDataTypeFloat;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return CellDataTypeBool;
|
||||
}
|
||||
|
||||
+ (NSString *)propertyStringForPropertyType:(ASLayoutElementPropertyType)property
|
||||
{
|
||||
NSString *string;
|
||||
switch (property) {
|
||||
case ASLayoutElementPropertyFlexGrow:
|
||||
string = @"FlexGrow";
|
||||
break;
|
||||
case ASLayoutElementPropertyFlexShrink:
|
||||
string = @"FlexShrink";
|
||||
break;
|
||||
case ASLayoutElementPropertyAlignSelf:
|
||||
string = @"AlignSelf";
|
||||
break;
|
||||
case ASLayoutElementPropertyFlexBasis:
|
||||
string = @"FlexBasis";
|
||||
break;
|
||||
case ASLayoutElementPropertySpacingBefore:
|
||||
string = @"SpacingBefore";
|
||||
break;
|
||||
case ASLayoutElementPropertySpacingAfter:
|
||||
string = @"SpacingAfter";
|
||||
break;
|
||||
case ASLayoutElementPropertyAscender:
|
||||
string = @"Ascender";
|
||||
break;
|
||||
case ASLayoutElementPropertyDescender:
|
||||
string = @"Descender";
|
||||
break;
|
||||
default:
|
||||
string = @"Unknown";
|
||||
break;
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)alignSelfTypeNames
|
||||
{
|
||||
return @{@(ASStackLayoutAlignSelfAuto) : @"Auto",
|
||||
@(ASStackLayoutAlignSelfStart) : @"Start",
|
||||
@(ASStackLayoutAlignSelfEnd) : @"End",
|
||||
@(ASStackLayoutAlignSelfCenter) : @"Center",
|
||||
@(ASStackLayoutAlignSelfStretch) : @"Stretch"};
|
||||
}
|
||||
|
||||
+ (NSString *)alignSelfEnumValueString:(NSUInteger)type
|
||||
{
|
||||
return [[self class] alignSelfTypeNames][@(type)];
|
||||
}
|
||||
|
||||
+ (NSArray <NSString *> *)alignSelfEnumStringArray
|
||||
{
|
||||
return @[@"ASStackLayoutAlignSelfAuto",
|
||||
@"ASStackLayoutAlignSelfStart",
|
||||
@"ASStackLayoutAlignSelfEnd",
|
||||
@"ASStackLayoutAlignSelfCenter",
|
||||
@"ASStackLayoutAlignSelfStretch"];
|
||||
}
|
||||
|
||||
+ (NSDictionary *)ASRelativeDimensionTypeNames
|
||||
{
|
||||
return @{@(ASDimensionUnitPoints) : @"pts",
|
||||
@(ASDimensionUnitFraction) : @"%"};
|
||||
}
|
||||
|
||||
+ (NSString *)ASRelativeDimensionEnumString:(NSUInteger)type
|
||||
{
|
||||
return [[self class] ASRelativeDimensionTypeNames][@(type)];
|
||||
}
|
||||
|
||||
#pragma mark - formatting helper methods
|
||||
|
||||
+ (NSAttributedString *)attributedStringFromString:(NSString *)string
|
||||
{
|
||||
return [ASLayoutElementInspectorCell attributedStringFromString:string withTextColor:[UIColor whiteColor]];
|
||||
}
|
||||
|
||||
+ (NSAttributedString *)attributedStringFromString:(NSString *)string withTextColor:(nullable UIColor *)color
|
||||
{
|
||||
NSDictionary *attributes = @{NSForegroundColorAttributeName : color,
|
||||
NSFontAttributeName : [UIFont fontWithName:@"Menlo-Regular" size:12]};
|
||||
|
||||
return [[NSAttributedString alloc] initWithString:string attributes:attributes];
|
||||
}
|
||||
|
||||
- (ASButtonNode *)makeBtnNodeWithTitle:(NSString *)title
|
||||
{
|
||||
UIColor *orangeColor = [UIColor colorWithRed:255/255.0 green:181/255.0 blue:68/255.0 alpha:1];
|
||||
UIImage *orangeStretchBtnImg = [ASLayoutElementInspectorCell imageForButtonWithBackgroundColor:orangeColor
|
||||
borderColor:[UIColor whiteColor]
|
||||
borderWidth:3];
|
||||
UIImage *greyStretchBtnImg = [ASLayoutElementInspectorCell imageForButtonWithBackgroundColor:[UIColor darkGrayColor]
|
||||
borderColor:[UIColor lightGrayColor]
|
||||
borderWidth:3];
|
||||
UIImage *clearStretchBtnImg = [ASLayoutElementInspectorCell imageForButtonWithBackgroundColor:[UIColor clearColor]
|
||||
borderColor:[UIColor whiteColor]
|
||||
borderWidth:3];
|
||||
ASButtonNode *btn = [[ASButtonNode alloc] init];
|
||||
btn.contentEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
|
||||
[btn setAttributedTitle:[ASLayoutElementInspectorCell attributedStringFromString:title] forState:UIControlStateNormal];
|
||||
[btn setAttributedTitle:[ASLayoutElementInspectorCell attributedStringFromString:title withTextColor:[UIColor lightGrayColor]] forState:UIControlStateDisabled];
|
||||
[btn setBackgroundImage:clearStretchBtnImg forState:UIControlStateNormal];
|
||||
[btn setBackgroundImage:orangeStretchBtnImg forState:UIControlStateSelected];
|
||||
[btn setBackgroundImage:greyStretchBtnImg forState:UIControlStateDisabled];
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
#define CORNER_RADIUS 3
|
||||
+ (UIImage *)imageForButtonWithBackgroundColor:(UIColor *)backgroundColor borderColor:(UIColor *)borderColor borderWidth:(CGFloat)width
|
||||
{
|
||||
CGSize unstretchedSize = CGSizeMake(2 * CORNER_RADIUS + 1, 2 * CORNER_RADIUS + 1);
|
||||
CGRect rect = (CGRect) {CGPointZero, unstretchedSize};
|
||||
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:CORNER_RADIUS];
|
||||
|
||||
// create a graphics context for the following status button
|
||||
UIGraphicsBeginImageContextWithOptions(unstretchedSize, NO, 0);
|
||||
|
||||
[path addClip];
|
||||
[backgroundColor setFill];
|
||||
[path fill];
|
||||
|
||||
path.lineWidth = width;
|
||||
[borderColor setStroke];
|
||||
[path stroke];
|
||||
|
||||
UIImage *btnImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
return [btnImage stretchableImageWithLeftCapWidth:CORNER_RADIUS topCapHeight:CORNER_RADIUS];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@implementation ASLayoutElementInspectorCellEditingBubble
|
||||
{
|
||||
NSMutableArray<ASButtonNode *> *_textNodes;
|
||||
ASDisplayNode *_slider;
|
||||
}
|
||||
|
||||
- (instancetype)initWithEnumOptions:(BOOL)yes enumStrings:(NSArray<NSString *> *)options currentOptionIndex:(NSUInteger)currentOption
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.automaticallyManagesSubnodes = YES;
|
||||
self.backgroundColor = [UIColor colorWithRed:255/255.0 green:181/255.0 blue:68/255.0 alpha:1];
|
||||
|
||||
_textNodes = [[NSMutableArray alloc] init];
|
||||
int index = 0;
|
||||
for (NSString *optionStr in options) {
|
||||
ASButtonNode *btn = [[ASButtonNode alloc] init];
|
||||
[btn setAttributedTitle:[ASLayoutElementInspectorCell attributedStringFromString:optionStr] forState:UIControlStateNormal];
|
||||
[btn setAttributedTitle:[ASLayoutElementInspectorCell attributedStringFromString:optionStr withTextColor:[UIColor redColor]]
|
||||
forState:UIControlStateSelected];
|
||||
[btn addTarget:self action:@selector(enumOptionSelected:) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
btn.selected = (index == currentOption) ? YES : NO;
|
||||
[_textNodes addObject:btn];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithSliderMinValue:(CGFloat)min maxValue:(CGFloat)max currentValue:(CGFloat)current
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.userInteractionEnabled = YES;
|
||||
self.automaticallyManagesSubnodes = YES;
|
||||
self.backgroundColor = [UIColor colorWithRed:255/255.0 green:181/255.0 blue:68/255.0 alpha:1];
|
||||
|
||||
__weak id weakSelf = self;
|
||||
_slider = [[ASDisplayNode alloc] initWithViewBlock:^UIView * _Nonnull{
|
||||
UISlider *slider = [[UISlider alloc] init];
|
||||
slider.minimumValue = min;
|
||||
slider.maximumValue = max;
|
||||
slider.value = current;
|
||||
[slider addTarget:weakSelf action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
return slider;
|
||||
}];
|
||||
_slider.userInteractionEnabled = YES;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_slider.style.preferredSize = CGSizeMake(constrainedSize.max.width, 25);
|
||||
|
||||
NSMutableArray *children = [[NSMutableArray alloc] init];
|
||||
if (_textNodes) {
|
||||
ASStackLayoutSpec *textStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
textStack.children = _textNodes;
|
||||
textStack.spacing = 2;
|
||||
[children addObject:textStack];
|
||||
}
|
||||
if (_slider) {
|
||||
_slider.style.flexGrow = 1.0;
|
||||
[children addObject:_slider];
|
||||
}
|
||||
|
||||
ASStackLayoutSpec *verticalStackSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
verticalStackSpec.children = children;
|
||||
verticalStackSpec.spacing = 2;
|
||||
verticalStackSpec.style.flexGrow = 1.0;
|
||||
verticalStackSpec.style.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||
|
||||
ASInsetLayoutSpec *insetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(8, 8, 8, 8) child:verticalStackSpec];
|
||||
|
||||
return insetSpec;
|
||||
}
|
||||
|
||||
#pragma mark - gesture handling
|
||||
- (void)enumOptionSelected:(ASButtonNode *)sender
|
||||
{
|
||||
sender.selected = !sender.selected;
|
||||
for (ASButtonNode *node in _textNodes) {
|
||||
if (node != sender) {
|
||||
node.selected = NO;
|
||||
}
|
||||
}
|
||||
[self.delegate valueChangedToIndex:[_textNodes indexOfObject:sender]];
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)sliderValueChanged:(UISlider *)sender
|
||||
{
|
||||
[self.delegate valueChangedToIndex:roundf(sender.value)];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
//
|
||||
// ASLayoutElementInspectorNode.h
|
||||
// Sample
|
||||
//
|
||||
// Created by Hannah Troisi on 3/19/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode.h>
|
||||
|
||||
@protocol ASLayoutElement;
|
||||
|
||||
@protocol ASLayoutElementInspectorNodeDelegate <NSObject>
|
||||
|
||||
- (void)toggleVisualization:(BOOL)toggle;
|
||||
|
||||
@end
|
||||
|
||||
@interface ASLayoutElementInspectorNode : ASDisplayNode
|
||||
|
||||
@property (nonatomic, strong) id<ASLayoutElement> layoutElementToEdit;
|
||||
@property (nonatomic, strong) id<ASLayoutElementInspectorNodeDelegate> delegate;
|
||||
@property (nonatomic, assign) CGFloat vizNodeInsetSize;
|
||||
|
||||
+ (instancetype)sharedInstance;
|
||||
|
||||
@end
|
||||
@@ -1,408 +0,0 @@
|
||||
//
|
||||
// ASLayoutElementInspectorNode.m
|
||||
// Sample
|
||||
//
|
||||
// Created by Hannah Troisi on 3/19/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/ASLayoutElementInspectorNode.h>
|
||||
#import <AsyncDisplayKit/ASLayoutElementInspectorCell.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode+Beta.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
|
||||
#import <AsyncDisplayKit/ASLayoutSpec+Debug.h>
|
||||
#import <AsyncDisplayKit/ASTableNode.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode.h>
|
||||
|
||||
@interface ASLayoutElementInspectorNode () <ASTableDelegate, ASTableDataSource>
|
||||
@end
|
||||
|
||||
@implementation ASLayoutElementInspectorNode
|
||||
{
|
||||
ASTableNode *_tableNode;
|
||||
}
|
||||
|
||||
#pragma mark - class methods
|
||||
+ (instancetype)sharedInstance
|
||||
{
|
||||
static ASLayoutElementInspectorNode *__inspector = nil;
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
__inspector = [[ASLayoutElementInspectorNode alloc] init];
|
||||
});
|
||||
|
||||
return __inspector;
|
||||
}
|
||||
|
||||
#pragma mark - lifecycle
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
|
||||
_tableNode = [[ASTableNode alloc] init];
|
||||
_tableNode.delegate = self;
|
||||
_tableNode.dataSource = self;
|
||||
|
||||
[self addSubnode:_tableNode]; // required because of manual layout
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)didLoad
|
||||
{
|
||||
[super didLoad];
|
||||
_tableNode.view.backgroundColor = [UIColor colorWithRed:40/255.0 green:43/255.0 blue:53/255.0 alpha:1];
|
||||
_tableNode.view.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_tableNode.view.allowsSelection = NO;
|
||||
_tableNode.view.sectionHeaderHeight = 40;
|
||||
}
|
||||
|
||||
- (void)layout
|
||||
{
|
||||
[super layout];
|
||||
_tableNode.frame = self.bounds;
|
||||
}
|
||||
|
||||
#pragma mark - intstance methods
|
||||
- (void)setLayoutElementToEdit:(id<ASLayoutElement>)layoutElementToEdit
|
||||
{
|
||||
if (_layoutElementToEdit != layoutElementToEdit) {
|
||||
_layoutElementToEdit = layoutElementToEdit;
|
||||
}
|
||||
[_tableNode reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - ASTableDataSource
|
||||
|
||||
- (ASCellNode *)tableView:(ASTableView *)tableView nodeForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == 0) {
|
||||
NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor colorWithRed:255/255.0 green:181/255.0 blue:68/255.0 alpha:1],
|
||||
NSFontAttributeName : [UIFont fontWithName:@"Menlo-Regular" size:12]};
|
||||
ASTextCellNode *textCell = [[ASTextCellNode alloc] initWithAttributes:attributes insets:UIEdgeInsetsMake(0, 4, 0, 0)];
|
||||
textCell.text = [_layoutElementToEdit description];
|
||||
return textCell;
|
||||
} else {
|
||||
return [[ASLayoutElementInspectorCell alloc] initWithProperty:(ASLayoutElementPropertyType)indexPath.row layoutElementToEdit:_layoutElementToEdit];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return ASLayoutElementPropertyCount;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UILabel *headerTitle = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
|
||||
NSString *title;
|
||||
if (section == 0) {
|
||||
title = @"<Layoutable> Item";
|
||||
} else {
|
||||
title = @"<Layoutable> Properties";
|
||||
}
|
||||
|
||||
NSDictionary *attributes = @{NSForegroundColorAttributeName : [UIColor whiteColor],
|
||||
NSFontAttributeName : [UIFont fontWithName:@"Menlo-Bold" size:12]};
|
||||
headerTitle.attributedText = [[NSAttributedString alloc] initWithString:title attributes:attributes];
|
||||
|
||||
return headerTitle;
|
||||
}
|
||||
|
||||
//- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
//{
|
||||
// // navigate layout hierarchy
|
||||
//
|
||||
// _parentNodeNavBtn.alignSelf = ASStackLayoutAlignSelfCenter;
|
||||
// _childNodeNavBtn.alignSelf = ASStackLayoutAlignSelfCenter;
|
||||
//
|
||||
// ASStackLayoutSpec *horizontalStackNav = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
// horizontalStackNav.style.flexGrow = 1.0;
|
||||
// horizontalStackNav.alignSelf = ASStackLayoutAlignSelfCenter;
|
||||
// horizontalStackNav.children = @[_siblingNodeLefttNavBtn, _siblingNodeRightNavBtn];
|
||||
//
|
||||
// ASStackLayoutSpec *horizontalStack = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
// horizontalStack.style.flexGrow = 1.0;
|
||||
// ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||
//
|
||||
// spacer.style.flexGrow = 1.0;
|
||||
// horizontalStack.children = @[_flexGrowBtn, spacer];
|
||||
// _flexGrowValue.alignSelf = ASStackLayoutAlignSelfEnd; // FIXME: make framework give a warning if you use ASAlignmentBottom!!!!!
|
||||
//
|
||||
// ASStackLayoutSpec *horizontalStack2 = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
// horizontalStack2.style.flexGrow = 1.0;
|
||||
// horizontalStack2.children = @[_flexShrinkBtn, spacer];
|
||||
// _flexShrinkValue.alignSelf = ASStackLayoutAlignSelfEnd;
|
||||
//
|
||||
// ASStackLayoutSpec *horizontalStack3 = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
// horizontalStack3.style.flexGrow = 1.0;
|
||||
// horizontalStack3.children = @[_flexBasisBtn, spacer, _flexBasisValue];
|
||||
// _flexBasisValue.alignSelf = ASStackLayoutAlignSelfEnd;
|
||||
//
|
||||
// ASStackLayoutSpec *itemDescriptionStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
// itemDescriptionStack.children = @[_itemDescription];
|
||||
// itemDescriptionStack.spacing = 5;
|
||||
// itemDescriptionStack.style.flexGrow = 1.0;
|
||||
//
|
||||
// ASStackLayoutSpec *layoutableStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
// layoutableStack.children = @[_layoutablePropertiesSectionTitle, horizontalStack, horizontalStack2, horizontalStack3, _alignSelfBtn];
|
||||
// layoutableStack.spacing = 5;
|
||||
// layoutableStack.style.flexGrow = 1.0;
|
||||
//
|
||||
// ASStackLayoutSpec *layoutSpecStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
// layoutSpecStack.children = @[_layoutSpecPropertiesSectionTitle, _alignItemsBtn];
|
||||
// layoutSpecStack.spacing = 5;
|
||||
// layoutSpecStack.style.flexGrow = 1.0;
|
||||
//
|
||||
// ASStackLayoutSpec *debugHelpStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
// debugHelpStack.children = @[_debugSectionTitle, _vizNodeInsetSizeBtn, _vizNodeBordersBtn];
|
||||
// debugHelpStack.spacing = 5;
|
||||
// debugHelpStack.style.flexGrow = 1.0;
|
||||
//
|
||||
// ASStackLayoutSpec *verticalLayoutableStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
// verticalLayoutableStack.style.flexGrow = 1.0;
|
||||
// verticalLayoutableStack.spacing = 20;
|
||||
// verticalLayoutableStack.children = @[_parentNodeNavBtn, horizontalStackNav, _childNodeNavBtn, itemDescriptionStack, layoutableStack, layoutSpecStack, debugHelpStack];
|
||||
// verticalLayoutableStack.alignItems = ASStackLayoutAlignItemsStretch; // stretch headerStack to fill horizontal space
|
||||
//
|
||||
// ASLayoutSpec *insetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(100, 10, 10, 10) child:verticalLayoutableStack];
|
||||
// insetSpec.style.flexGrow = 1.0;
|
||||
// return insetSpec;
|
||||
//}
|
||||
//
|
||||
//#pragma mark - configure Inspector node for layoutable
|
||||
//- (void)updateInspectorWithLayoutable
|
||||
//{
|
||||
// _itemDescription.attributedText = [self attributedStringFromLayoutable:_layoutElementToEdit];
|
||||
//
|
||||
// if ([self node]) {
|
||||
// UIColor *nodeBackgroundColor = [[self node] backgroundColor];
|
||||
// UIImage *colorBtnImg = [ASLayoutElementInspectorNode imageForButtonWithBackgroundColor:nodeBackgroundColor
|
||||
// borderColor:[UIColor whiteColor]
|
||||
// borderWidth:3];
|
||||
// [_itemBackgroundColorBtn setBackgroundImage:colorBtnImg forState:UIControlStateNormal];
|
||||
// } else {
|
||||
// _itemBackgroundColorBtn.enabled = NO;
|
||||
// }
|
||||
//
|
||||
// _flexGrowBtn.selected = [self.layoutElementToEdit flexGrow];
|
||||
// _flexGrowValue.attributedText = [self attributedStringFromString: (_flexGrowBtn.selected) ? @"YES" : @"NO"];
|
||||
//
|
||||
// _flexShrinkBtn.selected = self.layoutElementToEdit.style.flexShrink;
|
||||
// _flexShrinkValue.attributedText = [self attributedStringFromString: (_flexShrinkBtn.selected) ? @"YES" : @"NO"];
|
||||
//
|
||||
// // _flexBasisBtn.selected = self.layoutElementToEdit.style.flexShrink;
|
||||
// // _flexBasisValue.attributedText = [self attributedStringFromString: (_flexBasisBtn.selected) ? @"YES" : @"NO"];
|
||||
//
|
||||
//
|
||||
// NSUInteger alignSelfValue = [self.layoutElementToEdit alignSelf];
|
||||
// NSString *newTitle = [@"alignSelf:" stringByAppendingString:[self alignSelfName:alignSelfValue]];
|
||||
// [_alignSelfBtn setAttributedTitle:[self attributedStringFromString:newTitle] forState:UIControlStateNormal];
|
||||
//
|
||||
// if ([self layoutSpec]) {
|
||||
// _alignItemsBtn.enabled = YES;
|
||||
//// NSUInteger alignItemsValue = [[self layoutSpec] alignItems];
|
||||
//// newTitle = [@"alignItems:" stringByAppendingString:[self alignSelfName:alignItemsValue]];
|
||||
//// [_alignItemsBtn setAttributedTitle:[self attributedStringFromString:newTitle] forState:UIControlStateNormal];
|
||||
// }
|
||||
//
|
||||
// [self setNeedsLayout];
|
||||
//}
|
||||
|
||||
|
||||
//- (void)enableInspectorNodesForLayoutable
|
||||
//{
|
||||
// if ([self layoutSpec]) {
|
||||
//
|
||||
// _itemBackgroundColorBtn.enabled = YES;
|
||||
// _flexGrowBtn.enabled = YES;
|
||||
// _flexShrinkBtn.enabled = YES;
|
||||
// _flexBasisBtn.enabled = YES;
|
||||
// _alignSelfBtn.enabled = YES;
|
||||
// _spacingBeforeBtn.enabled = YES;
|
||||
// _spacingAfterBtn.enabled = YES;
|
||||
// _alignItemsBtn.enabled = YES;
|
||||
//
|
||||
// } else if ([self node]) {
|
||||
//
|
||||
// _itemBackgroundColorBtn.enabled = YES;
|
||||
// _flexGrowBtn.enabled = YES;
|
||||
// _flexShrinkBtn.enabled = YES;
|
||||
// _flexBasisBtn.enabled = YES;
|
||||
// _alignSelfBtn.enabled = YES;
|
||||
// _spacingBeforeBtn.enabled = YES;
|
||||
// _spacingAfterBtn.enabled = YES;
|
||||
// _alignItemsBtn.enabled = NO;
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// _itemBackgroundColorBtn.enabled = NO;
|
||||
// _flexGrowBtn.enabled = NO;
|
||||
// _flexShrinkBtn.enabled = NO;
|
||||
// _flexBasisBtn.enabled = NO;
|
||||
// _alignSelfBtn.enabled = NO;
|
||||
// _spacingBeforeBtn.enabled = NO;
|
||||
// _spacingAfterBtn.enabled = NO;
|
||||
// _alignItemsBtn.enabled = YES;
|
||||
// }
|
||||
//}
|
||||
|
||||
//+ (NSDictionary *)alignSelfTypeNames
|
||||
//{
|
||||
// return @{@(ASStackLayoutAlignSelfAuto) : @"Auto",
|
||||
// @(ASStackLayoutAlignSelfStart) : @"Start",
|
||||
// @(ASStackLayoutAlignSelfEnd) : @"End",
|
||||
// @(ASStackLayoutAlignSelfCenter) : @"Center",
|
||||
// @(ASStackLayoutAlignSelfStretch) : @"Stretch"};
|
||||
//}
|
||||
//
|
||||
//- (NSString *)alignSelfName:(NSUInteger)type
|
||||
//{
|
||||
// return [[self class] alignSelfTypeNames][@(type)];
|
||||
//}
|
||||
//
|
||||
//+ (NSDictionary *)alignItemTypeNames
|
||||
//{
|
||||
// return @{@(ASStackLayoutAlignItemsBaselineFirst) : @"BaselineFirst",
|
||||
// @(ASStackLayoutAlignItemsBaselineLast) : @"BaselineLast",
|
||||
// @(ASStackLayoutAlignItemsCenter) : @"Center",
|
||||
// @(ASStackLayoutAlignItemsEnd) : @"End",
|
||||
// @(ASStackLayoutAlignItemsStart) : @"Start",
|
||||
// @(ASStackLayoutAlignItemsStretch) : @"Stretch"};
|
||||
//}
|
||||
//
|
||||
//- (NSString *)alignItemName:(NSUInteger)type
|
||||
//{
|
||||
// return [[self class] alignItemTypeNames][@(type)];
|
||||
//}
|
||||
|
||||
//#pragma mark - gesture handling
|
||||
//- (void)changeColor:(ASButtonNode *)sender
|
||||
//{
|
||||
// if ([self node]) {
|
||||
// NSArray *colorArray = @[[UIColor orangeColor],
|
||||
// [UIColor redColor],
|
||||
// [UIColor greenColor],
|
||||
// [UIColor purpleColor]];
|
||||
//
|
||||
// UIColor *nodeBackgroundColor = [(ASDisplayNode *)self.layoutElementToEdit backgroundColor];
|
||||
//
|
||||
// NSUInteger colorIndex = [colorArray indexOfObject:nodeBackgroundColor];
|
||||
// colorIndex = (colorIndex + 1 < [colorArray count]) ? colorIndex + 1 : 0;
|
||||
//
|
||||
// [[self node] setBackgroundColor: [colorArray objectAtIndex:colorIndex]];
|
||||
// }
|
||||
//
|
||||
// [self updateInspectorWithLayoutable];
|
||||
//}
|
||||
//
|
||||
//- (void)setFlexGrowValue:(ASButtonNode *)sender
|
||||
//{
|
||||
// [sender setSelected:!sender.isSelected]; // FIXME: fix ASControlNode documentation that this is automatic - unlike highlighted, it is up to the application to decide when a button should be selected or not. Selected is a more persistant thing and highlighted is for the moment, like as a user has a finger on it,
|
||||
//
|
||||
// if ([self layoutSpec]) {
|
||||
// [[self layoutSpec] setFlexGrow:sender.isSelected];
|
||||
// } else if ([self node]) {
|
||||
// [[self node] setFlexGrow:sender.isSelected];
|
||||
// }
|
||||
//
|
||||
// [self updateInspectorWithLayoutable];
|
||||
//}
|
||||
//
|
||||
//- (void)setFlexShrinkValue:(ASButtonNode *)sender
|
||||
//{
|
||||
// [sender setSelected:!sender.isSelected]; // FIXME: fix ASControlNode documentation that this is automatic - unlike highlighted, it is up to the application to decide when a button should be selected or not. Selected is a more persistant thing and highlighted is for the moment, like as a user has a finger on it,
|
||||
//
|
||||
// if ([self layoutSpec]) {
|
||||
// [[self layoutSpec] setFlexShrink:sender.isSelected];
|
||||
// } else if ([self node]) {
|
||||
// [[self node] setFlexShrink:sender.isSelected];
|
||||
// }
|
||||
//
|
||||
// [self updateInspectorWithLayoutable];
|
||||
//}
|
||||
//
|
||||
//- (void)setAlignSelfValue:(ASButtonNode *)sender
|
||||
//{
|
||||
// NSUInteger currentAlignSelfValue;
|
||||
// NSUInteger nextAlignSelfValue;
|
||||
//
|
||||
// if ([self layoutSpec]) {
|
||||
// currentAlignSelfValue = [[self layoutSpec] alignSelf];
|
||||
// nextAlignSelfValue = (currentAlignSelfValue + 1 <= ASStackLayoutAlignSelfStretch) ? currentAlignSelfValue + 1 : 0;
|
||||
// [[self layoutSpec] setAlignSelf:nextAlignSelfValue];
|
||||
//
|
||||
// } else if ([self node]) {
|
||||
// currentAlignSelfValue = [[self node] alignSelf];
|
||||
// nextAlignSelfValue = (currentAlignSelfValue + 1 <= ASStackLayoutAlignSelfStretch) ? currentAlignSelfValue + 1 : 0;
|
||||
// [[self node] setAlignSelf:nextAlignSelfValue];
|
||||
// }
|
||||
//
|
||||
// [self updateInspectorWithLayoutable];
|
||||
//}
|
||||
//
|
||||
//- (void)setAlignItemsValue:(ASButtonNode *)sender
|
||||
//{
|
||||
// NSUInteger currentAlignItemsValue;
|
||||
// NSUInteger nextAlignItemsValue;
|
||||
//
|
||||
// if ([self layoutSpec]) {
|
||||
// currentAlignItemsValue = [[self layoutSpec] alignSelf];
|
||||
// nextAlignItemsValue = (currentAlignItemsValue + 1 <= ASStackLayoutAlignSelfStretch) ? currentAlignItemsValue + 1 : 0;
|
||||
//// [[self layoutSpec] setAlignItems:nextAlignItemsValue];
|
||||
//
|
||||
// } else if ([self node]) {
|
||||
// currentAlignItemsValue = [[self node] alignSelf];
|
||||
// nextAlignItemsValue = (currentAlignItemsValue + 1 <= ASStackLayoutAlignSelfStretch) ? currentAlignItemsValue + 1 : 0;
|
||||
//// [[self node] setAlignItems:nextAlignItemsValue];
|
||||
// }
|
||||
//
|
||||
// [self updateInspectorWithLayoutable];
|
||||
//}
|
||||
//- (void)setFlexBasisValue:(ASButtonNode *)sender
|
||||
//{
|
||||
// [sender setSelected:!sender.isSelected]; // FIXME: fix ASControlNode documentation that this is automatic - unlike highlighted, it is up to the application to decide when a button should be selected or not. Selected is a more persistant thing and highlighted is for the moment, like as a user has a finger on it,
|
||||
// FIXME: finish
|
||||
//}
|
||||
//
|
||||
//- (void)setVizNodeInsets:(ASButtonNode *)sender
|
||||
//{
|
||||
// BOOL newState = !sender.selected;
|
||||
//
|
||||
// if (newState == YES) {
|
||||
// self.vizNodeInsetSize = 0;
|
||||
// [self.delegate toggleVisualization:NO]; // FIXME
|
||||
// [self.delegate toggleVisualization:YES]; // FIXME
|
||||
// _vizNodeBordersBtn.selected = YES;
|
||||
//
|
||||
// } else {
|
||||
// self.vizNodeInsetSize = 10;
|
||||
// [self.delegate toggleVisualization:NO]; // FIXME
|
||||
// [self.delegate toggleVisualization:YES]; // FIXME
|
||||
// }
|
||||
//
|
||||
// sender.selected = newState;
|
||||
//}
|
||||
//
|
||||
//- (void)setVizNodeBorders:(ASButtonNode *)sender
|
||||
//{
|
||||
// BOOL newState = !sender.selected;
|
||||
//
|
||||
// [self.delegate toggleVisualization:newState]; // FIXME
|
||||
//
|
||||
// sender.selected = newState;
|
||||
//}
|
||||
|
||||
@end
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// ASLayoutSpec+Debug.h
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Hannah Troisi on 3/20/16.
|
||||
//
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#import <AsyncDisplayKit/ASControlNode.h>
|
||||
|
||||
#define ASLAYOUTSPEC_DEBUG 1
|
||||
|
||||
#if ASLAYOUTSPEC_DEBUG
|
||||
|
||||
@class ASLayoutSpec;
|
||||
|
||||
@interface ASLayoutSpecVisualizerNode : ASControlNode
|
||||
|
||||
@property (nonatomic, strong) ASLayoutSpec *layoutSpec;
|
||||
|
||||
- (instancetype)initWithLayoutSpec:(ASLayoutSpec *)layoutSpec;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
//
|
||||
// ASLayoutSpec+Debug.m
|
||||
// AsyncDisplayKit
|
||||
//
|
||||
// Created by Hannah Troisi on 3/20/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/ASLayoutSpec+Debug.h>
|
||||
|
||||
#if ASLAYOUTSPEC_DEBUG
|
||||
|
||||
#import <AsyncDisplayKit/ASDisplayNode+Beta.h>
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||
#import <AsyncDisplayKit/ASLayoutElementInspectorNode.h>
|
||||
|
||||
@implementation ASLayoutSpecVisualizerNode
|
||||
|
||||
- (instancetype)initWithLayoutSpec:(ASLayoutSpec *)layoutSpec
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.borderWidth = 2;
|
||||
self.borderColor = [[UIColor redColor] CGColor];
|
||||
self.layoutSpec = layoutSpec;
|
||||
self.layoutSpec.neverShouldVisualize = YES;
|
||||
self.automaticallyManagesSubnodes = YES;
|
||||
self.shouldCacheLayoutSpec = YES;
|
||||
[self addTarget:self action:@selector(visualizerNodeTapped:) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
CGFloat insetFloat = [ASLayoutElementInspectorNode sharedInstance].vizNodeInsetSize;
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(insetFloat, insetFloat, insetFloat, insetFloat);
|
||||
|
||||
// FIXME in framework: auto pass properties to children
|
||||
ASInsetLayoutSpec *insetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:self.layoutSpec];
|
||||
insetSpec.neverShouldVisualize = YES;
|
||||
|
||||
// propogate child's layoutSpec properties to the inset that we are adding
|
||||
// insetSpec.style.flexGrow = _layoutSpec.style.flexGrow;
|
||||
// insetSpec.style.flexShrink = _layoutSpec.style.flexShrink;
|
||||
// insetSpec.alignSelf = _layoutSpec.alignSelf;
|
||||
|
||||
// NSLog(@"%@: vizNode = %f, child = %f", self, insetSpec.style.flexGrow, _layoutSpec.style.flexGrow);
|
||||
|
||||
return insetSpec;
|
||||
}
|
||||
|
||||
- (void)setLayoutSpec:(ASLayoutSpec *)layoutSpec // FIXME: this is duplicated in InspectorNode - make it a category on ASLayoutSpec?
|
||||
{
|
||||
_layoutSpec = layoutSpec; // FIXME: should copy layoutSpec properities to self?
|
||||
|
||||
if ([layoutSpec isKindOfClass:[ASInsetLayoutSpec class]]) {
|
||||
self.borderColor = [[UIColor redColor] CGColor];
|
||||
|
||||
} else if ([layoutSpec isKindOfClass:[ASStackLayoutSpec class]]) {
|
||||
self.borderColor = [[UIColor greenColor] CGColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
return [self.layoutSpec description]; // FIXME: expand on layoutSpec description (e.g. have StackLayoutSpec return horz/vert)
|
||||
}
|
||||
|
||||
- (void)visualizerNodeTapped:(UIGestureRecognizer *)sender
|
||||
{
|
||||
[[ASLayoutElementInspectorNode sharedInstance] setLayoutElementToEdit:self.layoutSpec];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
@@ -42,11 +42,10 @@ CGSize const ASLayoutElementParentSizeUndefined = {ASLayoutElementParentDimensio
|
||||
int32_t const ASLayoutElementContextInvalidTransitionID = 0;
|
||||
int32_t const ASLayoutElementContextDefaultTransitionID = ASLayoutElementContextInvalidTransitionID + 1;
|
||||
|
||||
static inline ASLayoutElementContext _ASLayoutElementContextMake(int32_t transitionID, BOOL needsVisualizeNode)
|
||||
static inline ASLayoutElementContext _ASLayoutElementContextMake(int32_t transitionID)
|
||||
{
|
||||
struct ASLayoutElementContext context;
|
||||
context.transitionID = transitionID;
|
||||
context.needsVisualizeNode = needsVisualizeNode;
|
||||
return context;
|
||||
}
|
||||
|
||||
@@ -55,17 +54,17 @@ static inline BOOL _IsValidTransitionID(int32_t transitionID)
|
||||
return transitionID > ASLayoutElementContextInvalidTransitionID;
|
||||
}
|
||||
|
||||
struct ASLayoutElementContext const ASLayoutElementContextNull = _ASLayoutElementContextMake(ASLayoutElementContextInvalidTransitionID, NO);
|
||||
struct ASLayoutElementContext const ASLayoutElementContextNull = _ASLayoutElementContextMake(ASLayoutElementContextInvalidTransitionID);
|
||||
|
||||
BOOL ASLayoutElementContextIsNull(struct ASLayoutElementContext context)
|
||||
{
|
||||
return !_IsValidTransitionID(context.transitionID);
|
||||
}
|
||||
|
||||
ASLayoutElementContext ASLayoutElementContextMake(int32_t transitionID, BOOL needsVisualizeNode)
|
||||
ASLayoutElementContext ASLayoutElementContextMake(int32_t transitionID)
|
||||
{
|
||||
NSCAssert(_IsValidTransitionID(transitionID), @"Invalid transition ID");
|
||||
return _ASLayoutElementContextMake(transitionID, needsVisualizeNode);
|
||||
return _ASLayoutElementContextMake(transitionID);
|
||||
}
|
||||
|
||||
// Note: This is a non-recursive static lock. If it needs to be recursive, use ASDISPLAYNODE_MUTEX_RECURSIVE_INITIALIZER
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
struct ASLayoutElementContext {
|
||||
int32_t transitionID;
|
||||
BOOL needsVisualizeNode;
|
||||
};
|
||||
|
||||
extern int32_t const ASLayoutElementContextInvalidTransitionID;
|
||||
@@ -35,7 +34,7 @@ extern struct ASLayoutElementContext const ASLayoutElementContextNull;
|
||||
|
||||
extern BOOL ASLayoutElementContextIsNull(struct ASLayoutElementContext context);
|
||||
|
||||
extern struct ASLayoutElementContext ASLayoutElementContextMake(int32_t transitionID, BOOL needsVisualizeNode);
|
||||
extern struct ASLayoutElementContext ASLayoutElementContextMake(int32_t transitionID);
|
||||
|
||||
extern void ASLayoutElementSetCurrentContext(struct ASLayoutElementContext context);
|
||||
|
||||
|
||||
@@ -52,10 +52,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
@property (nullable, strong, nonatomic) NSArray<id<ASLayoutElement>> *children;
|
||||
|
||||
@property (nonatomic, assign) BOOL shouldVisualize;
|
||||
@property (nonatomic, assign) BOOL neverShouldVisualize;
|
||||
- (void)recursivelySetShouldVisualize:(BOOL)visualize;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#import <AsyncDisplayKit/ASLayoutSpecPrivate.h>
|
||||
|
||||
#import <AsyncDisplayKit/ASLayoutSpec+Subclasses.h>
|
||||
#import <AsyncDisplayKit/ASLayoutSpec+Debug.h>
|
||||
|
||||
#import <AsyncDisplayKit/ASLayoutElementStylePrivate.h>
|
||||
#import <AsyncDisplayKit/ASTraitCollection.h>
|
||||
@@ -70,45 +69,7 @@
|
||||
|
||||
#pragma mark - Final LayoutElement
|
||||
|
||||
@synthesize isFinalLayoutElement = _isFinalLayoutElement;
|
||||
|
||||
- (id<ASLayoutElement>)finalLayoutElement
|
||||
{
|
||||
#if ASLAYOUTSPEC_DEBUG
|
||||
if (ASLayoutElementGetCurrentContext().needsVisualizeNode && !self.neverShouldVisualize) {
|
||||
return [[ASLayoutSpecVisualizerNode alloc] initWithLayoutSpec:self];
|
||||
} else {
|
||||
return self;
|
||||
}
|
||||
#else
|
||||
return self;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)recursivelySetShouldVisualize:(BOOL)visualize
|
||||
{
|
||||
NSMutableArray *mutableChildren = [self.children mutableCopy];
|
||||
|
||||
#if ASLAYOUTSPEC_DEBUG
|
||||
for (id<ASLayoutElement>layoutElement in self.children) {
|
||||
if (layoutElement.layoutElementType == ASLayoutElementTypeLayoutSpec) {
|
||||
|
||||
ASLayoutSpec *layoutSpec = (ASLayoutSpec *)layoutElement;
|
||||
[mutableChildren replaceObjectAtIndex:[mutableChildren indexOfObjectIdenticalTo:layoutSpec]
|
||||
withObject:[[ASLayoutSpecVisualizerNode alloc] initWithLayoutSpec:layoutSpec]];
|
||||
|
||||
[layoutSpec recursivelySetShouldVisualize:visualize];
|
||||
layoutSpec.shouldVisualize = visualize;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ([mutableChildren count] == 1) { // HACK for wrapper layoutSpecs (e.g. insetLayoutSpec)
|
||||
self.child = mutableChildren[0];
|
||||
} else if ([mutableChildren count] > 1) {
|
||||
self.children = mutableChildren;
|
||||
}
|
||||
}
|
||||
ASLayoutElementFinalLayoutElementDefault
|
||||
|
||||
#pragma mark - Style
|
||||
|
||||
@@ -160,9 +121,6 @@
|
||||
ASDisplayNodeAssert(_childrenArray.count < 2, @"This layout spec does not support more than one child. Use the setChildren: or the setChild:AtIndex: API");
|
||||
|
||||
if (child) {
|
||||
if (child.layoutElementType == ASLayoutElementTypeLayoutSpec) {
|
||||
[(ASLayoutSpec *)child setShouldVisualize:self.shouldVisualize];
|
||||
}
|
||||
id<ASLayoutElement> finalLayoutElement = [self layoutElementToAddFromLayoutElement:child];
|
||||
if (finalLayoutElement) {
|
||||
_childrenArray[0] = finalLayoutElement;
|
||||
@@ -192,11 +150,7 @@
|
||||
NSUInteger i = 0;
|
||||
for (id<ASLayoutElement> child in children) {
|
||||
ASDisplayNodeAssert([child conformsToProtocol:NSProtocolFromString(@"ASLayoutElement")], @"Child %@ of spec %@ is not an ASLayoutElement!", child, self);
|
||||
id <ASLayoutElement> finalLayoutElement = [self layoutElementToAddFromLayoutElement:child];
|
||||
if (finalLayoutElement.layoutElementType == ASLayoutElementTypeLayoutSpec) {
|
||||
[(ASLayoutSpec *)finalLayoutElement setShouldVisualize:self.shouldVisualize];
|
||||
}
|
||||
_childrenArray[i] = finalLayoutElement;
|
||||
_childrenArray[i] = [self layoutElementToAddFromLayoutElement:child];
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ typedef NS_OPTIONS(NSUInteger, ASHierarchyState)
|
||||
Any layout calculated during this state should not be applied immediately, but pending until later. */
|
||||
ASHierarchyStateLayoutPending = 1 << 3,
|
||||
ASHierarchyStateYogaLayoutEnabled = 1 << 4,
|
||||
ASHierarchyStateYogaLayoutMeasuring = 1 << 5,
|
||||
ASHierarchyStateVisualizeLayout = 1 << 6
|
||||
ASHierarchyStateYogaLayoutMeasuring = 1 << 5
|
||||
};
|
||||
|
||||
ASDISPLAYNODE_INLINE BOOL ASHierarchyStateIncludesLayoutPending(ASHierarchyState hierarchyState)
|
||||
@@ -74,11 +73,6 @@ ASDISPLAYNODE_INLINE BOOL ASHierarchyStateIncludesYogaLayoutEnabled(ASHierarchyS
|
||||
return ((hierarchyState & ASHierarchyStateYogaLayoutEnabled) == ASHierarchyStateYogaLayoutEnabled);
|
||||
}
|
||||
|
||||
ASDISPLAYNODE_INLINE BOOL ASHierarchyStateIncludesVisualizeLayout(ASHierarchyState hierarchyState)
|
||||
{
|
||||
return ((hierarchyState & ASHierarchyStateVisualizeLayout) == ASHierarchyStateVisualizeLayout);
|
||||
}
|
||||
|
||||
ASDISPLAYNODE_INLINE BOOL ASHierarchyStateIncludesRasterized(ASHierarchyState hierarchyState)
|
||||
{
|
||||
return ((hierarchyState & ASHierarchyStateRasterized) == ASHierarchyStateRasterized);
|
||||
|
||||
@@ -136,8 +136,6 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo
|
||||
ASLayoutTransition *_pendingLayoutTransition;
|
||||
std::shared_ptr<ASDisplayNodeLayout> _calculatedDisplayNodeLayout;
|
||||
std::shared_ptr<ASDisplayNodeLayout> _pendingDisplayNodeLayout;
|
||||
ASLayoutSpec *_layoutSpec;
|
||||
BOOL _shouldCacheLayoutSpec;
|
||||
|
||||
ASDisplayNodeViewBlock _viewBlock;
|
||||
ASDisplayNodeLayerBlock _layerBlock;
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
@@ -1,6 +0,0 @@
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
platform :ios, '8.0'
|
||||
target 'Sample' do
|
||||
pod 'AsyncDisplayKit', :path => '../..'
|
||||
end
|
||||
|
||||
@@ -1,400 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0585428019D4DBE100606EA6 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0585427F19D4DBE100606EA6 /* Default-568h@2x.png */; };
|
||||
05E2128719D4DB510098F589 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128619D4DB510098F589 /* main.m */; };
|
||||
6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AA19EE274300767484 /* Default-667h@2x.png */; };
|
||||
6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AB19EE274300767484 /* Default-736h@3x.png */; };
|
||||
7602C7651CA4F83100D0D917 /* Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 7602C7641CA4F83100D0D917 /* Utilities.m */; };
|
||||
7602C7671CA4FB5300D0D917 /* resizeHandle.png in Resources */ = {isa = PBXBuildFile; fileRef = 7602C7661CA4FB5300D0D917 /* resizeHandle.png */; };
|
||||
76466F321C9DFFC4006C4D2D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 76466F2B1C9DFFC4006C4D2D /* AppDelegate.m */; };
|
||||
76466F341C9DFFC4006C4D2D /* PhotoPostNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 76466F2F1C9DFFC4006C4D2D /* PhotoPostNode.m */; };
|
||||
76466F351C9DFFC4006C4D2D /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 76466F311C9DFFC4006C4D2D /* ViewController.m */; };
|
||||
76F58D5C1C9E15C1004512CC /* PlaygroundContainerNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 76F58D5B1C9E15C1004512CC /* PlaygroundContainerNode.m */; };
|
||||
80A6A5181D88F08F00473431 /* LayoutExampleNodes.m in Sources */ = {isa = PBXBuildFile; fileRef = 80A6A5171D88F08F00473431 /* LayoutExampleNodes.m */; };
|
||||
B971D066CC023A00C53D8575 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 54A6EB3DE8D9A9EC4AE2867D /* libPods-Sample.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0585427F19D4DBE100606EA6 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = "<group>"; };
|
||||
05E2128119D4DB510098F589 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
05E2128519D4DB510098F589 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
05E2128619D4DB510098F589 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
|
||||
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
54A6EB3DE8D9A9EC4AE2867D /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5C5154389F056C672F4E9EEA /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = "<group>"; };
|
||||
6C2C82AA19EE274300767484 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = SOURCE_ROOT; };
|
||||
6C2C82AB19EE274300767484 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = SOURCE_ROOT; };
|
||||
7602C7631CA4F83100D0D917 /* Utilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utilities.h; sourceTree = "<group>"; };
|
||||
7602C7641CA4F83100D0D917 /* Utilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utilities.m; sourceTree = "<group>"; };
|
||||
7602C7661CA4FB5300D0D917 /* resizeHandle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = resizeHandle.png; sourceTree = "<group>"; };
|
||||
76466F2A1C9DFFC4006C4D2D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
76466F2B1C9DFFC4006C4D2D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
76466F2E1C9DFFC4006C4D2D /* PhotoPostNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoPostNode.h; sourceTree = "<group>"; };
|
||||
76466F2F1C9DFFC4006C4D2D /* PhotoPostNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoPostNode.m; sourceTree = "<group>"; };
|
||||
76466F301C9DFFC4006C4D2D /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
||||
76466F311C9DFFC4006C4D2D /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
||||
76F58D5A1C9E15C1004512CC /* PlaygroundContainerNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlaygroundContainerNode.h; sourceTree = "<group>"; };
|
||||
76F58D5B1C9E15C1004512CC /* PlaygroundContainerNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlaygroundContainerNode.m; sourceTree = "<group>"; };
|
||||
80A6A5161D88F08F00473431 /* LayoutExampleNodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutExampleNodes.h; sourceTree = "<group>"; };
|
||||
80A6A5171D88F08F00473431 /* LayoutExampleNodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LayoutExampleNodes.m; sourceTree = "<group>"; };
|
||||
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
FDF496F367580DF9280D36EA /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
05E2127E19D4DB510098F589 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B971D066CC023A00C53D8575 /* libPods-Sample.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
05E2127819D4DB510098F589 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
05E2128319D4DB510098F589 /* Sample */,
|
||||
05E2128219D4DB510098F589 /* Products */,
|
||||
1A943BF0259746F18D6E423F /* Frameworks */,
|
||||
1AE410B73DA5C3BD087ACDD7 /* Pods */,
|
||||
);
|
||||
indentWidth = 2;
|
||||
sourceTree = "<group>";
|
||||
tabWidth = 2;
|
||||
usesTabs = 0;
|
||||
};
|
||||
05E2128219D4DB510098F589 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
05E2128119D4DB510098F589 /* Sample.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
05E2128319D4DB510098F589 /* Sample */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
76466F2A1C9DFFC4006C4D2D /* AppDelegate.h */,
|
||||
76466F2B1C9DFFC4006C4D2D /* AppDelegate.m */,
|
||||
76466F301C9DFFC4006C4D2D /* ViewController.h */,
|
||||
76466F311C9DFFC4006C4D2D /* ViewController.m */,
|
||||
76F58D5A1C9E15C1004512CC /* PlaygroundContainerNode.h */,
|
||||
76F58D5B1C9E15C1004512CC /* PlaygroundContainerNode.m */,
|
||||
76466F2E1C9DFFC4006C4D2D /* PhotoPostNode.h */,
|
||||
76466F2F1C9DFFC4006C4D2D /* PhotoPostNode.m */,
|
||||
80A6A5161D88F08F00473431 /* LayoutExampleNodes.h */,
|
||||
80A6A5171D88F08F00473431 /* LayoutExampleNodes.m */,
|
||||
7602C7631CA4F83100D0D917 /* Utilities.h */,
|
||||
7602C7641CA4F83100D0D917 /* Utilities.m */,
|
||||
05E2128419D4DB510098F589 /* Supporting Files */,
|
||||
);
|
||||
path = Sample;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
05E2128419D4DB510098F589 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0585427F19D4DBE100606EA6 /* Default-568h@2x.png */,
|
||||
6C2C82AA19EE274300767484 /* Default-667h@2x.png */,
|
||||
7602C7661CA4FB5300D0D917 /* resizeHandle.png */,
|
||||
6C2C82AB19EE274300767484 /* Default-736h@3x.png */,
|
||||
05E2128519D4DB510098F589 /* Info.plist */,
|
||||
05E2128619D4DB510098F589 /* main.m */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1A943BF0259746F18D6E423F /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */,
|
||||
54A6EB3DE8D9A9EC4AE2867D /* libPods-Sample.a */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
1AE410B73DA5C3BD087ACDD7 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */,
|
||||
088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */,
|
||||
FDF496F367580DF9280D36EA /* Pods-Sample.debug.xcconfig */,
|
||||
5C5154389F056C672F4E9EEA /* Pods-Sample.release.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
05E2128019D4DB510098F589 /* Sample */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 05E212A419D4DB510098F589 /* Build configuration list for PBXNativeTarget "Sample" */;
|
||||
buildPhases = (
|
||||
E080B80F89C34A25B3488E26 /* [CP] Check Pods Manifest.lock */,
|
||||
05E2127D19D4DB510098F589 /* Sources */,
|
||||
05E2127E19D4DB510098F589 /* Frameworks */,
|
||||
05E2127F19D4DB510098F589 /* Resources */,
|
||||
F012A6F39E0149F18F564F50 /* [CP] Copy Pods Resources */,
|
||||
2291CF7AF2D4B273DDAD8AAC /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Sample;
|
||||
productName = Sample;
|
||||
productReference = 05E2128119D4DB510098F589 /* Sample.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
05E2127919D4DB510098F589 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0720;
|
||||
ORGANIZATIONNAME = Facebook;
|
||||
TargetAttributes = {
|
||||
05E2128019D4DB510098F589 = {
|
||||
CreatedOnToolsVersion = 6.0.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 05E2127C19D4DB510098F589 /* Build configuration list for PBXProject "Sample" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 05E2127819D4DB510098F589;
|
||||
productRefGroup = 05E2128219D4DB510098F589 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
05E2128019D4DB510098F589 /* Sample */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
05E2127F19D4DB510098F589 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
0585428019D4DBE100606EA6 /* Default-568h@2x.png in Resources */,
|
||||
6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */,
|
||||
6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */,
|
||||
7602C7671CA4FB5300D0D917 /* resizeHandle.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
2291CF7AF2D4B273DDAD8AAC /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
E080B80F89C34A25B3488E26 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
F012A6F39E0149F18F564F50 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
05E2127D19D4DB510098F589 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
76466F321C9DFFC4006C4D2D /* AppDelegate.m in Sources */,
|
||||
05E2128719D4DB510098F589 /* main.m in Sources */,
|
||||
7602C7651CA4F83100D0D917 /* Utilities.m in Sources */,
|
||||
76466F341C9DFFC4006C4D2D /* PhotoPostNode.m in Sources */,
|
||||
76F58D5C1C9E15C1004512CC /* PlaygroundContainerNode.m in Sources */,
|
||||
76466F351C9DFFC4006C4D2D /* ViewController.m in Sources */,
|
||||
80A6A5181D88F08F00473431 /* LayoutExampleNodes.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
05E212A219D4DB510098F589 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
05E212A319D4DB510098F589 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
05E212A519D4DB510098F589 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = FDF496F367580DF9280D36EA /* Pods-Sample.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = Sample/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.AsyncDisplayKit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
05E212A619D4DB510098F589 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 5C5154389F056C672F4E9EEA /* Pods-Sample.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = Sample/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.AsyncDisplayKit.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
05E2127C19D4DB510098F589 /* Build configuration list for PBXProject "Sample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
05E212A219D4DB510098F589 /* Debug */,
|
||||
05E212A319D4DB510098F589 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
05E212A419D4DB510098F589 /* Build configuration list for PBXNativeTarget "Sample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
05E212A519D4DB510098F589 /* Debug */,
|
||||
05E212A619D4DB510098F589 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 05E2127919D4DB510098F589 /* Project object */;
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "05E2128019D4DB510098F589"
|
||||
BuildableName = "Sample.app"
|
||||
BlueprintName = "Sample"
|
||||
ReferencedContainer = "container:Sample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "05E2128019D4DB510098F589"
|
||||
BuildableName = "Sample.app"
|
||||
BlueprintName = "Sample"
|
||||
ReferencedContainer = "container:Sample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "05E2128019D4DB510098F589"
|
||||
BuildableName = "Sample.app"
|
||||
BlueprintName = "Sample"
|
||||
ReferencedContainer = "container:Sample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "05E2128019D4DB510098F589"
|
||||
BuildableName = "Sample.app"
|
||||
BlueprintName = "Sample"
|
||||
ReferencedContainer = "container:Sample.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,16 +0,0 @@
|
||||
//
|
||||
// AppDelegate.h
|
||||
// ASLayoutSpecPlayground
|
||||
//
|
||||
// Created by Hannah Troisi on 3/11/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
//
|
||||
// AppDelegate.m
|
||||
// ASLayoutSpecPlayground
|
||||
//
|
||||
// Created by Hannah Troisi on 3/11/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewController.h"
|
||||
#import "Utilities.h"
|
||||
#import <AsyncDisplayKit/ASLayoutElementInspectorNode.h>
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
|
||||
UIViewController *rootVC = nil;
|
||||
|
||||
UIDevice *device = [UIDevice currentDevice];
|
||||
if (device.userInterfaceIdiom == UIUserInterfaceIdiomPad) {
|
||||
|
||||
ASViewController *masterVC = [[ASViewController alloc] initWithNode:[ASLayoutElementInspectorNode sharedInstance]];
|
||||
masterVC.view.backgroundColor = [UIColor customOrangeColor];
|
||||
UINavigationController *masterNav = [[UINavigationController alloc] initWithRootViewController:masterVC];
|
||||
|
||||
ViewController *detailVC = [[ViewController alloc] init];
|
||||
UINavigationController *detailNav = [[UINavigationController alloc] initWithRootViewController:detailVC];
|
||||
|
||||
UISplitViewController *splitVC = [[UISplitViewController alloc] init];
|
||||
splitVC.viewControllers = @[masterNav, detailNav];
|
||||
splitVC.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
|
||||
splitVC.maximumPrimaryColumnWidth = 250;
|
||||
|
||||
rootVC = splitVC;
|
||||
|
||||
} else {
|
||||
// FIXME: make this work for iPhones
|
||||
NSAssert(YES, @"App optimized for iPad only.");
|
||||
}
|
||||
|
||||
[self.window setRootViewController:rootVC];
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict/>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,49 +0,0 @@
|
||||
//
|
||||
// LayoutExampleNodes.h
|
||||
// Sample
|
||||
//
|
||||
// Created by Hannah Troisi on 9/13/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||
|
||||
@interface LayoutExampleNode : ASDisplayNode
|
||||
|
||||
- (NSAttributedString *)usernameAttributedStringWithFontSize:(CGFloat)size;
|
||||
- (NSAttributedString *)locationAttributedStringWithFontSize:(CGFloat)size;
|
||||
- (NSAttributedString *)uploadDateAttributedStringWithFontSize:(CGFloat)size;
|
||||
- (NSAttributedString *)likesAttributedStringWithFontSize:(CGFloat)size;
|
||||
- (NSAttributedString *)descriptionAttributedStringWithFontSize:(CGFloat)size;
|
||||
|
||||
@end
|
||||
|
||||
@interface HorizontalStackWithSpacer : LayoutExampleNode
|
||||
|
||||
@property (nonatomic, strong) ASTextNode *usernameNode;
|
||||
@property (nonatomic, strong) ASTextNode *postLocationNode;
|
||||
@property (nonatomic, strong) ASTextNode *postTimeNode;
|
||||
|
||||
@end
|
||||
|
||||
@interface PhotoWithInsetTextOverlay : LayoutExampleNode
|
||||
|
||||
@property (nonatomic, strong) ASNetworkImageNode *photoNode;
|
||||
@property (nonatomic, strong) ASTextNode *titleNode;
|
||||
|
||||
@end
|
||||
|
||||
@interface PhotoWithOutsetIconOverlay : LayoutExampleNode
|
||||
|
||||
@property (nonatomic, strong) ASNetworkImageNode *photoNode;
|
||||
@property (nonatomic, strong) ASNetworkImageNode *iconNode;
|
||||
|
||||
@end
|
||||
|
||||
@interface FlexibleSeparatorSurroundingContent : LayoutExampleNode
|
||||
|
||||
@property (nonatomic, strong) ASImageNode *topSeparator;
|
||||
@property (nonatomic, strong) ASImageNode *bottomSeparator;
|
||||
@property (nonatomic, strong) ASTextNode *textNode;
|
||||
|
||||
@end
|
||||
@@ -1,272 +0,0 @@
|
||||
//
|
||||
// LayoutExampleNodes.m
|
||||
// Sample
|
||||
//
|
||||
// Created by Hannah Troisi on 9/13/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "LayoutExampleNodes.h"
|
||||
#import "Utilities.h"
|
||||
#import "UIImage+ASConvenience.h"
|
||||
|
||||
#define USER_IMAGE_HEIGHT 60
|
||||
#define HORIZONTAL_BUFFER 10
|
||||
#define VERTICAL_BUFFER 5
|
||||
#define FONT_SIZE 20
|
||||
|
||||
@implementation LayoutExampleNode
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.automaticallyManagesSubnodes = YES;
|
||||
self.shouldVisualizeLayoutSpecs = NO;
|
||||
self.shouldCacheLayoutSpec = NO;
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - helper methods
|
||||
|
||||
- (NSAttributedString *)usernameAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"hannahmbanana"
|
||||
fontSize:size
|
||||
color:[UIColor darkBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)locationAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"San Fransisco, CA"
|
||||
fontSize:size
|
||||
color:[UIColor lightBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)uploadDateAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"30m"
|
||||
fontSize:size
|
||||
color:[UIColor lightGrayColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)likesAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"♥︎ 17 likes"
|
||||
fontSize:size
|
||||
color:[UIColor darkBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)descriptionAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
NSString *string = [NSString stringWithFormat:@"hannahmbanana check out this cool pic from the internet!"];
|
||||
NSAttributedString *attrString = [NSAttributedString attributedStringWithString:string
|
||||
fontSize:size
|
||||
color:[UIColor darkGrayColor]
|
||||
firstWordColor:[UIColor darkBlueColor]];
|
||||
return attrString;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation HorizontalStackWithSpacer
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_usernameNode = [[ASTextNode alloc] init];
|
||||
_usernameNode.attributedText = [self usernameAttributedStringWithFontSize:FONT_SIZE];
|
||||
|
||||
_postLocationNode = [[ASTextNode alloc] init];
|
||||
_postLocationNode.maximumNumberOfLines = 1;
|
||||
_postLocationNode.attributedText = [self locationAttributedStringWithFontSize:FONT_SIZE];
|
||||
|
||||
_postTimeNode = [[ASTextNode alloc] init];
|
||||
_postTimeNode.attributedText = [self uploadDateAttributedStringWithFontSize:FONT_SIZE];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_usernameNode.style.flexShrink = 1.0;
|
||||
_postLocationNode.style.flexShrink = 1.0;
|
||||
|
||||
ASStackLayoutSpec *verticalStackSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
verticalStackSpec.style.flexShrink = 1.0;
|
||||
|
||||
// Example: see ASDKgram for how this technique can be used to animate in the location label
|
||||
// once a separate network request provides the data.
|
||||
if (_postLocationNode.attributedText) {
|
||||
[verticalStackSpec setChildren:@[_usernameNode, _postLocationNode]];
|
||||
} else {
|
||||
[verticalStackSpec setChildren:@[_usernameNode]];
|
||||
}
|
||||
|
||||
ASLayoutSpec *spacerSpec = [[ASLayoutSpec alloc] init];
|
||||
spacerSpec.style.flexGrow = 1.0;
|
||||
spacerSpec.style.flexShrink = 1.0;
|
||||
|
||||
// horizontal stack
|
||||
ASStackLayoutSpec *horizontalStackSpec = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
horizontalStackSpec.alignItems = ASStackLayoutAlignItemsCenter; // center items vertically in horiz stack
|
||||
horizontalStackSpec.justifyContent = ASStackLayoutJustifyContentStart; // justify content to left
|
||||
horizontalStackSpec.style.flexShrink = 1.0;
|
||||
horizontalStackSpec.style.flexGrow = 1.0;
|
||||
[horizontalStackSpec setChildren:@[verticalStackSpec, spacerSpec, _postTimeNode]];
|
||||
|
||||
// inset horizontal stack
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(0, 10, 0, 10);
|
||||
ASInsetLayoutSpec *headerInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:horizontalStackSpec];
|
||||
headerInsetSpec.style.flexShrink = 1.0;
|
||||
headerInsetSpec.style.flexGrow = 1.0;
|
||||
|
||||
return headerInsetSpec;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation PhotoWithInsetTextOverlay
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_photoNode = [[ASNetworkImageNode alloc] init];
|
||||
_photoNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-inset-text-overlay-photo.png"];
|
||||
|
||||
_titleNode = [[ASTextNode alloc] init];
|
||||
_titleNode.maximumNumberOfLines = 2;
|
||||
_titleNode.truncationAttributedText = [NSAttributedString attributedStringWithString:@"..."
|
||||
fontSize:16
|
||||
color:[UIColor whiteColor]
|
||||
firstWordColor:nil];
|
||||
_titleNode.attributedText = [NSAttributedString attributedStringWithString:@"family fall hikes"
|
||||
fontSize:16
|
||||
color:[UIColor whiteColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_photoNode.style.preferredSize = CGSizeMake(USER_IMAGE_HEIGHT*2, USER_IMAGE_HEIGHT*2);
|
||||
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(INFINITY, 12, 12, 12);
|
||||
ASInsetLayoutSpec *textInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets
|
||||
child:_titleNode];
|
||||
|
||||
ASOverlayLayoutSpec *textOverlaySpec = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:_photoNode
|
||||
overlay:textInsetSpec];
|
||||
|
||||
return textOverlaySpec;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation PhotoWithOutsetIconOverlay
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
|
||||
_photoNode = [[ASNetworkImageNode alloc] init];
|
||||
_photoNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-outset-icon-overlay-photo.png"];
|
||||
|
||||
_iconNode = [[ASNetworkImageNode alloc] init];
|
||||
_iconNode.URL = [NSURL URLWithString:@"http://asyncdisplaykit.org/static/images/layout-examples-photo-with-outset-icon-overlay-icon.png"];
|
||||
|
||||
[_iconNode setImageModificationBlock:^UIImage *(UIImage *image) { // FIXME: in framework autocomplete for setImageModificationBlock line seems broken
|
||||
CGSize profileImageSize = CGSizeMake(USER_IMAGE_HEIGHT, USER_IMAGE_HEIGHT);
|
||||
return [image makeCircularImageWithSize:profileImageSize withBorderWidth:10];
|
||||
}];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_iconNode.style.preferredSize = CGSizeMake(40, 40);
|
||||
_photoNode.style.preferredSize = CGSizeMake(150, 150);
|
||||
|
||||
CGFloat x = 150;
|
||||
CGFloat y = 0;
|
||||
|
||||
_iconNode.style.layoutPosition = CGPointMake(x, y);
|
||||
_photoNode.style.layoutPosition = CGPointMake(40 / 2.0, 40 / 2.0);
|
||||
|
||||
ASAbsoluteLayoutSpec *absoluteLayoutSpec = [ASAbsoluteLayoutSpec absoluteLayoutSpecWithChildren:@[_photoNode, _iconNode]];
|
||||
|
||||
return absoluteLayoutSpec;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation FlexibleSeparatorSurroundingContent
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
|
||||
self.backgroundColor = [UIColor cyanColor];
|
||||
|
||||
_topSeparator = [[ASImageNode alloc] init];
|
||||
_topSeparator.image = [UIImage as_resizableRoundedImageWithCornerRadius:1.0
|
||||
cornerColor:[UIColor blackColor]
|
||||
fillColor:[UIColor blackColor]];
|
||||
|
||||
_textNode = [[ASTextNode alloc] init];
|
||||
_textNode.attributedText = [NSAttributedString attributedStringWithString:@"this is a long text node"
|
||||
fontSize:16
|
||||
color:[UIColor blackColor]
|
||||
firstWordColor:nil];
|
||||
|
||||
_bottomSeparator = [[ASImageNode alloc] init];
|
||||
_bottomSeparator.image = [UIImage as_resizableRoundedImageWithCornerRadius:1.0
|
||||
cornerColor:[UIColor blackColor]
|
||||
fillColor:[UIColor blackColor]];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_topSeparator.style.flexGrow = 1.0;
|
||||
_bottomSeparator.style.flexGrow = 1.0;
|
||||
|
||||
UIEdgeInsets contentInsets = UIEdgeInsetsMake(10, 10, 10, 10);
|
||||
ASInsetLayoutSpec *insetContentSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:contentInsets
|
||||
child:_textNode];
|
||||
// final vertical stack
|
||||
ASStackLayoutSpec *verticalStackSpec = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
verticalStackSpec.direction = ASStackLayoutDirectionVertical;
|
||||
verticalStackSpec.justifyContent = ASStackLayoutJustifyContentCenter;
|
||||
verticalStackSpec.alignItems = ASStackLayoutAlignItemsStretch;
|
||||
verticalStackSpec.children = @[_topSeparator, insetContentSpec, _bottomSeparator];
|
||||
|
||||
return verticalStackSpec;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
//
|
||||
// PhotoPostNode.h
|
||||
// ASLayoutSpecPlayground
|
||||
//
|
||||
// Created by Hannah Troisi on 3/11/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AsyncDisplayKit.h"
|
||||
|
||||
@interface PhotoPostNode : ASDisplayNode
|
||||
|
||||
- (instancetype)initWithIndex:(NSUInteger)index;
|
||||
|
||||
@end
|
||||
@@ -1,249 +0,0 @@
|
||||
//
|
||||
// PhotoPostNode.m
|
||||
// ASLayoutSpecPlayground
|
||||
//
|
||||
// Created by Hannah Troisi on 3/11/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PhotoPostNode.h"
|
||||
#import "AsyncDisplayKit+Debug.h"
|
||||
#import "Utilities.h"
|
||||
|
||||
#define USER_IMAGE_HEIGHT 60
|
||||
#define HORIZONTAL_BUFFER 10
|
||||
#define VERTICAL_BUFFER 5
|
||||
#define FONT_SIZE 20
|
||||
|
||||
@implementation PhotoPostNode
|
||||
{
|
||||
NSUInteger _index;
|
||||
ASNetworkImageNode *_userAvatarImageView;
|
||||
ASNetworkImageNode *_photoImageView;
|
||||
ASTextNode *_userNameLabel;
|
||||
ASTextNode *_photoLocationLabel;
|
||||
ASTextNode *_photoTimeIntervalSincePostLabel;
|
||||
ASTextNode *_photoLikesLabel;
|
||||
ASTextNode *_photoDescriptionLabel;
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
- (instancetype)initWithIndex:(NSUInteger)index
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
self.automaticallyManagesSubnodes = YES;
|
||||
self.shouldVisualizeLayoutSpecs = YES;
|
||||
self.shouldCacheLayoutSpec = YES;
|
||||
|
||||
_index = index;
|
||||
|
||||
_userAvatarImageView = [[ASNetworkImageNode alloc] init];
|
||||
_userAvatarImageView.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/avatars/503h_1458880322_140.jpg"];
|
||||
|
||||
[_userAvatarImageView setImageModificationBlock:^UIImage *(UIImage *image) { // FIXME: in framework autocomplete for setImageModificationBlock line seems broken
|
||||
CGSize profileImageSize = CGSizeMake(USER_IMAGE_HEIGHT, USER_IMAGE_HEIGHT);
|
||||
return [image makeCircularImageWithSize:profileImageSize withBorderWidth:0];
|
||||
}];
|
||||
|
||||
_userNameLabel = [[ASTextNode alloc] init];
|
||||
_userNameLabel.attributedText = [self usernameAttributedStringWithFontSize:FONT_SIZE];
|
||||
|
||||
_photoLocationLabel = [[ASTextNode alloc] init];
|
||||
_photoLocationLabel.maximumNumberOfLines = 1;
|
||||
_photoLocationLabel.attributedText = [self locationAttributedStringWithFontSize:FONT_SIZE];
|
||||
|
||||
_photoTimeIntervalSincePostLabel = [[ASTextNode alloc] init];
|
||||
_photoTimeIntervalSincePostLabel.attributedText = [self uploadDateAttributedStringWithFontSize:FONT_SIZE];
|
||||
|
||||
_photoImageView = [[ASNetworkImageNode alloc] init];
|
||||
_photoImageView.URL = [NSURL URLWithString:@"https://s-media-cache-ak0.pinimg.com/564x/9f/5b/3a/9f5b3a35640bc7a5d484b66124c48c46.jpg"];
|
||||
|
||||
_photoLikesLabel = [[ASTextNode alloc] init];
|
||||
_photoLikesLabel.attributedText = [self likesAttributedStringWithFontSize:FONT_SIZE];
|
||||
|
||||
_photoDescriptionLabel = [[ASTextNode alloc] init];
|
||||
_photoDescriptionLabel.attributedText = [self descriptionAttributedStringWithFontSize:FONT_SIZE];
|
||||
_photoDescriptionLabel.maximumNumberOfLines = 3;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
switch (_index) {
|
||||
case 1:
|
||||
return [self layoutSpecThatFitsNavBar:constrainedSize];
|
||||
case 2:
|
||||
return [self layoutSpecThatFitsASDKgram:constrainedSize];
|
||||
default:
|
||||
return [self layoutSpecThatFitsASDKgram:constrainedSize];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFitsNavBar:(ASSizeRange)constrainedSize
|
||||
{
|
||||
// username / photo location header vertical stack
|
||||
|
||||
_userNameLabel.style.flexShrink = 1.0;
|
||||
_photoLocationLabel.style.flexShrink = 1.0;
|
||||
|
||||
ASStackLayoutSpec *headerSubStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
headerSubStack.style.flexShrink = 1.0;
|
||||
|
||||
if (_photoLocationLabel.attributedText) {
|
||||
[headerSubStack setChildren:@[_userNameLabel, _photoLocationLabel]];
|
||||
} else {
|
||||
[headerSubStack setChildren:@[_userNameLabel]];
|
||||
}
|
||||
|
||||
// header stack
|
||||
|
||||
_userAvatarImageView.style.preferredSize = CGSizeMake(USER_IMAGE_HEIGHT, USER_IMAGE_HEIGHT);
|
||||
_photoTimeIntervalSincePostLabel.style.spacingBefore = HORIZONTAL_BUFFER; // hack to remove double spaces around spacer
|
||||
|
||||
UIEdgeInsets avatarInsets = UIEdgeInsetsMake(HORIZONTAL_BUFFER, 0, HORIZONTAL_BUFFER, HORIZONTAL_BUFFER);
|
||||
ASInsetLayoutSpec *avatarInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:avatarInsets child:_userAvatarImageView];
|
||||
|
||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||
spacer.style.flexGrow = 1.0;
|
||||
spacer.style.flexShrink = 1.0; // FIXME: this overrides stuff :) THIS IS A SYSTEMIC ISSUE - can we make layoutSpecThatFits only run once? cache layoutSpec, just use new constrainedSize, don't put properties in layoutSpecThatFits
|
||||
// separate the idea of laying out and rerunning with new constrainedSize
|
||||
|
||||
ASStackLayoutSpec *headerStack = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
headerStack.alignItems = ASStackLayoutAlignItemsCenter; // center items vertically in horizontal stack
|
||||
headerStack.justifyContent = ASStackLayoutJustifyContentStart; // justify content to the left side of the header stack
|
||||
headerStack.style.flexShrink = 1.0;
|
||||
headerStack.style.flexGrow = 1.0;
|
||||
|
||||
[headerStack setChildren:@[avatarInset, headerSubStack, spacer, _photoTimeIntervalSincePostLabel]];
|
||||
|
||||
// header inset stack
|
||||
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(0, HORIZONTAL_BUFFER, 0, HORIZONTAL_BUFFER);
|
||||
ASInsetLayoutSpec *headerWithInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:headerStack];
|
||||
headerWithInset.style.flexShrink = 1.0;
|
||||
headerWithInset.style.flexGrow = 1.0;
|
||||
|
||||
return headerWithInset;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFitsASDKgram:(ASSizeRange)constrainedSize
|
||||
{
|
||||
// username / photo location header vertical stack
|
||||
|
||||
_userNameLabel.style.flexShrink = 1.0;
|
||||
_photoLocationLabel.style.flexShrink = 1.0;
|
||||
|
||||
ASStackLayoutSpec *headerSubStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
headerSubStack.style.flexShrink = 1.0;
|
||||
|
||||
if (_photoLocationLabel.attributedText) {
|
||||
[headerSubStack setChildren:@[_userNameLabel, _photoLocationLabel]];
|
||||
} else {
|
||||
[headerSubStack setChildren:@[_userNameLabel]];
|
||||
}
|
||||
|
||||
// header stack
|
||||
|
||||
_userAvatarImageView.style.preferredSize = CGSizeMake(USER_IMAGE_HEIGHT, USER_IMAGE_HEIGHT);
|
||||
_photoTimeIntervalSincePostLabel.style.spacingBefore = HORIZONTAL_BUFFER; // hack to remove double spaces around spacer
|
||||
|
||||
UIEdgeInsets avatarInsets = UIEdgeInsetsMake(HORIZONTAL_BUFFER, 0, HORIZONTAL_BUFFER, HORIZONTAL_BUFFER);
|
||||
ASInsetLayoutSpec *avatarInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:avatarInsets child:_userAvatarImageView];
|
||||
|
||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||
spacer.style.flexGrow = 1.0;
|
||||
spacer.style.flexShrink = 1.0; // FIXME: this overrides stuff :) THIS IS A SYSTEMIC ISSUE - can we make layoutSpecThatFits only run once? cache layoutSpec, just use new constrainedSize, don't put properties in layoutSpecThatFits
|
||||
// separate the idea of laying out and rerunning with new constrainedSize
|
||||
|
||||
ASStackLayoutSpec *headerStack = [ASStackLayoutSpec horizontalStackLayoutSpec];
|
||||
headerStack.alignItems = ASStackLayoutAlignItemsCenter; // center items vertically in horizontal stack
|
||||
headerStack.justifyContent = ASStackLayoutJustifyContentStart; // justify content to the left side of the header stack
|
||||
headerStack.style.flexShrink = 1.0;
|
||||
headerStack.style.flexGrow = 1.0;
|
||||
|
||||
[headerStack setChildren:@[avatarInset, headerSubStack, spacer, _photoTimeIntervalSincePostLabel]];
|
||||
|
||||
// header inset stack
|
||||
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(0, HORIZONTAL_BUFFER, 0, HORIZONTAL_BUFFER);
|
||||
ASInsetLayoutSpec *headerWithInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:insets child:headerStack];
|
||||
headerWithInset.style.flexShrink = 1.0;
|
||||
headerWithInset.style.flexGrow = 1.0;
|
||||
|
||||
// footer stack
|
||||
|
||||
ASStackLayoutSpec *footerStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
footerStack.spacing = VERTICAL_BUFFER;
|
||||
|
||||
[footerStack setChildren:@[_photoLikesLabel, _photoDescriptionLabel]];
|
||||
|
||||
// footer inset stack
|
||||
|
||||
UIEdgeInsets footerInsets = UIEdgeInsetsMake(VERTICAL_BUFFER, HORIZONTAL_BUFFER, VERTICAL_BUFFER, HORIZONTAL_BUFFER);
|
||||
ASInsetLayoutSpec *footerWithInset = [ASInsetLayoutSpec insetLayoutSpecWithInsets:footerInsets child:footerStack];
|
||||
|
||||
// vertical stack
|
||||
|
||||
ASRatioLayoutSpec *photoRatioSpec = [ASRatioLayoutSpec ratioLayoutSpecWithRatio:1.0 child:_photoImageView];
|
||||
|
||||
ASStackLayoutSpec *verticalStack = [ASStackLayoutSpec verticalStackLayoutSpec];
|
||||
verticalStack.alignItems = ASStackLayoutAlignItemsStretch; // sretch headerStack to fill horizontal space
|
||||
[verticalStack setChildren:@[headerWithInset, photoRatioSpec, footerWithInset]];
|
||||
verticalStack.style.flexShrink = 1.0;
|
||||
|
||||
return verticalStack;
|
||||
}
|
||||
|
||||
#pragma mark - helper methods
|
||||
|
||||
- (NSAttributedString *)usernameAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"hannahmbanana"
|
||||
fontSize:size
|
||||
color:[UIColor darkBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)locationAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"San Fransisco, CA"
|
||||
fontSize:size
|
||||
color:[UIColor lightBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)uploadDateAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"30m"
|
||||
fontSize:size
|
||||
color:[UIColor lightGrayColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)likesAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
return [NSAttributedString attributedStringWithString:@"♥︎ 17 likes"
|
||||
fontSize:size
|
||||
color:[UIColor darkBlueColor]
|
||||
firstWordColor:nil];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)descriptionAttributedStringWithFontSize:(CGFloat)size
|
||||
{
|
||||
NSString *string = [NSString stringWithFormat:@"hannahmbanana check out this cool pic from the internet!"];
|
||||
NSAttributedString *attrString = [NSAttributedString attributedStringWithString:string
|
||||
fontSize:size
|
||||
color:[UIColor darkGrayColor]
|
||||
firstWordColor:[UIColor darkBlueColor]];
|
||||
return attrString;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// PlaygroundContainerNode.h
|
||||
// Sample
|
||||
//
|
||||
// Created by Hannah Troisi on 3/19/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||
|
||||
@protocol PlaygroundContainerNodeDelegate <NSObject>
|
||||
|
||||
- (void)relayoutWithSize:(ASSizeRange)size;
|
||||
|
||||
@end
|
||||
|
||||
@interface PlaygroundContainerNode : ASCellNode
|
||||
|
||||
@property (nonatomic, weak) id<PlaygroundContainerNodeDelegate> delegate;
|
||||
|
||||
+ (NSUInteger)containerNodeCount;
|
||||
- (instancetype)initWithIndex:(NSUInteger)index;
|
||||
|
||||
@end
|
||||
@@ -1,124 +0,0 @@
|
||||
//
|
||||
// PlaygroundContainerNode.m
|
||||
// Sample
|
||||
//
|
||||
// Created by Hannah Troisi on 3/19/16.
|
||||
// Copyright © 2016 Facebook. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PlaygroundContainerNode.h"
|
||||
#import "LayoutExampleNodes.h"
|
||||
#import "PhotoPostNode.h"
|
||||
#import <AsyncDisplayKit/ASLayoutElementInspectorNode.h>
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit+Debug.h>
|
||||
|
||||
#define RESIZE_HANDLE_SIZE 30
|
||||
|
||||
@implementation PlaygroundContainerNode
|
||||
{
|
||||
ASDisplayNode *_playgroundNode;
|
||||
ASImageNode *_resizeHandle;
|
||||
CGPoint _resizeStartLocation;
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
+ (NSUInteger)containerNodeCount
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
+ (ASDisplayNode *)nodeForIndex:(NSUInteger)index
|
||||
{
|
||||
switch (index) {
|
||||
case 0: return [[HorizontalStackWithSpacer alloc] init];
|
||||
case 1: return [[PhotoWithInsetTextOverlay alloc] init];
|
||||
case 2: return [[PhotoWithOutsetIconOverlay alloc] init];
|
||||
case 3: return [[FlexibleSeparatorSurroundingContent alloc] init];
|
||||
case 4: return [[PhotoPostNode alloc] initWithIndex:0];
|
||||
default: return [[PhotoPostNode alloc] initWithIndex:1];
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initWithIndex:(NSUInteger)index
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
self.backgroundColor = [UIColor whiteColor]; //[UIColor colorWithRed:255/255.0 green:181/255.0 blue:68/255.0 alpha:1];
|
||||
self.automaticallyManagesSubnodes = YES;
|
||||
|
||||
_playgroundNode = [[self class] nodeForIndex:index];
|
||||
|
||||
_resizeHandle = [[ASImageNode alloc] init];
|
||||
_resizeHandle.image = [UIImage imageNamed:@"resizeHandle"];
|
||||
_resizeHandle.userInteractionEnabled = YES;
|
||||
// [self addSubnode:_resizeHandle];
|
||||
|
||||
[ASLayoutElementInspectorNode sharedInstance].style.flexBasis = ASDimensionMakeWithFraction(1.0);
|
||||
[ASLayoutElementInspectorNode sharedInstance].vizNodeInsetSize = 10.0;
|
||||
|
||||
self.shouldVisualizeLayoutSpecs = NO;
|
||||
self.shouldCacheLayoutSpec = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)didLoad
|
||||
{
|
||||
[super didLoad];
|
||||
UIPanGestureRecognizer *gr = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(resizePlayground:)];
|
||||
[_resizeHandle.view addGestureRecognizer:gr];
|
||||
}
|
||||
|
||||
// manually layout _resizeHandle // FIXME: add this to an overlayStack in layoutSpecThatFits?
|
||||
- (void)layout
|
||||
{
|
||||
[super layout];
|
||||
[self.view bringSubviewToFront:_resizeHandle.view];
|
||||
|
||||
CGSize playgroundSize = _playgroundNode.calculatedLayout.size;
|
||||
CGRect rect = CGRectZero;
|
||||
rect.size = CGSizeMake(RESIZE_HANDLE_SIZE, RESIZE_HANDLE_SIZE);
|
||||
rect.origin = CGPointMake(playgroundSize.width - rect.size.width, playgroundSize.height - rect.size.height);
|
||||
_resizeHandle.frame = rect;
|
||||
}
|
||||
|
||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||
{
|
||||
_playgroundNode.style.flexGrow = 1.0;
|
||||
_playgroundNode.style.flexShrink = 1.0;
|
||||
|
||||
return [ASInsetLayoutSpec insetLayoutSpecWithInsets:UIEdgeInsetsMake(10, 10, 10, 10)
|
||||
child:_playgroundNode];
|
||||
}
|
||||
|
||||
#pragma mark - Gesture Handling
|
||||
|
||||
- (void)resizePlayground:(UIPanGestureRecognizer *)sender
|
||||
{
|
||||
if (sender.state == UIGestureRecognizerStateBegan) {
|
||||
_resizeStartLocation = [sender locationInView:sender.view];
|
||||
}
|
||||
else if (sender.state == UIGestureRecognizerStateChanged) {
|
||||
CGPoint location = [sender locationInView:sender.view];
|
||||
CGPoint translation = CGPointMake(location.x - _resizeStartLocation.x, location.y - _resizeStartLocation.y);
|
||||
[self changePlaygroundFrameWithTranslation:translation];
|
||||
}
|
||||
else if (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled || sender.state == UIGestureRecognizerStateFailed) {
|
||||
_resizeStartLocation = CGPointZero;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)changePlaygroundFrameWithTranslation:(CGPoint)translation
|
||||
{
|
||||
ASSizeRange constrainedSize = self.constrainedSizeForCalculatedLayout;
|
||||
|
||||
constrainedSize.max.width = MAX(0, constrainedSize.max.width + translation.x);
|
||||
constrainedSize.max.height = MAX(0, constrainedSize.max.height + translation.y);
|
||||
|
||||
[self.delegate relayoutWithSize:constrainedSize];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,32 +0,0 @@
|
||||
//
|
||||
// Utilities.h
|
||||
// Flickrgram
|
||||
//
|
||||
// Created by Hannah Troisi on 3/9/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UIColor (Additions)
|
||||
|
||||
+ (UIColor *)darkBlueColor;
|
||||
+ (UIColor *)lightBlueColor;
|
||||
+ (UIColor *)duskColor;
|
||||
+ (UIColor *)customOrangeColor;
|
||||
|
||||
@end
|
||||
|
||||
@interface UIImage (Additions)
|
||||
|
||||
- (UIImage *)makeCircularImageWithSize:(CGSize)size withBorderWidth:(CGFloat)width;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSAttributedString (Additions)
|
||||
|
||||
+ (NSAttributedString *)attributedStringWithString:(NSString *)string fontSize:(CGFloat)size
|
||||
color:(UIColor *)color firstWordColor:(UIColor *)firstWordColor;
|
||||
|
||||
@end
|
||||
@@ -1,98 +0,0 @@
|
||||
//
|
||||
// Utilities.m
|
||||
// Flickrgram
|
||||
//
|
||||
// Created by Hannah Troisi on 3/9/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Utilities.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#define StrokeRoundedImages 0
|
||||
|
||||
@implementation UIColor (Additions)
|
||||
|
||||
+ (UIColor *)darkBlueColor
|
||||
{
|
||||
return [UIColor colorWithRed:18.0/255.0 green:86.0/255.0 blue:136.0/255.0 alpha:1.0];
|
||||
}
|
||||
|
||||
+ (UIColor *)lightBlueColor
|
||||
{
|
||||
return [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0];
|
||||
}
|
||||
|
||||
+ (UIColor *)duskColor
|
||||
{
|
||||
return [UIColor colorWithRed:255/255.0 green:181/255.0 blue:68/255.0 alpha:1];
|
||||
}
|
||||
|
||||
+ (UIColor *)customOrangeColor
|
||||
{
|
||||
return [UIColor colorWithRed:40/255.0 green:43/255.0 blue:53/255.0 alpha:1.0];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIImage (Additions)
|
||||
|
||||
- (UIImage *)makeCircularImageWithSize:(CGSize)size withBorderWidth:(CGFloat)width
|
||||
{
|
||||
// make a CGRect with the image's size
|
||||
CGRect circleRect = (CGRect) {CGPointZero, size};
|
||||
|
||||
// begin the image context since we're not in a drawRect:
|
||||
UIGraphicsBeginImageContextWithOptions(circleRect.size, NO, 0);
|
||||
|
||||
// create a UIBezierPath circle
|
||||
UIBezierPath *circle = [UIBezierPath bezierPathWithRoundedRect:circleRect cornerRadius:circleRect.size.width/2];
|
||||
|
||||
// clip to the circle
|
||||
[circle addClip];
|
||||
|
||||
[[UIColor whiteColor] set];
|
||||
[circle fill];
|
||||
|
||||
// draw the image in the circleRect *AFTER* the context is clipped
|
||||
[self drawInRect:circleRect];
|
||||
|
||||
// create a border (for white background pictures)
|
||||
if (width > 0) {
|
||||
circle.lineWidth = width;
|
||||
[[UIColor whiteColor] set];
|
||||
[circle stroke];
|
||||
}
|
||||
|
||||
// get an image from the image context
|
||||
UIImage *roundedImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
|
||||
// end the image context since we're not in a drawRect:
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
return roundedImage;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSAttributedString (Additions)
|
||||
|
||||
+ (NSAttributedString *)attributedStringWithString:(NSString *)string fontSize:(CGFloat)size
|
||||
color:(nullable UIColor *)color firstWordColor:(nullable UIColor *)firstWordColor
|
||||
{
|
||||
NSDictionary *attributes = @{NSForegroundColorAttributeName: color ? : [UIColor blackColor],
|
||||
NSFontAttributeName: [UIFont boldSystemFontOfSize:size]};
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
|
||||
[attributedString addAttributes:attributes range:NSMakeRange(0, string.length)];
|
||||
|
||||
if (firstWordColor) {
|
||||
NSRange firstSpaceRange = [string rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
NSRange firstWordRange = NSMakeRange(0, firstSpaceRange.location);
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:firstWordColor range:firstWordRange];
|
||||
}
|
||||
|
||||
return attributedString;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,14 +0,0 @@
|
||||
//
|
||||
// ViewController.h
|
||||
// ASLayoutSpecPlayground
|
||||
//
|
||||
// Created by Hannah Troisi on 3/11/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AsyncDisplayKit.h"
|
||||
|
||||
@interface ViewController : ASViewController
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
//
|
||||
// ViewController.m
|
||||
// ASLayoutSpecPlayground
|
||||
//
|
||||
// Created by Hannah Troisi on 3/11/16.
|
||||
// Copyright © 2016 Hannah Troisi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
#import "PlaygroundContainerNode.h"
|
||||
#import "ASLayoutElementInspectorNode.h"
|
||||
|
||||
@interface ViewController () <ASPagerDelegate, ASPagerDataSource, ASLayoutElementInspectorNodeDelegate, PlaygroundContainerNodeDelegate>
|
||||
@end
|
||||
|
||||
@implementation ViewController
|
||||
{
|
||||
ASPagerNode *_pagerNode;
|
||||
ASSizeRange _sizeRange;
|
||||
}
|
||||
|
||||
#pragma mark - Lifecycle
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
_pagerNode = [[ASPagerNode alloc] init];
|
||||
self = [super initWithNode:_pagerNode];
|
||||
|
||||
if (self) {
|
||||
_pagerNode.delegate = self;
|
||||
_pagerNode.dataSource = self;
|
||||
self.navigationItem.title = @"ASLayoutSpec Playground";
|
||||
self.edgesForExtendedLayout = UIRectEdgeNone;
|
||||
[ASLayoutElementInspectorNode sharedInstance].delegate = self;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - ASPagerNodeDataSource
|
||||
|
||||
- (NSInteger)numberOfPagesInPagerNode:(ASPagerNode *)pagerNode
|
||||
{
|
||||
return [PlaygroundContainerNode containerNodeCount];
|
||||
}
|
||||
|
||||
- (ASCellNodeBlock)pagerNode:(ASPagerNode *)pagerNode nodeBlockAtIndex:(NSInteger)index
|
||||
{
|
||||
return ^{
|
||||
PlaygroundContainerNode *containerCellNode = [[PlaygroundContainerNode alloc] initWithIndex:index];
|
||||
containerCellNode.delegate = self;
|
||||
return containerCellNode;
|
||||
};
|
||||
}
|
||||
|
||||
// [ASViewController] Override this method to provide a custom size range to the backing node.
|
||||
// Neccessary to allow the user to stretch / shrink the size of playground container.
|
||||
- (ASSizeRange)nodeConstrainedSize
|
||||
{
|
||||
if (CGSizeEqualToSize(_sizeRange.max, CGSizeZero)) {
|
||||
return [super nodeConstrainedSize];
|
||||
}
|
||||
return _sizeRange;
|
||||
}
|
||||
|
||||
- (ASSizeRange)pagerNode:(ASPagerNode *)pagerNode constrainedSizeForNodeAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (CGSizeEqualToSize(_sizeRange.max, CGSizeZero)) {
|
||||
return [super nodeConstrainedSize];
|
||||
}
|
||||
return _sizeRange;
|
||||
}
|
||||
|
||||
#pragma mark - PlaygroundContainerNodeDelegate
|
||||
|
||||
- (void)relayoutWithSize:(ASSizeRange)size
|
||||
{
|
||||
// NSLog(@"DELEGATE constrainedSize = %@", NSStringFromCGSize(size.max));
|
||||
_sizeRange = size;
|
||||
[self.view setNeedsLayout];
|
||||
[_pagerNode reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - ASLayoutElementInspectorNodeDelegate
|
||||
|
||||
- (void)toggleVisualization:(BOOL)toggle
|
||||
{
|
||||
NSLog(@"shouldVisualizeLayoutSpecs:%d", toggle);
|
||||
[self.node setShouldVisualizeLayoutSpecs:toggle];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,20 +0,0 @@
|
||||
/* This file provided by Facebook is for non-commercial testing and evaluation
|
||||
* purposes only. Facebook reserves all rights not expressly granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "AppDelegate.h"
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 238 B |
Reference in New Issue
Block a user