1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | #import "RCTShadowView+Layout.h"
|
9 |
|
10 | #import <yoga/Yoga.h>
|
11 |
|
12 | #import "RCTAssert.h"
|
13 |
|
14 | @implementation RCTShadowView (Layout)
|
15 |
|
16 | #pragma mark - Computed Layout-Inferred Metrics
|
17 |
|
18 | - (UIEdgeInsets)paddingAsInsets
|
19 | {
|
20 | YGNodeRef yogaNode = self.yogaNode;
|
21 | return (UIEdgeInsets){
|
22 | RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeTop)),
|
23 | RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeLeft)),
|
24 | RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeBottom)),
|
25 | RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetPadding(yogaNode, YGEdgeRight))
|
26 | };
|
27 | }
|
28 |
|
29 | - (UIEdgeInsets)borderAsInsets
|
30 | {
|
31 | YGNodeRef yogaNode = self.yogaNode;
|
32 | return (UIEdgeInsets){
|
33 | RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeTop)),
|
34 | RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeLeft)),
|
35 | RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeBottom)),
|
36 | RCTCoreGraphicsFloatFromYogaFloat(YGNodeLayoutGetBorder(yogaNode, YGEdgeRight))
|
37 | };
|
38 | }
|
39 |
|
40 | - (UIEdgeInsets)compoundInsets
|
41 | {
|
42 | UIEdgeInsets borderAsInsets = self.borderAsInsets;
|
43 | UIEdgeInsets paddingAsInsets = self.paddingAsInsets;
|
44 |
|
45 | return (UIEdgeInsets){
|
46 | borderAsInsets.top + paddingAsInsets.top,
|
47 | borderAsInsets.left + paddingAsInsets.left,
|
48 | borderAsInsets.bottom + paddingAsInsets.bottom,
|
49 | borderAsInsets.right + paddingAsInsets.right
|
50 | };
|
51 | }
|
52 |
|
53 | - (CGSize)availableSize
|
54 | {
|
55 | return self.layoutMetrics.contentFrame.size;
|
56 | }
|
57 |
|
58 | - (CGRect)contentFrame
|
59 | {
|
60 | return self.layoutMetrics.contentFrame;
|
61 | }
|
62 |
|
63 | #pragma mark - Dirty Propagation Control
|
64 |
|
65 | - (void)dirtyLayout
|
66 | {
|
67 | // The default implementation does nothing.
|
68 | }
|
69 |
|
70 | - (void)clearLayout
|
71 | {
|
72 | // The default implementation does nothing.
|
73 | }
|
74 |
|
75 | @end
|