[ASEnvironmentTraitCollection] default user interface idiom to UIUserInterfaceIdiomUnspecified (#1998)

* [ASEnvironmentTraitCollection] default user interface idiom to ASEnvironmentTraitCollection

UIUserInterfaceIdiomUnspecified is -1 so we were actually defaulting our trait collection to UIUserInterfaceIdiomPhone (which is 0).

* Fix a few places where we weren’t using the default method to create the base traits
This commit is contained in:
ricky 2016-07-28 10:03:32 -07:00 committed by Adlai Holler
parent 95bf8bbe1f
commit f0b1f12160
4 changed files with 16 additions and 10 deletions

View File

@ -1848,7 +1848,9 @@ static NSInteger incrementIfFound(NSInteger i) {
}
// now that we have a supernode, propagate its traits to self.
ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]);
if (newSupernode != nil) {
ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]);
}
}
}

View File

@ -50,6 +50,7 @@ typedef struct ASEnvironmentLayoutOptionsState {
struct ASEnvironmentStateExtensions _extensions;
} ASEnvironmentLayoutOptionsState;
extern ASEnvironmentLayoutOptionsState ASEnvironmentLayoutOptionsStateMakeDefault();
#pragma mark - ASEnvironmentHierarchyState
@ -60,6 +61,7 @@ typedef struct ASEnvironmentHierarchyState {
unsigned transitioningSupernodes:1; // = NO
unsigned layoutPending:1; // = NO
} ASEnvironmentHierarchyState;
extern ASEnvironmentHierarchyState ASEnvironmentHierarchyStateMakeDefault();
#pragma mark - ASEnvironmentDisplayTraits
@ -72,6 +74,7 @@ typedef struct ASEnvironmentTraitCollection {
CGSize containerSize;
} ASEnvironmentTraitCollection;
extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionMakeDefault();
extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionFromUITraitCollection(UITraitCollection *traitCollection);
extern BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnvironmentTraitCollection lhs, ASEnvironmentTraitCollection rhs);

View File

@ -11,24 +11,25 @@
#import "ASEnvironmentInternal.h"
#import "ASAvailability.h"
ASEnvironmentLayoutOptionsState _ASEnvironmentLayoutOptionsStateMakeDefault()
ASEnvironmentLayoutOptionsState ASEnvironmentLayoutOptionsStateMakeDefault()
{
return (ASEnvironmentLayoutOptionsState) {
// Default values can be defined in here
};
}
ASEnvironmentHierarchyState _ASEnvironmentHierarchyStateMakeDefault()
ASEnvironmentHierarchyState ASEnvironmentHierarchyStateMakeDefault()
{
return (ASEnvironmentHierarchyState) {
// Default values can be defined in here
};
}
ASEnvironmentTraitCollection _ASEnvironmentTraitCollectionMakeDefault()
ASEnvironmentTraitCollection ASEnvironmentTraitCollectionMakeDefault()
{
return (ASEnvironmentTraitCollection) {
// Default values can be defined in here
.userInterfaceIdiom = UIUserInterfaceIdiomUnspecified,
.containerSize = CGSizeZero,
};
}
@ -62,9 +63,9 @@ BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnviron
ASEnvironmentState ASEnvironmentStateMakeDefault()
{
return (ASEnvironmentState) {
.layoutOptionsState = _ASEnvironmentLayoutOptionsStateMakeDefault(),
.hierarchyState = _ASEnvironmentHierarchyStateMakeDefault(),
.environmentTraitCollection = _ASEnvironmentTraitCollectionMakeDefault()
.layoutOptionsState = ASEnvironmentLayoutOptionsStateMakeDefault(),
.hierarchyState = ASEnvironmentHierarchyStateMakeDefault(),
.environmentTraitCollection = ASEnvironmentTraitCollectionMakeDefault()
};
}

View File

@ -43,13 +43,13 @@ enum class ASEnvironmentStatePropagation { DOWN, UP };
static const struct ASEnvironmentStateExtensions ASEnvironmentDefaultStateExtensions = {};
static const struct ASEnvironmentLayoutOptionsState ASEnvironmentDefaultLayoutOptionsState = {};
static const struct ASEnvironmentLayoutOptionsState ASEnvironmentDefaultLayoutOptionsState = ASEnvironmentLayoutOptionsStateMakeDefault();
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentLayoutOptionsState state, ASEnvironmentStatePropagation propagation);
static const struct ASEnvironmentHierarchyState ASEnvironmentDefaultHierarchyState = {};
static const struct ASEnvironmentHierarchyState ASEnvironmentDefaultHierarchyState = ASEnvironmentHierarchyStateMakeDefault();
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentHierarchyState state, ASEnvironmentStatePropagation propagation);
static const struct ASEnvironmentTraitCollection ASEnvironmentDefaultTraitCollection = {};
static const struct ASEnvironmentTraitCollection ASEnvironmentDefaultTraitCollection = ASEnvironmentTraitCollectionMakeDefault();
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentTraitCollection state, ASEnvironmentStatePropagation propagation);