Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASPrimitiveTraitCollection] Always treat preferredContentSize as a potential nil #trivial #757

Merged
merged 3 commits into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/ASViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Set this block to customize the ASDisplayTraits returned when the VC transitions to the given window size.
*/
@property (nonatomic, copy) ASDisplayTraitsForTraitWindowSizeBlock overrideDisplayTraitsWithWindowSize;
@property (nonatomic, copy) ASDisplayTraitsForTraitWindowSizeBlock overrideDisplayTraitsWithWindowSize ASDISPLAYNODE_DEPRECATED_MSG("This property is actually never accessed inside the framework");

/**
* @abstract Passthrough property to the the .interfaceState of the node.
Expand Down
36 changes: 30 additions & 6 deletions Source/Details/ASTraitCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ extern ASPrimitiveContentSizeCategory ASPrimitiveContentSizeCategoryMake(UIConte

#pragma mark - ASPrimitiveTraitCollection

/**
* @abstract This is an internal struct-representation of ASTraitCollection.
*
* @discussion This struct is for internal use only. Framework users should always use ASTraitCollection.
*
* If you use ASPrimitiveTraitCollection, please do make sure to initialize it with ASPrimitiveTraitCollectionMakeDefault()
* or ASPrimitiveTraitCollectionFromUITraitCollection(UITraitCollection*).
*/
typedef struct ASPrimitiveTraitCollection {
UIUserInterfaceSizeClass horizontalSizeClass;
UIUserInterfaceSizeClass verticalSizeClass;
Expand Down Expand Up @@ -112,17 +120,23 @@ ASDISPLAYNODE_EXTERN_C_END
@protocol ASTraitEnvironment <NSObject>

/**
* Returns a struct-representation of the environment's ASEnvironmentDisplayTraits. This only exists as a internal
* convenience method. Users should access the trait collections through the NSObject based asyncTraitCollection API
* @abstract Returns a struct-representation of the environment's ASEnvironmentDisplayTraits.
*
* @discussion This only exists as an internal convenience method. Users should access the trait collections through
* the NSObject based asyncTraitCollection API
*/
- (ASPrimitiveTraitCollection)primitiveTraitCollection;

/**
* Sets a trait collection on this environment state.
* @abstract Sets a trait collection on this environment state.
*
* @discussion This only exists as an internal convenience method. Users should not override trait collection using it.
* Use [ASViewController overrideDisplayTraitsWithTraitCollection] block instead.
*/
- (void)setPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traitCollection;

/**
* @abstract Returns the thread-safe UITraitCollection equivalent.
*/
- (ASTraitCollection *)asyncTraitCollection;

Expand Down Expand Up @@ -179,8 +193,6 @@ AS_SUBCLASSING_RESTRICTED

@property (nonatomic, assign, readonly) CGSize containerSize;

+ (ASTraitCollection *)traitCollectionWithASPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traits;

+ (ASTraitCollection *)traitCollectionWithUITraitCollection:(UITraitCollection *)traitCollection
containerSize:(CGSize)windowSize;

Expand Down Expand Up @@ -211,13 +223,25 @@ AS_SUBCLASSING_RESTRICTED
containerSize:(CGSize)windowSize;
#endif

- (ASPrimitiveTraitCollection)primitiveTraitCollection;
- (BOOL)isEqualToTraitCollection:(ASTraitCollection *)traitCollection;

@end

/**
* These are internal helper methods. Should never be called by the framework users.
*/
@interface ASTraitCollection (PrimitiveTraits)

+ (ASTraitCollection *)traitCollectionWithASPrimitiveTraitCollection:(ASPrimitiveTraitCollection)traits;

- (ASPrimitiveTraitCollection)primitiveTraitCollection;

@end

@interface ASTraitCollection (Deprecated)

- (instancetype)init ASDISPLAYNODE_DEPRECATED_MSG("The default constructor of this class is going to become unavailable. Use other constructors instead.");

+ (ASTraitCollection *)traitCollectionWithDisplayScale:(CGFloat)displayScale
userInterfaceIdiom:(UIUserInterfaceIdiom)userInterfaceIdiom
horizontalSizeClass:(UIUserInterfaceSizeClass)horizontalSizeClass
Expand Down
Loading