@exterio/react-native-yamap-lite 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +510 -0
  3. package/YamapLite.podspec +21 -0
  4. package/android/build.gradle +101 -0
  5. package/android/gradle.properties +14 -0
  6. package/android/settings.gradle +1 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/java/com/yamaplite/ClusteredYamapLiteViewManager.kt +181 -0
  9. package/android/src/main/java/com/yamaplite/Components/ClusteredYamapLiteView.kt +169 -0
  10. package/android/src/main/java/com/yamaplite/Components/YamapLiteCircleView.kt +145 -0
  11. package/android/src/main/java/com/yamaplite/Components/YamapLiteMarkerView.kt +214 -0
  12. package/android/src/main/java/com/yamaplite/Components/YamapLitePolygon.kt +149 -0
  13. package/android/src/main/java/com/yamaplite/Components/YamapLitePolyline.kt +171 -0
  14. package/android/src/main/java/com/yamaplite/Components/YamapLiteView.kt +678 -0
  15. package/android/src/main/java/com/yamaplite/Events/CameraPositionChangeEvent.kt +38 -0
  16. package/android/src/main/java/com/yamaplite/Events/MapLoadEvent.kt +34 -0
  17. package/android/src/main/java/com/yamaplite/Events/PressEvent.kt +24 -0
  18. package/android/src/main/java/com/yamaplite/Utils/ImageCache.kt +45 -0
  19. package/android/src/main/java/com/yamaplite/Utils/PointParser.kt +39 -0
  20. package/android/src/main/java/com/yamaplite/Utils/ResolveImageHelper.kt +122 -0
  21. package/android/src/main/java/com/yamaplite/Utils/YamapUtils.kt +169 -0
  22. package/android/src/main/java/com/yamaplite/YamapLiteCircleViewManager.kt +67 -0
  23. package/android/src/main/java/com/yamaplite/YamapLiteMarkerViewManager.kt +82 -0
  24. package/android/src/main/java/com/yamaplite/YamapLitePackage.kt +41 -0
  25. package/android/src/main/java/com/yamaplite/YamapLitePolygonViewManager.kt +61 -0
  26. package/android/src/main/java/com/yamaplite/YamapLitePolylineViewManager.kt +75 -0
  27. package/android/src/main/java/com/yamaplite/YamapLiteViewManager.kt +176 -0
  28. package/ios/ClusteredYamapLiteView.h +15 -0
  29. package/ios/ClusteredYamapLiteView.mm +325 -0
  30. package/ios/ClusteredYamapLiteViewManager.mm +17 -0
  31. package/ios/Components/Circle.swift +108 -0
  32. package/ios/Components/ClusteredYamap.swift +190 -0
  33. package/ios/Components/Marker.swift +187 -0
  34. package/ios/Components/Polygon.swift +108 -0
  35. package/ios/Components/Polyline.swift +125 -0
  36. package/ios/Components/Yamap.swift +585 -0
  37. package/ios/Listeners/CameraListener.swift +54 -0
  38. package/ios/Listeners/ClusterListener.swift +38 -0
  39. package/ios/Listeners/MapInputListener.swift +35 -0
  40. package/ios/Listeners/MapLoadListener.swift +35 -0
  41. package/ios/Listeners/MapObjectTap.swift +12 -0
  42. package/ios/Listeners/UserLocationObjectListener.swift +29 -0
  43. package/ios/Models/YamapModels.swift +77 -0
  44. package/ios/Utils/ImageCache.swift +20 -0
  45. package/ios/Utils/PointsEqual.h +45 -0
  46. package/ios/Utils/ResolveImageHelper.swift +142 -0
  47. package/ios/YamapLiteCircleView.h +15 -0
  48. package/ios/YamapLiteCircleView.mm +102 -0
  49. package/ios/YamapLiteMarkerView.h +15 -0
  50. package/ios/YamapLiteMarkerView.mm +102 -0
  51. package/ios/YamapLitePolygonView.h +15 -0
  52. package/ios/YamapLitePolygonView.mm +120 -0
  53. package/ios/YamapLitePolylineView.h +15 -0
  54. package/ios/YamapLitePolylineView.mm +115 -0
  55. package/ios/YamapLiteView.h +15 -0
  56. package/ios/YamapLiteView.mm +361 -0
  57. package/ios/YamapLiteViewManager.mm +17 -0
  58. package/ios/YamapUtils.h +5 -0
  59. package/ios/YamapUtils.mm +205 -0
  60. package/lib/module/@types/index.js +8 -0
  61. package/lib/module/@types/index.js.map +1 -0
  62. package/lib/module/ClusteredYamapLiteViewNativeComponent.ts +98 -0
  63. package/lib/module/Components/Circle.js +20 -0
  64. package/lib/module/Components/Circle.js.map +1 -0
  65. package/lib/module/Components/ClusteredYamap.js +133 -0
  66. package/lib/module/Components/ClusteredYamap.js.map +1 -0
  67. package/lib/module/Components/Marker.js +40 -0
  68. package/lib/module/Components/Marker.js.map +1 -0
  69. package/lib/module/Components/Polygon.js +25 -0
  70. package/lib/module/Components/Polygon.js.map +1 -0
  71. package/lib/module/Components/Polyline.js +25 -0
  72. package/lib/module/Components/Polyline.js.map +1 -0
  73. package/lib/module/Components/Yamap.js +124 -0
  74. package/lib/module/Components/Yamap.js.map +1 -0
  75. package/lib/module/Components/index.js +9 -0
  76. package/lib/module/Components/index.js.map +1 -0
  77. package/lib/module/NativeYamapUtils.js +5 -0
  78. package/lib/module/NativeYamapUtils.js.map +1 -0
  79. package/lib/module/Utils/YamapUtils.js +14 -0
  80. package/lib/module/Utils/YamapUtils.js.map +1 -0
  81. package/lib/module/YamapCircleViewNativeComponent.ts +28 -0
  82. package/lib/module/YamapLiteViewNativeComponent.ts +93 -0
  83. package/lib/module/YamapMarkerViewNativeComponent.ts +32 -0
  84. package/lib/module/YamapPolygonViewNativeComponent.ts +28 -0
  85. package/lib/module/YamapPolylineViewNativeComponent.ts +31 -0
  86. package/lib/module/index.js +7 -0
  87. package/lib/module/index.js.map +1 -0
  88. package/lib/module/package.json +1 -0
  89. package/lib/typescript/package.json +1 -0
  90. package/lib/typescript/src/@types/index.d.ts +257 -0
  91. package/lib/typescript/src/@types/index.d.ts.map +1 -0
  92. package/lib/typescript/src/ClusteredYamapLiteViewNativeComponent.d.ts +82 -0
  93. package/lib/typescript/src/ClusteredYamapLiteViewNativeComponent.d.ts.map +1 -0
  94. package/lib/typescript/src/Components/Circle.d.ts +4 -0
  95. package/lib/typescript/src/Components/Circle.d.ts.map +1 -0
  96. package/lib/typescript/src/Components/ClusteredYamap.d.ts +3 -0
  97. package/lib/typescript/src/Components/ClusteredYamap.d.ts.map +1 -0
  98. package/lib/typescript/src/Components/Marker.d.ts +3 -0
  99. package/lib/typescript/src/Components/Marker.d.ts.map +1 -0
  100. package/lib/typescript/src/Components/Polygon.d.ts +4 -0
  101. package/lib/typescript/src/Components/Polygon.d.ts.map +1 -0
  102. package/lib/typescript/src/Components/Polyline.d.ts +4 -0
  103. package/lib/typescript/src/Components/Polyline.d.ts.map +1 -0
  104. package/lib/typescript/src/Components/Yamap.d.ts +3 -0
  105. package/lib/typescript/src/Components/Yamap.d.ts.map +1 -0
  106. package/lib/typescript/src/Components/index.d.ts +7 -0
  107. package/lib/typescript/src/Components/index.d.ts.map +1 -0
  108. package/lib/typescript/src/NativeYamapUtils.d.ts +30 -0
  109. package/lib/typescript/src/NativeYamapUtils.d.ts.map +1 -0
  110. package/lib/typescript/src/Utils/YamapUtils.d.ts +27 -0
  111. package/lib/typescript/src/Utils/YamapUtils.d.ts.map +1 -0
  112. package/lib/typescript/src/YamapCircleViewNativeComponent.d.ts +20 -0
  113. package/lib/typescript/src/YamapCircleViewNativeComponent.d.ts.map +1 -0
  114. package/lib/typescript/src/YamapLiteViewNativeComponent.d.ts +80 -0
  115. package/lib/typescript/src/YamapLiteViewNativeComponent.d.ts.map +1 -0
  116. package/lib/typescript/src/YamapMarkerViewNativeComponent.d.ts +25 -0
  117. package/lib/typescript/src/YamapMarkerViewNativeComponent.d.ts.map +1 -0
  118. package/lib/typescript/src/YamapPolygonViewNativeComponent.d.ts +20 -0
  119. package/lib/typescript/src/YamapPolygonViewNativeComponent.d.ts.map +1 -0
  120. package/lib/typescript/src/YamapPolylineViewNativeComponent.d.ts +23 -0
  121. package/lib/typescript/src/YamapPolylineViewNativeComponent.d.ts.map +1 -0
  122. package/lib/typescript/src/index.d.ts +5 -0
  123. package/lib/typescript/src/index.d.ts.map +1 -0
  124. package/package.json +189 -0
  125. package/src/@types/index.ts +314 -0
  126. package/src/ClusteredYamapLiteViewNativeComponent.ts +98 -0
  127. package/src/Components/Circle.tsx +22 -0
  128. package/src/Components/ClusteredYamap.tsx +194 -0
  129. package/src/Components/Marker.tsx +50 -0
  130. package/src/Components/Polygon.tsx +27 -0
  131. package/src/Components/Polyline.tsx +27 -0
  132. package/src/Components/Yamap.tsx +176 -0
  133. package/src/Components/index.ts +6 -0
  134. package/src/NativeYamapUtils.ts +47 -0
  135. package/src/Utils/YamapUtils.ts +63 -0
  136. package/src/YamapCircleViewNativeComponent.ts +28 -0
  137. package/src/YamapLiteViewNativeComponent.ts +93 -0
  138. package/src/YamapMarkerViewNativeComponent.ts +32 -0
  139. package/src/YamapPolygonViewNativeComponent.ts +28 -0
  140. package/src/YamapPolylineViewNativeComponent.ts +31 -0
  141. package/src/index.tsx +5 -0
@@ -0,0 +1,120 @@
1
+ #import "YamapLitePolygonView.h"
2
+ #include "ReactCodegen/react/renderer/components/YamapLiteViewSpec/EventEmitters.h"
3
+ #include "react/renderer/components/YamapLiteViewSpec/EventEmitters.h"
4
+ #include <Foundation/Foundation.h>
5
+ #include <objc/NSObject.h>
6
+
7
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
8
+ #import <React/RCTConversions.h>
9
+ #import <react/renderer/components/YamapLiteViewSpec/ComponentDescriptors.h>
10
+ #import <react/renderer/components/YamapLiteViewSpec/EventEmitters.h>
11
+ #import <react/renderer/components/YamapLiteViewSpec/Props.h>
12
+ #import <react/renderer/components/YamapLiteViewSpec/RCTComponentViewHelpers.h>
13
+ #import <react/renderer/graphics/Color.h>
14
+
15
+ #import "RCTFabricComponentsPlugins.h"
16
+ #import "Utils/PointsEqual.h"
17
+ #import "YamapLite-Swift.h"
18
+ #import <YandexMapsMobile/YMKMapKitFactory.h>
19
+
20
+ using namespace facebook::react;
21
+
22
+ @interface YamapLitePolygonView () <RCTYamapLitePolygonViewViewProtocol,
23
+ YamapLitePolygonComponentDelegate>
24
+
25
+ @end
26
+
27
+ @implementation YamapLitePolygonView {
28
+ YamapLitePolygon *_view;
29
+ }
30
+
31
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
32
+ return concreteComponentDescriptorProvider<
33
+ YamapLitePolygonViewComponentDescriptor>();
34
+ }
35
+
36
+ - (instancetype)initWithFrame:(CGRect)frame {
37
+ if (self = [super initWithFrame:frame]) {
38
+ static const auto defaultProps =
39
+ std::make_shared<const YamapLitePolygonViewProps>();
40
+ _props = defaultProps;
41
+ _view = [[YamapLitePolygon alloc] init];
42
+ _view.delegate = self;
43
+ self.contentView = _view;
44
+ }
45
+ return self;
46
+ }
47
+
48
+ - (void)updateProps:(Props::Shared const &)props
49
+ oldProps:(Props::Shared const &)oldProps {
50
+ const auto &oldViewProps =
51
+ *std::static_pointer_cast<YamapLitePolygonViewProps const>(_props);
52
+ const auto &newViewProps =
53
+ *std::static_pointer_cast<YamapLitePolygonViewProps const>(props);
54
+ if (oldViewProps.fillColor != newViewProps.fillColor) {
55
+ UIColor *uiColor = RCTUIColorFromSharedColor(newViewProps.fillColor);
56
+ if (uiColor) {
57
+ _view.fillColor = uiColor;
58
+ }
59
+ }
60
+ if (oldViewProps.strokeColor != newViewProps.strokeColor) {
61
+ UIColor *uiColor = RCTUIColorFromSharedColor(newViewProps.strokeColor);
62
+ if (uiColor) {
63
+ _view.strokeColor = uiColor;
64
+ }
65
+ }
66
+ if (oldViewProps.strokeWidth != newViewProps.strokeWidth) {
67
+ _view.strokeWidth = newViewProps.strokeWidth;
68
+ }
69
+ if (oldViewProps.zInd != newViewProps.zInd) {
70
+ _view.zIndex = newViewProps.zInd;
71
+ }
72
+
73
+ if (!yamaplite::pointsEqual(oldViewProps.points, newViewProps.points)) {
74
+ NSMutableArray<YMKPoint *> *pointsArr =
75
+ [NSMutableArray arrayWithCapacity:newViewProps.points.size()];
76
+ for (const auto &p : newViewProps.points) {
77
+ [pointsArr addObject:[YMKPoint pointWithLatitude:p.lat longitude:p.lon]];
78
+ }
79
+ _view.points = pointsArr;
80
+ }
81
+
82
+ if (!yamaplite::ringsEqual(oldViewProps.innerRings,
83
+ newViewProps.innerRings)) {
84
+ NSMutableArray<NSArray<YMKPoint *> *> *innerRingsArr =
85
+ [NSMutableArray arrayWithCapacity:newViewProps.innerRings.size()];
86
+ for (const auto &ring : newViewProps.innerRings) {
87
+ NSMutableArray<YMKPoint *> *ringArr =
88
+ [NSMutableArray arrayWithCapacity:ring.size()];
89
+ for (const auto &p : ring) {
90
+ [ringArr addObject:[YMKPoint pointWithLatitude:p.lat longitude:p.lon]];
91
+ }
92
+ [innerRingsArr addObject:ringArr];
93
+ }
94
+ _view.innerRings = innerRingsArr;
95
+ }
96
+
97
+ if (oldViewProps.handled != newViewProps.handled) {
98
+ _view.handled = newViewProps.handled;
99
+ }
100
+
101
+ [super updateProps:props oldProps:oldProps];
102
+ }
103
+
104
+ - (void)onPolygonPressWithPoint:
105
+ (NSDictionary<NSString *, NSNumber *> *_Nonnull)point {
106
+ if (_eventEmitter != nil) {
107
+ YamapLitePolygonViewEventEmitter::OnPolygonPress event = {};
108
+ event.lat = [[point objectForKey:@"lat"] doubleValue];
109
+ event.lon = [[point objectForKey:@"lon"] doubleValue];
110
+ std::dynamic_pointer_cast<const YamapLitePolygonViewEventEmitter>(
111
+ _eventEmitter)
112
+ ->onPolygonPress(event);
113
+ }
114
+ }
115
+
116
+ Class<RCTComponentViewProtocol> YamapLitePolygonViewCls(void) {
117
+ return YamapLitePolygonView.class;
118
+ }
119
+
120
+ @end
@@ -0,0 +1,15 @@
1
+ #import <React/RCTViewComponentView.h>
2
+ #import <React/RCTViewManager.h>
3
+ #import <UIKit/UIKit.h>
4
+
5
+ #ifndef YamapLitePolylineViewNativeComponent_h
6
+ #define YamapLitePolylineViewNativeComponent_h
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ @interface YamapLitePolylineView : RCTViewComponentView
11
+ @end
12
+
13
+ NS_ASSUME_NONNULL_END
14
+
15
+ #endif /* YamapLitePolylineViewNativeComponent_h */
@@ -0,0 +1,115 @@
1
+ #import "YamapLitePolylineView.h"
2
+ #include "ReactCodegen/react/renderer/components/YamapLiteViewSpec/EventEmitters.h"
3
+ #include "react/renderer/components/YamapLiteViewSpec/EventEmitters.h"
4
+ #include <Foundation/Foundation.h>
5
+ #include <objc/NSObject.h>
6
+
7
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
8
+ #import <React/RCTConversions.h>
9
+ #import <react/renderer/components/YamapLiteViewSpec/ComponentDescriptors.h>
10
+ #import <react/renderer/components/YamapLiteViewSpec/EventEmitters.h>
11
+ #import <react/renderer/components/YamapLiteViewSpec/Props.h>
12
+ #import <react/renderer/components/YamapLiteViewSpec/RCTComponentViewHelpers.h>
13
+ #import <react/renderer/graphics/Color.h>
14
+
15
+ #import "RCTFabricComponentsPlugins.h"
16
+ #import "Utils/PointsEqual.h"
17
+ #import "YamapLite-Swift.h"
18
+ #import <YandexMapsMobile/YMKMapKitFactory.h>
19
+
20
+ using namespace facebook::react;
21
+
22
+ @interface YamapLitePolylineView () <RCTYamapLitePolylineViewViewProtocol,
23
+ YamapLitePolylineComponentDelegate>
24
+
25
+ @end
26
+
27
+ @implementation YamapLitePolylineView {
28
+ YamapLitePolyline *_view;
29
+ }
30
+
31
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
32
+ return concreteComponentDescriptorProvider<
33
+ YamapLitePolylineViewComponentDescriptor>();
34
+ }
35
+
36
+ - (instancetype)initWithFrame:(CGRect)frame {
37
+ if (self = [super initWithFrame:frame]) {
38
+ static const auto defaultProps =
39
+ std::make_shared<const YamapLitePolylineViewProps>();
40
+ _props = defaultProps;
41
+ _view = [[YamapLitePolyline alloc] init];
42
+ _view.delegate = self;
43
+ self.contentView = _view;
44
+ }
45
+ return self;
46
+ }
47
+
48
+ - (void)updateProps:(Props::Shared const &)props
49
+ oldProps:(Props::Shared const &)oldProps {
50
+ const auto &oldViewProps =
51
+ *std::static_pointer_cast<YamapLitePolylineViewProps const>(_props);
52
+ const auto &newViewProps =
53
+ *std::static_pointer_cast<YamapLitePolylineViewProps const>(props);
54
+ if (oldViewProps.strokeColor != newViewProps.strokeColor) {
55
+ UIColor *uiColor = RCTUIColorFromSharedColor(newViewProps.strokeColor);
56
+ if (uiColor) {
57
+ _view.strokeColor = uiColor;
58
+ }
59
+ }
60
+ if (oldViewProps.strokeWidth != newViewProps.strokeWidth) {
61
+ _view.strokeWidth = newViewProps.strokeWidth;
62
+ }
63
+ if (oldViewProps.outlineColor != newViewProps.outlineColor) {
64
+ UIColor *uiColor = RCTUIColorFromSharedColor(newViewProps.outlineColor);
65
+ if (uiColor) {
66
+ _view.outlineColor = uiColor;
67
+ }
68
+ }
69
+ if (oldViewProps.dashLength != newViewProps.dashLength) {
70
+ _view.dashLength = newViewProps.dashLength;
71
+ }
72
+ if (oldViewProps.gapLength != newViewProps.gapLength) {
73
+ _view.gapLength = newViewProps.gapLength;
74
+ }
75
+ if (oldViewProps.outlineWidth != newViewProps.outlineWidth) {
76
+ _view.outlineWidth = newViewProps.outlineWidth;
77
+ }
78
+ if (oldViewProps.dashOffset != newViewProps.dashOffset) {
79
+ _view.dashOffset = newViewProps.dashOffset;
80
+ }
81
+ if (oldViewProps.zInd != newViewProps.zInd) {
82
+ _view.zIndex = newViewProps.zInd;
83
+ }
84
+ if (!yamaplite::pointsEqual(oldViewProps.points, newViewProps.points)) {
85
+ NSMutableArray<YMKPoint *> *pointsArr =
86
+ [NSMutableArray arrayWithCapacity:newViewProps.points.size()];
87
+ for (const auto &p : newViewProps.points) {
88
+ [pointsArr addObject:[YMKPoint pointWithLatitude:p.lat longitude:p.lon]];
89
+ }
90
+ _view.points = pointsArr;
91
+ }
92
+ if (oldViewProps.handled != newViewProps.handled) {
93
+ _view.handled = newViewProps.handled;
94
+ }
95
+
96
+ [super updateProps:props oldProps:oldProps];
97
+ }
98
+
99
+ - (void)onPolylinePressWithPoint:
100
+ (NSDictionary<NSString *, NSNumber *> *_Nonnull)point {
101
+ if (_eventEmitter != nil) {
102
+ YamapLitePolylineViewEventEmitter::OnPolylinePress event = {};
103
+ event.lat = [[point objectForKey:@"lat"] doubleValue];
104
+ event.lon = [[point objectForKey:@"lon"] doubleValue];
105
+ std::dynamic_pointer_cast<const YamapLitePolylineViewEventEmitter>(
106
+ _eventEmitter)
107
+ ->onPolylinePress(event);
108
+ }
109
+ }
110
+
111
+ Class<RCTComponentViewProtocol> YamapLitePolylineViewCls(void) {
112
+ return YamapLitePolylineView.class;
113
+ }
114
+
115
+ @end
@@ -0,0 +1,15 @@
1
+ #import <React/RCTViewManager.h>
2
+ #import <React/RCTViewComponentView.h>
3
+ #import <UIKit/UIKit.h>
4
+
5
+ #ifndef YamapLiteViewNativeComponent_h
6
+ #define YamapLiteViewNativeComponent_h
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ @interface YamapLiteView : RCTViewComponentView
11
+ @end
12
+
13
+ NS_ASSUME_NONNULL_END
14
+
15
+ #endif /* YamapLiteViewNativeComponent_h */
@@ -0,0 +1,361 @@
1
+ #import "YamapLiteView.h"
2
+ #include "ReactCodegen/react/renderer/components/YamapLiteViewSpec/EventEmitters.h"
3
+ #include "YamapLiteCircleView.h"
4
+ #include "YamapLiteMarkerView.h"
5
+ #import "YamapLitePolygonView.h"
6
+ #import "YamapLitePolylineView.h"
7
+ #include <os/log.h>
8
+
9
+ #include <Foundation/Foundation.h>
10
+ #include <objc/NSObject.h>
11
+
12
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
13
+ #import <React/RCTConversions.h>
14
+ #import <react/renderer/components/YamapLiteViewSpec/ComponentDescriptors.h>
15
+ #import <react/renderer/components/YamapLiteViewSpec/EventEmitters.h>
16
+ #import <react/renderer/components/YamapLiteViewSpec/Props.h>
17
+ #import <react/renderer/components/YamapLiteViewSpec/RCTComponentViewHelpers.h>
18
+
19
+ #import "RCTFabricComponentsPlugins.h"
20
+ #import "YamapLite-Swift.h"
21
+
22
+ using namespace facebook::react;
23
+
24
+ @interface YamapLiteView () <RCTYamapLiteViewViewProtocol,
25
+ YamapViewComponentDelegate>
26
+
27
+ @end
28
+
29
+ @implementation YamapLiteView {
30
+ YamapView *_view;
31
+ }
32
+
33
+ + (ComponentDescriptorProvider)componentDescriptorProvider {
34
+ return concreteComponentDescriptorProvider<
35
+ YamapLiteViewComponentDescriptor>();
36
+ }
37
+
38
+ - (instancetype)initWithFrame:(CGRect)frame {
39
+ if (self = [super initWithFrame:frame]) {
40
+ static const auto defaultProps =
41
+ std::make_shared<const YamapLiteViewProps>();
42
+ _props = defaultProps;
43
+
44
+ _view = [[YamapView alloc] init];
45
+ _view.delegate = self;
46
+
47
+ self.contentView = _view;
48
+ }
49
+
50
+ return self;
51
+ }
52
+
53
+ - (void)updateProps:(Props::Shared const &)props
54
+ oldProps:(Props::Shared const &)oldProps {
55
+ const auto &oldViewProps =
56
+ *std::static_pointer_cast<YamapLiteViewProps const>(_props);
57
+ const auto &newViewProps =
58
+ *std::static_pointer_cast<YamapLiteViewProps const>(props);
59
+
60
+ if (oldViewProps.mapType != newViewProps.mapType) {
61
+ self->_view.mapType = RCTNSStringFromString(toString(newViewProps.mapType));
62
+ }
63
+ if (oldViewProps.nightMode != newViewProps.nightMode) {
64
+ self->_view.nightMode = newViewProps.nightMode;
65
+ }
66
+ if (oldViewProps.zoomGesturesEnabled != newViewProps.zoomGesturesEnabled) {
67
+ self->_view.zoomGesturesEnabled = newViewProps.zoomGesturesEnabled;
68
+ }
69
+ if (oldViewProps.scrollGesturesEnabled !=
70
+ newViewProps.scrollGesturesEnabled) {
71
+ self->_view.scrollGesturesEnabled = newViewProps.scrollGesturesEnabled;
72
+ }
73
+ if (oldViewProps.rotateGesturesEnabled !=
74
+ newViewProps.rotateGesturesEnabled) {
75
+ self->_view.rotateGesturesEnabled = newViewProps.rotateGesturesEnabled;
76
+ }
77
+
78
+ if (oldViewProps.initialRegion.lat != newViewProps.initialRegion.lat ||
79
+ oldViewProps.initialRegion.lon != newViewProps.initialRegion.lon ||
80
+ oldViewProps.initialRegion.zoom != newViewProps.initialRegion.zoom ||
81
+ oldViewProps.initialRegion.azimuth !=
82
+ newViewProps.initialRegion.azimuth ||
83
+ oldViewProps.initialRegion.tilt != newViewProps.initialRegion.tilt) {
84
+ [self->_view move:newViewProps.initialRegion.lat :newViewProps.initialRegion.lon :newViewProps.initialRegion.zoom :newViewProps.initialRegion.azimuth :newViewProps.initialRegion.tilt];
85
+ }
86
+ if (oldViewProps.tiltGesturesEnabled != newViewProps.tiltGesturesEnabled) {
87
+ self->_view.tiltGesturesEnabled = newViewProps.tiltGesturesEnabled;
88
+ }
89
+ if (oldViewProps.fastTapEnabled != newViewProps.fastTapEnabled) {
90
+ self->_view.fastTapEnabled = newViewProps.fastTapEnabled;
91
+ }
92
+ if (oldViewProps.userLocationAccuracyFillColor !=
93
+ newViewProps.userLocationAccuracyFillColor) {
94
+ self->_view.userLocationAccuracyFillColor =
95
+ [self hexStringToColor:RCTNSStringFromString(
96
+ newViewProps.userLocationAccuracyFillColor)];
97
+ }
98
+ if (oldViewProps.userLocationAccuracyStrokeColor !=
99
+ newViewProps.userLocationAccuracyStrokeColor) {
100
+ self->_view.userLocationAccuracyStrokeColor = [self
101
+ hexStringToColor:RCTNSStringFromString(
102
+ newViewProps.userLocationAccuracyStrokeColor)];
103
+ }
104
+ if (oldViewProps.userLocationAccuracyStrokeWidth !=
105
+ newViewProps.userLocationAccuracyStrokeWidth) {
106
+ self->_view.userLocationAccuracyStrokeWidth =
107
+ newViewProps.userLocationAccuracyStrokeWidth;
108
+ }
109
+ if (oldViewProps.showUserPosition != newViewProps.showUserPosition) {
110
+ [self->_view setShowUserPositionState:newViewProps.showUserPosition];
111
+ }
112
+ if (oldViewProps.userLocationIcon != newViewProps.userLocationIcon) {
113
+ [self->_view
114
+ setUserLocationIconWithPath:RCTNSStringFromString(
115
+ newViewProps.userLocationIcon)];
116
+ }
117
+ if (oldViewProps.userLocationIconScale !=
118
+ newViewProps.userLocationIconScale) {
119
+ self->_view.userLocationIconScale = newViewProps.userLocationIconScale;
120
+ }
121
+ if (oldViewProps.followUser != newViewProps.followUser) {
122
+ self->_view.followUser = newViewProps.followUser;
123
+ }
124
+ if (oldViewProps.logoPosition.horizontal !=
125
+ newViewProps.logoPosition.horizontal ||
126
+ oldViewProps.logoPosition.vertical !=
127
+ newViewProps.logoPosition.vertical) {
128
+ [self->_view setLogoPositionWithPosition:@{
129
+ @"horizontal" :
130
+ RCTNSStringFromString(toString(newViewProps.logoPosition.horizontal)),
131
+ @"vertical" :
132
+ RCTNSStringFromString(toString(newViewProps.logoPosition.vertical))
133
+ }];
134
+ }
135
+ if (oldViewProps.logoPadding.vertical != newViewProps.logoPadding.vertical ||
136
+ oldViewProps.logoPadding.horizontal !=
137
+ newViewProps.logoPadding.horizontal) {
138
+ [self->_view
139
+ setLogoPaddingWithVertical:newViewProps.logoPadding.vertical
140
+ horizontal:newViewProps.logoPadding.horizontal];
141
+ }
142
+ if (oldViewProps.maxFps != newViewProps.maxFps) {
143
+ self->_view.maxFps = newViewProps.maxFps;
144
+ }
145
+ [self->_view applyProperties];
146
+
147
+ [super updateProps:props oldProps:oldProps];
148
+ }
149
+
150
+ - (void)handleCommand:(NSString *)commandName args:(NSArray *)args {
151
+ }
152
+
153
+ - (void)setCenter:(double)latitude
154
+ longitude:(double)longitude
155
+ zoom:(float)zoom
156
+ azimuth:(float)azimuth
157
+ tilt:(float)tilt
158
+ duration:(float)duration
159
+ animation:(NSString *)animation {
160
+ [_view setCenterWithLatitude:latitude
161
+ longitude:longitude
162
+ zoom:zoom
163
+ azimuth:azimuth
164
+ tilt:tilt
165
+ duration:duration
166
+ animation:animation];
167
+ }
168
+
169
+ - (void)setZoom:(float)zoom
170
+ duration:(float)duration
171
+ animation:(NSString *)animation {
172
+ if (_view != nil) {
173
+ [_view setZoomWithZoom:zoom duration:duration animation:animation];
174
+ } else {
175
+ os_log_error(OS_LOG_DEFAULT, "YamapLiteView: _view is nil");
176
+ }
177
+ }
178
+
179
+ - (void)fitAllMarkers {
180
+ if (_view != nil) {
181
+ [_view fitAllMarkers];
182
+ } else {
183
+ os_log_error(OS_LOG_DEFAULT, "YamapLiteView: _view is nil");
184
+ }
185
+ }
186
+
187
+ - (void)handleOnMapLoadedWithResult:(NSDictionary *)obj {
188
+ if (_view != nil) {
189
+ [_view applyProperties];
190
+ }
191
+
192
+ if (_eventEmitter != nil) {
193
+ YamapLiteViewEventEmitter::OnMapLoaded event = {};
194
+ event.curZoomGeometryLoaded =
195
+ [[obj objectForKey:@"curZoomGeometryLoaded"] doubleValue];
196
+ event.curZoomModelsLoaded =
197
+ [[obj objectForKey:@"curZoomModelsLoaded"] doubleValue];
198
+ event.curZoomLabelsLoaded =
199
+ [[obj objectForKey:@"curZoomLabelsLoaded"] doubleValue];
200
+ event.curZoomPlacemarksLoaded =
201
+ [[obj objectForKey:@"curZoomPlacemarksLoaded"] doubleValue];
202
+ event.fullyLoaded = [[obj objectForKey:@"fullyLoaded"] doubleValue];
203
+ event.renderObjectCount =
204
+ [[obj objectForKey:@"renderObjectCount"] doubleValue];
205
+ event.tileMemoryUsage = [[obj objectForKey:@"tileMemoryUsage"] doubleValue];
206
+ event.delayedGeometryLoaded =
207
+ [[obj objectForKey:@"delayedGeometryLoaded"] doubleValue];
208
+ event.fullyAppeared = [[obj objectForKey:@"fullyAppeared"] doubleValue];
209
+ std::dynamic_pointer_cast<const YamapLiteViewEventEmitter>(_eventEmitter)
210
+ ->onMapLoaded(event);
211
+ }
212
+ }
213
+
214
+ - (void)handleOnCameraPositionChangeWithCoords:(NSDictionary *)coords {
215
+ if (_eventEmitter != nil) {
216
+ YamapLiteViewEventEmitter::OnCameraPositionChange event = {};
217
+ event.point.lat = [[coords objectForKey:@"lat"] doubleValue];
218
+ event.point.lon = [[coords objectForKey:@"lon"] doubleValue];
219
+ event.zoom = [[coords objectForKey:@"zoom"] doubleValue];
220
+ event.azimuth = [[coords objectForKey:@"azimuth"] doubleValue];
221
+ event.tilt = [[coords objectForKey:@"tilt"] doubleValue];
222
+ event.finished = [[coords objectForKey:@"finished"] boolValue];
223
+ event.target = [[coords objectForKey:@"target"] doubleValue];
224
+
225
+ id reasonObj = [coords objectForKey:@"reason"];
226
+ NSString *reasonString = @"GESTURES";
227
+ if ([reasonObj isKindOfClass:[NSString class]]) {
228
+ reasonString = (NSString *)reasonObj;
229
+ } else if (reasonObj != nil) {
230
+ reasonString = [NSString stringWithFormat:@"%@", reasonObj];
231
+ }
232
+ if ([reasonString isEqualToString:@"APPLICATION"]) {
233
+ event.reason =
234
+ YamapLiteViewEventEmitter::OnCameraPositionChangeReason::APPLICATION;
235
+ } else {
236
+ event.reason =
237
+ YamapLiteViewEventEmitter::OnCameraPositionChangeReason::GESTURES;
238
+ }
239
+
240
+ std::dynamic_pointer_cast<const YamapLiteViewEventEmitter>(_eventEmitter)
241
+ ->onCameraPositionChange(event);
242
+ }
243
+ }
244
+
245
+ - (void)handleOnCameraPositionChangeEndWithCoords:
246
+ (NSDictionary<NSString *, id> *)coords {
247
+ if (_eventEmitter != nil) {
248
+ YamapLiteViewEventEmitter::OnCameraPositionChangeEnd event = {};
249
+ event.point.lat = [[coords objectForKey:@"lat"] doubleValue];
250
+ event.point.lon = [[coords objectForKey:@"lon"] doubleValue];
251
+ event.zoom = [[coords objectForKey:@"zoom"] doubleValue];
252
+ event.azimuth = [[coords objectForKey:@"azimuth"] doubleValue];
253
+ event.tilt = [[coords objectForKey:@"tilt"] doubleValue];
254
+ event.finished = [[coords objectForKey:@"finished"] boolValue];
255
+ event.target = [[coords objectForKey:@"target"] doubleValue];
256
+
257
+ id reasonObj = [coords objectForKey:@"reason"];
258
+ NSString *reasonString = @"GESTURES";
259
+ if ([reasonObj isKindOfClass:[NSString class]]) {
260
+ reasonString = (NSString *)reasonObj;
261
+ } else if (reasonObj != nil) {
262
+ reasonString = [NSString stringWithFormat:@"%@", reasonObj];
263
+ }
264
+ if ([reasonString isEqualToString:@"APPLICATION"]) {
265
+ event.reason = YamapLiteViewEventEmitter::
266
+ OnCameraPositionChangeEndReason::APPLICATION;
267
+ } else {
268
+ event.reason =
269
+ YamapLiteViewEventEmitter::OnCameraPositionChangeEndReason::GESTURES;
270
+ }
271
+
272
+ std::dynamic_pointer_cast<const YamapLiteViewEventEmitter>(_eventEmitter)
273
+ ->onCameraPositionChangeEnd(event);
274
+ }
275
+ }
276
+
277
+ - (void)handleOnMapLongPressWithCoords:(NSDictionary *)coords {
278
+ if (_eventEmitter != nil) {
279
+ YamapLiteViewEventEmitter::OnMapLongPress event = {};
280
+ event.lat = [[coords objectForKey:@"lat"] doubleValue];
281
+ event.lon = [[coords objectForKey:@"lon"] doubleValue];
282
+ std::dynamic_pointer_cast<const YamapLiteViewEventEmitter>(_eventEmitter)
283
+ ->onMapLongPress(event);
284
+ }
285
+ }
286
+
287
+ - (void)handleOnMapPressWithCoords:(NSDictionary *)coords {
288
+ if (_eventEmitter != nil) {
289
+ YamapLiteViewEventEmitter::OnMapPress event = {};
290
+ event.lat = [[coords objectForKey:@"lat"] doubleValue];
291
+ event.lon = [[coords objectForKey:@"lon"] doubleValue];
292
+ std::dynamic_pointer_cast<const YamapLiteViewEventEmitter>(_eventEmitter)
293
+ ->onMapPress(event);
294
+ }
295
+ }
296
+
297
+ - (void)mountChildComponentView:
298
+ (nonnull UIView<RCTComponentViewProtocol> *)childComponentView
299
+ index:(NSInteger)index {
300
+ if ([childComponentView isKindOfClass:YamapLiteMarkerView.class]) {
301
+ [_view insertReactSubview:childComponentView atIndex:index];
302
+ }
303
+ if ([childComponentView isKindOfClass:YamapLiteCircleView.class]) {
304
+ [_view insertReactSubview:childComponentView atIndex:index];
305
+ }
306
+ if ([childComponentView isKindOfClass:YamapLitePolylineView.class]) {
307
+ [_view insertReactSubview:childComponentView atIndex:index];
308
+ }
309
+ if ([childComponentView isKindOfClass:YamapLitePolygonView.class]) {
310
+ [_view insertReactSubview:childComponentView atIndex:index];
311
+ }
312
+ }
313
+
314
+ - (void)unmountChildComponentView:
315
+ (nonnull UIView<RCTComponentViewProtocol> *)childComponentView
316
+ index:(NSInteger)index {
317
+ if ([childComponentView isKindOfClass:YamapLiteMarkerView.class] ||
318
+ [childComponentView isKindOfClass:YamapLiteCircleView.class] ||
319
+ [childComponentView isKindOfClass:YamapLitePolylineView.class] ||
320
+ [childComponentView isKindOfClass:YamapLitePolygonView.class]) {
321
+ [_view removeReactSubview:childComponentView];
322
+ [childComponentView removeFromSuperview];
323
+ }
324
+ }
325
+
326
+ Class<RCTComponentViewProtocol> YamapLiteViewCls(void) {
327
+ return YamapLiteView.class;
328
+ }
329
+
330
+ - hexStringToColor:(NSString *)stringToConvert {
331
+ NSString *noHashString =
332
+ [stringToConvert stringByReplacingOccurrencesOfString:@"#"
333
+ withString:@""];
334
+ NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
335
+
336
+ unsigned hex;
337
+ if (![stringScanner scanHexInt:&hex])
338
+ return nil;
339
+
340
+ if (noHashString.length == 8) {
341
+ // AARRGGBB
342
+ int a = (hex >> 24) & 0xFF;
343
+ int r = (hex >> 16) & 0xFF;
344
+ int g = (hex >> 8) & 0xFF;
345
+ int b = (hex) & 0xFF;
346
+ return [UIColor colorWithRed:r / 255.0f
347
+ green:g / 255.0f
348
+ blue:b / 255.0f
349
+ alpha:a / 255.0f];
350
+ }
351
+
352
+ int r = (hex >> 16) & 0xFF;
353
+ int g = (hex >> 8) & 0xFF;
354
+ int b = (hex) & 0xFF;
355
+ return [UIColor colorWithRed:r / 255.0f
356
+ green:g / 255.0f
357
+ blue:b / 255.0f
358
+ alpha:1.0f];
359
+ }
360
+
361
+ @end
@@ -0,0 +1,17 @@
1
+ #import <React/RCTViewManager.h>
2
+ #import <React/RCTUIManager.h>
3
+ #import "RCTBridge.h"
4
+
5
+ @interface YamapLiteViewManager : RCTViewManager
6
+ @end
7
+
8
+ @implementation YamapLiteViewManager
9
+
10
+ RCT_EXPORT_MODULE(YamapLiteView)
11
+
12
+ - (UIView *)view
13
+ {
14
+ return [[UIView alloc] init];
15
+ }
16
+
17
+ @end
@@ -0,0 +1,5 @@
1
+ #import "YamapLiteViewSpec.h"
2
+ #import <Foundation/Foundation.h>
3
+ @interface YamapUtils : NSObject <NativeYamapUtilsSpec>
4
+
5
+ @end