mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-10 16:29:55 +00:00
Merge pull request #1693 from rcancro/traitUpdate
[ASTraitCollection] Bug fixing/LayoutSpec propagation
This commit is contained in:
commit
e5eed560e1
@ -589,8 +589,8 @@
|
|||||||
E55D86331CA8A14000A0C26F /* ASLayoutable.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55D86311CA8A14000A0C26F /* ASLayoutable.mm */; };
|
E55D86331CA8A14000A0C26F /* ASLayoutable.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55D86311CA8A14000A0C26F /* ASLayoutable.mm */; };
|
||||||
E5711A2B1C840C81009619D4 /* ASIndexedNodeContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
E5711A2B1C840C81009619D4 /* ASIndexedNodeContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
E5711A2C1C840C81009619D4 /* ASIndexedNodeContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */; };
|
E5711A2C1C840C81009619D4 /* ASIndexedNodeContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */; };
|
||||||
E5711A2E1C840C96009619D4 /* ASIndexedNodeContext.m in Sources */ = {isa = PBXBuildFile; fileRef = E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.m */; };
|
E5711A2E1C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */; };
|
||||||
E5711A301C840C96009619D4 /* ASIndexedNodeContext.m in Sources */ = {isa = PBXBuildFile; fileRef = E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.m */; };
|
E5711A301C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -955,7 +955,7 @@
|
|||||||
E52405B41C8FEF16004DC8E7 /* ASLayoutTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutTransition.h; sourceTree = "<group>"; };
|
E52405B41C8FEF16004DC8E7 /* ASLayoutTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutTransition.h; sourceTree = "<group>"; };
|
||||||
E55D86311CA8A14000A0C26F /* ASLayoutable.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayoutable.mm; path = AsyncDisplayKit/Layout/ASLayoutable.mm; sourceTree = "<group>"; };
|
E55D86311CA8A14000A0C26F /* ASLayoutable.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayoutable.mm; path = AsyncDisplayKit/Layout/ASLayoutable.mm; sourceTree = "<group>"; };
|
||||||
E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIndexedNodeContext.h; sourceTree = "<group>"; };
|
E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIndexedNodeContext.h; sourceTree = "<group>"; };
|
||||||
E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIndexedNodeContext.m; sourceTree = "<group>"; };
|
E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASIndexedNodeContext.mm; sourceTree = "<group>"; };
|
||||||
EFA731F0396842FF8AB635EE /* libPods-AsyncDisplayKitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AsyncDisplayKitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
EFA731F0396842FF8AB635EE /* libPods-AsyncDisplayKitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AsyncDisplayKitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
FB07EABBCF28656C6297BC2D /* Pods-AsyncDisplayKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AsyncDisplayKitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests.debug.xcconfig"; sourceTree = "<group>"; };
|
FB07EABBCF28656C6297BC2D /* Pods-AsyncDisplayKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AsyncDisplayKitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
@ -1417,7 +1417,7 @@
|
|||||||
AC026B671BD57D6F00BBC17E /* ASChangeSetDataController.h */,
|
AC026B671BD57D6F00BBC17E /* ASChangeSetDataController.h */,
|
||||||
AC026B681BD57D6F00BBC17E /* ASChangeSetDataController.m */,
|
AC026B681BD57D6F00BBC17E /* ASChangeSetDataController.m */,
|
||||||
E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */,
|
E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */,
|
||||||
E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.m */,
|
E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */,
|
||||||
);
|
);
|
||||||
name = "Data Controller";
|
name = "Data Controller";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -2114,7 +2114,7 @@
|
|||||||
205F0E121B371BD7007741D0 /* ASScrollDirection.m in Sources */,
|
205F0E121B371BD7007741D0 /* ASScrollDirection.m in Sources */,
|
||||||
9C8898BB1C738B9800D6B02E /* ASTextKitFontSizeAdjuster.mm in Sources */,
|
9C8898BB1C738B9800D6B02E /* ASTextKitFontSizeAdjuster.mm in Sources */,
|
||||||
D785F6631A74327E00291744 /* ASScrollNode.m in Sources */,
|
D785F6631A74327E00291744 /* ASScrollNode.m in Sources */,
|
||||||
E5711A2E1C840C96009619D4 /* ASIndexedNodeContext.m in Sources */,
|
E5711A2E1C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */,
|
||||||
058D0A2C195D050800B7D73C /* ASSentinel.m in Sources */,
|
058D0A2C195D050800B7D73C /* ASSentinel.m in Sources */,
|
||||||
9C8221971BA237B80037F19A /* ASStackBaselinePositionedLayout.mm in Sources */,
|
9C8221971BA237B80037F19A /* ASStackBaselinePositionedLayout.mm in Sources */,
|
||||||
251B8EF81BBB3D690087C538 /* ASCollectionDataController.mm in Sources */,
|
251B8EF81BBB3D690087C538 /* ASCollectionDataController.mm in Sources */,
|
||||||
@ -2242,7 +2242,7 @@
|
|||||||
69E100701CA89CB600D88C1B /* ASEnvironmentInternal.mm in Sources */,
|
69E100701CA89CB600D88C1B /* ASEnvironmentInternal.mm in Sources */,
|
||||||
254C6B891BF94F8A003EC431 /* ASTextKitRenderer+Positioning.mm in Sources */,
|
254C6B891BF94F8A003EC431 /* ASTextKitRenderer+Positioning.mm in Sources */,
|
||||||
68355B341CB579B9001D4E68 /* ASImageNode+AnimatedImage.mm in Sources */,
|
68355B341CB579B9001D4E68 /* ASImageNode+AnimatedImage.mm in Sources */,
|
||||||
E5711A301C840C96009619D4 /* ASIndexedNodeContext.m in Sources */,
|
E5711A301C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */,
|
||||||
B35062511B010EFD0018CF92 /* ASDisplayNode+UIViewBridge.mm in Sources */,
|
B35062511B010EFD0018CF92 /* ASDisplayNode+UIViewBridge.mm in Sources */,
|
||||||
B35061FC1B010EFD0018CF92 /* ASDisplayNode.mm in Sources */,
|
B35061FC1B010EFD0018CF92 /* ASDisplayNode.mm in Sources */,
|
||||||
B35061FF1B010EFD0018CF92 /* ASDisplayNodeExtras.mm in Sources */,
|
B35061FF1B010EFD0018CF92 /* ASDisplayNodeExtras.mm in Sources */,
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#import "ASCollectionViewLayoutFacilitatorProtocol.h"
|
#import "ASCollectionViewLayoutFacilitatorProtocol.h"
|
||||||
#import "ASDisplayNode+Subclasses.h"
|
#import "ASDisplayNode+Subclasses.h"
|
||||||
#import "ASEnvironmentInternal.h"
|
#import "ASEnvironmentInternal.h"
|
||||||
|
#import "ASInternalHelpers.h"
|
||||||
#import "ASRangeControllerUpdateRangeProtocol+Beta.h"
|
#import "ASRangeControllerUpdateRangeProtocol+Beta.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@ -1252,7 +1252,7 @@ static bool disableNotificationsForMovingBetweenParents(ASDisplayNode *from, ASD
|
|||||||
// This call will apply our .hierarchyState to the new subnode.
|
// This call will apply our .hierarchyState to the new subnode.
|
||||||
// If we are a managed hierarchy, as in ASCellNode trees, it will also apply our .interfaceState.
|
// If we are a managed hierarchy, as in ASCellNode trees, it will also apply our .interfaceState.
|
||||||
[subnode __setSupernode:self];
|
[subnode __setSupernode:self];
|
||||||
|
|
||||||
if (self.nodeLoaded) {
|
if (self.nodeLoaded) {
|
||||||
// If this node has a view or layer, force the subnode to also create its view or layer and add it to the hierarchy here.
|
// If this node has a view or layer, force the subnode to also create its view or layer and add it to the hierarchy here.
|
||||||
// Otherwise there is no way for the subnode's view or layer to enter the hierarchy, except recursing down all
|
// Otherwise there is no way for the subnode's view or layer to enter the hierarchy, except recursing down all
|
||||||
@ -1298,7 +1298,7 @@ static bool disableNotificationsForMovingBetweenParents(ASDisplayNode *from, ASD
|
|||||||
_subnodes = [[NSMutableArray alloc] init];
|
_subnodes = [[NSMutableArray alloc] init];
|
||||||
[_subnodes insertObject:subnode atIndex:subnodeIndex];
|
[_subnodes insertObject:subnode atIndex:subnodeIndex];
|
||||||
[subnode __setSupernode:self];
|
[subnode __setSupernode:self];
|
||||||
|
|
||||||
// Don't bother inserting the view/layer if in a rasterized subtree, because there are no layers in the hierarchy and none of this could possibly work.
|
// Don't bother inserting the view/layer if in a rasterized subtree, because there are no layers in the hierarchy and none of this could possibly work.
|
||||||
if (!_flags.shouldRasterizeDescendants && [self __shouldLoadViewOrLayer]) {
|
if (!_flags.shouldRasterizeDescendants && [self __shouldLoadViewOrLayer]) {
|
||||||
if (_layer) {
|
if (_layer) {
|
||||||
@ -1740,6 +1740,9 @@ static NSInteger incrementIfFound(NSInteger i) {
|
|||||||
|
|
||||||
[self exitHierarchyState:stateToEnterOrExit];
|
[self exitHierarchyState:stateToEnterOrExit];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now that we have a supernode, propagate its traits to self.
|
||||||
|
ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1902,6 +1905,7 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
|||||||
if ((_methodOverrides & ASDisplayNodeMethodOverrideLayoutSpecThatFits) || _layoutSpecBlock != NULL) {
|
if ((_methodOverrides & ASDisplayNodeMethodOverrideLayoutSpecThatFits) || _layoutSpecBlock != NULL) {
|
||||||
ASLayoutSpec *layoutSpec = [self layoutSpecThatFits:constrainedSize];
|
ASLayoutSpec *layoutSpec = [self layoutSpecThatFits:constrainedSize];
|
||||||
layoutSpec.parent = self; // This causes upward propogation of any non-default layoutable values.
|
layoutSpec.parent = self; // This causes upward propogation of any non-default layoutable values.
|
||||||
|
layoutSpec.traitCollection = self.asyncTraitCollection;
|
||||||
layoutSpec.isMutable = NO;
|
layoutSpec.isMutable = NO;
|
||||||
ASLayout *layout = [layoutSpec measureWithSizeRange:constrainedSize];
|
ASLayout *layout = [layoutSpec measureWithSizeRange:constrainedSize];
|
||||||
// Make sure layoutableObject of the root layout is `self`, so that the flattened layout will be structurally correct.
|
// Make sure layoutableObject of the root layout is `self`, so that the flattened layout will be structurally correct.
|
||||||
@ -2722,7 +2726,12 @@ static const char *ASDisplayNodeDrawingPriorityKey = "ASDrawingPriority";
|
|||||||
|
|
||||||
- (ASEnvironmentTraitCollection)environmentTraitCollection
|
- (ASEnvironmentTraitCollection)environmentTraitCollection
|
||||||
{
|
{
|
||||||
return _environmentState.traitCollection;
|
return _environmentState.environmentTraitCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setEnvironmentTraitCollection:(ASEnvironmentTraitCollection)environmentTraitCollection
|
||||||
|
{
|
||||||
|
_environmentState.environmentTraitCollection = environmentTraitCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASEnvironmentLayoutOptionsForwarding
|
ASEnvironmentLayoutOptionsForwarding
|
||||||
@ -2731,7 +2740,7 @@ ASEnvironmentLayoutExtensibilityForwarding
|
|||||||
- (ASTraitCollection *)asyncTraitCollection
|
- (ASTraitCollection *)asyncTraitCollection
|
||||||
{
|
{
|
||||||
ASDN::MutexLocker l(_propertyLock);
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
return [ASTraitCollection traitCollectionWithASEnvironmentTraitCollection:_environmentState.traitCollection];
|
return [ASTraitCollection traitCollectionWithASEnvironmentTraitCollection:self.environmentTraitCollection];
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
|
|||||||
@ -7,10 +7,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "ASEnvironmentInternal.h"
|
#import "ASEnvironmentInternal.h"
|
||||||
#import "ASFlowLayoutController.h"
|
|
||||||
#import "ASTableViewInternal.h"
|
|
||||||
#import "ASDisplayNode+Subclasses.h"
|
#import "ASDisplayNode+Subclasses.h"
|
||||||
|
#import "ASFlowLayoutController.h"
|
||||||
|
#import "ASInternalHelpers.h"
|
||||||
#import "ASRangeControllerUpdateRangeProtocol+Beta.h"
|
#import "ASRangeControllerUpdateRangeProtocol+Beta.h"
|
||||||
|
#import "ASTableViewInternal.h"
|
||||||
|
|
||||||
@interface _ASTablePendingState : NSObject
|
@interface _ASTablePendingState : NSObject
|
||||||
@property (weak, nonatomic) id <ASTableDelegate> delegate;
|
@property (weak, nonatomic) id <ASTableDelegate> delegate;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ typedef ASTraitCollection * _Nonnull (^ASDisplayTraitsForTraitWindowSizeBlock)(C
|
|||||||
* ASVC keeps a strong reference to the context to make sure that it stays alive. If you change this value
|
* ASVC keeps a strong reference to the context to make sure that it stays alive. If you change this value
|
||||||
* it will propagate the change to the subnodes.
|
* it will propagate the change to the subnodes.
|
||||||
*/
|
*/
|
||||||
@property (nonatomic, strong) id _Nullable traitColectionContext;
|
@property (nonatomic, strong) id _Nullable traitCollectionContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set this block to customize the ASDisplayTraits returned when the VC transitions to the given traitCollection.
|
* Set this block to customize the ASDisplayTraits returned when the VC transitions to the given traitCollection.
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#import "ASViewController.h"
|
#import "ASViewController.h"
|
||||||
#import "ASAssert.h"
|
#import "ASAssert.h"
|
||||||
|
#import "ASAvailability.h"
|
||||||
#import "ASDimension.h"
|
#import "ASDimension.h"
|
||||||
#import "ASDisplayNodeInternal.h"
|
#import "ASDisplayNodeInternal.h"
|
||||||
#import "ASDisplayNode+FrameworkPrivate.h"
|
#import "ASDisplayNode+FrameworkPrivate.h"
|
||||||
@ -55,12 +56,12 @@
|
|||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
if (_traitColectionContext != nil) {
|
if (_traitCollectionContext != nil) {
|
||||||
// The setter will iterate through the VC's subnodes and replace the traitCollectionContext in their ASEnvironmentTraitCollection with nil.
|
// The setter will iterate through the VC's subnodes and replace the traitCollectionContext in their ASEnvironmentTraitCollection with nil.
|
||||||
// Since the VC holds the only strong reference to this context and we are in the process of destroying
|
// Since the VC holds the only strong reference to this context and we are in the process of destroying
|
||||||
// the VC, all the references in the subnodes will be unsafe unless we nil them out. More than likely all the subnodes will be dealloc'ed
|
// the VC, all the references in the subnodes will be unsafe unless we nil them out. More than likely all the subnodes will be dealloc'ed
|
||||||
// as part of the VC being dealloc'ed, but this is just to make extra sure.
|
// as part of the VC being dealloc'ed, but this is just to make extra sure.
|
||||||
self.traitColectionContext = nil;
|
self.traitCollectionContext = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +83,13 @@
|
|||||||
_node.frame = frame;
|
_node.frame = frame;
|
||||||
_node.autoresizingMask = autoresizingMask;
|
_node.autoresizingMask = autoresizingMask;
|
||||||
self.view = view;
|
self.view = view;
|
||||||
|
|
||||||
|
// ensure that self.node has a valid trait collection before a subclass's implementation of viewDidLoad.
|
||||||
|
// Any subnodes added in viewDidLoad will then inherit the proper environment.
|
||||||
|
if (AS_AT_LEAST_IOS8) {
|
||||||
|
ASEnvironmentTraitCollection traitCollection = [self environmentTraitCollectionForUITraitCollection:self.traitCollection];
|
||||||
|
[self progagateNewEnvironmentTraitCollection:traitCollection];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewWillLayoutSubviews
|
- (void)viewWillLayoutSubviews
|
||||||
@ -187,52 +195,53 @@ ASVisibilityDepthImplementation;
|
|||||||
|
|
||||||
#pragma mark - ASEnvironmentTraitCollection
|
#pragma mark - ASEnvironmentTraitCollection
|
||||||
|
|
||||||
- (void)setTraitColectionContext:(id)traitColectionContext
|
- (void)setTraitCollectionContext:(id)traitCollectionContext
|
||||||
{
|
{
|
||||||
if (_traitColectionContext != traitColectionContext) {
|
if (_traitCollectionContext != traitCollectionContext) {
|
||||||
// propagate first so that nodes aren't hanging around with a dealloc'ed pointer
|
// nil out the displayContext in the subnodes so they aren't hanging around with a dealloc'ed pointer don't set
|
||||||
ASEnvironmentTraitCollectionUpdateDisplayContext(self.node, traitColectionContext);
|
// the new context yet as this will cause ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection to fail
|
||||||
|
ASEnvironmentTraitCollectionUpdateDisplayContext(self.node, nil);
|
||||||
|
|
||||||
_traitColectionContext = traitColectionContext;
|
_traitCollectionContext = traitCollectionContext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASEnvironmentTraitCollection)displayTraitsForTraitCollection:(UITraitCollection *)traitCollection
|
- (ASEnvironmentTraitCollection)environmentTraitCollectionForUITraitCollection:(UITraitCollection *)traitCollection
|
||||||
{
|
{
|
||||||
if (self.overrideDisplayTraitsWithTraitCollection) {
|
if (self.overrideDisplayTraitsWithTraitCollection) {
|
||||||
ASTraitCollection *asyncTraitCollection = self.overrideDisplayTraitsWithTraitCollection(traitCollection);
|
ASTraitCollection *asyncTraitCollection = self.overrideDisplayTraitsWithTraitCollection(traitCollection);
|
||||||
self.traitColectionContext = asyncTraitCollection.traitCollectionContext;
|
self.traitCollectionContext = asyncTraitCollection.traitCollectionContext;
|
||||||
return [asyncTraitCollection environmentTraitCollection];
|
return [asyncTraitCollection environmentTraitCollection];
|
||||||
}
|
}
|
||||||
|
|
||||||
ASEnvironmentTraitCollection asyncTraitCollection = ASEnvironmentTraitCollectionFromUITraitCollection(traitCollection);
|
ASEnvironmentTraitCollection asyncTraitCollection = ASEnvironmentTraitCollectionFromUITraitCollection(traitCollection);
|
||||||
asyncTraitCollection.displayContext = self.traitColectionContext;
|
asyncTraitCollection.displayContext = self.traitCollectionContext;
|
||||||
return asyncTraitCollection;
|
return asyncTraitCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASEnvironmentTraitCollection)displayTraitsForWindowSize:(CGSize)windowSize
|
- (ASEnvironmentTraitCollection)environmentTraitCollectionForWindowSize:(CGSize)windowSize
|
||||||
{
|
{
|
||||||
if (self.overrideDisplayTraitsWithWindowSize) {
|
if (self.overrideDisplayTraitsWithWindowSize) {
|
||||||
ASTraitCollection *traitCollection = self.overrideDisplayTraitsWithWindowSize(windowSize);
|
ASTraitCollection *traitCollection = self.overrideDisplayTraitsWithWindowSize(windowSize);
|
||||||
self.traitColectionContext = traitCollection.traitCollectionContext;
|
self.traitCollectionContext = traitCollection.traitCollectionContext;
|
||||||
return [traitCollection environmentTraitCollection];
|
return [traitCollection environmentTraitCollection];
|
||||||
}
|
}
|
||||||
return self.node.environmentTraitCollection;
|
return self.node.environmentTraitCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)progagateNewDisplayTraits:(ASEnvironmentTraitCollection)traitCollection
|
- (void)progagateNewEnvironmentTraitCollection:(ASEnvironmentTraitCollection)environmentTraitCollection
|
||||||
{
|
{
|
||||||
ASEnvironmentState environmentState = self.node.environmentState;
|
ASEnvironmentState environmentState = self.node.environmentState;
|
||||||
ASEnvironmentTraitCollection oldTraitCollection = environmentState.traitCollection;
|
ASEnvironmentTraitCollection oldEnvironmentTraitCollection = environmentState.environmentTraitCollection;
|
||||||
|
|
||||||
if (ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(traitCollection, oldTraitCollection) == NO) {
|
if (ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(environmentTraitCollection, oldEnvironmentTraitCollection) == NO) {
|
||||||
environmentState.traitCollection = traitCollection;
|
environmentState.environmentTraitCollection = environmentTraitCollection;
|
||||||
self.node.environmentState = environmentState;
|
self.node.environmentState = environmentState;
|
||||||
[self.node setNeedsLayout];
|
[self.node setNeedsLayout];
|
||||||
|
|
||||||
NSArray<id<ASEnvironment>> *children = [self.node children];
|
NSArray<id<ASEnvironment>> *children = [self.node children];
|
||||||
for (id<ASEnvironment> child in children) {
|
for (id<ASEnvironment> child in children) {
|
||||||
ASEnvironmentStatePropagateDown(child, environmentState.traitCollection);
|
ASEnvironmentStatePropagateDown(child, environmentState.environmentTraitCollection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,24 +250,24 @@ ASVisibilityDepthImplementation;
|
|||||||
{
|
{
|
||||||
[super traitCollectionDidChange:previousTraitCollection];
|
[super traitCollectionDidChange:previousTraitCollection];
|
||||||
|
|
||||||
ASEnvironmentTraitCollection traitCollection = [self displayTraitsForTraitCollection:self.traitCollection];
|
ASEnvironmentTraitCollection environmentTraitCollection = [self environmentTraitCollectionForUITraitCollection:self.traitCollection];
|
||||||
[self progagateNewDisplayTraits:traitCollection];
|
[self progagateNewEnvironmentTraitCollection:environmentTraitCollection];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
||||||
{
|
{
|
||||||
[super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
|
[super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator];
|
||||||
|
|
||||||
ASEnvironmentTraitCollection traitCollection = [self displayTraitsForTraitCollection:newCollection];
|
ASEnvironmentTraitCollection environmentTraitCollection = [self environmentTraitCollectionForUITraitCollection:newCollection];
|
||||||
[self progagateNewDisplayTraits:traitCollection];
|
[self progagateNewEnvironmentTraitCollection:environmentTraitCollection];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
|
||||||
{
|
{
|
||||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||||
|
|
||||||
ASEnvironmentTraitCollection traitCollection = [self displayTraitsForWindowSize:size];
|
ASEnvironmentTraitCollection environmentTraitCollection = [self environmentTraitCollectionForWindowSize:size];
|
||||||
[self progagateNewDisplayTraits:traitCollection];
|
[self progagateNewEnvironmentTraitCollection:environmentTraitCollection];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -158,6 +158,9 @@
|
|||||||
|
|
||||||
- (void)_populateSupplementaryNodesOfKind:(NSString *)kind withMutableContexts:(NSMutableArray<ASIndexedNodeContext *> *)contexts
|
- (void)_populateSupplementaryNodesOfKind:(NSString *)kind withMutableContexts:(NSMutableArray<ASIndexedNodeContext *> *)contexts
|
||||||
{
|
{
|
||||||
|
id<ASEnvironment> environment = [self.environmentDelegate dataControllerEnvironment];
|
||||||
|
ASEnvironmentTraitCollection environmentTraitCollection = environment.environmentTraitCollection;
|
||||||
|
|
||||||
NSUInteger sectionCount = [self.collectionDataSource dataController:self numberOfSectionsForSupplementaryNodeOfKind:kind];
|
NSUInteger sectionCount = [self.collectionDataSource dataController:self numberOfSectionsForSupplementaryNodeOfKind:kind];
|
||||||
for (NSUInteger i = 0; i < sectionCount; i++) {
|
for (NSUInteger i = 0; i < sectionCount; i++) {
|
||||||
NSIndexPath *sectionIndexPath = [[NSIndexPath alloc] initWithIndex:i];
|
NSIndexPath *sectionIndexPath = [[NSIndexPath alloc] initWithIndex:i];
|
||||||
@ -176,7 +179,8 @@
|
|||||||
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:kind atIndexPath:indexPath];
|
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:kind atIndexPath:indexPath];
|
||||||
ASIndexedNodeContext *context = [[ASIndexedNodeContext alloc] initWithNodeBlock:supplementaryCellBlock
|
ASIndexedNodeContext *context = [[ASIndexedNodeContext alloc] initWithNodeBlock:supplementaryCellBlock
|
||||||
indexPath:indexPath
|
indexPath:indexPath
|
||||||
constrainedSize:constrainedSize];
|
constrainedSize:constrainedSize
|
||||||
|
environmentTraitCollection:environmentTraitCollection];
|
||||||
[contexts addObject:context];
|
[contexts addObject:context];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,6 +188,9 @@
|
|||||||
|
|
||||||
- (void)_populateSupplementaryNodesOfKind:(NSString *)kind withSections:(NSIndexSet *)sections mutableContexts:(NSMutableArray<ASIndexedNodeContext *> *)contexts
|
- (void)_populateSupplementaryNodesOfKind:(NSString *)kind withSections:(NSIndexSet *)sections mutableContexts:(NSMutableArray<ASIndexedNodeContext *> *)contexts
|
||||||
{
|
{
|
||||||
|
id<ASEnvironment> environment = [self.environmentDelegate dataControllerEnvironment];
|
||||||
|
ASEnvironmentTraitCollection environmentTraitCollection = environment.environmentTraitCollection;
|
||||||
|
|
||||||
[sections enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
[sections enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
||||||
NSUInteger rowNum = [self.collectionDataSource dataController:self supplementaryNodesOfKind:kind inSection:idx];
|
NSUInteger rowNum = [self.collectionDataSource dataController:self supplementaryNodesOfKind:kind inSection:idx];
|
||||||
NSIndexPath *sectionIndex = [[NSIndexPath alloc] initWithIndex:idx];
|
NSIndexPath *sectionIndex = [[NSIndexPath alloc] initWithIndex:idx];
|
||||||
@ -201,7 +208,8 @@
|
|||||||
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:kind atIndexPath:indexPath];
|
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:kind atIndexPath:indexPath];
|
||||||
ASIndexedNodeContext *context = [[ASIndexedNodeContext alloc] initWithNodeBlock:supplementaryCellBlock
|
ASIndexedNodeContext *context = [[ASIndexedNodeContext alloc] initWithNodeBlock:supplementaryCellBlock
|
||||||
indexPath:indexPath
|
indexPath:indexPath
|
||||||
constrainedSize:constrainedSize];
|
constrainedSize:constrainedSize
|
||||||
|
environmentTraitCollection:environmentTraitCollection];
|
||||||
[contexts addObject:context];
|
[contexts addObject:context];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|||||||
@ -519,6 +519,9 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
*/
|
*/
|
||||||
- (NSArray<ASIndexedNodeContext *> *)_populateFromDataSourceWithSectionIndexSet:(NSIndexSet *)indexSet
|
- (NSArray<ASIndexedNodeContext *> *)_populateFromDataSourceWithSectionIndexSet:(NSIndexSet *)indexSet
|
||||||
{
|
{
|
||||||
|
id<ASEnvironment> environment = [self.environmentDelegate dataControllerEnvironment];
|
||||||
|
ASEnvironmentTraitCollection environmentTraitCollection = environment.environmentTraitCollection;
|
||||||
|
|
||||||
NSMutableArray<ASIndexedNodeContext *> *contexts = [NSMutableArray array];
|
NSMutableArray<ASIndexedNodeContext *> *contexts = [NSMutableArray array];
|
||||||
[indexSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
[indexSet enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
|
||||||
NSUInteger rowNum = [_dataSource dataController:self rowsInSection:idx];
|
NSUInteger rowNum = [_dataSource dataController:self rowsInSection:idx];
|
||||||
@ -527,18 +530,11 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
NSIndexPath *indexPath = [sectionIndex indexPathByAddingIndex:i];
|
NSIndexPath *indexPath = [sectionIndex indexPathByAddingIndex:i];
|
||||||
ASCellNodeBlock nodeBlock = [_dataSource dataController:self nodeBlockAtIndexPath:indexPath];
|
ASCellNodeBlock nodeBlock = [_dataSource dataController:self nodeBlockAtIndexPath:indexPath];
|
||||||
|
|
||||||
// When creating a node, make sure to pass along the current display traits so it will be laid out properly
|
|
||||||
ASCellNodeBlock nodeBlockPropagatingDisplayTraits = ^{
|
|
||||||
ASCellNode *cellNode = nodeBlock();
|
|
||||||
id<ASEnvironment> environment = [self.environmentDelegate dataControllerEnvironment];
|
|
||||||
ASEnvironmentStatePropagateDown(cellNode, [environment environmentTraitCollection]);
|
|
||||||
return cellNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:ASDataControllerRowNodeKind atIndexPath:indexPath];
|
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:ASDataControllerRowNodeKind atIndexPath:indexPath];
|
||||||
[contexts addObject:[[ASIndexedNodeContext alloc] initWithNodeBlock:nodeBlockPropagatingDisplayTraits
|
[contexts addObject:[[ASIndexedNodeContext alloc] initWithNodeBlock:nodeBlock
|
||||||
indexPath:indexPath
|
indexPath:indexPath
|
||||||
constrainedSize:constrainedSize]];
|
constrainedSize:constrainedSize
|
||||||
|
environmentTraitCollection:environmentTraitCollection]];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
return contexts;
|
return contexts;
|
||||||
@ -791,12 +787,16 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
NSMutableArray<ASIndexedNodeContext *> *contexts = [[NSMutableArray alloc] initWithCapacity:indexPaths.count];
|
NSMutableArray<ASIndexedNodeContext *> *contexts = [[NSMutableArray alloc] initWithCapacity:indexPaths.count];
|
||||||
|
|
||||||
[self accessDataSourceWithBlock:^{
|
[self accessDataSourceWithBlock:^{
|
||||||
|
id<ASEnvironment> environment = [self.environmentDelegate dataControllerEnvironment];
|
||||||
|
ASEnvironmentTraitCollection environmentTraitCollection = environment.environmentTraitCollection;
|
||||||
|
|
||||||
for (NSIndexPath *indexPath in sortedIndexPaths) {
|
for (NSIndexPath *indexPath in sortedIndexPaths) {
|
||||||
ASCellNodeBlock nodeBlock = [_dataSource dataController:self nodeBlockAtIndexPath:indexPath];
|
ASCellNodeBlock nodeBlock = [_dataSource dataController:self nodeBlockAtIndexPath:indexPath];
|
||||||
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:ASDataControllerRowNodeKind atIndexPath:indexPath];
|
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:ASDataControllerRowNodeKind atIndexPath:indexPath];
|
||||||
[contexts addObject:[[ASIndexedNodeContext alloc] initWithNodeBlock:nodeBlock
|
[contexts addObject:[[ASIndexedNodeContext alloc] initWithNodeBlock:nodeBlock
|
||||||
indexPath:indexPath
|
indexPath:indexPath
|
||||||
constrainedSize:constrainedSize]];
|
constrainedSize:constrainedSize
|
||||||
|
environmentTraitCollection:environmentTraitCollection]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[_editingTransactionQueue addOperationWithBlock:^{
|
[_editingTransactionQueue addOperationWithBlock:^{
|
||||||
@ -842,12 +842,16 @@ static void *kASSizingQueueContext = &kASSizingQueueContext;
|
|||||||
// FIXME: Shouldn't deletes be sorted in descending order?
|
// FIXME: Shouldn't deletes be sorted in descending order?
|
||||||
[indexPaths sortedArrayUsingSelector:@selector(compare:)];
|
[indexPaths sortedArrayUsingSelector:@selector(compare:)];
|
||||||
|
|
||||||
|
id<ASEnvironment> environment = [self.environmentDelegate dataControllerEnvironment];
|
||||||
|
ASEnvironmentTraitCollection environmentTraitCollection = environment.environmentTraitCollection;
|
||||||
|
|
||||||
for (NSIndexPath *indexPath in indexPaths) {
|
for (NSIndexPath *indexPath in indexPaths) {
|
||||||
ASCellNodeBlock nodeBlock = [_dataSource dataController:self nodeBlockAtIndexPath:indexPath];
|
ASCellNodeBlock nodeBlock = [_dataSource dataController:self nodeBlockAtIndexPath:indexPath];
|
||||||
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:ASDataControllerRowNodeKind atIndexPath:indexPath];
|
ASSizeRange constrainedSize = [self constrainedSizeForNodeOfKind:ASDataControllerRowNodeKind atIndexPath:indexPath];
|
||||||
[contexts addObject:[[ASIndexedNodeContext alloc] initWithNodeBlock:nodeBlock
|
[contexts addObject:[[ASIndexedNodeContext alloc] initWithNodeBlock:nodeBlock
|
||||||
indexPath:indexPath
|
indexPath:indexPath
|
||||||
constrainedSize:constrainedSize]];
|
constrainedSize:constrainedSize
|
||||||
|
environmentTraitCollection:environmentTraitCollection]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[_editingTransactionQueue addOperationWithBlock:^{
|
[_editingTransactionQueue addOperationWithBlock:^{
|
||||||
|
|||||||
@ -97,7 +97,7 @@ extern BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(AS
|
|||||||
typedef struct ASEnvironmentState {
|
typedef struct ASEnvironmentState {
|
||||||
struct ASEnvironmentHierarchyState hierarchyState;
|
struct ASEnvironmentHierarchyState hierarchyState;
|
||||||
struct ASEnvironmentLayoutOptionsState layoutOptionsState;
|
struct ASEnvironmentLayoutOptionsState layoutOptionsState;
|
||||||
struct ASEnvironmentTraitCollection traitCollection;
|
struct ASEnvironmentTraitCollection environmentTraitCollection;
|
||||||
} ASEnvironmentState;
|
} ASEnvironmentState;
|
||||||
extern ASEnvironmentState ASEnvironmentStateMakeDefault();
|
extern ASEnvironmentState ASEnvironmentStateMakeDefault();
|
||||||
|
|
||||||
@ -137,6 +137,8 @@ ASDISPLAYNODE_EXTERN_C_END
|
|||||||
/// convenience method. Users should access the trait collections through the NSObject based asyncTraitCollection API
|
/// convenience method. Users should access the trait collections through the NSObject based asyncTraitCollection API
|
||||||
- (ASEnvironmentTraitCollection)environmentTraitCollection;
|
- (ASEnvironmentTraitCollection)environmentTraitCollection;
|
||||||
|
|
||||||
|
/// sets a trait collection on this environment state.
|
||||||
|
- (void)setEnvironmentTraitCollection:(ASEnvironmentTraitCollection)environmentTraitCollection;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ASCollection/TableNodes don't actually have ASCellNodes as subnodes. Because of this we can't rely on display trait
|
// ASCollection/TableNodes don't actually have ASCellNodes as subnodes. Because of this we can't rely on display trait
|
||||||
@ -150,17 +152,19 @@ ASDISPLAYNODE_EXTERN_C_END
|
|||||||
- (void)setEnvironmentState:(ASEnvironmentState)environmentState\
|
- (void)setEnvironmentState:(ASEnvironmentState)environmentState\
|
||||||
{\
|
{\
|
||||||
ASDN::MutexLocker l(lock);\
|
ASDN::MutexLocker l(lock);\
|
||||||
ASEnvironmentTraitCollection oldTraits = self.environmentState.traitCollection;\
|
ASEnvironmentTraitCollection oldTraits = self.environmentState.environmentTraitCollection;\
|
||||||
[super setEnvironmentState:environmentState];\
|
[super setEnvironmentState:environmentState];\
|
||||||
ASEnvironmentTraitCollection currentTraits = environmentState.traitCollection;\
|
ASEnvironmentTraitCollection currentTraits = environmentState.environmentTraitCollection;\
|
||||||
if (ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(currentTraits, oldTraits) == NO) {\
|
if (ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(currentTraits, oldTraits) == NO) {\
|
||||||
NSArray<NSArray <ASCellNode *> *> *completedNodes = [self.view.dataController completedNodes];\
|
ASPerformBlockOnMainThread(^{\
|
||||||
for (NSArray *sectionArray in completedNodes) {\
|
NSArray<NSArray <ASCellNode *> *> *completedNodes = [self.view.dataController completedNodes];\
|
||||||
for (ASCellNode *cellNode in sectionArray) {\
|
for (NSArray *sectionArray in completedNodes) {\
|
||||||
ASEnvironmentStatePropagateDown(cellNode, currentTraits);\
|
for (ASCellNode *cellNode in sectionArray) {\
|
||||||
[cellNode setNeedsLayout];\
|
ASEnvironmentStatePropagateDown(cellNode, currentTraits);\
|
||||||
|
[cellNode setNeedsLayout];\
|
||||||
|
}\
|
||||||
}\
|
}\
|
||||||
}\
|
});\
|
||||||
}\
|
}\
|
||||||
}\
|
}\
|
||||||
|
|
||||||
|
|||||||
@ -29,13 +29,13 @@ ASEnvironmentHierarchyState _ASEnvironmentHierarchyStateMakeDefault()
|
|||||||
extern void ASEnvironmentTraitCollectionUpdateDisplayContext(id<ASEnvironment> rootEnvironment, id context)
|
extern void ASEnvironmentTraitCollectionUpdateDisplayContext(id<ASEnvironment> rootEnvironment, id context)
|
||||||
{
|
{
|
||||||
ASEnvironmentState envState = [rootEnvironment environmentState];
|
ASEnvironmentState envState = [rootEnvironment environmentState];
|
||||||
ASEnvironmentTraitCollection displayTraits = envState.traitCollection;
|
ASEnvironmentTraitCollection environmentTraitCollection = envState.environmentTraitCollection;
|
||||||
displayTraits.displayContext = context;
|
environmentTraitCollection.displayContext = context;
|
||||||
envState.traitCollection = displayTraits;
|
envState.environmentTraitCollection = environmentTraitCollection;
|
||||||
[rootEnvironment setEnvironmentState:envState];
|
[rootEnvironment setEnvironmentState:envState];
|
||||||
|
|
||||||
for (id<ASEnvironment> child in [rootEnvironment children]) {
|
for (id<ASEnvironment> child in [rootEnvironment children]) {
|
||||||
ASEnvironmentStatePropagateDown(child, displayTraits);
|
ASEnvironmentStatePropagateDown(child, environmentTraitCollection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ ASEnvironmentState ASEnvironmentStateMakeDefault()
|
|||||||
return (ASEnvironmentState) {
|
return (ASEnvironmentState) {
|
||||||
.layoutOptionsState = _ASEnvironmentLayoutOptionsStateMakeDefault(),
|
.layoutOptionsState = _ASEnvironmentLayoutOptionsStateMakeDefault(),
|
||||||
.hierarchyState = _ASEnvironmentHierarchyStateMakeDefault(),
|
.hierarchyState = _ASEnvironmentHierarchyStateMakeDefault(),
|
||||||
.traitCollection = _ASEnvironmentTraitCollectionMakeDefault()
|
.environmentTraitCollection = _ASEnvironmentTraitCollectionMakeDefault()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,15 +7,18 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import <AsyncDisplayKit/ASDataController.h>
|
#import <AsyncDisplayKit/ASDataController.h>
|
||||||
|
#import <AsyncDisplayKit/ASEnvironment.h>
|
||||||
|
|
||||||
@interface ASIndexedNodeContext : NSObject
|
@interface ASIndexedNodeContext : NSObject
|
||||||
|
|
||||||
@property (nonatomic, readonly, strong) NSIndexPath *indexPath;
|
@property (nonatomic, readonly, strong) NSIndexPath *indexPath;
|
||||||
@property (nonatomic, readonly, assign) ASSizeRange constrainedSize;
|
@property (nonatomic, readonly, assign) ASSizeRange constrainedSize;
|
||||||
|
@property (nonatomic, readonly, assign) ASEnvironmentTraitCollection environmentTraitCollection;
|
||||||
|
|
||||||
- (instancetype)initWithNodeBlock:(ASCellNodeBlock)nodeBlock
|
- (instancetype)initWithNodeBlock:(ASCellNodeBlock)nodeBlock
|
||||||
indexPath:(NSIndexPath *)indexPath
|
indexPath:(NSIndexPath *)indexPath
|
||||||
constrainedSize:(ASSizeRange)constrainedSize;
|
constrainedSize:(ASSizeRange)constrainedSize
|
||||||
|
environmentTraitCollection:(ASEnvironmentTraitCollection)environmentTraitCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a node allocated by executing node block. Node block will be nil out immediately.
|
* Returns a node allocated by executing node block. Node block will be nil out immediately.
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "ASIndexedNodeContext.h"
|
#import "ASIndexedNodeContext.h"
|
||||||
|
#import "ASEnvironmentInternal.h"
|
||||||
|
#import "ASCellNode.h"
|
||||||
|
|
||||||
@interface ASIndexedNodeContext ()
|
@interface ASIndexedNodeContext ()
|
||||||
|
|
||||||
@ -19,7 +21,8 @@
|
|||||||
|
|
||||||
- (instancetype)initWithNodeBlock:(ASCellNodeBlock)nodeBlock
|
- (instancetype)initWithNodeBlock:(ASCellNodeBlock)nodeBlock
|
||||||
indexPath:(NSIndexPath *)indexPath
|
indexPath:(NSIndexPath *)indexPath
|
||||||
constrainedSize:(ASSizeRange)constrainedSize;
|
constrainedSize:(ASSizeRange)constrainedSize
|
||||||
|
environmentTraitCollection:(ASEnvironmentTraitCollection)environmentTraitCollection
|
||||||
{
|
{
|
||||||
NSAssert(nodeBlock != nil && indexPath != nil, @"Node block and index path must not be nil");
|
NSAssert(nodeBlock != nil && indexPath != nil, @"Node block and index path must not be nil");
|
||||||
self = [super init];
|
self = [super init];
|
||||||
@ -27,6 +30,7 @@
|
|||||||
_nodeBlock = nodeBlock;
|
_nodeBlock = nodeBlock;
|
||||||
_indexPath = indexPath;
|
_indexPath = indexPath;
|
||||||
_constrainedSize = constrainedSize;
|
_constrainedSize = constrainedSize;
|
||||||
|
_environmentTraitCollection = environmentTraitCollection;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -36,6 +40,7 @@
|
|||||||
NSAssert(_nodeBlock != nil, @"Node block is gone. Should not execute it more than once");
|
NSAssert(_nodeBlock != nil, @"Node block is gone. Should not execute it more than once");
|
||||||
ASCellNode *node = _nodeBlock();
|
ASCellNode *node = _nodeBlock();
|
||||||
_nodeBlock = nil;
|
_nodeBlock = nil;
|
||||||
|
ASEnvironmentStatePropagateDown(node, _environmentTraitCollection);
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@
|
|||||||
* Be aware that internally this context is held by a C struct which cannot retain the pointer.
|
* Be aware that internally this context is held by a C struct which cannot retain the pointer.
|
||||||
* ASTraitCollection is generally a very short-lived class, existing only to provide a non-struct API
|
* ASTraitCollection is generally a very short-lived class, existing only to provide a non-struct API
|
||||||
* to trait collections. When an ASTraitCollection is returned via one of ASViewController's 2
|
* to trait collections. When an ASTraitCollection is returned via one of ASViewController's 2
|
||||||
* custom trait collection creation blocks, traitColectionContext is assigned to the VC's traitColectionContext.
|
* custom trait collection creation blocks, traitCollectionContext is assigned to the VC's traitCollectionContext.
|
||||||
* This makes sure that the VC is the owner of the context and ASEnvironmentTraitCollections will not
|
* This makes sure that the VC is the owner of the context and ASEnvironmentTraitCollections will not
|
||||||
* have a reference to a dangling pointer.
|
* have a reference to a dangling pointer.
|
||||||
*/
|
*/
|
||||||
@ -50,5 +50,6 @@
|
|||||||
|
|
||||||
|
|
||||||
- (ASEnvironmentTraitCollection)environmentTraitCollection;
|
- (ASEnvironmentTraitCollection)environmentTraitCollection;
|
||||||
|
- (BOOL)isEqualToTraitCollection:(ASTraitCollection *)traitCollection;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -95,4 +95,14 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isEqualToTraitCollection:(ASTraitCollection *)traitCollection
|
||||||
|
{
|
||||||
|
return self.displayScale == traitCollection.displayScale &&
|
||||||
|
self.horizontalSizeClass == traitCollection.horizontalSizeClass &&
|
||||||
|
self.verticalSizeClass == traitCollection.verticalSizeClass &&
|
||||||
|
self.userInterfaceIdiom == traitCollection.userInterfaceIdiom &&
|
||||||
|
self.traitCollectionContext == traitCollection.traitCollectionContext &&
|
||||||
|
self.forceTouchCapability == traitCollection.forceTouchCapability;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -68,15 +68,4 @@ static NSString * const kBackgroundChildKey = @"kBackgroundChildKey";
|
|||||||
return [super childForIdentifier:kBackgroundChildKey];
|
return [super childForIdentifier:kBackgroundChildKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setChildren:(NSArray *)children
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSArray *)children
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -115,15 +115,4 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner)
|
|||||||
return [ASLayout layoutWithLayoutableObject:self size:computedSize sublayouts:@[sublayout]];
|
return [ASLayout layoutWithLayoutableObject:self size:computedSize 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
#import <AsyncDisplayKit/ASLayoutable.h>
|
#import <AsyncDisplayKit/ASLayoutable.h>
|
||||||
#import <AsyncDisplayKit/ASAsciiArtBoxCreator.h>
|
#import <AsyncDisplayKit/ASAsciiArtBoxCreator.h>
|
||||||
|
|
||||||
|
@class ASTraitCollection;
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
/** A layout spec is an immutable object that describes a layout, loosely inspired by React. */
|
/** A layout spec is an immutable object that describes a layout, loosely inspired by React. */
|
||||||
@ -23,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
@property (nonatomic, assign) BOOL isMutable;
|
@property (nonatomic, assign) BOOL isMutable;
|
||||||
|
|
||||||
|
@property (nonatomic, strong, nullable) ASTraitCollection *traitCollection;
|
||||||
|
|
||||||
- (instancetype)init;
|
- (instancetype)init;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -26,7 +26,6 @@
|
|||||||
ASEnvironmentState _environmentState;
|
ASEnvironmentState _environmentState;
|
||||||
ASDN::RecursiveMutex _propertyLock;
|
ASDN::RecursiveMutex _propertyLock;
|
||||||
|
|
||||||
id<ASLayoutable> _child;
|
|
||||||
NSArray *_children;
|
NSArray *_children;
|
||||||
NSMutableDictionary *_childrenWithIdentifier;
|
NSMutableDictionary *_childrenWithIdentifier;
|
||||||
}
|
}
|
||||||
@ -45,7 +44,7 @@
|
|||||||
}
|
}
|
||||||
_isMutable = YES;
|
_isMutable = YES;
|
||||||
_environmentState = ASEnvironmentStateMakeDefault();
|
_environmentState = ASEnvironmentStateMakeDefault();
|
||||||
|
_children = [NSArray array];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,28 +112,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setChild:(id<ASLayoutable>)child;
|
- (void)setChild:(id<ASLayoutable>)child
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
|
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
|
||||||
|
if (child) {
|
||||||
id<ASLayoutable> finalLayoutable = [self layoutableToAddFromLayoutable:child];
|
id<ASLayoutable> finalLayoutable = [self layoutableToAddFromLayoutable:child];
|
||||||
_child = finalLayoutable;
|
if (finalLayoutable) {
|
||||||
[self propagateUpLayoutable:finalLayoutable];
|
_children = @[finalLayoutable];
|
||||||
|
[self propagateUpLayoutable:finalLayoutable];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// remove the only child
|
||||||
|
_children = [NSArray array];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setChild:(id<ASLayoutable>)child forIdentifier:(NSString *)identifier
|
- (void)setChild:(id<ASLayoutable>)child forIdentifier:(NSString *)identifier
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
|
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
|
||||||
|
if (child) {
|
||||||
id<ASLayoutable> finalLayoutable = [self layoutableToAddFromLayoutable:child];
|
id<ASLayoutable> finalLayoutable = [self layoutableToAddFromLayoutable:child];
|
||||||
self.childrenWithIdentifier[identifier] = finalLayoutable;
|
self.childrenWithIdentifier[identifier] = finalLayoutable;
|
||||||
|
if (finalLayoutable) {
|
||||||
|
_children = [_children arrayByAddingObject:finalLayoutable];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
id<ASLayoutable> oldChild = self.childrenWithIdentifier[identifier];
|
||||||
|
if (oldChild) {
|
||||||
|
self.childrenWithIdentifier[identifier] = nil;
|
||||||
|
NSMutableArray *mutableChildren = [_children mutableCopy];
|
||||||
|
[mutableChildren removeObject:oldChild];
|
||||||
|
_children = [mutableChildren copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Should we propagate up the layoutable at it could happen that multiple children will propagated up their
|
// TODO: Should we propagate up the layoutable at it could happen that multiple children will propagated up their
|
||||||
// layout options and one child will overwrite values from another child
|
// layout options and one child will overwrite values from another child
|
||||||
// [self propagateUpLayoutable:finalLayoutable];
|
// [self propagateUpLayoutable:finalLayoutable];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setChildren:(NSArray *)children
|
- (void)setChildren:(NSArray<id<ASLayoutable>> *)children
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
|
ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");
|
||||||
|
|
||||||
@ -146,6 +163,8 @@
|
|||||||
_children = nil;
|
_children = nil;
|
||||||
if (finalChildren.size() > 0) {
|
if (finalChildren.size() > 0) {
|
||||||
_children = [NSArray arrayWithObjects:&finalChildren[0] count:finalChildren.size()];
|
_children = [NSArray arrayWithObjects:&finalChildren[0] count:finalChildren.size()];
|
||||||
|
} else {
|
||||||
|
_children = [NSArray array];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,14 +175,21 @@
|
|||||||
|
|
||||||
- (id<ASLayoutable>)child
|
- (id<ASLayoutable>)child
|
||||||
{
|
{
|
||||||
return _child;
|
return [_children firstObject];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *)children
|
- (NSArray *)children
|
||||||
{
|
{
|
||||||
return [_children copy];
|
return _children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setTraitCollection:(ASTraitCollection *)traitCollection
|
||||||
|
{
|
||||||
|
if ([traitCollection isEqualToTraitCollection:self.traitCollection] == NO) {
|
||||||
|
_traitCollection = traitCollection;
|
||||||
|
ASEnvironmentStatePropagateDown(self, [traitCollection environmentTraitCollection]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - ASEnvironment
|
#pragma mark - ASEnvironment
|
||||||
|
|
||||||
@ -201,7 +227,12 @@
|
|||||||
|
|
||||||
- (ASEnvironmentTraitCollection)environmentTraitCollection
|
- (ASEnvironmentTraitCollection)environmentTraitCollection
|
||||||
{
|
{
|
||||||
return _environmentState.traitCollection;
|
return _environmentState.environmentTraitCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setEnvironmentTraitCollection:(ASEnvironmentTraitCollection)environmentTraitCollection
|
||||||
|
{
|
||||||
|
_environmentState.environmentTraitCollection = environmentTraitCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
ASEnvironmentLayoutOptionsForwarding
|
ASEnvironmentLayoutOptionsForwarding
|
||||||
@ -210,7 +241,7 @@ ASEnvironmentLayoutExtensibilityForwarding
|
|||||||
- (ASTraitCollection *)asyncTraitCollection
|
- (ASTraitCollection *)asyncTraitCollection
|
||||||
{
|
{
|
||||||
ASDN::MutexLocker l(_propertyLock);
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
return [ASTraitCollection traitCollectionWithASEnvironmentTraitCollection:_environmentState.traitCollection];
|
return [ASTraitCollection traitCollectionWithASEnvironmentTraitCollection:self.environmentTraitCollection];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -61,17 +61,6 @@ static NSString * const kOverlayChildKey = @"kOverlayChildKey";
|
|||||||
return [ASLayout layoutWithLayoutableObject:self size:contentsLayout.size sublayouts:sublayouts];
|
return [ASLayout layoutWithLayoutableObject:self size:contentsLayout.size sublayouts:sublayouts];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setChildren:(NSArray *)children
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSArray *)children
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssert(NO, @"not supported by this layout spec");
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ASOverlayLayoutSpec (Debugging)
|
@implementation ASOverlayLayoutSpec (Debugging)
|
||||||
|
|||||||
@ -75,17 +75,6 @@
|
|||||||
return [ASLayout layoutWithLayoutableObject:self size:sublayout.size sublayouts:@[sublayout]];
|
return [ASLayout layoutWithLayoutableObject:self size:sublayout.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ASRatioLayoutSpec (Debugging)
|
@implementation ASRatioLayoutSpec (Debugging)
|
||||||
|
|||||||
@ -92,17 +92,6 @@
|
|||||||
return [ASLayout layoutWithLayoutableObject:self size:size sublayouts:@[sublayout]];
|
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
|
- (CGFloat)proportionOfAxisForAxisPosition:(ASRelativeLayoutSpecPosition)position
|
||||||
{
|
{
|
||||||
if ((position & ASRelativeLayoutSpecPositionCenter) != 0) {
|
if ((position & ASRelativeLayoutSpecPositionCenter) != 0) {
|
||||||
|
|||||||
@ -121,17 +121,6 @@
|
|||||||
_baselineRelativeArrangement = baselineRelativeArrangement;
|
_baselineRelativeArrangement = baselineRelativeArrangement;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setChild:(id<ASLayoutable>)child forIdentifier:(NSString *)identifier
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssert(NO, @"ASStackLayoutSpec only supports setChildren");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id<ASLayoutable>)childForIdentifier:(NSString *)identifier
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssert(NO, @"ASStackLayoutSpec only supports children");
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
|
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
if (self.children.count == 0) {
|
if (self.children.count == 0) {
|
||||||
|
|||||||
@ -72,17 +72,6 @@
|
|||||||
sublayouts:sublayouts];
|
sublayouts:sublayouts];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setChild:(id<ASLayoutable>)child forIdentifier:(NSString *)identifier
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssert(NO, @"ASStaticLayoutSpec only supports setChildren");
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id<ASLayoutable>)childForIdentifier:(NSString *)identifier
|
|
||||||
{
|
|
||||||
ASDisplayNodeAssert(NO, @"ASStaticLayoutSpec only supports children");
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ASStaticLayoutSpec (ASEnvironment)
|
@implementation ASStaticLayoutSpec (ASEnvironment)
|
||||||
|
|||||||
@ -58,14 +58,14 @@ ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environme
|
|||||||
template <typename ASEnvironmentStateType>
|
template <typename ASEnvironmentStateType>
|
||||||
void ASEnvironmentStatePropagateDown(id<ASEnvironment> object, ASEnvironmentStateType state) {
|
void ASEnvironmentStatePropagateDown(id<ASEnvironment> object, ASEnvironmentStateType state) {
|
||||||
ASEnvironmentPerformBlockOnObjectAndChildren(object, ^(id<ASEnvironment> node) {
|
ASEnvironmentPerformBlockOnObjectAndChildren(object, ^(id<ASEnvironment> node) {
|
||||||
object.environmentState = ASEnvironmentMergeObjectAndState(object.environmentState, state, ASEnvironmentStatePropagation::DOWN);
|
node.environmentState = ASEnvironmentMergeObjectAndState(node.environmentState, state, ASEnvironmentStatePropagation::DOWN);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ASEnvironmentStateType>
|
template <typename ASEnvironmentStateType>
|
||||||
void ASEnvironmentStatePropagateUp(id<ASEnvironment> object, ASEnvironmentStateType state) {
|
void ASEnvironmentStatePropagateUp(id<ASEnvironment> object, ASEnvironmentStateType state) {
|
||||||
ASEnvironmentPerformBlockOnObjectAndParents(object, ^(id<ASEnvironment> node) {
|
ASEnvironmentPerformBlockOnObjectAndParents(object, ^(id<ASEnvironment> node) {
|
||||||
object.environmentState = ASEnvironmentMergeObjectAndState(object.environmentState, state, ASEnvironmentStatePropagation::UP);
|
node.environmentState = ASEnvironmentMergeObjectAndState(node.environmentState, state, ASEnvironmentStatePropagation::UP);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -201,14 +201,14 @@ ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState childEnvi
|
|||||||
|
|
||||||
// Support propagate down
|
// Support propagate down
|
||||||
if (propagation == ASEnvironmentStatePropagation::DOWN) {
|
if (propagation == ASEnvironmentStatePropagation::DOWN) {
|
||||||
ASEnvironmentTraitCollection childTraitCollection = childEnvironmentState.traitCollection;
|
ASEnvironmentTraitCollection childTraitCollection = childEnvironmentState.environmentTraitCollection;
|
||||||
childTraitCollection.horizontalSizeClass = parentTraitCollection.horizontalSizeClass;
|
childTraitCollection.horizontalSizeClass = parentTraitCollection.horizontalSizeClass;
|
||||||
childTraitCollection.verticalSizeClass = parentTraitCollection.verticalSizeClass;
|
childTraitCollection.verticalSizeClass = parentTraitCollection.verticalSizeClass;
|
||||||
childTraitCollection.userInterfaceIdiom = parentTraitCollection.userInterfaceIdiom;
|
childTraitCollection.userInterfaceIdiom = parentTraitCollection.userInterfaceIdiom;
|
||||||
childTraitCollection.forceTouchCapability = parentTraitCollection.forceTouchCapability;
|
childTraitCollection.forceTouchCapability = parentTraitCollection.forceTouchCapability;
|
||||||
childTraitCollection.displayScale = parentTraitCollection.displayScale;
|
childTraitCollection.displayScale = parentTraitCollection.displayScale;
|
||||||
childTraitCollection.displayContext = parentTraitCollection.displayContext;
|
childTraitCollection.displayContext = parentTraitCollection.displayContext;
|
||||||
childEnvironmentState.traitCollection = childTraitCollection;
|
childEnvironmentState.environmentTraitCollection = childTraitCollection;
|
||||||
|
|
||||||
}
|
}
|
||||||
return childEnvironmentState;
|
return childEnvironmentState;
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
source 'https://github.com/CocoaPods/Specs.git'
|
source 'https://github.com/CocoaPods/Specs.git'
|
||||||
platform :ios, '8.0'
|
platform :ios, '7.0'
|
||||||
pod 'AsyncDisplayKit', :path => '../..'
|
target 'Sample' do
|
||||||
|
pod 'AsyncDisplayKit', :path => '../..'
|
||||||
|
end
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
05E2128719D4DB510098F589 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128619D4DB510098F589 /* main.m */; };
|
05E2128719D4DB510098F589 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128619D4DB510098F589 /* main.m */; };
|
||||||
05E2128A19D4DB510098F589 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128919D4DB510098F589 /* AppDelegate.m */; };
|
05E2128A19D4DB510098F589 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128919D4DB510098F589 /* AppDelegate.m */; };
|
||||||
05E2128D19D4DB510098F589 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128C19D4DB510098F589 /* ViewController.m */; };
|
05E2128D19D4DB510098F589 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128C19D4DB510098F589 /* ViewController.m */; };
|
||||||
3EC0CDCBA10D483D9F386E5E /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3D24B17D1E4A4E7A9566C5E9 /* libPods.a */; };
|
1BEECAB53F4B61DCB949ED44 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EEDFC574739077BA65E0CF5 /* libPods-Sample.a */; };
|
||||||
9C37D01E1CC94BC9004C8BC1 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9C37D01D1CC94BC9004C8BC1 /* Launch Screen.storyboard */; };
|
9C37D01E1CC94BC9004C8BC1 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9C37D01D1CC94BC9004C8BC1 /* Launch Screen.storyboard */; };
|
||||||
9CACC7811CCEAF9E009A1613 /* TableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CACC7801CCEAF9E009A1613 /* TableViewController.m */; };
|
9CACC7811CCEAF9E009A1613 /* TableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CACC7801CCEAF9E009A1613 /* TableViewController.m */; };
|
||||||
9CACC7841CCEAFAE009A1613 /* CollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CACC7831CCEAFAE009A1613 /* CollectionViewController.m */; };
|
9CACC7841CCEAFAE009A1613 /* CollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CACC7831CCEAFAE009A1613 /* CollectionViewController.m */; };
|
||||||
@ -19,6 +19,7 @@
|
|||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
056298286C03B7760575CC56 /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
05E2128119D4DB510098F589 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
05E2128119D4DB510098F589 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
05E2128519D4DB510098F589 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
05E2128519D4DB510098F589 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
05E2128619D4DB510098F589 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
05E2128619D4DB510098F589 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
@ -27,6 +28,7 @@
|
|||||||
05E2128B19D4DB510098F589 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
05E2128B19D4DB510098F589 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
|
||||||
05E2128C19D4DB510098F589 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
05E2128C19D4DB510098F589 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
|
||||||
088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
|
088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
|
1EEDFC574739077BA65E0CF5 /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
9C37D01D1CC94BC9004C8BC1 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
|
9C37D01D1CC94BC9004C8BC1 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
|
||||||
9CACC77F1CCEAF9E009A1613 /* TableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewController.h; sourceTree = "<group>"; };
|
9CACC77F1CCEAF9E009A1613 /* TableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewController.h; sourceTree = "<group>"; };
|
||||||
@ -37,6 +39,7 @@
|
|||||||
9CACC7861CCEBD3B009A1613 /* KittenNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KittenNode.m; sourceTree = "<group>"; };
|
9CACC7861CCEBD3B009A1613 /* KittenNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KittenNode.m; sourceTree = "<group>"; };
|
||||||
9CACC7881CCEC82C009A1613 /* OverrideViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverrideViewController.h; sourceTree = "<group>"; };
|
9CACC7881CCEC82C009A1613 /* OverrideViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OverrideViewController.h; sourceTree = "<group>"; };
|
||||||
9CACC7891CCEC82C009A1613 /* OverrideViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OverrideViewController.m; sourceTree = "<group>"; };
|
9CACC7891CCEC82C009A1613 /* OverrideViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OverrideViewController.m; sourceTree = "<group>"; };
|
||||||
|
A7F0013FBBCBEA0C9FB68986 /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@ -45,7 +48,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
3EC0CDCBA10D483D9F386E5E /* libPods.a in Frameworks */,
|
1BEECAB53F4B61DCB949ED44 /* libPods-Sample.a in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -107,6 +110,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */,
|
3D24B17D1E4A4E7A9566C5E9 /* libPods.a */,
|
||||||
|
1EEDFC574739077BA65E0CF5 /* libPods-Sample.a */,
|
||||||
);
|
);
|
||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -116,6 +120,8 @@
|
|||||||
children = (
|
children = (
|
||||||
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */,
|
C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */,
|
||||||
088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */,
|
088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */,
|
||||||
|
056298286C03B7760575CC56 /* Pods-Sample.debug.xcconfig */,
|
||||||
|
A7F0013FBBCBEA0C9FB68986 /* Pods-Sample.release.xcconfig */,
|
||||||
);
|
);
|
||||||
name = Pods;
|
name = Pods;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -127,12 +133,12 @@
|
|||||||
isa = PBXNativeTarget;
|
isa = PBXNativeTarget;
|
||||||
buildConfigurationList = 05E212A419D4DB510098F589 /* Build configuration list for PBXNativeTarget "Sample" */;
|
buildConfigurationList = 05E212A419D4DB510098F589 /* Build configuration list for PBXNativeTarget "Sample" */;
|
||||||
buildPhases = (
|
buildPhases = (
|
||||||
E080B80F89C34A25B3488E26 /* Check Pods Manifest.lock */,
|
E080B80F89C34A25B3488E26 /* 📦 Check Pods Manifest.lock */,
|
||||||
05E2127D19D4DB510098F589 /* Sources */,
|
05E2127D19D4DB510098F589 /* Sources */,
|
||||||
05E2127E19D4DB510098F589 /* Frameworks */,
|
05E2127E19D4DB510098F589 /* Frameworks */,
|
||||||
05E2127F19D4DB510098F589 /* Resources */,
|
05E2127F19D4DB510098F589 /* Resources */,
|
||||||
F012A6F39E0149F18F564F50 /* Copy Pods Resources */,
|
F012A6F39E0149F18F564F50 /* 📦 Copy Pods Resources */,
|
||||||
FFF65E837E66ADA71296F0FF /* Embed Pods Frameworks */,
|
FFF65E837E66ADA71296F0FF /* 📦 Embed Pods Frameworks */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
@ -187,14 +193,14 @@
|
|||||||
/* End PBXResourcesBuildPhase section */
|
/* End PBXResourcesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXShellScriptBuildPhase section */
|
/* Begin PBXShellScriptBuildPhase section */
|
||||||
E080B80F89C34A25B3488E26 /* Check Pods Manifest.lock */ = {
|
E080B80F89C34A25B3488E26 /* 📦 Check Pods Manifest.lock */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
);
|
);
|
||||||
name = "Check Pods Manifest.lock";
|
name = "📦 Check Pods Manifest.lock";
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -202,34 +208,34 @@
|
|||||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
||||||
showEnvVarsInLog = 0;
|
showEnvVarsInLog = 0;
|
||||||
};
|
};
|
||||||
F012A6F39E0149F18F564F50 /* Copy Pods Resources */ = {
|
F012A6F39E0149F18F564F50 /* 📦 Copy Pods Resources */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
);
|
);
|
||||||
name = "Copy Pods Resources";
|
name = "📦 Copy Pods Resources";
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
|
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n";
|
||||||
showEnvVarsInLog = 0;
|
showEnvVarsInLog = 0;
|
||||||
};
|
};
|
||||||
FFF65E837E66ADA71296F0FF /* Embed Pods Frameworks */ = {
|
FFF65E837E66ADA71296F0FF /* 📦 Embed Pods Frameworks */ = {
|
||||||
isa = PBXShellScriptBuildPhase;
|
isa = PBXShellScriptBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
);
|
);
|
||||||
name = "Embed Pods Frameworks";
|
name = "📦 Embed Pods Frameworks";
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n";
|
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n";
|
||||||
showEnvVarsInLog = 0;
|
showEnvVarsInLog = 0;
|
||||||
};
|
};
|
||||||
/* End PBXShellScriptBuildPhase section */
|
/* End PBXShellScriptBuildPhase section */
|
||||||
@ -330,7 +336,7 @@
|
|||||||
};
|
};
|
||||||
05E212A519D4DB510098F589 /* Debug */ = {
|
05E212A519D4DB510098F589 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
baseConfigurationReference = C068F1D3F0CC317E895FCDAB /* Pods.debug.xcconfig */;
|
baseConfigurationReference = 056298286C03B7760575CC56 /* Pods-Sample.debug.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
INFOPLIST_FILE = Sample/Info.plist;
|
INFOPLIST_FILE = Sample/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
@ -342,7 +348,7 @@
|
|||||||
};
|
};
|
||||||
05E212A619D4DB510098F589 /* Release */ = {
|
05E212A619D4DB510098F589 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
baseConfigurationReference = 088AA6578212BE9BFBB07B70 /* Pods.release.xcconfig */;
|
baseConfigurationReference = A7F0013FBBCBEA0C9FB68986 /* Pods-Sample.release.xcconfig */;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
INFOPLIST_FILE = Sample/Info.plist;
|
INFOPLIST_FILE = Sample/Info.plist;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
|
|||||||
@ -130,13 +130,11 @@ static const CGFloat kInnerPadding = 10.0f;
|
|||||||
|
|
||||||
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
ASTraitCollection *traitCollection = [self asyncTraitCollection];
|
|
||||||
|
|
||||||
ASStackLayoutSpec *stackSpec = [[ASStackLayoutSpec alloc] init];
|
ASStackLayoutSpec *stackSpec = [[ASStackLayoutSpec alloc] init];
|
||||||
stackSpec.spacing = kInnerPadding;
|
stackSpec.spacing = kInnerPadding;
|
||||||
stackSpec.children = @[_imageNode, _textNode];
|
[stackSpec setChildren:@[_imageNode, _textNode]];
|
||||||
|
|
||||||
if (traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular) {
|
if (self.asyncTraitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular) {
|
||||||
_imageNode.alignSelf = ASStackLayoutAlignSelfStart;
|
_imageNode.alignSelf = ASStackLayoutAlignSelfStart;
|
||||||
stackSpec.direction = ASStackLayoutDirectionHorizontal;
|
stackSpec.direction = ASStackLayoutDirectionHorizontal;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user