Merge remote-tracking branch 'facebook/master' into ASLayoutPlayground

This commit is contained in:
Hannah Troisi
2016-03-22 20:21:36 -07:00
78 changed files with 1397 additions and 275 deletions

View File

@@ -3,6 +3,7 @@ osx_image: xcode7.2
before_install:
- brew update
- brew reinstall xctool
- brew reinstall carthage
- gem install cocoapods -v 0.38.2
- gem install slather
- xcrun simctl list

View File

@@ -261,6 +261,7 @@
69F10C861C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F10C851C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h */; settings = {ATTRIBUTES = (Public, ); }; };
69F10C871C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F10C851C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h */; settings = {ATTRIBUTES = (Public, ); }; };
6BDC61F61979037800E50D21 /* AsyncDisplayKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
7630FFA81C9E267E007A7C0E /* ASVideoNode.h in Headers */ = {isa = PBXBuildFile; fileRef = AEEC47DF1C20C2DD00EC1693 /* ASVideoNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
764D83D51C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 764D83D21C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h */; settings = {ATTRIBUTES = (Public, ); }; };
764D83D61C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 764D83D31C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m */; };
767E7F8D1C9019130066C000 /* AsyncDisplayKit+Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 764D83D21C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -275,6 +276,11 @@
76C0782F1C9F459C00E37AB1 /* ASLayoutableInspectorNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 76C0782B1C9F459C00E37AB1 /* ASLayoutableInspectorNode.m */; };
81EE384F1C8E94F000456208 /* ASRunLoopQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 81EE384D1C8E94F000456208 /* ASRunLoopQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
81EE38501C8E94F000456208 /* ASRunLoopQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 81EE384E1C8E94F000456208 /* ASRunLoopQueue.mm */; };
7A06A73A1C35F08800FE8DAA /* ASRelativeLayoutSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7A06A7381C35F08800FE8DAA /* ASRelativeLayoutSpec.mm */; };
7A06A73B1C35F08800FE8DAA /* ASRelativeLayoutSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A06A7391C35F08800FE8DAA /* ASRelativeLayoutSpec.h */; settings = {ATTRIBUTES = (Public, ); }; };
7AB338661C55B3420055FDE8 /* ASRelativeLayoutSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7A06A7381C35F08800FE8DAA /* ASRelativeLayoutSpec.mm */; };
7AB338671C55B3460055FDE8 /* ASRelativeLayoutSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A06A7391C35F08800FE8DAA /* ASRelativeLayoutSpec.h */; settings = {ATTRIBUTES = (Public, ); }; };
7AB338691C55B97B0055FDE8 /* ASRelativeLayoutSpecSnapshotTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AB338681C55B97B0055FDE8 /* ASRelativeLayoutSpecSnapshotTests.mm */; };
92DD2FE31BF4B97E0074C9DD /* ASMapNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 92DD2FE11BF4B97E0074C9DD /* ASMapNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
92DD2FE41BF4B97E0074C9DD /* ASMapNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */; };
92DD2FE61BF4D05E0074C9DD /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 92DD2FE51BF4D05E0074C9DD /* MapKit.framework */; };
@@ -372,13 +378,13 @@
ACF6ED631B178DC700DA7C62 /* ASStackLayoutSpecSnapshotTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED5B1B178DC700DA7C62 /* ASStackLayoutSpecSnapshotTests.mm */; };
AEB7B01A1C5962EA00662EF4 /* ASDefaultPlayButton.h in Headers */ = {isa = PBXBuildFile; fileRef = AEB7B0181C5962EA00662EF4 /* ASDefaultPlayButton.h */; };
AEB7B01B1C5962EA00662EF4 /* ASDefaultPlayButton.m in Sources */ = {isa = PBXBuildFile; fileRef = AEB7B0191C5962EA00662EF4 /* ASDefaultPlayButton.m */; };
AEEC47E11C20C2DD00EC1693 /* ASVideoNode.h in Headers */ = {isa = PBXBuildFile; fileRef = AEEC47DF1C20C2DD00EC1693 /* ASVideoNode.h */; };
AEEC47E11C20C2DD00EC1693 /* ASVideoNode.h in Headers */ = {isa = PBXBuildFile; fileRef = AEEC47DF1C20C2DD00EC1693 /* ASVideoNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
AEEC47E21C20C2DD00EC1693 /* ASVideoNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEC47E01C20C2DD00EC1693 /* ASVideoNode.mm */; };
AEEC47E41C21D3D200EC1693 /* ASVideoNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = AEEC47E31C21D3D200EC1693 /* ASVideoNodeTests.m */; };
B0F8805A1BEAEC7500D17647 /* ASTableNode.h in Headers */ = {isa = PBXBuildFile; fileRef = B0F880581BEAEC7500D17647 /* ASTableNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
B0F8805B1BEAEC7500D17647 /* ASTableNode.m in Sources */ = {isa = PBXBuildFile; fileRef = B0F880591BEAEC7500D17647 /* ASTableNode.m */; };
B13CA0F71C519E9400E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B13CA0F61C519E9400E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h */; };
B13CA0F81C519EBA00E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B13CA0F61C519E9400E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h */; };
B13CA0F71C519E9400E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B13CA0F61C519E9400E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
B13CA0F81C519EBA00E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = B13CA0F61C519E9400E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
B13CA1001C52004900E031AB /* ASCollectionNode+Beta.h in Headers */ = {isa = PBXBuildFile; fileRef = B13CA0FF1C52004900E031AB /* ASCollectionNode+Beta.h */; };
B13CA1011C52004900E031AB /* ASCollectionNode+Beta.h in Headers */ = {isa = PBXBuildFile; fileRef = B13CA0FF1C52004900E031AB /* ASCollectionNode+Beta.h */; };
B30BF6521C5964B0004FCD53 /* ASLayoutManager.h in Headers */ = {isa = PBXBuildFile; fileRef = B30BF6501C5964B0004FCD53 /* ASLayoutManager.h */; };
@@ -750,6 +756,9 @@
76C0782B1C9F459C00E37AB1 /* ASLayoutableInspectorNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASLayoutableInspectorNode.m; sourceTree = "<group>"; };
81EE384D1C8E94F000456208 /* ASRunLoopQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASRunLoopQueue.h; path = ../ASRunLoopQueue.h; sourceTree = "<group>"; };
81EE384E1C8E94F000456208 /* ASRunLoopQueue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASRunLoopQueue.mm; path = ../ASRunLoopQueue.mm; sourceTree = "<group>"; };
7A06A7381C35F08800FE8DAA /* ASRelativeLayoutSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASRelativeLayoutSpec.mm; path = AsyncDisplayKit/Layout/ASRelativeLayoutSpec.mm; sourceTree = "<group>"; };
7A06A7391C35F08800FE8DAA /* ASRelativeLayoutSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASRelativeLayoutSpec.h; path = AsyncDisplayKit/Layout/ASRelativeLayoutSpec.h; sourceTree = "<group>"; };
7AB338681C55B97B0055FDE8 /* ASRelativeLayoutSpecSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASRelativeLayoutSpecSnapshotTests.mm; sourceTree = "<group>"; };
92DD2FE11BF4B97E0074C9DD /* ASMapNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASMapNode.h; sourceTree = "<group>"; };
92DD2FE21BF4B97E0074C9DD /* ASMapNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASMapNode.mm; sourceTree = "<group>"; };
92DD2FE51BF4D05E0074C9DD /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; };
@@ -1072,6 +1081,7 @@
05EA6FE61AC0966E00E35788 /* ASSnapshotTestCase.mm */,
056D21541ABCEF50001107EF /* ASImageNodeSnapshotTests.m */,
ACF6ED531B178DC700DA7C62 /* ASCenterLayoutSpecSnapshotTests.mm */,
7AB338681C55B97B0055FDE8 /* ASRelativeLayoutSpecSnapshotTests.mm */,
ACF6ED551B178DC700DA7C62 /* ASInsetLayoutSpecSnapshotTests.mm */,
ACF6ED591B178DC700DA7C62 /* ASOverlayLayoutSpecSnapshotTests.mm */,
ACF6ED5A1B178DC700DA7C62 /* ASRatioLayoutSpecSnapshotTests.mm */,
@@ -1331,6 +1341,8 @@
ACF6ED131B17843500DA7C62 /* ASOverlayLayoutSpec.mm */,
ACF6ED141B17843500DA7C62 /* ASRatioLayoutSpec.h */,
ACF6ED151B17843500DA7C62 /* ASRatioLayoutSpec.mm */,
7A06A7391C35F08800FE8DAA /* ASRelativeLayoutSpec.h */,
7A06A7381C35F08800FE8DAA /* ASRelativeLayoutSpec.mm */,
9C49C36E1B853957000B0DD5 /* ASStackLayoutable.h */,
AC21EC0F1B3D0BF600C8B19A /* ASStackLayoutDefines.h */,
ACF6ED161B17843500DA7C62 /* ASStackLayoutSpec.h */,
@@ -1393,6 +1405,7 @@
058D0A6B195D05EC00B7D73C /* _ASAsyncTransactionContainer.h in Headers */,
058D0A6D195D05EC00B7D73C /* _ASAsyncTransactionGroup.h in Headers */,
058D0A72195D05F800B7D73C /* _ASCoreAnimationExtras.h in Headers */,
7A06A73B1C35F08800FE8DAA /* ASRelativeLayoutSpec.h in Headers */,
058D0A53195D05DC00B7D73C /* _ASDisplayLayer.h in Headers */,
058D0A55195D05DC00B7D73C /* _ASDisplayView.h in Headers */,
B13CA0F71C519E9400E031AB /* ASCollectionViewLayoutFacilitatorProtocol.h in Headers */,
@@ -1527,6 +1540,7 @@
B35062481B010EFD0018CF92 /* _AS-objc-internal.h in Headers */,
69F10C871C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h in Headers */,
B350623C1B010EFD0018CF92 /* _ASAsyncTransaction.h in Headers */,
7630FFA81C9E267E007A7C0E /* ASVideoNode.h in Headers */,
B350623F1B010EFD0018CF92 /* _ASAsyncTransactionContainer.h in Headers */,
B13CA1011C52004900E031AB /* ASCollectionNode+Beta.h in Headers */,
254C6B7E1BF94DF4003EC431 /* ASTextKitTailTruncater.h in Headers */,
@@ -1587,6 +1601,7 @@
AC7A2C181BDE11DF0093FE1A /* ASTableViewInternal.h in Headers */,
B35062531B010EFD0018CF92 /* ASImageNode+CGExtras.h in Headers */,
254C6B7F1BF94DF4003EC431 /* ASTextKitTruncating.h in Headers */,
7AB338671C55B3460055FDE8 /* ASRelativeLayoutSpec.h in Headers */,
B35062021B010EFD0018CF92 /* ASImageNode.h in Headers */,
B350621F1B010EFD0018CF92 /* ASImageProtocols.h in Headers */,
430E7C901B4C23F100697A4C /* ASIndexPath.h in Headers */,
@@ -1931,6 +1946,7 @@
CC3B20851C3F76D600798563 /* ASPendingStateController.mm in Sources */,
ACF6ED2C1B17843500DA7C62 /* ASOverlayLayoutSpec.mm in Sources */,
0442850F1BAA64EC00D16268 /* ASMultidimensionalArrayUtils.mm in Sources */,
7A06A73A1C35F08800FE8DAA /* ASRelativeLayoutSpec.mm in Sources */,
257754921BED28F300737CA5 /* ASEqualityHashHelpers.mm in Sources */,
E52405B31C8FEF03004DC8E7 /* ASDisplayNodeLayoutContext.mm in Sources */,
257754AB1BEE44CD00737CA5 /* ASTextKitEntityAttribute.m in Sources */,
@@ -1995,6 +2011,7 @@
058D0A3C195D057000B7D73C /* ASMutableAttributedStringBuilderTests.m in Sources */,
ACF6ED611B178DC700DA7C62 /* ASOverlayLayoutSpecSnapshotTests.mm in Sources */,
ACF6ED621B178DC700DA7C62 /* ASRatioLayoutSpecSnapshotTests.mm in Sources */,
7AB338691C55B97B0055FDE8 /* ASRelativeLayoutSpecSnapshotTests.mm in Sources */,
254C6B541BF8FF2A003EC431 /* ASTextKitTests.mm in Sources */,
05EA6FE71AC0966E00E35788 /* ASSnapshotTestCase.mm in Sources */,
ACF6ED631B178DC700DA7C62 /* ASStackLayoutSpecSnapshotTests.mm in Sources */,
@@ -2097,6 +2114,8 @@
9C8221981BA237B80037F19A /* ASStackBaselinePositionedLayout.mm in Sources */,
34EFC7721B701D0300AD841F /* ASStackLayoutSpec.mm in Sources */,
34EFC7761B701D2A00AD841F /* ASStackPositionedLayout.mm in Sources */,
DECC2ED01C35C1C600388446 /* ASRangeControllerBeta.mm in Sources */,
7AB338661C55B3420055FDE8 /* ASRelativeLayoutSpec.mm in Sources */,
34EFC7781B701D3100AD841F /* ASStackUnpositionedLayout.mm in Sources */,
DE84918E1C8FFF9F003D89E9 /* ASRunLoopQueue.mm in Sources */,
AC026B6C1BD57D6F00BBC17E /* ASChangeSetDataController.m in Sources */,

View File

@@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:AsyncDisplayKit.xcodeproj">
location = "self:">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,8 @@
<?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>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>

View File

@@ -60,6 +60,7 @@
_contentHorizontalAlignment = ASAlignmentMiddle;
_contentVerticalAlignment = ASAlignmentCenter;
_contentEdgeInsets = UIEdgeInsetsZero;
self.accessibilityTraits = UIAccessibilityTraitButton;
}
return self;
}
@@ -102,6 +103,11 @@
- (void)setEnabled:(BOOL)enabled
{
[super setEnabled:enabled];
if (enabled) {
self.accessibilityTraits = UIAccessibilityTraitButton;
} else {
self.accessibilityTraits = UIAccessibilityTraitButton | UIAccessibilityTraitNotEnabled;
}
[self updateButtonContent];
}
@@ -135,7 +141,7 @@
- (void)updateImage
{
ASDN::MutexLocker l(_propertyLock);
UIImage *newImage;
if (self.enabled == NO && _disabledImage) {
newImage = _disabledImage;
@@ -170,9 +176,10 @@
} else {
newTitle = _normalAttributedTitle;
}
if ((_titleNode != nil || newTitle.length > 0) && newTitle != self.titleNode.attributedString) {
_titleNode.attributedString = newTitle;
self.accessibilityLabel = _titleNode.accessibilityLabel;
[self setNeedsLayout];
}
}
@@ -331,6 +338,7 @@
default:
break;
}
[self updateTitle];
}

View File

@@ -13,13 +13,12 @@
#import <AsyncDisplayKit/ASBaseDefines.h>
#import <AsyncDisplayKit/ASBatchContext.h>
#import <AsyncDisplayKit/ASCollectionViewFlowLayoutInspector.h>
#import <AsyncDisplayKit/ASCollectionViewLayoutFacilitatorProtocol.h>
@class ASCellNode;
@class ASCollectionNode;
@protocol ASCollectionDataSource;
@protocol ASCollectionDelegate;
@protocol ASCollectionViewLayoutInspecting;
@protocol ASCollectionViewLayoutFacilitatorProtocol;
NS_ASSUME_NONNULL_BEGIN

View File

@@ -14,7 +14,6 @@
#import "ASCollectionDataController.h"
#import "ASCollectionViewLayoutController.h"
#import "ASCollectionViewFlowLayoutInspector.h"
#import "ASCollectionViewLayoutFacilitatorProtocol.h"
#import "ASDisplayNodeExtras.h"
#import "ASDisplayNode+FrameworkPrivate.h"
#import "ASDisplayNode+Beta.h"

View File

@@ -6,8 +6,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#ifndef ASCollectionViewLayoutFacilitatorProtocol_h
#define ASCollectionViewLayoutFacilitatorProtocol_h
#pragma once
/**
* This facilitator protocol is intended to help Layout to better
@@ -41,5 +40,3 @@
- (void)collectionViewWillPerformBatchUpdates;
@end
#endif /* ASCollectionViewLayoutFacilitatorProtocol_h */

View File

@@ -77,6 +77,7 @@ static BOOL _enableHitTestDebug = NO;
}
#pragma mark - Lifecycle
- (id)init
{
if (!(self = [super init]))
@@ -89,6 +90,13 @@ static BOOL _enableHitTestDebug = NO;
return self;
}
- (void)setUserInteractionEnabled:(BOOL)userInteractionEnabled
{
[super setUserInteractionEnabled:userInteractionEnabled];
self.isAccessibilityElement = userInteractionEnabled;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"

View File

@@ -91,4 +91,16 @@ ASDISPLAYNODE_EXTERN_C_END
shouldMeasureAsync:(BOOL)shouldMeasureAsync
measurementCompletion:(void(^)())completion;
/**
* @abstract Currently used by ASNetworkImageNode and ASMultiplexImageNode to allow their placeholders to stay if they are loading an image from the network.
* Otherwise, a display pass is scheduled and completes, but does not actually draw anything - and ASDisplayNode considers the element finished.
*/
- (BOOL)placeholderShouldPersist;
/**
* @abstract Cancels all performing layout transitions. Can be called on any thread.
*/
- (void)cancelLayoutTransitionsInProgress;
@end

View File

@@ -202,6 +202,12 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
class_replaceMethod(self, @selector(_staticInitialize), staticInitialize, "v:@");
}
+ (void)load
{
// Ensure this value is cached on the main thread before needed in the background.
ASScreenScale();
}
+ (BOOL)layerBackedNodesEnabled
{
return YES;
@@ -335,6 +341,8 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
- (void)dealloc
{
ASDisplayNodeAssertMainThread();
self.interfaceState &= ~ASInterfaceStateVisible;
self.asyncLayer.asyncDelegate = nil;
_view.asyncdisplaykit_node = nil;
@@ -424,6 +432,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
{
CALayer *layer;
ASDN::MutexLocker l(_propertyLock);
ASDisplayNodeAssert(_flags.layerBacked, @"_layerToLoad is only for layer-backed nodes");
if (_layerBlock) {
layer = _layerBlock();
@@ -479,10 +488,6 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
TIME_SCOPED(_debugTimeForDidLoad);
[self __didLoad];
}
if (self.placeholderEnabled) {
[self _setupPlaceholderLayer];
}
}
- (UIView *)view
@@ -594,14 +599,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
return _layout;
}
if ([self _hasTransitionsInProgress]) {
// Invalidate transition sentinel to cancel transitions in progress
[self _invalidateTransitionSentinel];
// Tell subnodes to exit layout pending state and clear related properties
ASDisplayNodePerformBlockOnEverySubnode(self, ^(ASDisplayNode * _Nonnull node) {
node.hierarchyState &= (~ASHierarchyStateLayoutPending);
});
}
[self cancelLayoutTransitionsInProgress];
ASLayout *previousLayout = _layout;
ASSizeRange previousConstrainedSize = _constrainedSize;
@@ -699,12 +697,14 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
}
ASPerformBlockOnMainThread(^{
// Grab _propertyLock here to make sure this transition isn't invalidated
// right after it passed the validation test and before it proceeds
ASDN::MutexLocker l(_propertyLock);
if ([self _shouldAbortTransitionWithID:transitionID]) {
return;
}
ASDN::MutexLocker l(_propertyLock);
ASLayout *previousLayout = _layout;
ASSizeRange previousConstrainedSize = _constrainedSize;
[self applyLayout:newLayout constrainedSize:constrainedSize layoutContext:nil];
@@ -747,17 +747,20 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
ASDN::MutexLocker l(_propertyLock);
[self calculatedLayoutDidChange];
// we generate placeholders at measureWithSizeRange: time so that a node is guaranteed
// to have a placeholder ready to go. Also, if a node has no size it should not have a placeholder
if (self.placeholderEnabled && [self _displaysAsynchronously] &&
_layout.size.width > 0.0 && _layout.size.height > 0.0) {
// We generate placeholders at measureWithSizeRange: time so that a node is guaranteed to have a placeholder ready to go.
// This is also because measurement is usually asynchronous, but placeholders need to be set up synchronously.
// First measurement is guaranteed to be before the node is onscreen, so we can create the image async. but still have it appear sync.
if (_placeholderEnabled && [self _displaysAsynchronously] && self.contents == nil) {
// Zero-sized nodes do not require a placeholder.
CGSize layoutSize = (_layout ? _layout.size : CGSizeZero);
if (CGSizeEqualToSize(layoutSize, CGSizeZero)) {
return;
}
if (!_placeholderImage) {
_placeholderImage = [self placeholderImage];
}
if (_placeholderLayer) {
[self _setupPlaceholderLayerContents];
}
}
}
@@ -767,6 +770,19 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
// subclass override
}
- (void)cancelLayoutTransitionsInProgress
{
ASDN::MutexLocker l(_propertyLock);
if ([self _hasTransitionsInProgress]) {
// Invalidate transition sentinel to cancel transitions in progress
[self _invalidateTransitionSentinel];
// Tell subnodes to exit layout pending state and clear related properties
ASDisplayNodePerformBlockOnEverySubnode(self, ^(ASDisplayNode * _Nonnull node) {
node.hierarchyState &= (~ASHierarchyStateLayoutPending);
});
}
}
#pragma mark - Layout Transition
- (BOOL)usesImplicitHierarchyManagement
@@ -1008,13 +1024,14 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
{
ASDisplayNodeAssertMainThread();
ASDN::MutexLocker l(_propertyLock);
if (CGRectEqualToRect(self.bounds, CGRectZero)) {
CGRect bounds = self.bounds;
if (CGRectEqualToRect(bounds, CGRectZero)) {
// Performing layout on a zero-bounds view often results in frame calculations
// with negative sizes after applying margins, which will cause
// measureWithSizeRange: on subnodes to assert.
return;
}
_placeholderLayer.frame = self.bounds;
_placeholderLayer.frame = bounds;
[self layout];
[self layoutDidFinish];
}
@@ -1543,9 +1560,20 @@ static NSInteger incrementIfFound(NSInteger i) {
}
_flags.isEnteringHierarchy = NO;
CALayer *layer = self.layer;
if (!layer.contents) {
// If we don't have contents finished drawing by the time we are on screen, immediately add the placeholder (if it is enabled and we do have something to draw).
if (self.contents == nil) {
CALayer *layer = self.layer;
[layer setNeedsDisplay];
if ([self _shouldHavePlaceholderLayer]) {
[CATransaction begin];
[CATransaction setDisableActions:YES];
[self _setupPlaceholderLayerIfNeeded];
_placeholderLayer.opacity = 1.0;
[CATransaction commit];
[self.layer addSublayer:_placeholderLayer];
}
}
}
}
@@ -1675,10 +1703,9 @@ static NSInteger incrementIfFound(NSInteger i) {
[_pendingDisplayNodes removeObject:node];
// only trampoline if there is a placeholder and nodes are done displaying
if ([self _pendingDisplayNodesHaveFinished] && _placeholderLayer.superlayer) {
if (_pendingDisplayNodes.count == 0 && _placeholderLayer.superlayer && ![self placeholderShouldPersist]) {
void (^cleanupBlock)() = ^{
[self _tearDownPlaceholderLayer];
[_placeholderLayer removeFromSuperlayer];
};
if (_placeholderFadeDuration > 0.0 && ASInterfaceStateIncludesVisible(self.interfaceState)) {
@@ -1693,33 +1720,46 @@ static NSInteger incrementIfFound(NSInteger i) {
}
}
// Helper method to check that all nodes that the current node is waiting to display are finished
// Use this method to check to remove any placeholder layers
- (BOOL)_pendingDisplayNodesHaveFinished
{
return _pendingDisplayNodes.count == 0;
}
// Helper method to summarize whether or not the node run through the display process
- (BOOL)__implementsDisplay
{
return _flags.implementsDrawRect || _flags.implementsImageDisplay || self.shouldRasterizeDescendants || _flags.implementsInstanceDrawRect || _flags.implementsInstanceImageDisplay;
}
- (void)_setupPlaceholderLayer
- (BOOL)placeholderShouldPersist
{
ASDisplayNodeAssertMainThread();
_placeholderLayer = [CALayer layer];
// do not set to CGFLOAT_MAX in the case that something needs to be overtop the placeholder
_placeholderLayer.zPosition = 9999.0;
return NO;
}
- (void)_tearDownPlaceholderLayer
- (BOOL)_shouldHavePlaceholderLayer
{
return (_placeholderEnabled && [self __implementsDisplay]);
}
- (void)_setupPlaceholderLayerIfNeeded
{
ASDisplayNodeAssertMainThread();
[_placeholderLayer removeFromSuperlayer];
if (!_placeholderLayer) {
_placeholderLayer = [CALayer layer];
// do not set to CGFLOAT_MAX in the case that something needs to be overtop the placeholder
_placeholderLayer.zPosition = 9999.0;
}
if (_placeholderLayer.contents == nil) {
if (!_placeholderImage) {
_placeholderImage = [self placeholderImage];
}
if (_placeholderImage) {
BOOL stretchable = !UIEdgeInsetsEqualToEdgeInsets(_placeholderImage.capInsets, UIEdgeInsetsZero);
if (stretchable) {
ASDisplayNodeSetupLayerContentsWithResizableImage(_placeholderLayer, _placeholderImage);
} else {
_placeholderLayer.contentsScale = self.contentsScale;
_placeholderLayer.contents = (id)_placeholderImage.CGImage;
}
}
}
}
void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
@@ -2270,26 +2310,6 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
[self _pendingNodeWillDisplay:self];
[_supernode subnodeDisplayWillStart:self];
if (_placeholderImage && _placeholderLayer && self.layer.contents == nil) {
[CATransaction begin];
[CATransaction setDisableActions:YES];
[self _setupPlaceholderLayerContents];
_placeholderLayer.opacity = 1.0;
[CATransaction commit];
[self.layer addSublayer:_placeholderLayer];
}
}
- (void)_setupPlaceholderLayerContents
{
BOOL stretchable = !UIEdgeInsetsEqualToEdgeInsets(_placeholderImage.capInsets, UIEdgeInsetsZero);
if (stretchable) {
ASDisplayNodeSetupLayerContentsWithResizableImage(_placeholderLayer, _placeholderImage);
} else {
_placeholderLayer.contentsScale = self.contentsScale;
_placeholderLayer.contents = (id)_placeholderImage.CGImage;
}
}
- (void)displayDidFinish

View File

@@ -25,6 +25,7 @@
@interface _ASImageNodeDrawParameters : NSObject
@property (nonatomic, retain) UIImage *image;
@property (nonatomic, assign) BOOL opaque;
@property (nonatomic, assign) CGRect bounds;
@property (nonatomic, assign) CGFloat contentsScale;
@@ -36,11 +37,17 @@
// TODO: eliminate explicit parameters with a set of keys copied from the node
@implementation _ASImageNodeDrawParameters
- (id)initWithBounds:(CGRect)bounds opaque:(BOOL)opaque contentsScale:(CGFloat)contentsScale backgroundColor:(UIColor *)backgroundColor contentMode:(UIViewContentMode)contentMode
- (id)initWithImage:(UIImage *)image
bounds:(CGRect)bounds
opaque:(BOOL)opaque
contentsScale:(CGFloat)contentsScale
backgroundColor:(UIColor *)backgroundColor
contentMode:(UIViewContentMode)contentMode
{
self = [self init];
if (!self) return nil;
if (!(self = [self init]))
return nil;
_image = image;
_opaque = opaque;
_bounds = bounds;
_contentsScale = contentsScale;
@@ -133,8 +140,13 @@
_image = image;
_imageLock.unlock();
[self invalidateCalculatedLayout];
[self setNeedsDisplay];
if (image) {
[self setNeedsDisplay];
} else {
self.contents = nil;
}
} else {
_imageLock.unlock(); // We avoid using MutexUnlocker as it needlessly re-locks at the end of the scope.
}
@@ -156,11 +168,12 @@
- (NSObject *)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer
{
return [[_ASImageNodeDrawParameters alloc] initWithBounds:self.bounds
opaque:self.opaque
contentsScale:self.contentsScaleForDisplay
backgroundColor:self.backgroundColor
contentMode:self.contentMode];
return [[_ASImageNodeDrawParameters alloc] initWithImage:self.image
bounds:self.bounds
opaque:self.opaque
contentsScale:self.contentsScaleForDisplay
backgroundColor:self.backgroundColor
contentMode:self.contentMode];
}
- (NSDictionary *)debugLabelAttributes
@@ -171,21 +184,26 @@
- (UIImage *)displayWithParameters:(_ASImageNodeDrawParameters *)parameters isCancelled:(asdisplaynode_iscancelled_block_t)isCancelled
{
UIImage *image;
BOOL cropEnabled;
BOOL forceUpscaling;
CGFloat contentsScale;
CGRect cropDisplayBounds;
CGRect cropRect;
UIImage *image = parameters.image;
if (!image) {
return nil;
}
BOOL forceUpscaling = NO;
BOOL cropEnabled = NO;
BOOL isOpaque = parameters.opaque;
UIColor *backgroundColor = parameters.backgroundColor;
UIViewContentMode contentMode = parameters.contentMode;
CGFloat contentsScale = 0.0;
CGRect cropDisplayBounds = CGRectZero;
CGRect cropRect = CGRectZero;
asimagenode_modification_block_t imageModificationBlock;
{
ASDN::MutexLocker l(_imageLock);
image = _image;
if (!image) {
return nil;
}
// FIXME: There is a small risk of these values changing between the main thread creation of drawParameters, and the execution of this method.
// We should package these up into the draw parameters object. Might be easiest to create a struct for the non-objects and make it one property.
cropEnabled = _cropEnabled;
forceUpscaling = _forceUpscaling;
contentsScale = _contentsScaleForDisplay;
@@ -194,16 +212,12 @@
imageModificationBlock = _imageModificationBlock;
}
BOOL hasValidCropBounds = cropEnabled && !CGRectIsNull(cropDisplayBounds) && !CGRectIsEmpty(cropDisplayBounds);
CGRect bounds = (hasValidCropBounds ? cropDisplayBounds : parameters.bounds);
ASDisplayNodeContextModifier preContextBlock = self.willDisplayNodeContentWithRenderingContext;
ASDisplayNodeContextModifier postContextBlock = self.didDisplayNodeContentWithRenderingContext;
BOOL hasValidCropBounds = cropEnabled && !CGRectIsNull(cropDisplayBounds) && !CGRectIsEmpty(cropDisplayBounds);
CGRect bounds = (hasValidCropBounds ? cropDisplayBounds : parameters.bounds);
BOOL isOpaque = parameters.opaque;
UIColor *backgroundColor = parameters.backgroundColor;
UIViewContentMode contentMode = parameters.contentMode;
ASDisplayNodeAssert(contentsScale > 0, @"invalid contentsScale at display time");
// if the image is resizable, bail early since the image has likely already been configured
@@ -232,17 +246,15 @@
}
}
BOOL contentModeSupported = contentMode == UIViewContentModeScaleAspectFill
|| contentMode == UIViewContentModeScaleAspectFit
|| contentMode == UIViewContentModeCenter;
BOOL contentModeSupported = contentMode == UIViewContentModeScaleAspectFill ||
contentMode == UIViewContentModeScaleAspectFit ||
contentMode == UIViewContentModeCenter;
CGSize backingSize;
CGRect imageDrawRect;
CGSize backingSize = CGSizeZero;
CGRect imageDrawRect = CGRectZero;
if (boundsSizeInPixels.width * contentsScale < 1.0f ||
boundsSizeInPixels.height * contentsScale < 1.0f ||
imageSizeInPixels.width < 1.0f ||
imageSizeInPixels.height < 1.0f) {
if (boundsSizeInPixels.width * contentsScale < 1.0f || boundsSizeInPixels.height * contentsScale < 1.0f ||
imageSizeInPixels.width < 1.0f || imageSizeInPixels.height < 1.0f) {
return nil;
}
@@ -260,10 +272,8 @@
&imageDrawRect);
}
if (backingSize.width <= 0.0f ||
backingSize.height <= 0.0f ||
imageDrawRect.size.width <= 0.0f ||
imageDrawRect.size.height <= 0.0f) {
if (backingSize.width <= 0.0f || backingSize.height <= 0.0f ||
imageDrawRect.size.width <= 0.0f || imageDrawRect.size.height <= 0.0f) {
return nil;
}

View File

@@ -134,12 +134,14 @@
- (void)setOptions:(MKMapSnapshotOptions *)options
{
ASDN::MutexLocker l(_propertyLock);
_options = options;
if (self.isLiveMap) {
[self applySnapshotOptions];
} else {
[self resetSnapshotter];
[self takeSnapshot];
if (!_options || ![options isEqual:_options]) {
_options = options;
if (self.isLiveMap) {
[self applySnapshotOptions];
} else if (_snapshotter) {
[self destroySnapshotter];
[self takeSnapshot];
}
}
}
@@ -160,7 +162,11 @@
if (!_snapshotter) {
[self setUpSnapshotter];
}
[_snapshotter cancel];
if (_snapshotter.isLoading) {
return;
}
[_snapshotter startWithQueue:dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
if (!error) {
@@ -207,12 +213,10 @@
_snapshotter = [[MKMapSnapshotter alloc] initWithOptions:self.options];
}
- (void)resetSnapshotter
- (void)destroySnapshotter
{
// FIXME: The semantics of this method / name would suggest that we cancel + destroy the snapshotter,
// but not that we create a new one. We should probably only create the new one in -takeSnapshot or something.
[_snapshotter cancel];
_snapshotter = [[MKMapSnapshotter alloc] initWithOptions:self.options];
_snapshotter = nil;
}
- (void)applySnapshotOptions
@@ -273,11 +277,14 @@
}
#pragma mark - Layout
- (void)setSnapshotSizeIfNeeded:(CGSize)snapshotSize
- (void)setSnapshotSizeWithReloadIfNeeded:(CGSize)snapshotSize
{
if (!CGSizeEqualToSize(self.options.size, snapshotSize)) {
_options.size = snapshotSize;
[self resetSnapshotter];
if (_snapshotter) {
[self destroySnapshotter];
[self takeSnapshot];
}
}
}
@@ -287,11 +294,11 @@
if (CGSizeEqualToSize(size, CGSizeZero)) {
size = constrainedSize;
}
[self setSnapshotSizeIfNeeded:size];
[self setSnapshotSizeWithReloadIfNeeded:size];
return constrainedSize;
}
// Layout isn't usually needed in the box model, but since we are making use of MKMapView this is preferred.
// -layout isn't usually needed over -layoutSpecThatFits, but this way we can avoid a needless node wrapper for MKMapView.
- (void)layout
{
[super layout];
@@ -300,10 +307,9 @@
} else {
// If our bounds.size is different from our current snapshot size, then let's request a new image from MKMapSnapshotter.
if (_needsMapReloadOnBoundsChange) {
[self setSnapshotSizeIfNeeded:self.bounds.size];
[self setSnapshotSizeWithReloadIfNeeded:self.bounds.size];
// FIXME: Adding a check for FetchData here seems to cause intermittent map load failures, but shouldn't.
// if (ASInterfaceStateIncludesFetchData(self.interfaceState)) {
[self takeSnapshot];
}
}
}

View File

@@ -250,7 +250,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
// Delegateify
if (_delegateFlags.displayFinish) {
if ([NSThread isMainThread])
if (ASDisplayNodeThreadIsMain())
[_delegate multiplexImageNodeDidFinishDisplay:self];
else {
__weak __typeof__(self) weakSelf = self;
@@ -265,6 +265,11 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
}
}
- (BOOL)placeholderShouldPersist
{
return (self.image == nil && self.imageIdentifiers.count > 0);
}
/* displayWillStart in ASNetworkImageNode has a very similar implementation. Changes here are likely necessary
in ASNetworkImageNode as well. */
- (void)displayWillStart
@@ -405,7 +410,7 @@ typedef void(^ASMultiplexImageLoadCompletionBlock)(UIImage *image, id imageIdent
// Delegateify.
// Note that we're using the params here instead of self.image and _displayedImageIdentifier because those can change before the async block below executes.
if (_delegateFlags.updatedImageDisplayFinish) {
if ([NSThread isMainThread])
if (ASDisplayNodeThreadIsMain())
[_delegate multiplexImageNode:self didDisplayUpdatedImage:image withIdentifier:displayedImageIdentifier];
else {
__weak __typeof__(self) weakSelf = self;

View File

@@ -173,6 +173,12 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
return _delegate;
}
- (BOOL)placeholderShouldPersist
{
ASDN::MutexLocker l(_lock);
return (self.image == nil && _URL != nil);
}
/* displayWillStart in ASMultiplexImageNode has a very similar implementation. Changes here are likely necessary
in ASMultiplexImageNode as well. */
- (void)displayWillStart
@@ -334,6 +340,7 @@ static const CGSize kMinReleaseImageOnBackgroundSize = {20.0, 20.0};
- (void)_lazilyLoadImageIfNecessary
{
// FIXME: We should revisit locking in this method (e.g. to access the instance variables at the top, and holding lock while calling delegate)
if (!_imageLoaded && _URL != nil && _downloadIdentifier == nil) {
{
ASDN::MutexLocker l(_lock);

View File

@@ -12,8 +12,13 @@
#import <cstdlib>
#import <deque>
#define ASRunLoopQueueLoggingEnabled 0
static void runLoopSourceCallback(void *info) {
// No-op
#if ASRunLoopQueueLoggingEnabled
NSLog(@"<%@> - Called runLoopSourceCallback", info);
#endif
}
@interface ASRunLoopQueue () {
@@ -22,6 +27,10 @@ static void runLoopSourceCallback(void *info) {
CFRunLoopSourceRef _runLoopSource;
std::deque<id> _internalQueue;
ASDN::RecursiveMutex _internalQueueLock;
#if ASRunLoopQueueLoggingEnabled
NSTimer *_runloopQueueLoggingTimer;
#endif
}
@property (nonatomic, copy) void (^queueConsumer)(id dequeuedItem, BOOL isQueueDrained);
@@ -47,9 +56,17 @@ static void runLoopSourceCallback(void *info) {
// the queue to stop. Attaching a custom loop source to the run loop and signal it if new work needs to be done
CFRunLoopSourceContext *runLoopSourceContext = (CFRunLoopSourceContext *)calloc(1, sizeof(CFRunLoopSourceContext));
runLoopSourceContext->perform = runLoopSourceCallback;
#if ASRunLoopQueueLoggingEnabled
runLoopSourceContext->info = (__bridge void *)self;
#endif
_runLoopSource = CFRunLoopSourceCreate(NULL, 0, runLoopSourceContext);
CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes);
free(runLoopSourceContext);
#if ASRunLoopQueueLoggingEnabled
_runloopQueueLoggingTimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(checkRunLoop) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:_runloopQueueLoggingTimer forMode:NSRunLoopCommonModes];
#endif
}
return self;
}
@@ -69,6 +86,13 @@ static void runLoopSourceCallback(void *info) {
_runLoopObserver = nil;
}
#if ASRunLoopQueueLoggingEnabled
- (void)checkRunLoop
{
NSLog(@"<%@> - Jobs: %ld", self, _internalQueue.size());
}
#endif
- (void)processQueue
{
std::deque<id> itemsToProcess = std::deque<id>();
@@ -102,6 +126,11 @@ static void runLoopSourceCallback(void *info) {
self.queueConsumer(itemsToProcess[i], isQueueDrained);
}
}
// If the queue is not fully drained yet force another run loop to process next batch of items
if (!isQueueDrained) {
CFRunLoopSourceSignal(_runLoopSource);
}
}
- (void)enqueue:(id)object

View File

@@ -6,13 +6,16 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <AsyncDisplayKit/AsyncDisplayKit.h>
#import <AsyncDisplayKit/ASButtonNode.h>
@class AVAsset, AVPlayer, AVPlayerItem;
@protocol ASVideoNodeDelegate;
// This is a relatively new component of AsyncDisplayKit. It has many useful features, but
// there is room for further expansion and optimization. Please report any issues or requests
// in an issue on GitHub: https://github.com/facebook/AsyncDisplayKit/issues
// IMPORTANT NOTES:
// 1. Applications using ASVideoNode must link AVFoundation! (this provides the AV* classes below)
// 2. This is a relatively new component of AsyncDisplayKit. It has many useful features, but
// there is room for further expansion and optimization. Please report any issues or requests
// in an issue on GitHub: https://github.com/facebook/AsyncDisplayKit/issues
@interface ASVideoNode : ASControlNode
@property (atomic, strong, readwrite) AVAsset *asset;

View File

@@ -14,6 +14,7 @@
#import <AsyncDisplayKit/ASTextNode.h>
#import <AsyncDisplayKit/ASButtonNode.h>
#import <AsyncDisplayKit/ASMapNode.h>
#import <AsyncDisplayKit/ASVideoNode.h>
#import <AsyncDisplayKit/ASEditableTextNode.h>
@@ -44,6 +45,7 @@
#import <AsyncDisplayKit/ASLayoutSpec.h>
#import <AsyncDisplayKit/ASBackgroundLayoutSpec.h>
#import <AsyncDisplayKit/ASCenterLayoutSpec.h>
#import <AsyncDisplayKit/ASRelativeLayoutSpec.h>
#import <AsyncDisplayKit/ASInsetLayoutSpec.h>
#import <AsyncDisplayKit/ASOverlayLayoutSpec.h>
#import <AsyncDisplayKit/ASRatioLayoutSpec.h>

View File

@@ -6,8 +6,9 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
#pragma once
#import <Foundation/Foundation.h>
#import <AsyncDisplayKit/ASDimension.h>
@class ASCollectionView;

View File

@@ -6,8 +6,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#ifndef ASDataControllerSubclasses_Included
#define ASDataControllerSubclasses_Included
#pragma once
@class ASIndexedNodeContext;
@@ -162,5 +161,3 @@ typedef void (^ASDataControllerCompletionBlock)(NSArray<ASCellNode *> *nodes, NS
- (void)willMoveSection:(NSInteger)section toSection:(NSInteger)newSection;
@end
#endif

View File

@@ -6,8 +6,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#ifndef ASDataController_Included
#define ASDataController_Included
#pragma once
#import <UIKit/UIKit.h>
#import <AsyncDisplayKit/ASDealloc2MainObject.h>
@@ -195,5 +194,3 @@ FOUNDATION_EXPORT NSString * const ASDataControllerRowNodeKind;
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -9,6 +9,7 @@
#import "ASMainSerialQueue.h"
#import "ASThread.h"
#import "ASInternalHelpers.h"
@interface ASMainSerialQueue ()
{
@@ -55,13 +56,7 @@
} while (true);
};
if ([NSThread isMainThread]) {
mainThread();
} else {
dispatch_async(dispatch_get_main_queue(), ^{
mainThread();
});
}
ASPerformBlockOnMainThread(mainThread);
}
- (NSString *)description

View File

@@ -8,7 +8,7 @@
*
*/
#import <AsyncDisplayKit/ASLayoutSpec.h>
#import <AsyncDisplayKit/ASRelativeLayoutSpec.h>
/** How the child is centered within the spec. */
typedef NS_OPTIONS(NSUInteger, ASCenterLayoutSpecCenteringOptions) {
@@ -25,19 +25,22 @@ typedef NS_OPTIONS(NSUInteger, ASCenterLayoutSpecCenteringOptions) {
/** How much space the spec will take up. */
typedef NS_OPTIONS(NSUInteger, ASCenterLayoutSpecSizingOptions) {
/** The spec will take up the maximum size possible */
ASCenterLayoutSpecSizingOptionDefault,
ASCenterLayoutSpecSizingOptionDefault = ASRelativeLayoutSpecSizingOptionDefault,
/** The spec will take up the minimum size possible along the X axis */
ASCenterLayoutSpecSizingOptionMinimumX = 1 << 0,
ASCenterLayoutSpecSizingOptionMinimumX = ASRelativeLayoutSpecSizingOptionMinimumWidth,
/** The spec will take up the minimum size possible along the Y axis */
ASCenterLayoutSpecSizingOptionMinimumY = 1 << 1,
ASCenterLayoutSpecSizingOptionMinimumY = ASRelativeLayoutSpecSizingOptionMinimumHeight,
/** Convenience option to take up the minimum size along both the X and Y axis */
ASCenterLayoutSpecSizingOptionMinimumXY = ASCenterLayoutSpecSizingOptionMinimumX | ASCenterLayoutSpecSizingOptionMinimumY,
ASCenterLayoutSpecSizingOptionMinimumXY = ASRelativeLayoutSpecSizingOptionMinimumSize
};
NS_ASSUME_NONNULL_BEGIN
/** Lays out a single layoutable child and position it so that it is centered into the layout bounds. */
@interface ASCenterLayoutSpec : ASLayoutSpec
/** Lays out a single layoutable child and position it so that it is centered into the layout bounds.
* NOTE: ASRelativeLayoutSpec offers all of the capabilities of Center, and more.
* Check it out if you would like to be able to position the child at any corner or the middle of an edge.
*/
@interface ASCenterLayoutSpec : ASRelativeLayoutSpec
@property (nonatomic, assign) ASCenterLayoutSpecCenteringOptions centeringOptions;
@property (nonatomic, assign) ASCenterLayoutSpecSizingOptions sizingOptions;

View File

@@ -23,13 +23,14 @@
sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions
child:(id<ASLayoutable>)child;
{
if (!(self = [super init])) {
ASRelativeLayoutSpecPosition verticalPosition = [self verticalPositionFromCenteringOptions:centeringOptions];
ASRelativeLayoutSpecPosition horizontalPosition = [self horizontalPositionFromCenteringOptions:centeringOptions];
if (!(self = [super initWithHorizontalPosition:horizontalPosition verticalPosition:verticalPosition sizingOption:sizingOptions child:child])) {
return nil;
}
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
_centeringOptions = centeringOptions;
_sizingOptions = sizingOptions;
[self setChild:child];
return self;
}
@@ -44,61 +45,36 @@
{
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
_centeringOptions = centeringOptions;
[self setHorizontalPosition:[self horizontalPositionFromCenteringOptions:centeringOptions]];
[self setVerticalPosition:[self verticalPositionFromCenteringOptions:centeringOptions]];
}
- (void)setSizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions
{
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
_sizingOptions = sizingOptions;
[self setSizingOption:sizingOptions];
}
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
- (ASRelativeLayoutSpecPosition)horizontalPositionFromCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions
{
CGSize size = {
constrainedSize.max.width,
constrainedSize.max.height
};
// Layout the child
const CGSize minChildSize = {
(_centeringOptions & ASCenterLayoutSpecCenteringX) != 0 ? 0 : constrainedSize.min.width,
(_centeringOptions & ASCenterLayoutSpecCenteringY) != 0 ? 0 : constrainedSize.min.height,
};
ASLayout *sublayout = [self.child measureWithSizeRange:ASSizeRangeMake(minChildSize, constrainedSize.max)];
// If we have an undetermined height or width, use the child size to define the layout
// size
size = ASSizeRangeClamp(constrainedSize, {
isnan(size.width) ? sublayout.size.width : size.width,
isnan(size.height) ? sublayout.size.height : size.height
});
// If minimum size options are set, attempt to shrink the size to the size of the child
size = ASSizeRangeClamp(constrainedSize, {
MIN(size.width, (_sizingOptions & ASCenterLayoutSpecSizingOptionMinimumX) != 0 ? sublayout.size.width : size.width),
MIN(size.height, (_sizingOptions & ASCenterLayoutSpecSizingOptionMinimumY) != 0 ? sublayout.size.height : size.height)
});
// Compute the centered position for the child
BOOL shouldCenterAlongX = (_centeringOptions & ASCenterLayoutSpecCenteringX);
BOOL shouldCenterAlongY = (_centeringOptions & ASCenterLayoutSpecCenteringY);
sublayout.position = {
ASRoundPixelValue(shouldCenterAlongX ? (size.width - sublayout.size.width) * 0.5f : 0),
ASRoundPixelValue(shouldCenterAlongY ? (size.height - sublayout.size.height) * 0.5f : 0)
};
return [ASLayout layoutWithLayoutableObject:self size:size sublayouts:@[sublayout]];
BOOL centerX = (centeringOptions & ASCenterLayoutSpecCenteringX) != 0;
if (centerX) {
return ASRelativeLayoutSpecPositionCenter;
} else {
return ASRelativeLayoutSpecPositionStart;
}
}
- (void)setChildren:(NSArray *)children
- (ASRelativeLayoutSpecPosition)verticalPositionFromCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
}
- (NSArray *)children
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
return nil;
BOOL centerY = (centeringOptions & ASCenterLayoutSpecCenteringY) != 0;
if (centerY) {
return ASRelativeLayoutSpecPositionCenter;
} else {
return ASRelativeLayoutSpecPositionStart;
}
}
@end

View File

@@ -0,0 +1,73 @@
//
// ASRelativeLayoutSpec.h
// AsyncDisplayKit
//
// Created by Samuel Stow on 12/31/15.
//
#import <AsyncDisplayKit/ASLayoutSpec.h>
/** How the child is positioned within the spec. */
typedef NS_OPTIONS(NSUInteger, ASRelativeLayoutSpecPosition) {
/** The child is positioned at point 0 relatively to the layout axis (ie left / top most) */
ASRelativeLayoutSpecPositionStart = 0,
/** The child is centered along the specified axis */
ASRelativeLayoutSpecPositionCenter = 1 << 0,
/** The child is positioned at the maximum point of the layout axis (ie right / bottom most) */
ASRelativeLayoutSpecPositionEnd = 1 << 1,
};
/** How much space the spec will take up. */
typedef NS_OPTIONS(NSUInteger, ASRelativeLayoutSpecSizingOption) {
/** The spec will take up the maximum size possible */
ASRelativeLayoutSpecSizingOptionDefault,
/** The spec will take up the minimum size possible along the X axis */
ASRelativeLayoutSpecSizingOptionMinimumWidth = 1 << 0,
/** The spec will take up the minimum size possible along the Y axis */
ASRelativeLayoutSpecSizingOptionMinimumHeight = 1 << 1,
/** Convenience option to take up the minimum size along both the X and Y axis */
ASRelativeLayoutSpecSizingOptionMinimumSize = ASRelativeLayoutSpecSizingOptionMinimumWidth | ASRelativeLayoutSpecSizingOptionMinimumHeight,
};
NS_ASSUME_NONNULL_BEGIN
/** Lays out a single layoutable child and positions it within the layout bounds according to vertical and horizontal positional specifiers.
* Can position the child at any of the 4 corners, or the middle of any of the 4 edges, as well as the center - similar to "9-part" image areas.
*/
@interface ASRelativeLayoutSpec : ASLayoutSpec
// You may create a spec with alloc / init, then set any non-default properties; or use a convenience initialize that accepts all properties.
@property (nonatomic, assign) ASRelativeLayoutSpecPosition horizontalPosition;
@property (nonatomic, assign) ASRelativeLayoutSpecPosition verticalPosition;
@property (nonatomic, assign) ASRelativeLayoutSpecSizingOption sizingOption;
/*!
* @discussion convenience constructor for a ASRelativeLayoutSpec
* @param horizontalPosition how to position the item on the horizontal (x) axis
* @param verticalPosition how to position the item on the vertical (y) axis
* @param sizingOption how much size to take up
* @param child the child to layout
* @return a configured ASRelativeLayoutSpec
*/
+ (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition
verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition
sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption
child:(id<ASLayoutable>)child;
/*!
* @discussion convenience initializer for a ASRelativeLayoutSpec
* @param horizontalPosition how to position the item on the horizontal (x) axis
* @param verticalPosition how to position the item on the vertical (y) axis
* @param sizingOption how much size to take up
* @param child the child to layout
* @return a configured ASRelativeLayoutSpec
*/
- (instancetype)initWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition
verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition
sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption
child:(id<ASLayoutable>)child;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,117 @@
//
// ASRelativeLayoutSpec.mm
// AsyncDisplayKit
//
// Created by Samuel Stow on 12/31/15.
//
#import "ASRelativeLayoutSpec.h"
#import "ASInternalHelpers.h"
#import "ASLayout.h"
@implementation ASRelativeLayoutSpec
- (instancetype)initWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption child:(id<ASLayoutable>)child
{
if (!(self = [super init])) {
return nil;
}
ASDisplayNodeAssertNotNil(child, @"Child cannot be nil");
_horizontalPosition = horizontalPosition;
_verticalPosition = verticalPosition;
_sizingOption = sizingOption;
[self setChild:child];
return self;
}
+ (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption child:(id<ASLayoutable>)child
{
return [[self alloc] initWithHorizontalPosition:horizontalPosition verticalPosition:verticalPosition sizingOption:sizingOption child:child];
}
- (void)setHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition
{
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
_horizontalPosition = horizontalPosition;
}
- (void)setVerticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition {
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
_verticalPosition = verticalPosition;
}
- (void)setSizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption
{
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
_sizingOption = sizingOption;
}
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
{
CGSize size = {
constrainedSize.max.width,
constrainedSize.max.height
};
BOOL reduceWidth = (_horizontalPosition & ASRelativeLayoutSpecPositionCenter) != 0 ||
(_horizontalPosition & ASRelativeLayoutSpecPositionEnd) != 0;
BOOL reduceHeight = (_verticalPosition & ASRelativeLayoutSpecPositionCenter) != 0 ||
(_verticalPosition & ASRelativeLayoutSpecPositionEnd) != 0;
// Layout the child
const CGSize minChildSize = {
reduceWidth ? 0 : constrainedSize.min.width,
reduceHeight ? 0 : constrainedSize.min.height,
};
ASLayout *sublayout = [self.child measureWithSizeRange:ASSizeRangeMake(minChildSize, constrainedSize.max)];
// If we have an undetermined height or width, use the child size to define the layout
// size
size = ASSizeRangeClamp(constrainedSize, {
isfinite(size.width) == NO ? sublayout.size.width : size.width,
isfinite(size.height) == NO ? sublayout.size.height : size.height
});
// If minimum size options are set, attempt to shrink the size to the size of the child
size = ASSizeRangeClamp(constrainedSize, {
MIN(size.width, (_sizingOption & ASRelativeLayoutSpecSizingOptionMinimumWidth) != 0 ? sublayout.size.width : size.width),
MIN(size.height, (_sizingOption & ASRelativeLayoutSpecSizingOptionMinimumHeight) != 0 ? sublayout.size.height : size.height)
});
// Compute the position for the child on each axis according to layout parameters
CGFloat xPosition = [self proportionOfAxisForAxisPosition:_horizontalPosition];
CGFloat yPosition = [self proportionOfAxisForAxisPosition:_verticalPosition];
sublayout.position = {
ASRoundPixelValue((size.width - sublayout.size.width) * xPosition),
ASRoundPixelValue((size.height - sublayout.size.height) * yPosition)
};
return [ASLayout layoutWithLayoutableObject:self size:size sublayouts:@[sublayout]];
}
- (void)setChildren:(NSArray *)children
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
}
- (NSArray *)children
{
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
return nil;
}
- (CGFloat)proportionOfAxisForAxisPosition:(ASRelativeLayoutSpecPosition)position
{
if ((position & ASRelativeLayoutSpecPositionCenter) != 0) {
return 0.5f;
} else if ((position & ASRelativeLayoutSpecPositionEnd) != 0) {
return 1.0f;
} else {
return 0.0f;
}
}
@end

View File

@@ -34,19 +34,6 @@ BOOL ASSubclassOverridesClassSelector(Class superclass, Class subclass, SEL sele
return (superclassIMP != subclassIMP);
}
static void ASDispatchOnceOnMainThread(dispatch_once_t *predicate, dispatch_block_t block)
{
if (ASDisplayNodeThreadIsMain()) {
dispatch_once(predicate, block);
} else {
if (DISPATCH_EXPECT(*predicate == 0L, NO)) {
dispatch_sync(dispatch_get_main_queue(), ^{
dispatch_once(predicate, block);
});
}
}
}
void ASPerformBlockOnMainThread(void (^block)())
{
if (ASDisplayNodeThreadIsMain()) {
@@ -67,12 +54,13 @@ void ASPerformBlockOnBackgroundThread(void (^block)())
CGFloat ASScreenScale()
{
static CGFloat _scale;
static CGFloat __scale = 0.0;
static dispatch_once_t onceToken;
ASDispatchOnceOnMainThread(&onceToken, ^{
_scale = [UIScreen mainScreen].scale;
dispatch_once(&onceToken, ^{
ASDisplayNodeCAssertMainThread();
__scale = [[UIScreen mainScreen] scale];
});
return _scale;
return __scale;
}
CGFloat ASFloorPixelValue(CGFloat f)

View File

@@ -8,12 +8,11 @@
*
*/
#pragma once
#import <UIKit/UIKit.h>
#import "ASEqualityHelpers.h"
#ifndef ComponentKit_ASTextKitAttributes_h
#define ComponentKit_ASTextKitAttributes_h
@protocol ASTextKitTruncating;
extern NSString *const ASTextKitTruncationAttributeName;
@@ -141,5 +140,3 @@ struct ASTextKitAttributes {
size_t hash() const;
};
#endif

View File

@@ -38,10 +38,14 @@ static const ASSizeRange kSize = {{100, 120}, {320, 160}};
- (void)testWithSizingOptions
{
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:ASCenterLayoutSpecSizingOptionDefault];
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:ASCenterLayoutSpecSizingOptionMinimumX];
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:ASCenterLayoutSpecSizingOptionMinimumY];
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:ASCenterLayoutSpecSizingOptionMinimumXY];
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone
sizingOptions:ASCenterLayoutSpecSizingOptionDefault];
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone
sizingOptions:ASCenterLayoutSpecSizingOptionMinimumX];
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone
sizingOptions:ASCenterLayoutSpecSizingOptionMinimumY];
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone
sizingOptions:ASCenterLayoutSpecSizingOptionMinimumXY];
}
- (void)testWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)options
@@ -51,14 +55,7 @@ static const ASSizeRange kSize = {{100, 120}, {320, 160}};
ASStaticSizeDisplayNode *foregroundNode = ASDisplayNodeWithBackgroundColor([UIColor greenColor]);
foregroundNode.staticSize = {70, 100};
ASLayoutSpec *layoutSpec =
[ASBackgroundLayoutSpec
backgroundLayoutSpecWithChild:
[ASCenterLayoutSpec
centerLayoutSpecWithCenteringOptions:options
sizingOptions:sizingOptions
child:foregroundNode]
background:backgroundNode];
ASLayoutSpec *layoutSpec = [ASBackgroundLayoutSpec backgroundLayoutSpecWithChild:[ASCenterLayoutSpec centerLayoutSpecWithCenteringOptions:options sizingOptions:sizingOptions child:foregroundNode]background:backgroundNode];
[self testLayoutSpec:layoutSpec
sizeRange:kSize
@@ -97,14 +94,7 @@ static NSString *suffixForCenteringOptions(ASCenterLayoutSpecCenteringOptions ce
foregroundNode.staticSize = {10, 10};
foregroundNode.flexGrow = YES;
ASCenterLayoutSpec *layoutSpec =
[ASCenterLayoutSpec
centerLayoutSpecWithCenteringOptions:ASCenterLayoutSpecCenteringNone
sizingOptions:{}
child:
[ASBackgroundLayoutSpec
backgroundLayoutSpecWithChild:[ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[foregroundNode]]
background:backgroundNode]];
ASCenterLayoutSpec *layoutSpec = [ASCenterLayoutSpec centerLayoutSpecWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:{} child:[ASBackgroundLayoutSpec backgroundLayoutSpecWithChild:[ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[foregroundNode]] background:backgroundNode]];
[self testLayoutSpec:layoutSpec sizeRange:kSize subnodes:@[backgroundNode, foregroundNode] identifier:nil];
}

View File

@@ -0,0 +1,130 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#import "ASLayoutSpecSnapshotTestsHelper.h"
#import "ASBackgroundLayoutSpec.h"
#import "ASRelativeLayoutSpec.h"
#import "ASStackLayoutSpec.h"
#import "ASLayoutOptions.h"
static const ASSizeRange kSize = {{100, 120}, {320, 160}};
@interface ASRelativeLayoutSpecSnapshotTests : ASLayoutSpecSnapshotTestCase
@end
@implementation ASRelativeLayoutSpecSnapshotTests
- (void)setUp
{
[super setUp];
self.recordMode = NO;
}
- (void)testWithOptions
{
[self testAllVerticalPositionsForHorizontalPosition:ASRelativeLayoutSpecPositionStart];
[self testAllVerticalPositionsForHorizontalPosition:ASRelativeLayoutSpecPositionCenter];
[self testAllVerticalPositionsForHorizontalPosition:ASRelativeLayoutSpecPositionEnd];
}
- (void)testAllVerticalPositionsForHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition {
[self testWithHorizontalPosition:horizontalPosition verticalPosition:ASRelativeLayoutSpecPositionStart sizingOptions:{}];
[self testWithHorizontalPosition:horizontalPosition verticalPosition:ASRelativeLayoutSpecPositionCenter sizingOptions:{}];
[self testWithHorizontalPosition:horizontalPosition verticalPosition:ASRelativeLayoutSpecPositionEnd sizingOptions:{}];
}
- (void)testWithSizingOptions
{
[self testWithHorizontalPosition:ASRelativeLayoutSpecPositionStart
verticalPosition:ASRelativeLayoutSpecPositionStart
sizingOptions:ASRelativeLayoutSpecSizingOptionDefault];
[self testWithHorizontalPosition:ASRelativeLayoutSpecPositionStart
verticalPosition:ASRelativeLayoutSpecPositionStart
sizingOptions:ASRelativeLayoutSpecSizingOptionMinimumWidth];
[self testWithHorizontalPosition:ASRelativeLayoutSpecPositionStart
verticalPosition:ASRelativeLayoutSpecPositionStart
sizingOptions:ASRelativeLayoutSpecSizingOptionMinimumHeight];
[self testWithHorizontalPosition:ASRelativeLayoutSpecPositionStart
verticalPosition:ASRelativeLayoutSpecPositionStart
sizingOptions:ASRelativeLayoutSpecSizingOptionMinimumSize];
}
- (void)testWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition
verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition
sizingOptions:(ASRelativeLayoutSpecSizingOption)sizingOptions
{
ASDisplayNode *backgroundNode = ASDisplayNodeWithBackgroundColor([UIColor redColor]);
ASStaticSizeDisplayNode *foregroundNode = ASDisplayNodeWithBackgroundColor([UIColor greenColor]);
foregroundNode.staticSize = {70, 100};
ASLayoutSpec *layoutSpec =
[ASBackgroundLayoutSpec
backgroundLayoutSpecWithChild:
[ASRelativeLayoutSpec
relativePositionLayoutSpecWithHorizontalPosition:horizontalPosition verticalPosition:verticalPosition sizingOption:sizingOptions child:foregroundNode]
background:backgroundNode];
[self testLayoutSpec:layoutSpec
sizeRange:kSize
subnodes:@[backgroundNode, foregroundNode]
identifier:suffixForPositionOptions(horizontalPosition, verticalPosition, sizingOptions)];
}
static NSString *suffixForPositionOptions(ASRelativeLayoutSpecPosition horizontalPosition,
ASRelativeLayoutSpecPosition verticalPosition,
ASRelativeLayoutSpecSizingOption sizingOptions)
{
NSMutableString *suffix = [NSMutableString string];
if ((horizontalPosition & ASRelativeLayoutSpecPositionCenter) != 0) {
[suffix appendString:@"CenterX"];
} else if ((horizontalPosition & ASRelativeLayoutSpecPositionEnd) != 0) {
[suffix appendString:@"EndX"];
}
if ((verticalPosition & ASRelativeLayoutSpecPositionCenter) != 0) {
[suffix appendString:@"CenterY"];
} else if ((verticalPosition & ASRelativeLayoutSpecPositionEnd) != 0) {
[suffix appendString:@"EndY"];
}
if ((sizingOptions & ASRelativeLayoutSpecSizingOptionMinimumWidth) != 0) {
[suffix appendString:@"SizingMinimumWidth"];
}
if ((sizingOptions & ASRelativeLayoutSpecSizingOptionMinimumHeight) != 0) {
[suffix appendString:@"SizingMinimumHeight"];
}
return suffix;
}
- (void)testMinimumSizeRangeIsGivenToChildWhenNotPositioning
{
ASDisplayNode *backgroundNode = ASDisplayNodeWithBackgroundColor([UIColor redColor]);
ASStaticSizeDisplayNode *foregroundNode = ASDisplayNodeWithBackgroundColor([UIColor redColor]);
foregroundNode.staticSize = {10, 10};
foregroundNode.flexGrow = YES;
ASLayoutSpec *childSpec = [ASBackgroundLayoutSpec
backgroundLayoutSpecWithChild:[ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[foregroundNode]]
background:backgroundNode];
ASRelativeLayoutSpec *layoutSpec = [ASRelativeLayoutSpec
relativePositionLayoutSpecWithHorizontalPosition:ASRelativeLayoutSpecPositionStart verticalPosition:ASRelativeLayoutSpecPositionStart sizingOption:{} child:childSpec];
[self testLayoutSpec:layoutSpec sizeRange:kSize subnodes:@[backgroundNode, foregroundNode] identifier:nil];
}
@end

View File

@@ -144,18 +144,6 @@
@implementation ASTableViewTests
- (void)setUp
{
/// Load a display node before the first test.
/// Without this, running this suite specifically
/// (as opposed to all tests) will cause a deadlock
/// because of the dispatch_sync in `ASScreenScale()`.
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[ASDisplayNode new];
});
}
// TODO: Convert this to ARC.
- (void)DISABLED_testTableViewDoesNotRetainItselfAndDelegate
{

View File

@@ -8,7 +8,8 @@
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "ASVideoNode.h"
#import <AVFoundation/AVFoundation.h>
#import <AsyncDisplayKit/AsyncDisplayKit.h>
@interface ASVideoNodeTests : XCTestCase
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -9,6 +9,7 @@
#pragma once
#import <Foundation/NSException.h>
#import <pthread.h>
#define ASDisplayNodeAssertWithSignalAndLogFunction(condition, description, logFunction, ...) NSAssert(condition, description, ##__VA_ARGS__);
#define ASDisplayNodeCAssertWithSignalAndLogFunction(condition, description, logFunction, ...) NSCAssert(condition, description, ##__VA_ARGS__);
@@ -30,11 +31,11 @@
#define ASDisplayNodeAssertNotInstantiable() ASDisplayNodeAssertWithSignal(NO, nil, @"This class is not instantiable.");
#define ASDisplayNodeAssertNotSupported() ASDisplayNodeAssertWithSignal(NO, nil, @"This method is not supported by class %@", [self class]);
#define ASDisplayNodeAssertMainThread() ASDisplayNodeAssertWithSignal([NSThread isMainThread], nil, @"This method must be called on the main thread")
#define ASDisplayNodeCAssertMainThread() ASDisplayNodeCAssertWithSignal([NSThread isMainThread], nil, @"This function must be called on the main thread")
#define ASDisplayNodeAssertMainThread() ASDisplayNodeAssertWithSignal(0 != pthread_main_np(), nil, @"This method must be called on the main thread")
#define ASDisplayNodeCAssertMainThread() ASDisplayNodeCAssertWithSignal(0 != pthread_main_np(), nil, @"This function must be called on the main thread")
#define ASDisplayNodeAssertNotMainThread() ASDisplayNodeAssertWithSignal(![NSThread isMainThread], nil, @"This method must be called off the main thread")
#define ASDisplayNodeCAssertNotMainThread() ASDisplayNodeCAssertWithSignal(![NSThread isMainThread], nil, @"This function must be called off the main thread")
#define ASDisplayNodeAssertNotMainThread() ASDisplayNodeAssertWithSignal(0 == pthread_main_np(), nil, @"This method must be called off the main thread")
#define ASDisplayNodeCAssertNotMainThread() ASDisplayNodeCAssertWithSignal(0 == pthread_main_np(), nil, @"This function must be called off the main thread")
#define ASDisplayNodeAssertFlag(X) ASDisplayNodeAssertWithSignal((1 == __builtin_popcount(X)), nil, nil)
#define ASDisplayNodeCAssertFlag(X) ASDisplayNodeCAssertWithSignal((1 == __builtin_popcount(X)), nil, nil)

View File

@@ -35,13 +35,35 @@ if [ "$MODE" = "examples" ]; then
for example in examples/*/; do
echo "Building $example."
pod install --project-directory=$example
xctool \
-workspace "${example}Sample.xcworkspace" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build
if [ -f "${example}/Podfile" ]; then
echo "Using CocoaPods"
pod install --project-directory=$example
xctool \
-workspace "${example}Sample.xcworkspace" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build
elif [ -f "${example}/Cartfile" ]; then
echo "Using Carthage"
local_repo=`pwd`
current_branch=`git rev-parse --abbrev-ref HEAD`
cd $example
echo "git \"file://${local_repo}\" \"${current_branch}\"" > "Cartfile"
carthage update --platform iOS
xctool \
-project "Sample.xcodeproj" \
-scheme Sample \
-sdk "$SDK" \
-destination "$PLATFORM" \
build
cd ../..
fi
done
trap - EXIT
exit 0

View File

@@ -0,0 +1 @@
git "file:///build.sh/will/put/local/absolute/path/here" "master"

View File

@@ -0,0 +1,17 @@
//
// AppDelegate.h
// CarthageExample
//
// Created by Engin Kurutepe on 23/02/16.
// Copyright © 2016 Engin Kurutepe. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

View File

@@ -0,0 +1,47 @@
//
// AppDelegate.m
// CarthageExample
//
// Created by Engin Kurutepe on 23/02/16.
// Copyright © 2016 Engin Kurutepe. All rights reserved.
//
@import AsyncDisplayKit;
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end

View File

@@ -0,0 +1,38 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>

View File

@@ -0,0 +1,40 @@
<?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>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,15 @@
//
// ViewController.h
// CarthageExample
//
// Created by Engin Kurutepe on 23/02/16.
// Copyright © 2016 Engin Kurutepe. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end

View File

@@ -0,0 +1,36 @@
//
// ViewController.m
// CarthageExample
//
// Created by Engin Kurutepe on 23/02/16.
// Copyright © 2016 Engin Kurutepe. All rights reserved.
//
@import AsyncDisplayKit;
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
CGSize screenSize = self.view.bounds.size;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
ASTextNode *node = [[ASTextNode alloc] init];
node.attributedString = [[NSAttributedString alloc] initWithString:@"hello world"];
[node measure:(CGSize){.width = screenSize.width, .height = CGFLOAT_MAX}];
node.frame = (CGRect) {.origin = (CGPoint){.x = 100, .y = 100}, .size = node.calculatedSize };
dispatch_async(dispatch_get_main_queue(), ^{
[self.view addSubview:node.view];
});
});
}
@end

View File

@@ -0,0 +1,16 @@
//
// main.m
// CarthageExample
//
// Created by Engin Kurutepe on 23/02/16.
// Copyright © 2016 Engin Kurutepe. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}

View File

@@ -0,0 +1,7 @@
This project is supposed to test that the `AsyncDisplayKit.framework` built by Carthage from the master branch can be imported as a module without causing any warnings and errors.
Steps to verify:
- Run `carthage update --platform iOS`
- Build `CarthageExample.xcodeproj`
- Verify that there are 0 Errors and 0 Warnings

View File

@@ -0,0 +1,349 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
871BB34E1C7C98B1005CF62A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 871BB34D1C7C98B1005CF62A /* main.m */; };
871BB3511C7C98B1005CF62A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 871BB3501C7C98B1005CF62A /* AppDelegate.m */; };
871BB3541C7C98B1005CF62A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 871BB3531C7C98B1005CF62A /* ViewController.m */; };
871BB3571C7C98B1005CF62A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 871BB3551C7C98B1005CF62A /* Main.storyboard */; };
871BB3591C7C98B1005CF62A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 871BB3581C7C98B1005CF62A /* Assets.xcassets */; };
871BB35C1C7C98B1005CF62A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 871BB35A1C7C98B1005CF62A /* LaunchScreen.storyboard */; };
871BB3651C7C99B0005CF62A /* AsyncDisplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 871BB3641C7C99B0005CF62A /* AsyncDisplayKit.framework */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
871BB3491C7C98B1005CF62A /* CarthageExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CarthageExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
871BB34D1C7C98B1005CF62A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
871BB34F1C7C98B1005CF62A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
871BB3501C7C98B1005CF62A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
871BB3521C7C98B1005CF62A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
871BB3531C7C98B1005CF62A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
871BB3561C7C98B1005CF62A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
871BB3581C7C98B1005CF62A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
871BB35B1C7C98B1005CF62A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
871BB35D1C7C98B1005CF62A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
871BB3641C7C99B0005CF62A /* AsyncDisplayKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AsyncDisplayKit.framework; path = Carthage/Build/iOS/AsyncDisplayKit.framework; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
871BB3461C7C98B1005CF62A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
871BB3651C7C99B0005CF62A /* AsyncDisplayKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
871BB3401C7C98B1005CF62A = {
isa = PBXGroup;
children = (
871BB34B1C7C98B1005CF62A /* CarthageExample */,
871BB34A1C7C98B1005CF62A /* Products */,
);
sourceTree = "<group>";
};
871BB34A1C7C98B1005CF62A /* Products */ = {
isa = PBXGroup;
children = (
871BB3491C7C98B1005CF62A /* CarthageExample.app */,
);
name = Products;
sourceTree = "<group>";
};
871BB34B1C7C98B1005CF62A /* CarthageExample */ = {
isa = PBXGroup;
children = (
871BB34F1C7C98B1005CF62A /* AppDelegate.h */,
871BB3501C7C98B1005CF62A /* AppDelegate.m */,
871BB3581C7C98B1005CF62A /* Assets.xcassets */,
871BB3631C7C9994005CF62A /* Frameworks */,
871BB35D1C7C98B1005CF62A /* Info.plist */,
871BB35A1C7C98B1005CF62A /* LaunchScreen.storyboard */,
871BB3551C7C98B1005CF62A /* Main.storyboard */,
871BB34C1C7C98B1005CF62A /* Supporting Files */,
871BB3521C7C98B1005CF62A /* ViewController.h */,
871BB3531C7C98B1005CF62A /* ViewController.m */,
);
path = CarthageExample;
sourceTree = "<group>";
};
871BB34C1C7C98B1005CF62A /* Supporting Files */ = {
isa = PBXGroup;
children = (
871BB34D1C7C98B1005CF62A /* main.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
871BB3631C7C9994005CF62A /* Frameworks */ = {
isa = PBXGroup;
children = (
871BB3641C7C99B0005CF62A /* AsyncDisplayKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
871BB3481C7C98B1005CF62A /* CarthageExample */ = {
isa = PBXNativeTarget;
buildConfigurationList = 871BB3601C7C98B1005CF62A /* Build configuration list for PBXNativeTarget "CarthageExample" */;
buildPhases = (
871BB3451C7C98B1005CF62A /* Sources */,
871BB3461C7C98B1005CF62A /* Frameworks */,
871BB3471C7C98B1005CF62A /* Resources */,
871BB3661C7C99B8005CF62A /* Copy Framworks */,
);
buildRules = (
);
dependencies = (
);
name = CarthageExample;
productName = CarthageExample;
productReference = 871BB3491C7C98B1005CF62A /* CarthageExample.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
871BB3411C7C98B1005CF62A /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0720;
ORGANIZATIONNAME = "Engin Kurutepe";
TargetAttributes = {
871BB3481C7C98B1005CF62A = {
CreatedOnToolsVersion = 7.2.1;
};
};
};
buildConfigurationList = 871BB3441C7C98B1005CF62A /* Build configuration list for PBXProject "CarthageExample" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 871BB3401C7C98B1005CF62A;
productRefGroup = 871BB34A1C7C98B1005CF62A /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
871BB3481C7C98B1005CF62A /* CarthageExample */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
871BB3471C7C98B1005CF62A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
871BB35C1C7C98B1005CF62A /* LaunchScreen.storyboard in Resources */,
871BB3591C7C98B1005CF62A /* Assets.xcassets in Resources */,
871BB3571C7C98B1005CF62A /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
871BB3661C7C99B8005CF62A /* Copy Framworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"$(SRCROOT)/Carthage/Build/iOS/AsyncDisplayKit.framework",
);
name = "Copy Framworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/usr/local/bin/carthage copy-frameworks";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
871BB3451C7C98B1005CF62A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
871BB3541C7C98B1005CF62A /* ViewController.m in Sources */,
871BB3511C7C98B1005CF62A /* AppDelegate.m in Sources */,
871BB34E1C7C98B1005CF62A /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
871BB3551C7C98B1005CF62A /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
871BB3561C7C98B1005CF62A /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
871BB35A1C7C98B1005CF62A /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
871BB35B1C7C98B1005CF62A /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
871BB35E1C7C98B1005CF62A /* 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;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
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 = 9.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
871BB35F1C7C98B1005CF62A /* 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 = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
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 = 9.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
871BB3611C7C98B1005CF62A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = CarthageExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.asyncdisplaykit.CarthageExample;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
871BB3621C7C98B1005CF62A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = CarthageExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = org.asyncdisplaykit.CarthageExample;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
871BB3441C7C98B1005CF62A /* Build configuration list for PBXProject "CarthageExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
871BB35E1C7C98B1005CF62A /* Debug */,
871BB35F1C7C98B1005CF62A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
871BB3601C7C98B1005CF62A /* Build configuration list for PBXNativeTarget "CarthageExample" */ = {
isa = XCConfigurationList;
buildConfigurations = (
871BB3611C7C98B1005CF62A /* Debug */,
871BB3621C7C98B1005CF62A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 871BB3411C7C98B1005CF62A /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:CarthageExample.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,8 @@
<?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>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "871BB3481C7C98B1005CF62A"
BuildableName = "CarthageExample.app"
BlueprintName = "CarthageExample"
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>
<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">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "871BB3481C7C98B1005CF62A"
BuildableName = "CarthageExample.app"
BlueprintName = "CarthageExample"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "871BB3481C7C98B1005CF62A"
BuildableName = "CarthageExample.app"
BlueprintName = "CarthageExample"
ReferencedContainer = "container:Sample.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -119,7 +119,7 @@
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds
{
if (!CGRectEqualToRect(self.collectionView.bounds, newBounds)) {
if (!CGSizeEqualToSize(self.collectionView.bounds.size, newBounds.size)) {
return YES;
}
return NO;