mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Improve deprecation situation for 2.0 (#2514)
* Improve deprecations for 2.0 - Add deprecations for node / layoutSpec style properties - Implement missing methods on ASDisplay from deprecation header - Cleanup all of the deprecation categories * Remove DeprecatedProtocolMethods * Fix "Life without Cocoapods" * Update comments
This commit is contained in:
committed by
GitHub
parent
f09b92641c
commit
4464b7de60
@@ -22,6 +22,18 @@
|
||||
*/
|
||||
@property (nullable, nonatomic, copy) NSString *name ASDISPLAYNODE_DEPRECATED_MSG("Use .debugName instead.");
|
||||
|
||||
/**
|
||||
* @abstract Provides a default intrinsic content size for calculateSizeThatFits:. This is useful when laying out
|
||||
* a node that either has no intrinsic content size or should be laid out at a different size than its intrinsic content
|
||||
* size. For example, this property could be set on an ASImageNode to display at a size different from the underlying
|
||||
* image size.
|
||||
*
|
||||
* @return Try to create a CGSize for preferredFrameSize of this node from the width and height property of this node. It will return CGSizeZero if width and height dimensions are not of type ASDimensionUnitPoints.
|
||||
*
|
||||
* @deprecated Deprecated in version 2.0: Just calls through to set the height and width property of the node. Convert to use sizing properties instead: height, minHeight, maxHeight, width, minWidth, maxWidth.
|
||||
*/
|
||||
@property (nonatomic, assign, readwrite) CGSize preferredFrameSize ASDISPLAYNODE_DEPRECATED_MSG("Use .style.preferredSize instead OR set individual values with .style.height and .style.width.");
|
||||
|
||||
/**
|
||||
* @abstract Asks the node to measure and return the size that best fits its subnodes.
|
||||
*
|
||||
@@ -43,16 +55,7 @@
|
||||
*/
|
||||
- (CGSize)measure:(CGSize)constrainedSize ASDISPLAYNODE_DEPRECATED_MSG("Use layoutThatFits: with a constrained size of (CGSizeZero, constrainedSize) and call size on the returned ASLayout.");
|
||||
|
||||
/**
|
||||
* @abstract Calculate a layout based on given size range.
|
||||
*
|
||||
* @param constrainedSize The minimum and maximum sizes the receiver should fit in.
|
||||
*
|
||||
* @return An ASLayout instance defining the layout of the receiver and its children.
|
||||
*
|
||||
* @deprecated Deprecated in version 2.0: Use ASCalculateRootLayout() or ASCalculateLayout() instead
|
||||
*/
|
||||
- (nonnull ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize ASDISPLAYNODE_DEPRECATED_MSG("Use layoutThatFits: instead.");
|
||||
ASLayoutElementStyleForwardingDeclaration
|
||||
|
||||
/**
|
||||
* @abstract Called whenever the visiblity of the node changed.
|
||||
|
||||
@@ -814,45 +814,6 @@ extern NSInteger const ASDefaultDrawingPriority;
|
||||
|
||||
@end
|
||||
|
||||
@interface ASDisplayNode (DeprecatedProtocolMethods) <ASStackLayoutElement, ASAbsoluteLayoutElement>
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
/**
|
||||
* @abstract Asks the node to measure and return the size that best fits its subnodes.
|
||||
*
|
||||
* @param constrainedSize The maximum size the receiver should fit in.
|
||||
*
|
||||
* @return A new size that fits the receiver's subviews.
|
||||
*
|
||||
* @discussion Though this method does not set the bounds of the view, it does have side effects--caching both the
|
||||
* constraint and the result.
|
||||
*
|
||||
* @warning Subclasses must not override this; it calls -measureWithSizeRange: with zero min size.
|
||||
* -measureWithSizeRange: caches results from -calculateLayoutThatFits:. Calling this method may
|
||||
* be expensive if result is not cached.
|
||||
*
|
||||
* @see measureWithSizeRange:
|
||||
* @see [ASDisplayNode(Subclassing) calculateLayoutThatFits:]
|
||||
*
|
||||
* @deprecated Deprecated in version 2.0: Use layoutThatFits: with a constrained size of (CGSizeZero, constrainedSize) and call size on the returned ASLayout
|
||||
*/
|
||||
- (CGSize)measure:(CGSize)constrainedSize ASDISPLAYNODE_DEPRECATED;
|
||||
|
||||
/**
|
||||
* @abstract Provides a default intrinsic content size for calculateSizeThatFits:. This is useful when laying out
|
||||
* a node that either has no intrinsic content size or should be laid out at a different size than its intrinsic content
|
||||
* size. For example, this property could be set on an ASImageNode to display at a size different from the underlying
|
||||
* image size.
|
||||
*
|
||||
* @return Try to create a CGSize for preferredFrameSize of this node from the width and height property of this node. It will return CGSizeZero if widht and height dimensions are not of type ASDimensionUnitPoints.
|
||||
*
|
||||
* @deprecated Deprecated in version 2.0: Just calls through to set the height and width property of the node. Convert to use sizing properties instead: height, minHeight, maxHeight, width, minWidth, maxWidth.
|
||||
*/
|
||||
@property (nonatomic, assign, readwrite) CGSize preferredFrameSize ASDISPLAYNODE_DEPRECATED_MSG("Use .style.preferredSize instead OR set individual values with .style.height and .style.width.");
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* ASDisplayNode support for automatic subnode management.
|
||||
*/
|
||||
|
||||
@@ -3471,8 +3471,6 @@ static const char *ASDisplayNodeDrawingPriorityKey = "ASDrawingPriority";
|
||||
|
||||
#pragma mark - Deprecated
|
||||
|
||||
ASLayoutElementStyleForwarding
|
||||
|
||||
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
|
||||
{
|
||||
return [self layoutThatFits:constrainedSize parentSize:constrainedSize.max];
|
||||
@@ -3642,11 +3640,6 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode";
|
||||
self.debugName = name;
|
||||
}
|
||||
|
||||
- (CGSize)measure:(CGSize)constrainedSize
|
||||
{
|
||||
return [self layoutThatFits:ASSizeRangeMake(CGSizeZero, constrainedSize)].size;
|
||||
}
|
||||
|
||||
- (void)setPreferredFrameSize:(CGSize)preferredFrameSize
|
||||
{
|
||||
// Deprecated preferredFrameSize just calls through to set width and height
|
||||
@@ -3661,6 +3654,49 @@ static const char *ASDisplayNodeAssociatedNodeKey = "ASAssociatedNode";
|
||||
return isPoints ? CGSizeMake(size.width.value, size.height.value) : CGSizeZero;
|
||||
}
|
||||
|
||||
- (CGSize)measure:(CGSize)constrainedSize
|
||||
{
|
||||
return [self layoutThatFits:ASSizeRangeMake(CGSizeZero, constrainedSize)].size;
|
||||
}
|
||||
|
||||
ASLayoutElementStyleForwarding
|
||||
|
||||
- (void)visibilityDidChange:(BOOL)isVisible
|
||||
{
|
||||
if (isVisible) {
|
||||
[self didEnterVisibleState];
|
||||
} else {
|
||||
[self didExitVisibleState];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)visibleStateDidChange:(BOOL)isVisible
|
||||
{
|
||||
if (isVisible) {
|
||||
[self didEnterVisibleState];
|
||||
} else {
|
||||
[self didExitVisibleState];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)displayStateDidChange:(BOOL)inDisplayState
|
||||
{
|
||||
if (inDisplayState) {
|
||||
[self didEnterVisibleState];
|
||||
} else {
|
||||
[self didExitVisibleState];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)loadStateDidChange:(BOOL)inLoadState
|
||||
{
|
||||
if (inLoadState) {
|
||||
[self didEnterPreloadState];
|
||||
} else {
|
||||
[self didExitPreloadState];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cancelLayoutTransitionsInProgress
|
||||
{
|
||||
[self cancelLayoutTransition];
|
||||
|
||||
@@ -93,5 +93,6 @@
|
||||
#import <AsyncDisplayKit/NSArray+Diffing.h>
|
||||
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit+Debug.h>
|
||||
#import <AsyncDisplayKit/ASDisplayNode+Deprecated.h>
|
||||
|
||||
#import <AsyncDisplayKit/ASCollectionNode+Beta.h>
|
||||
|
||||
@@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* access to the options via convenience properties. If you are creating custom layout spec, then you can
|
||||
* extend the backing layout options class to accommodate any new layout options.
|
||||
*/
|
||||
@protocol ASLayoutElement <ASEnvironment, ASLayoutElementPrivate, ASLayoutElementExtensibility, ASLayoutElementStylability, NSFastEnumeration, ASStackLayoutElement, ASAbsoluteLayoutElement>
|
||||
@protocol ASLayoutElement <ASEnvironment, ASLayoutElementPrivate, ASLayoutElementExtensibility, ASLayoutElementStylability, NSFastEnumeration>
|
||||
|
||||
#pragma mark - Getter
|
||||
|
||||
@@ -149,9 +149,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*
|
||||
* @return An ASLayout instance defining the layout of the receiver and its children.
|
||||
*
|
||||
* @deprecated Deprecated in version 2.0: Use ASCalculateRootLayout() or ASCalculateLayout() instead
|
||||
* @deprecated Deprecated in version 2.0: Use layoutThatFits: or layoutThatFits:parentSize: if used in
|
||||
* ASLayoutSpec subclasses
|
||||
*/
|
||||
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize ASDISPLAYNODE_DEPRECATED_MSG("Use layoutThatFits: instead");
|
||||
- (nonnull ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize ASDISPLAYNODE_DEPRECATED_MSG("Use layoutThatFits: instead.");
|
||||
|
||||
@end
|
||||
|
||||
@@ -319,4 +320,3 @@ extern NSString * const ASLayoutElementStyleLayoutPositionProperty;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
#define ASLayoutable ASLayoutElement
|
||||
|
||||
@@ -95,6 +95,20 @@ extern void ASLayoutElementClearCurrentContext();
|
||||
}\
|
||||
|
||||
|
||||
#pragma mark ASLayoutElementStyleForwardingDeclaration (Deprecated)
|
||||
|
||||
#define ASLayoutElementStyleForwardingDeclaration \
|
||||
@property (nonatomic, readwrite) CGFloat spacingBefore ASDISPLAYNODE_DEPRECATED_MSG("Use style.spacingBefore"); \
|
||||
@property (nonatomic, readwrite) CGFloat spacingAfter ASDISPLAYNODE_DEPRECATED_MSG("Use style.spacingAfter"); \
|
||||
@property (nonatomic, readwrite) CGFloat flexGrow ASDISPLAYNODE_DEPRECATED_MSG("Use style.flexGrow"); \
|
||||
@property (nonatomic, readwrite) CGFloat flexShrink ASDISPLAYNODE_DEPRECATED_MSG("Use style.flexShrink"); \
|
||||
@property (nonatomic, readwrite) ASDimension flexBasis ASDISPLAYNODE_DEPRECATED_MSG("Use style.flexBasis"); \
|
||||
@property (nonatomic, readwrite) ASStackLayoutAlignSelf alignSelf ASDISPLAYNODE_DEPRECATED_MSG("Use style.alignSelf"); \
|
||||
@property (nonatomic, readwrite) CGFloat ascender ASDISPLAYNODE_DEPRECATED_MSG("Use style.ascender"); \
|
||||
@property (nonatomic, readwrite) CGFloat descender ASDISPLAYNODE_DEPRECATED_MSG("Use style.descender"); \
|
||||
@property (nonatomic, assign) ASRelativeSizeRange sizeRange ASDISPLAYNODE_DEPRECATED_MSG("Don't use sizeRange anymore instead set style.width or style.height"); \
|
||||
@property (nonatomic, assign) CGPoint layoutPosition ASDISPLAYNODE_DEPRECATED_MSG("Use style.layoutPosition"); \
|
||||
|
||||
|
||||
#pragma mark - ASLayoutElementStyleForwarding (Deprecated)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/**
|
||||
* A layout spec is an immutable object that describes a layout, loosely inspired by React.
|
||||
*/
|
||||
@interface ASLayoutSpec : NSObject <ASLayoutElement, ASStackLayoutElement, ASAbsoluteLayoutElement>
|
||||
@interface ASLayoutSpec : NSObject <ASLayoutElement>
|
||||
|
||||
/**
|
||||
* Creation of a layout spec should only happen by a user in layoutSpecThatFits:. During that method, a
|
||||
@@ -105,4 +105,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@end
|
||||
|
||||
@interface ASLayoutSpec (Deprecated)
|
||||
|
||||
ASLayoutElementStyleForwardingDeclaration
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -262,8 +262,6 @@ ASEnvironmentLayoutExtensibilityForwarding
|
||||
return [self layoutThatFits:constrainedSize];
|
||||
}
|
||||
|
||||
ASLayoutElementStyleForwarding
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - ASWrapperLayoutSpec
|
||||
@@ -361,3 +359,11 @@ ASLayoutElementStyleForwarding
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - ASLayoutSpec (Deprecated)
|
||||
|
||||
@implementation ASLayoutSpec (Deprecated)
|
||||
|
||||
ASLayoutElementStyleForwarding
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user