UNPKG

6.97 kBPlain TextView Raw
1#import "RNSConvert.h"
2
3#ifdef RCT_NEW_ARCH_ENABLED
4@implementation RNSConvert
5
6+ (UISemanticContentAttribute)UISemanticContentAttributeFromCppEquivalent:
7 (react::RNSScreenStackHeaderConfigDirection)direction
8{
9 switch (direction) {
10 case react::RNSScreenStackHeaderConfigDirection::Rtl:
11 return UISemanticContentAttributeForceRightToLeft;
12 case react::RNSScreenStackHeaderConfigDirection::Ltr:
13 return UISemanticContentAttributeForceLeftToRight;
14 }
15}
16
17+ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayModeFromCppEquivalent:
18 (react::RNSScreenStackHeaderConfigBackButtonDisplayMode)backButtonDisplayMode
19{
20 switch (backButtonDisplayMode) {
21 case react::RNSScreenStackHeaderConfigBackButtonDisplayMode::Default:
22 return UINavigationItemBackButtonDisplayModeDefault;
23 case react::RNSScreenStackHeaderConfigBackButtonDisplayMode::Generic:
24 return UINavigationItemBackButtonDisplayModeGeneric;
25 case react::RNSScreenStackHeaderConfigBackButtonDisplayMode::Minimal:
26 return UINavigationItemBackButtonDisplayModeMinimal;
27 }
28}
29
30+ (RNSScreenStackPresentation)RNSScreenStackPresentationFromCppEquivalent:
31 (react::RNSScreenStackPresentation)stackPresentation
32{
33 switch (stackPresentation) {
34 case react::RNSScreenStackPresentation::Push:
35 return RNSScreenStackPresentationPush;
36 case react::RNSScreenStackPresentation::Modal:
37 return RNSScreenStackPresentationModal;
38 case react::RNSScreenStackPresentation::FullScreenModal:
39 return RNSScreenStackPresentationFullScreenModal;
40 case react::RNSScreenStackPresentation::FormSheet:
41 return RNSScreenStackPresentationFormSheet;
42 case react::RNSScreenStackPresentation::ContainedModal:
43 return RNSScreenStackPresentationContainedModal;
44 case react::RNSScreenStackPresentation::TransparentModal:
45 return RNSScreenStackPresentationTransparentModal;
46 case react::RNSScreenStackPresentation::ContainedTransparentModal:
47 return RNSScreenStackPresentationContainedTransparentModal;
48 }
49}
50
51+ (RNSScreenStackAnimation)RNSScreenStackAnimationFromCppEquivalent:(react::RNSScreenStackAnimation)stackAnimation
52{
53 switch (stackAnimation) {
54 // these three are intentionally grouped
55 case react::RNSScreenStackAnimation::Slide_from_right:
56 case react::RNSScreenStackAnimation::Ios:
57 case react::RNSScreenStackAnimation::Default:
58 return RNSScreenStackAnimationDefault;
59 case react::RNSScreenStackAnimation::Slide_from_left:
60 return RNSScreenStackAnimationSlideFromLeft;
61 case react::RNSScreenStackAnimation::Flip:
62 return RNSScreenStackAnimationFlip;
63 case react::RNSScreenStackAnimation::Simple_push:
64 return RNSScreenStackAnimationSimplePush;
65 case react::RNSScreenStackAnimation::None:
66 return RNSScreenStackAnimationNone;
67 case react::RNSScreenStackAnimation::Fade:
68 return RNSScreenStackAnimationFade;
69 case react::RNSScreenStackAnimation::Slide_from_bottom:
70 return RNSScreenStackAnimationSlideFromBottom;
71 case react::RNSScreenStackAnimation::Fade_from_bottom:
72 return RNSScreenStackAnimationFadeFromBottom;
73 }
74}
75
76+ (RNSScreenStackHeaderSubviewType)RNSScreenStackHeaderSubviewTypeFromCppEquivalent:
77 (react::RNSScreenStackHeaderSubviewType)subviewType
78{
79 switch (subviewType) {
80 case react::RNSScreenStackHeaderSubviewType::Left:
81 return RNSScreenStackHeaderSubviewTypeLeft;
82 case react::RNSScreenStackHeaderSubviewType::Right:
83 return RNSScreenStackHeaderSubviewTypeRight;
84 case react::RNSScreenStackHeaderSubviewType::Title:
85 return RNSScreenStackHeaderSubviewTypeTitle;
86 case react::RNSScreenStackHeaderSubviewType::Center:
87 return RNSScreenStackHeaderSubviewTypeCenter;
88 case react::RNSScreenStackHeaderSubviewType::SearchBar:
89 return RNSScreenStackHeaderSubviewTypeSearchBar;
90 case react::RNSScreenStackHeaderSubviewType::Back:
91 return RNSScreenStackHeaderSubviewTypeBackButton;
92 }
93}
94
95+ (RNSScreenReplaceAnimation)RNSScreenReplaceAnimationFromCppEquivalent:
96 (react::RNSScreenReplaceAnimation)replaceAnimation
97{
98 switch (replaceAnimation) {
99 case react::RNSScreenReplaceAnimation::Pop:
100 return RNSScreenReplaceAnimationPop;
101 case react::RNSScreenReplaceAnimation::Push:
102 return RNSScreenReplaceAnimationPush;
103 }
104}
105
106+ (RNSScreenSwipeDirection)RNSScreenSwipeDirectionFromCppEquivalent:(react::RNSScreenSwipeDirection)swipeDirection
107{
108 switch (swipeDirection) {
109 case react::RNSScreenSwipeDirection::Horizontal:
110 return RNSScreenSwipeDirectionHorizontal;
111 case react::RNSScreenSwipeDirection::Vertical:
112 return RNSScreenSwipeDirectionVertical;
113 }
114}
115
116+ (RNSScreenDetentType)RNSScreenDetentTypeFromAllowedDetents:(react::RNSScreenSheetAllowedDetents)allowedDetents
117{
118 switch (allowedDetents) {
119 case react::RNSScreenSheetAllowedDetents::All:
120 return RNSScreenDetentTypeAll;
121 case react::RNSScreenSheetAllowedDetents::Large:
122 return RNSScreenDetentTypeLarge;
123 case react::RNSScreenSheetAllowedDetents::Medium:
124 return RNSScreenDetentTypeMedium;
125 }
126}
127
128+ (RNSScreenDetentType)RNSScreenDetentTypeFromLargestUndimmedDetent:(react::RNSScreenSheetLargestUndimmedDetent)detent
129{
130 switch (detent) {
131 case react::RNSScreenSheetLargestUndimmedDetent::All:
132 return RNSScreenDetentTypeAll;
133 case react::RNSScreenSheetLargestUndimmedDetent::Large:
134 return RNSScreenDetentTypeLarge;
135 case react::RNSScreenSheetLargestUndimmedDetent::Medium:
136 return RNSScreenDetentTypeMedium;
137 }
138}
139
140+ (NSDictionary *)gestureResponseDistanceDictFromCppStruct:
141 (const react::RNSScreenGestureResponseDistanceStruct &)gestureResponseDistance
142{
143 return @{
144 @"start" : @(gestureResponseDistance.start),
145 @"end" : @(gestureResponseDistance.end),
146 @"top" : @(gestureResponseDistance.top),
147 @"bottom" : @(gestureResponseDistance.bottom),
148 };
149}
150
151#if !TARGET_OS_VISION
152+ (UITextAutocapitalizationType)UITextAutocapitalizationTypeFromCppEquivalent:
153 (react::RNSSearchBarAutoCapitalize)autoCapitalize
154{
155 switch (autoCapitalize) {
156 case react::RNSSearchBarAutoCapitalize::Words:
157 return UITextAutocapitalizationTypeWords;
158 case react::RNSSearchBarAutoCapitalize::Sentences:
159 return UITextAutocapitalizationTypeSentences;
160 case react::RNSSearchBarAutoCapitalize::Characters:
161 return UITextAutocapitalizationTypeAllCharacters;
162 case react::RNSSearchBarAutoCapitalize::None:
163 return UITextAutocapitalizationTypeNone;
164 }
165}
166#endif
167
168+ (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(react::RNSSearchBarPlacement)placement
169{
170 switch (placement) {
171 case react::RNSSearchBarPlacement::Stacked:
172 return RNSSearchBarPlacementStacked;
173 case react::RNSSearchBarPlacement::Automatic:
174 return RNSSearchBarPlacementAutomatic;
175 case react::RNSSearchBarPlacement::Inline:
176 return RNSSearchBarPlacementInline;
177 }
178}
179
180@end
181
182#endif // RCT_NEW_ARCH_ENABLED