Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit f0b1f12

Browse files
rcancroAdlai Holler
authored andcommitted
[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
1 parent 95bf8bb commit f0b1f12

4 files changed

Lines changed: 16 additions & 10 deletions

File tree

AsyncDisplayKit/ASDisplayNode.mm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,9 @@ - (void)__setSupernode:(ASDisplayNode *)newSupernode
18481848
}
18491849

18501850
// now that we have a supernode, propagate its traits to self.
1851-
ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]);
1851+
if (newSupernode != nil) {
1852+
ASEnvironmentStatePropagateDown(self, [newSupernode environmentTraitCollection]);
1853+
}
18521854
}
18531855
}
18541856

AsyncDisplayKit/Details/ASEnvironment.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ typedef struct ASEnvironmentLayoutOptionsState {
5050

5151
struct ASEnvironmentStateExtensions _extensions;
5252
} ASEnvironmentLayoutOptionsState;
53+
extern ASEnvironmentLayoutOptionsState ASEnvironmentLayoutOptionsStateMakeDefault();
5354

5455

5556
#pragma mark - ASEnvironmentHierarchyState
@@ -60,6 +61,7 @@ typedef struct ASEnvironmentHierarchyState {
6061
unsigned transitioningSupernodes:1; // = NO
6162
unsigned layoutPending:1; // = NO
6263
} ASEnvironmentHierarchyState;
64+
extern ASEnvironmentHierarchyState ASEnvironmentHierarchyStateMakeDefault();
6365

6466
#pragma mark - ASEnvironmentDisplayTraits
6567

@@ -72,6 +74,7 @@ typedef struct ASEnvironmentTraitCollection {
7274

7375
CGSize containerSize;
7476
} ASEnvironmentTraitCollection;
77+
extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionMakeDefault();
7578

7679
extern ASEnvironmentTraitCollection ASEnvironmentTraitCollectionFromUITraitCollection(UITraitCollection *traitCollection);
7780
extern BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnvironmentTraitCollection lhs, ASEnvironmentTraitCollection rhs);

AsyncDisplayKit/Details/ASEnvironment.mm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,25 @@
1111
#import "ASEnvironmentInternal.h"
1212
#import "ASAvailability.h"
1313

14-
ASEnvironmentLayoutOptionsState _ASEnvironmentLayoutOptionsStateMakeDefault()
14+
ASEnvironmentLayoutOptionsState ASEnvironmentLayoutOptionsStateMakeDefault()
1515
{
1616
return (ASEnvironmentLayoutOptionsState) {
1717
// Default values can be defined in here
1818
};
1919
}
2020

21-
ASEnvironmentHierarchyState _ASEnvironmentHierarchyStateMakeDefault()
21+
ASEnvironmentHierarchyState ASEnvironmentHierarchyStateMakeDefault()
2222
{
2323
return (ASEnvironmentHierarchyState) {
2424
// Default values can be defined in here
2525
};
2626
}
2727

28-
ASEnvironmentTraitCollection _ASEnvironmentTraitCollectionMakeDefault()
28+
ASEnvironmentTraitCollection ASEnvironmentTraitCollectionMakeDefault()
2929
{
3030
return (ASEnvironmentTraitCollection) {
3131
// Default values can be defined in here
32+
.userInterfaceIdiom = UIUserInterfaceIdiomUnspecified,
3233
.containerSize = CGSizeZero,
3334
};
3435
}
@@ -62,9 +63,9 @@ BOOL ASEnvironmentTraitCollectionIsEqualToASEnvironmentTraitCollection(ASEnviron
6263
ASEnvironmentState ASEnvironmentStateMakeDefault()
6364
{
6465
return (ASEnvironmentState) {
65-
.layoutOptionsState = _ASEnvironmentLayoutOptionsStateMakeDefault(),
66-
.hierarchyState = _ASEnvironmentHierarchyStateMakeDefault(),
67-
.environmentTraitCollection = _ASEnvironmentTraitCollectionMakeDefault()
66+
.layoutOptionsState = ASEnvironmentLayoutOptionsStateMakeDefault(),
67+
.hierarchyState = ASEnvironmentHierarchyStateMakeDefault(),
68+
.environmentTraitCollection = ASEnvironmentTraitCollectionMakeDefault()
6869
};
6970
}
7071

AsyncDisplayKit/Private/ASEnvironmentInternal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ enum class ASEnvironmentStatePropagation { DOWN, UP };
4343

4444
static const struct ASEnvironmentStateExtensions ASEnvironmentDefaultStateExtensions = {};
4545

46-
static const struct ASEnvironmentLayoutOptionsState ASEnvironmentDefaultLayoutOptionsState = {};
46+
static const struct ASEnvironmentLayoutOptionsState ASEnvironmentDefaultLayoutOptionsState = ASEnvironmentLayoutOptionsStateMakeDefault();
4747
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentLayoutOptionsState state, ASEnvironmentStatePropagation propagation);
4848

49-
static const struct ASEnvironmentHierarchyState ASEnvironmentDefaultHierarchyState = {};
49+
static const struct ASEnvironmentHierarchyState ASEnvironmentDefaultHierarchyState = ASEnvironmentHierarchyStateMakeDefault();
5050
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentHierarchyState state, ASEnvironmentStatePropagation propagation);
5151

52-
static const struct ASEnvironmentTraitCollection ASEnvironmentDefaultTraitCollection = {};
52+
static const struct ASEnvironmentTraitCollection ASEnvironmentDefaultTraitCollection = ASEnvironmentTraitCollectionMakeDefault();
5353
ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environmentState, ASEnvironmentTraitCollection state, ASEnvironmentStatePropagation propagation);
5454

5555

0 commit comments

Comments
 (0)