mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
[Layout] Improve Layout System Abstraction (#2941)
* Improve Layout Abstraction * Address naming comments - Rename ASPrimitiveTraitEnvironment to ASTraitEnvironment - Rename ASPrimitiveTraitCollectionPropagateDown to ASTraitCollectionPropagateDown - Rename progagateNewPrimitiveTraitCollection: to propagateNewTraitCollection:
This commit is contained in:
committed by
GitHub
parent
a2ff2b9900
commit
12e4e5b048
@@ -8,19 +8,24 @@
|
||||
// of patent rights can be found in the PATENTS file in the same directory.
|
||||
//
|
||||
|
||||
#import <AsyncDisplayKit/ASAvailability.h>
|
||||
#import <AsyncDisplayKit/ASLayoutElementPrivate.h>
|
||||
#import <AsyncDisplayKit/ASLayoutElementExtensibility.h>
|
||||
#import <AsyncDisplayKit/ASDimensionInternal.h>
|
||||
#import <AsyncDisplayKit/ASStackLayoutDefines.h>
|
||||
#import <AsyncDisplayKit/ASStackLayoutElement.h>
|
||||
#import <AsyncDisplayKit/ASAbsoluteLayoutElement.h>
|
||||
|
||||
#import <AsyncDisplayKit/ASEnvironment.h>
|
||||
|
||||
@class ASLayout;
|
||||
@class ASLayoutSpec;
|
||||
@protocol ASLayoutElementStylability;
|
||||
|
||||
#if AS_TARGET_OS_IOS
|
||||
#import "ASTraitCollection.h"
|
||||
@protocol ASTraitEnvironment;
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** A constant that indicates that the parent's size is not yet determined in a given dimension. */
|
||||
extern CGFloat const ASLayoutElementParentDimensionUndefined;
|
||||
|
||||
@@ -33,9 +38,19 @@ typedef NS_ENUM(NSUInteger, ASLayoutElementType) {
|
||||
ASLayoutElementTypeDisplayNode
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
ASDISPLAYNODE_EXTERN_C_BEGIN
|
||||
|
||||
/**
|
||||
/**
|
||||
This function will walk the layout element hierarchy. It does run the block on the node provided
|
||||
directly to the function call.
|
||||
*/
|
||||
extern void ASLayoutElementPerformBlockOnEveryElement(id<ASLayoutElement> root, void(^block)(id<ASLayoutElement> element));
|
||||
|
||||
ASDISPLAYNODE_EXTERN_C_END
|
||||
|
||||
#pragma mark - ASLayoutElement
|
||||
|
||||
/**
|
||||
* The ASLayoutElement protocol declares a method for measuring the layout of an object. A layout
|
||||
* is defined by an ASLayout return value, and must specify 1) the size (but not position) of the
|
||||
* layoutElement object, and 2) the size and position of all of its immediate child objects. The tree
|
||||
@@ -51,19 +66,18 @@ 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>
|
||||
#if AS_TARGET_OS_IOS
|
||||
@protocol ASLayoutElement <ASLayoutElementExtensibility, ASLayoutElementFinalLayoutElement, ASTraitEnvironment>
|
||||
#else
|
||||
@protocol ASLayoutElement <ASLayoutElementExtensibility, ASLayoutElementFinalLayoutElement>
|
||||
#endif
|
||||
|
||||
#pragma mark - Getter
|
||||
|
||||
/**
|
||||
* @abstract Returns type of layoutElement
|
||||
*/
|
||||
@property (nonatomic, assign, readonly) ASLayoutElementType layoutElementType;
|
||||
|
||||
/**
|
||||
* @abstract Returns if the layoutElement can be used to layout in an asynchronous way on a background thread.
|
||||
*/
|
||||
@property (nonatomic, assign, readonly) BOOL canLayoutAsynchronous;
|
||||
@property (nonatomic, assign, readonly) ASLayoutElementType layoutElementType;;
|
||||
|
||||
/**
|
||||
* @abstract A size constraint that should apply to this ASLayoutElement.
|
||||
@@ -71,7 +85,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, assign, readonly) ASLayoutElementStyle *style;
|
||||
|
||||
/**
|
||||
* @abstract Optional name that is printed by ascii art string and displayed in description.
|
||||
* @abstract Returns all children of an object which class conforms to the ASLayoutElement protocol
|
||||
*/
|
||||
- (nullable NSArray<id<ASLayoutElement>> *)sublayoutElements;
|
||||
|
||||
/**
|
||||
* @abstract Optional name that is printed by ascii art string and displayed in description.
|
||||
*/
|
||||
@property (nullable, nonatomic, copy) NSString *debugName;
|
||||
|
||||
@@ -157,6 +176,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - ASLayoutElementStyle
|
||||
|
||||
extern NSString * const ASLayoutElementStyleWidthProperty;
|
||||
extern NSString * const ASLayoutElementStyleMinWidthProperty;
|
||||
extern NSString * const ASLayoutElementStyleMaxWidthProperty;
|
||||
@@ -176,13 +197,11 @@ extern NSString * const ASLayoutElementStyleDescenderProperty;
|
||||
|
||||
extern NSString * const ASLayoutElementStyleLayoutPositionProperty;
|
||||
|
||||
#pragma mark - ASLayoutElementStyle
|
||||
|
||||
@protocol ASLayoutElementStyleDelegate <NSObject>
|
||||
- (void)style:(__kindof ASLayoutElementStyle *)style propertyDidChange:(NSString *)propertyName;
|
||||
@end
|
||||
|
||||
@interface ASLayoutElementStyle : NSObject <ASStackLayoutElement, ASAbsoluteLayoutElement>
|
||||
@interface ASLayoutElementStyle : NSObject <ASStackLayoutElement, ASAbsoluteLayoutElement, ASLayoutElementExtensibility>
|
||||
|
||||
/**
|
||||
* @abstract Initializes the layoutElement style with a specified delegate
|
||||
|
||||
Reference in New Issue
Block a user