11#import " LoaderKitView.h"
2- #import " NVActivityIndicatorView.h"
3- #import " React/RCTConvert.h"
4-
5- static const NSDictionary *nameToTypeMap = @{
6- @" BallPulse" : @(NVActivityIndicatorTypeBallPulse),
7- @" BallGridPulse" : @(NVActivityIndicatorTypeBallGridPulse),
8- @" BallClipRotate" : @(NVActivityIndicatorTypeBallClipRotate),
9- @" SquareSpin" : @(NVActivityIndicatorTypeSquareSpin),
10- @" BallClipRotatePulse" : @(NVActivityIndicatorTypeBallClipRotatePulse),
11- @" BallClipRotateMultiple" : @(NVActivityIndicatorTypeBallClipRotateMultiple),
12- @" BallPulseRise" : @(NVActivityIndicatorTypeBallPulseRise),
13- @" BallRotate" : @(NVActivityIndicatorTypeBallRotate),
14- @" CubeTransition" : @(NVActivityIndicatorTypeCubeTransition),
15- @" BallZigZag" : @(NVActivityIndicatorTypeBallZigZag),
16- @" BallZigZagDeflect" : @(NVActivityIndicatorTypeBallZigZagDeflect),
17- @" BallTrianglePath" : @(NVActivityIndicatorTypeBallTrianglePath),
18- @" BallScale" : @(NVActivityIndicatorTypeBallScale),
19- @" LineScale" : @(NVActivityIndicatorTypeLineScale),
20- @" LineScaleParty" : @(NVActivityIndicatorTypeLineScaleParty),
21- @" BallScaleMultiple" : @(NVActivityIndicatorTypeBallScaleMultiple),
22- @" BallPulseSync" : @(NVActivityIndicatorTypeBallPulseSync),
23- @" BallBeat" : @(NVActivityIndicatorTypeBallBeat),
24- @" LineScalePulseOut" : @(NVActivityIndicatorTypeLineScalePulseOut),
25- @" LineScalePulseOutRapid" : @(NVActivityIndicatorTypeLineScalePulseOutRapid),
26- @" BallScaleRipple" : @(NVActivityIndicatorTypeBallScaleRipple),
27- @" BallScaleRippleMultiple" : @(NVActivityIndicatorTypeBallScaleRippleMultiple),
28- @" BallSpinFadeLoader" : @(NVActivityIndicatorTypeBallSpinFadeLoader),
29- @" LineSpinFadeLoader" : @(NVActivityIndicatorTypeLineSpinFadeLoader),
30- @" TriangleSkewSpin" : @(NVActivityIndicatorTypeTriangleSkewSpin),
31- @" Pacman" : @(NVActivityIndicatorTypePacman),
32- @" BallGridBeat" : @(NVActivityIndicatorTypeBallGridBeat),
33- @" SemiCircleSpin" : @(NVActivityIndicatorTypeSemiCircleSpin),
34- @" BallRotateChase" : @(NVActivityIndicatorTypeBallRotateChase),
35- @" Orbit" : @(NVActivityIndicatorTypeOrbit),
36- @" AudioEqualizer" : @(NVActivityIndicatorTypeAudioEqualizer),
37- @" CircleStrokeSpin" : @(NVActivityIndicatorTypeCircleStrokeSpin),
38- @" BallDoubleBounce" : @(NVActivityIndicatorTypeBallDoubleBounce)
39- };
402
413#ifdef RCT_NEW_ARCH_ENABLED
424
5+ #import " React/RCTConvert.h"
6+
7+ #if __has_include(<LoaderKit/LoaderKit-Swift.h>)
8+ // if use_frameworks! :static
9+ #import < LoaderKit/LoaderKit-Swift.h>
10+ #else
11+ #import " LoaderKit-Swift.h"
12+ #endif
13+
4314#import < react/renderer/components/LoaderKitViewSpec/ComponentDescriptors.h>
4415#import < react/renderer/components/LoaderKitViewSpec/EventEmitters.h>
4516#import < react/renderer/components/LoaderKitViewSpec/Props.h>
@@ -68,8 +39,8 @@ - (instancetype)initWithFrame:(CGRect)frame
6839 static const auto defaultProps = std::make_shared<const LoaderKitViewProps>();
6940 _props = defaultProps;
7041
71- _indicatorView = [[NVActivityIndicatorView alloc ] init ];
72-
42+ _indicatorView = [[NVActivityIndicatorView alloc ] initWithFrame: CGRectZero ];
43+
7344 self.contentView = _indicatorView;
7445 }
7546
@@ -82,9 +53,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
8253 const auto &newViewProps = *std::static_pointer_cast<LoaderKitViewProps const >(props);
8354
8455 if (oldViewProps.name != newViewProps.name ) {
85- NSString * indicatorName = [[NSString alloc ] initWithUTF8String: newViewProps.name.c_str ()];
86- NVActivityIndicatorType type = [self getIndicatorTypeFromName: indicatorName];
87- _indicatorView.type = type;
56+ _indicatorView.name = [[NSString alloc ] initWithUTF8String: newViewProps.name.c_str ()];
8857 }
8958
9059 // Update color
@@ -104,65 +73,17 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
10473 return LoaderKitView.class ;
10574}
10675
107- - (NVActivityIndicatorType)getIndicatorTypeFromName : (NSString *)name
108- {
109- if (!name) return NVActivityIndicatorTypeBallPulse;
110-
111- NSNumber *typeNumber = nameToTypeMap[name];
112- if (typeNumber) {
113- return (NVActivityIndicatorType)[typeNumber integerValue ];
114- }
115-
116- return NVActivityIndicatorTypeBallPulse; // Default fallback
117- }
118-
11976@end
12077
12178#else
12279
123- @implementation LoaderKitViewManager
80+ @interface RCT_EXTERN_MODULE ( LoaderKitViewManager, RCTViewManager)
12481
125- RCT_EXPORT_MODULE (LoaderKitView )
82+ RCT_EXPORT_VIEW_PROPERTY (name, NSString )
12683
127- - (UIView *)view
128- {
129- return [[NVActivityIndicatorView alloc ] init ];
130- }
84+ RCT_REMAP_VIEW_PROPERTY(color, colorRN, NSNumber ) // map from "colorRN" of native view to "color" of react prop
13185
132- - (NVActivityIndicatorType)getIndicatorTypeFromName : (NSString *)name
133- {
134- if (!name) return NVActivityIndicatorTypeBallPulse;
135-
136- NSNumber *typeNumber = nameToTypeMap[name];
137- if (typeNumber) {
138- return (NVActivityIndicatorType)[typeNumber integerValue ];
139- }
140-
141- return NVActivityIndicatorTypeBallPulse;
142- }
143-
144- RCT_CUSTOM_VIEW_PROPERTY (name, NSString , NVActivityIndicatorView)
145- {
146- NSString *indicatorName = [RCTConvert NSString: json];
147- if (indicatorName) {
148- NVActivityIndicatorType type = [self getIndicatorTypeFromName: indicatorName];
149- view.type = type;
150- }
151- }
152-
153- RCT_CUSTOM_VIEW_PROPERTY (color, UIColor, NVActivityIndicatorView)
154- {
155- UIColor *color = [RCTConvert UIColor: json];
156- if (color) {
157- view.color = color;
158- }
159- }
160-
161- RCT_CUSTOM_VIEW_PROPERTY (animationSpeedMultiplier, CGFloat, NVActivityIndicatorView)
162- {
163- CGFloat speedMultiplier = [RCTConvert CGFloat: json];
164- view.animationSpeedMultiplier = speedMultiplier;
165- }
86+ RCT_REMAP_VIEW_PROPERTY(animationSpeedMultiplier, animationSpeedMultiplierRN, NSNumber ) // map from "animationSpeedMultiplierRN" of native view to "animationSpeedMultiplier" of react prop
16687
16788@end
16889
0 commit comments