Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Begin PBXBuildFile section */
044284FD1BAA365100D16268 /* UICollectionViewLayout+ASConvenience.m in Sources */ = {isa = PBXBuildFile; fileRef = 205F0E0E1B371875007741D0 /* UICollectionViewLayout+ASConvenience.m */; };
044284FE1BAA387800D16268 /* ASStackLayoutSpecUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED461B17847A00DA7C62 /* ASStackLayoutSpecUtilities.h */; };
044284FE1BAA387800D16268 /* ASStackLayoutSpecUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED461B17847A00DA7C62 /* ASStackLayoutSpecUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
044284FF1BAA3BD600D16268 /* UICollectionViewLayout+ASConvenience.h in Headers */ = {isa = PBXBuildFile; fileRef = 205F0E0D1B371875007741D0 /* UICollectionViewLayout+ASConvenience.h */; settings = {ATTRIBUTES = (Public, ); }; };
044285071BAA63FE00D16268 /* ASBatchFetching.h in Headers */ = {isa = PBXBuildFile; fileRef = 044285051BAA63FE00D16268 /* ASBatchFetching.h */; };
044285081BAA63FE00D16268 /* ASBatchFetching.h in Headers */ = {isa = PBXBuildFile; fileRef = 044285051BAA63FE00D16268 /* ASBatchFetching.h */; };
Expand Down Expand Up @@ -398,6 +398,10 @@
B350625D1B0111740018CF92 /* Photos.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943141A1575670030A7D0 /* Photos.framework */; };
B350625E1B0111780018CF92 /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051943121A1575630030A7D0 /* AssetsLibrary.framework */; };
B350625F1B0111800018CF92 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 058D09AF195D04C000B7D73C /* Foundation.framework */; };
B36D5B781BF38EF100AFFD83 /* ASVisualEffectNode.h in Headers */ = {isa = PBXBuildFile; fileRef = B36D5B761BF38EF100AFFD83 /* ASVisualEffectNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
B36D5B791BF38EF100AFFD83 /* ASVisualEffectNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = B36D5B771BF38EF100AFFD83 /* ASVisualEffectNode.mm */; };
B37B23C91BF5A7F000CC59F6 /* ASVisualEffectNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = B36D5B771BF38EF100AFFD83 /* ASVisualEffectNode.mm */; };
B37B23CA1BF5B7B900CC59F6 /* ASVisualEffectNode.h in Headers */ = {isa = PBXBuildFile; fileRef = B36D5B761BF38EF100AFFD83 /* ASVisualEffectNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
CC7FD9DE1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = CC7FD9DC1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
CC7FD9DF1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = CC7FD9DD1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m */; };
CC7FD9E11BB5F750005CCB2B /* ASPhotosFrameworkImageRequestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC7FD9E01BB5F750005CCB2B /* ASPhotosFrameworkImageRequestTests.m */; };
Expand Down Expand Up @@ -667,6 +671,8 @@
B0F880591BEAEC7500D17647 /* ASTableNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASTableNode.m; sourceTree = "<group>"; };
B35061DA1B010EDF0018CF92 /* AsyncDisplayKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = AsyncDisplayKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B35061DD1B010EDF0018CF92 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = "../AsyncDisplayKit-iOS/Info.plist"; sourceTree = "<group>"; };
B36D5B761BF38EF100AFFD83 /* ASVisualEffectNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASVisualEffectNode.h; sourceTree = "<group>"; };
B36D5B771BF38EF100AFFD83 /* ASVisualEffectNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASVisualEffectNode.mm; sourceTree = "<group>"; };
CC7FD9DC1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASPhotosFrameworkImageRequest.h; sourceTree = "<group>"; };
CC7FD9DD1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPhotosFrameworkImageRequest.m; sourceTree = "<group>"; };
CC7FD9E01BB5F750005CCB2B /* ASPhotosFrameworkImageRequestTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASPhotosFrameworkImageRequestTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -824,6 +830,8 @@
058D09E0195D050800B7D73C /* ASTextNode.mm */,
ACC945A81BA9E7A0005E1FB8 /* ASViewController.h */,
ACC945AA1BA9E7C1005E1FB8 /* ASViewController.m */,
B36D5B761BF38EF100AFFD83 /* ASVisualEffectNode.h */,
B36D5B771BF38EF100AFFD83 /* ASVisualEffectNode.mm */,
6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */,
058D09E1195D050800B7D73C /* Details */,
058D0A01195D050800B7D73C /* Private */,
Expand Down Expand Up @@ -1187,6 +1195,7 @@
058D0A7F195D05F900B7D73C /* ASSentinel.h in Headers */,
9C8221951BA237B80037F19A /* ASStackBaselinePositionedLayout.h in Headers */,
9C49C36F1B853957000B0DD5 /* ASStackLayoutable.h in Headers */,
B36D5B781BF38EF100AFFD83 /* ASVisualEffectNode.h in Headers */,
AC21EC101B3D0BF600C8B19A /* ASStackLayoutDefines.h in Headers */,
CC7FD9DE1BB5E962005CCB2B /* ASPhotosFrameworkImageRequest.h in Headers */,
ACF6ED2F1B17843500DA7C62 /* ASStackLayoutSpec.h in Headers */,
Expand Down Expand Up @@ -1299,8 +1308,9 @@
34EFC7701B701CFA00AD841F /* ASStackLayoutDefines.h in Headers */,
CC7FD9E21BB603FF005CCB2B /* ASPhotosFrameworkImageRequest.h in Headers */,
34EFC7711B701CFF00AD841F /* ASStackLayoutSpec.h in Headers */,
2767E9411BB19BD600EA9B77 /* ASViewController.h in Headers */,
044284FE1BAA387800D16268 /* ASStackLayoutSpecUtilities.h in Headers */,
2767E9411BB19BD600EA9B77 /* ASViewController.h in Headers */,
B37B23CA1BF5B7B900CC59F6 /* ASVisualEffectNode.h in Headers */,
34EFC7751B701D2400AD841F /* ASStackPositionedLayout.h in Headers */,
34EFC7771B701D2D00AD841F /* ASStackUnpositionedLayout.h in Headers */,
9C6BB3B31B8CC9C200F13F52 /* ASStaticLayoutable.h in Headers */,
Expand Down Expand Up @@ -1407,6 +1417,9 @@
058D09A4195D04C000B7D73C /* Project object */ = {
isa = PBXProject;
attributes = {
KnownAssetTags = (
New,
);
LastUpgradeCheck = 0710;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
Expand Down Expand Up @@ -1545,6 +1558,7 @@
0549634A1A1EA066000F8E56 /* ASBasicImageDownloader.mm in Sources */,
299DA1AA1A828D2900162D41 /* ASBatchContext.mm in Sources */,
AC6456091B0A335000CF11B8 /* ASCellNode.m in Sources */,
B36D5B791BF38EF100AFFD83 /* ASVisualEffectNode.mm in Sources */,
ACF6ED1D1B17843500DA7C62 /* ASCenterLayoutSpec.mm in Sources */,
18C2ED801B9B7DE800F627B3 /* ASCollectionNode.m in Sources */,
AC3C4A521A1139C100143C57 /* ASCollectionView.mm in Sources */,
Expand Down Expand Up @@ -1719,6 +1733,7 @@
B35062331B010EFD0018CF92 /* ASTextNodeShadower.m in Sources */,
B35062351B010EFD0018CF92 /* ASTextNodeTextKitHelpers.mm in Sources */,
B35062381B010EFD0018CF92 /* ASTextNodeWordKerner.m in Sources */,
B37B23C91BF5A7F000CC59F6 /* ASVisualEffectNode.mm in Sources */,
509E68661B3AEDD7009B9150 /* CGRect+ASConvenience.m in Sources */,
34566CB31BC1213700715E6B /* ASPhotosFrameworkImageRequest.m in Sources */,
B350623B1B010EFD0018CF92 /* NSMutableAttributedString+TextKitAdditions.m in Sources */,
Expand Down
8 changes: 8 additions & 0 deletions AsyncDisplayKit/ASDisplayNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,14 @@ typedef void (^ASDisplayNodeDidLoadBlock)(ASDisplayNode *node);
*/
- (CGRect)convertRect:(CGRect)rect fromNode:(ASDisplayNode *)node;

/**
* @abstract Returns the view by which this node's subnode views get added to.
*
* @discussion This property can be overriden in a subclass for nodes whose
* backing views expect subviews to be added to a separate view.
**/
@property (nonatomic, readonly) UIView *parentViewForSubnodeViews;

@end


Expand Down
10 changes: 8 additions & 2 deletions AsyncDisplayKit/ASDisplayNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1215,15 +1215,14 @@ - (void)insertSubnode:(ASDisplayNode *)subnode atIndex:(NSInteger)idx
[self _insertSubnode:subnode atSubnodeIndex:idx sublayerIndex:sublayerIndex andRemoveSubnode:nil];
}


- (void)_addSubnodeSubviewOrSublayer:(ASDisplayNode *)subnode
{
ASDisplayNodeAssertMainThread();
ASDisplayNodeAssert(self.nodeLoaded, @"_addSubnodeSubview: should never be called before our own view is created");

BOOL canUseViewAPI = !self.isLayerBacked && !subnode.isLayerBacked;
if (canUseViewAPI) {
[_view addSubview:subnode.view];
[self.parentViewForSubnodeViews addSubview:subnode.view];
} else {
// Disallow subviews in a layer-backed node
ASDisplayNodeAssert(subnode.isLayerBacked, @"Cannot add a subview to a layer-backed node; only sublayers permitted.");
Expand Down Expand Up @@ -2048,6 +2047,13 @@ - (void)_enqueueAsyncSizingWithSentinel:(ASSentinel *)sentinel completion:(void(
return self;
}

- (UIView *)parentViewForSubnodeViews
{
ASDisplayNodeAssert(!_flags.layerBacked, @"Call to -parentViewForSubnodeViews undefined on layer-backed nodes");
ASDN::MutexLocker l(_propertyLock);
return _view;
}

@end

@implementation ASDisplayNode (Debugging)
Expand Down
43 changes: 43 additions & 0 deletions AsyncDisplayKit/ASVisualEffectNode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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 <AsyncDisplayKit/AsyncDisplayKit.h>

/**
* This node adds a visual effect to any background for iOS8 and above.
* Use this with an ASBackgroundLayoutSpec to layer it behind another node.
*
* Notes: If the node has trouble rendering you may have to send it's view
* to the back on `didLoad`.
*
* Future plans: Child nodes should have their views added to the visualEffectView's
* contentView and not it's subview.
**/
NS_CLASS_AVAILABLE_IOS(8_0) @interface ASVisualEffectNode : ASDisplayNode

/**
* Initialize with a visual effect.
* @param visualEffect The UIVisualEffect which will be used to create the
* UIVisualEffectView
**/
- (instancetype)initWithEffect:(UIVisualEffect*)visualEffect;

/**
* Return a ASVisualEffectNode with a blur effect.
* @param effectStyle The style of blur to use to create the blur effect.
**/
+ (instancetype)blurNodeWithEffect:(UIBlurEffectStyle)effectStyle;

/**
* Returns the node's view as a UIVisualEffectView
**/
@property (nonatomic, readonly) UIVisualEffectView *visualEffectView;

@end
56 changes: 56 additions & 0 deletions AsyncDisplayKit/ASVisualEffectNode.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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 "ASVisualEffectNode.h"

#import "ASThread.h"

@interface ASVisualEffectNode ()
{
ASDN::RecursiveMutex _propertyLock;
}
@end

@implementation ASVisualEffectNode

+ (instancetype)blurNodeWithEffect:(UIBlurEffectStyle)effectStyle
{
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:effectStyle];
return [[self alloc] initWithEffect:blurEffect];
}

- (instancetype)initWithEffect:(UIVisualEffect*)visualEffect
{
return [self initWithViewBlock:^UIView *{
_visualEffectView = [[UIVisualEffectView alloc] initWithEffect:visualEffect];
_visualEffectView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
return _visualEffectView;
}];
}

- (instancetype)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock didLoadBlock:(ASDisplayNodeDidLoadBlock)didLoadBlock
{
ASDisplayNodeAssertNotSupported();
return nil;
}

- (void)setLayerBacked:(BOOL)layerBacked
{
// ASRangeController expects ASVisualEffectNode to be view-backed. (Layer-backing is supported on ASCellNode subnodes.)
ASDisplayNodeAssert(!layerBacked, @"ASVisualEffectNode does not support layer-backing.");
}

- (UIView *)parentViewForSubnodeViews
{
ASDN::MutexLocker l(_propertyLock);
return self.visualEffectView.contentView;
}

@end
2 changes: 1 addition & 1 deletion AsyncDisplayKit/AsyncDisplayKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#import <AsyncDisplayKit/ASCollectionView.h>
#import <AsyncDisplayKit/ASCollectionNode.h>
#import <AsyncDisplayKit/ASCellNode.h>

#import <AsyncDisplayKit/ASScrollNode.h>
#import <AsyncDisplayKit/ASVisualEffectNode.h>

#import <AsyncDisplayKit/ASViewController.h>

Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ SPEC CHECKSUMS:
FBSnapshotTestCase: 3dc3899168747a0319c5278f5b3445c13a6532dd
OCMock: a6a7dc0e3997fb9f35d99f72528698ebf60d64f2

COCOAPODS: 0.38.2
COCOAPODS: 0.39.0