react-native-beidou 1.0.3 → 1.0.5
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.
- package/BeiDouAIDLTestPage.tsx +7 -7
- package/Compass.android.tsx +20 -0
- package/Compass.ios.tsx +15 -0
- package/Compass.tsx +6 -0
- package/README.md +48 -124
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/android/.idea/AndroidProjectSystem.xml +6 -0
- package/android/.idea/gradle.xml +13 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +9 -0
- package/android/.idea/runConfigurations.xml +17 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/build.gradle +3 -0
- package/android/src/main/AndroidManifest.xml +7 -0
- package/android/src/main/java/com/cmcc_rn_module/BeiDouBluetoothModule.java +343 -101
- package/android/src/main/java/com/cmcc_rn_module/BeiDouBluetoothPackage.java +4 -1
- package/android/src/main/java/com/cmcc_rn_module/ChatDBManager.java +306 -0
- package/android/src/main/java/com/cmcc_rn_module/JsonUtil.java +113 -7
- package/android/src/main/java/com/cmcc_rn_module/view/CompassManager.java +41 -0
- package/android/src/main/java/com/cmcc_rn_module/view/CompassView.java +277 -0
- package/android/src/main/libs/bluetooth-sdk.aar +0 -0
- package/index.ts +188 -10
- package/ios/BDTCompassViewManager.h +15 -0
- package/ios/BDTCompassViewManager.m +24 -0
- package/ios/BeiDouBluetoothModule.h +20 -0
- package/ios/BeiDouBluetoothModule.m +424 -0
- package/ios/BeidouBluetooth.framework/BeidouBluetooth +0 -0
- package/ios/BeidouBluetooth.framework/Headers/BDTBluetoothManager.h +76 -0
- package/ios/BeidouBluetooth.framework/Headers/BDTChatDBManager.h +41 -0
- package/ios/BeidouBluetooth.framework/Headers/BDTDataPacketBuilder.h +62 -0
- package/ios/BeidouBluetooth.framework/Headers/BeidouBluetooth.h +21 -0
- package/ios/BeidouBluetooth.framework/Info.plist +0 -0
- package/ios/BeidouBluetooth.framework/Modules/module.modulemap +6 -0
- package/ios/BeidouBluetooth.framework/_CodeSignature/CodeDirectory +0 -0
- package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements +0 -0
- package/ios/BeidouBluetooth.framework/_CodeSignature/CodeRequirements-1 +0 -0
- package/ios/BeidouBluetooth.framework/_CodeSignature/CodeResources +177 -0
- package/ios/BeidouBluetooth.framework/_CodeSignature/CodeSignature +0 -0
- package/ios/CompassView.h +20 -0
- package/ios/CompassView.m +201 -0
- package/package.json +4 -1
- package/android/.gradle/8.8/checksums/checksums.lock +0 -0
- package/android/.gradle/8.8/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.8/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.8/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.8/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.8/gc.properties +0 -0
- package/ios/Podfile +0 -79
- package/ios/build_sdk.sh +0 -30
- package/ios/cmcc_rn_module/AppDelegate.h +0 -8
- package/ios/cmcc_rn_module/AppDelegate.mm +0 -108
- package/ios/cmcc_rn_module/CMCCAssetsLoaderModule.h +0 -17
- package/ios/cmcc_rn_module/CMCCAssetsLoaderModule.m +0 -38
- package/ios/cmcc_rn_module/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
- package/ios/cmcc_rn_module/Images.xcassets/Contents.json +0 -6
- package/ios/cmcc_rn_module/Info.plist +0 -62
- package/ios/cmcc_rn_module/LaunchScreen.storyboard +0 -47
- package/ios/cmcc_rn_module/main.m +0 -10
- package/ios/cmcc_rn_module.xcodeproj/project.pbxproj +0 -708
- package/ios/cmcc_rn_module.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/cmcc_rn_module.xcodeproj/xcshareddata/xcschemes/cmcc_rn_module.xcscheme +0 -88
- package/ios/cmcc_rn_module.xcworkspace/contents.xcworkspacedata +0 -10
- package/ios/cmcc_rn_module.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/cmcc_rn_moduleTests/Info.plist +0 -24
- package/ios/cmcc_rn_moduleTests/cmcc_rn_moduleTests.m +0 -66
- package/ios/reset_env.sh +0 -24
- package/ios/scripts/RNReanimated.podspec +0 -90
- package/ios/scripts/generate_dynamic_pod.rb +0 -166
- package/ios/scripts/native_modules_dy.rb +0 -317
- package/ios/scripts/react_native_pods_dy.rb +0 -773
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>files</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Headers/BDTBluetoothManager.h</key>
|
|
8
|
+
<data>
|
|
9
|
+
Mke3zeUQy40YfFrfW2gJ82VfWV4=
|
|
10
|
+
</data>
|
|
11
|
+
<key>Headers/BDTChatDBManager.h</key>
|
|
12
|
+
<data>
|
|
13
|
+
Ssm2BaxSbw5TyDQFFEvzaAIzti0=
|
|
14
|
+
</data>
|
|
15
|
+
<key>Headers/BDTDataPacketBuilder.h</key>
|
|
16
|
+
<data>
|
|
17
|
+
M2mub8VwH6cd3mT+Cmj6jU/wxfs=
|
|
18
|
+
</data>
|
|
19
|
+
<key>Headers/BeidouBluetooth.h</key>
|
|
20
|
+
<data>
|
|
21
|
+
GT//uw00ZbbeeNIbQ1sZNM1rENU=
|
|
22
|
+
</data>
|
|
23
|
+
<key>Info.plist</key>
|
|
24
|
+
<data>
|
|
25
|
+
DR5ddGL6XEMpus+lIMmzGrdLRFQ=
|
|
26
|
+
</data>
|
|
27
|
+
<key>Modules/module.modulemap</key>
|
|
28
|
+
<data>
|
|
29
|
+
yHOK7zkIIc74zmi9L/LHK2NDXUY=
|
|
30
|
+
</data>
|
|
31
|
+
</dict>
|
|
32
|
+
<key>files2</key>
|
|
33
|
+
<dict>
|
|
34
|
+
<key>Headers/BDTBluetoothManager.h</key>
|
|
35
|
+
<dict>
|
|
36
|
+
<key>hash</key>
|
|
37
|
+
<data>
|
|
38
|
+
Mke3zeUQy40YfFrfW2gJ82VfWV4=
|
|
39
|
+
</data>
|
|
40
|
+
<key>hash2</key>
|
|
41
|
+
<data>
|
|
42
|
+
za/DfAgrjgS1qm3F78y6hNJPqscxWzIx+vD7ol+wERA=
|
|
43
|
+
</data>
|
|
44
|
+
</dict>
|
|
45
|
+
<key>Headers/BDTChatDBManager.h</key>
|
|
46
|
+
<dict>
|
|
47
|
+
<key>hash</key>
|
|
48
|
+
<data>
|
|
49
|
+
Ssm2BaxSbw5TyDQFFEvzaAIzti0=
|
|
50
|
+
</data>
|
|
51
|
+
<key>hash2</key>
|
|
52
|
+
<data>
|
|
53
|
+
TFMm6gfl9wRQMpzzFN3/sm1qAREjTDYKKfkUREEoOM8=
|
|
54
|
+
</data>
|
|
55
|
+
</dict>
|
|
56
|
+
<key>Headers/BDTDataPacketBuilder.h</key>
|
|
57
|
+
<dict>
|
|
58
|
+
<key>hash</key>
|
|
59
|
+
<data>
|
|
60
|
+
M2mub8VwH6cd3mT+Cmj6jU/wxfs=
|
|
61
|
+
</data>
|
|
62
|
+
<key>hash2</key>
|
|
63
|
+
<data>
|
|
64
|
+
HDzbJwP03m263UzurGCq5CnM2RmRkmJAvzRPsKAmZ9U=
|
|
65
|
+
</data>
|
|
66
|
+
</dict>
|
|
67
|
+
<key>Headers/BeidouBluetooth.h</key>
|
|
68
|
+
<dict>
|
|
69
|
+
<key>hash</key>
|
|
70
|
+
<data>
|
|
71
|
+
GT//uw00ZbbeeNIbQ1sZNM1rENU=
|
|
72
|
+
</data>
|
|
73
|
+
<key>hash2</key>
|
|
74
|
+
<data>
|
|
75
|
+
9KnESYsMN0jIa0J3X3LKKHNDT/8mnHWXbXdWEShMazo=
|
|
76
|
+
</data>
|
|
77
|
+
</dict>
|
|
78
|
+
<key>Modules/module.modulemap</key>
|
|
79
|
+
<dict>
|
|
80
|
+
<key>hash</key>
|
|
81
|
+
<data>
|
|
82
|
+
yHOK7zkIIc74zmi9L/LHK2NDXUY=
|
|
83
|
+
</data>
|
|
84
|
+
<key>hash2</key>
|
|
85
|
+
<data>
|
|
86
|
+
2jYuzibwQKK2r2a2CS68WaFxOT/Tk941Kc8LUBwRUcg=
|
|
87
|
+
</data>
|
|
88
|
+
</dict>
|
|
89
|
+
</dict>
|
|
90
|
+
<key>rules</key>
|
|
91
|
+
<dict>
|
|
92
|
+
<key>^.*</key>
|
|
93
|
+
<true/>
|
|
94
|
+
<key>^.*\.lproj/</key>
|
|
95
|
+
<dict>
|
|
96
|
+
<key>optional</key>
|
|
97
|
+
<true/>
|
|
98
|
+
<key>weight</key>
|
|
99
|
+
<real>1000</real>
|
|
100
|
+
</dict>
|
|
101
|
+
<key>^.*\.lproj/locversion.plist$</key>
|
|
102
|
+
<dict>
|
|
103
|
+
<key>omit</key>
|
|
104
|
+
<true/>
|
|
105
|
+
<key>weight</key>
|
|
106
|
+
<real>1100</real>
|
|
107
|
+
</dict>
|
|
108
|
+
<key>^Base\.lproj/</key>
|
|
109
|
+
<dict>
|
|
110
|
+
<key>weight</key>
|
|
111
|
+
<real>1010</real>
|
|
112
|
+
</dict>
|
|
113
|
+
<key>^version.plist$</key>
|
|
114
|
+
<true/>
|
|
115
|
+
</dict>
|
|
116
|
+
<key>rules2</key>
|
|
117
|
+
<dict>
|
|
118
|
+
<key>.*\.dSYM($|/)</key>
|
|
119
|
+
<dict>
|
|
120
|
+
<key>weight</key>
|
|
121
|
+
<real>11</real>
|
|
122
|
+
</dict>
|
|
123
|
+
<key>^(.*/)?\.DS_Store$</key>
|
|
124
|
+
<dict>
|
|
125
|
+
<key>omit</key>
|
|
126
|
+
<true/>
|
|
127
|
+
<key>weight</key>
|
|
128
|
+
<real>2000</real>
|
|
129
|
+
</dict>
|
|
130
|
+
<key>^.*</key>
|
|
131
|
+
<true/>
|
|
132
|
+
<key>^.*\.lproj/</key>
|
|
133
|
+
<dict>
|
|
134
|
+
<key>optional</key>
|
|
135
|
+
<true/>
|
|
136
|
+
<key>weight</key>
|
|
137
|
+
<real>1000</real>
|
|
138
|
+
</dict>
|
|
139
|
+
<key>^.*\.lproj/locversion.plist$</key>
|
|
140
|
+
<dict>
|
|
141
|
+
<key>omit</key>
|
|
142
|
+
<true/>
|
|
143
|
+
<key>weight</key>
|
|
144
|
+
<real>1100</real>
|
|
145
|
+
</dict>
|
|
146
|
+
<key>^Base\.lproj/</key>
|
|
147
|
+
<dict>
|
|
148
|
+
<key>weight</key>
|
|
149
|
+
<real>1010</real>
|
|
150
|
+
</dict>
|
|
151
|
+
<key>^Info\.plist$</key>
|
|
152
|
+
<dict>
|
|
153
|
+
<key>omit</key>
|
|
154
|
+
<true/>
|
|
155
|
+
<key>weight</key>
|
|
156
|
+
<real>20</real>
|
|
157
|
+
</dict>
|
|
158
|
+
<key>^PkgInfo$</key>
|
|
159
|
+
<dict>
|
|
160
|
+
<key>omit</key>
|
|
161
|
+
<true/>
|
|
162
|
+
<key>weight</key>
|
|
163
|
+
<real>20</real>
|
|
164
|
+
</dict>
|
|
165
|
+
<key>^embedded\.provisionprofile$</key>
|
|
166
|
+
<dict>
|
|
167
|
+
<key>weight</key>
|
|
168
|
+
<real>20</real>
|
|
169
|
+
</dict>
|
|
170
|
+
<key>^version\.plist$</key>
|
|
171
|
+
<dict>
|
|
172
|
+
<key>weight</key>
|
|
173
|
+
<real>20</real>
|
|
174
|
+
</dict>
|
|
175
|
+
</dict>
|
|
176
|
+
</dict>
|
|
177
|
+
</plist>
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CompassView.h
|
|
3
|
+
// Bluetooth
|
|
4
|
+
//
|
|
5
|
+
// Created by 董建伟 on 2025/4/9.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <UIKit/UIKit.h>
|
|
9
|
+
#import <CoreLocation/CoreLocation.h>
|
|
10
|
+
#import <React/RCTComponent.h>
|
|
11
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
+
|
|
13
|
+
@interface CompassView : UIView
|
|
14
|
+
|
|
15
|
+
/// RN 回调 block
|
|
16
|
+
@property (nonatomic, copy) RCTBubblingEventBlock onHeadingChange;
|
|
17
|
+
|
|
18
|
+
@end
|
|
19
|
+
|
|
20
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
|
|
2
|
+
// CompassView.m
|
|
3
|
+
// Bluetooth
|
|
4
|
+
//
|
|
5
|
+
// Created by 董建伟 on 2025/4/9.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
#import "CompassView.h"
|
|
9
|
+
#import <CoreLocation/CoreLocation.h>
|
|
10
|
+
#include <math.h>
|
|
11
|
+
|
|
12
|
+
@interface CompassView () <CLLocationManagerDelegate>
|
|
13
|
+
|
|
14
|
+
@property (nonatomic, strong) CLLocationManager *locationManager;
|
|
15
|
+
|
|
16
|
+
/// 当前方向角,单位:弧度(0 表示北,顺时针递增)
|
|
17
|
+
@property (nonatomic, assign) CGFloat headingAngle;
|
|
18
|
+
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@implementation CompassView
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
- (instancetype)init
|
|
25
|
+
{
|
|
26
|
+
self = [super init];
|
|
27
|
+
if (self) {
|
|
28
|
+
[self setupLocationManager];
|
|
29
|
+
}
|
|
30
|
+
return self;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
// MARK: - 初始化 CLLocationManager
|
|
35
|
+
- (void)setupLocationManager {
|
|
36
|
+
self.locationManager = [[CLLocationManager alloc] init];
|
|
37
|
+
self.locationManager.delegate = self;
|
|
38
|
+
|
|
39
|
+
// 检查设备是否支持指南针
|
|
40
|
+
if ([CLLocationManager headingAvailable]) {
|
|
41
|
+
// 请求定位权限(必须)
|
|
42
|
+
[self.locationManager requestWhenInUseAuthorization];
|
|
43
|
+
|
|
44
|
+
// 开始更新指南针数据
|
|
45
|
+
[self.locationManager startUpdatingHeading];
|
|
46
|
+
} else {
|
|
47
|
+
NSLog(@"设备不支持指南针功能");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// MARK: - CLLocationManagerDelegate
|
|
53
|
+
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
|
|
54
|
+
// 获取真北方向(单位:度)
|
|
55
|
+
CGFloat magneticHeading = newHeading.magneticHeading;
|
|
56
|
+
int rounded = (int)roundf(magneticHeading);
|
|
57
|
+
NSLog(@"真北: %f---%d",magneticHeading,rounded);
|
|
58
|
+
// 转换为弧度(UIKit 的旋转是逆时针,所以取负值)
|
|
59
|
+
CGFloat radians = -magneticHeading * M_PI / 180.0;
|
|
60
|
+
NSLog(@"弧度:%f",radians);
|
|
61
|
+
// 主线程更新 UI
|
|
62
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
63
|
+
[self rotateCompassToAngle:radians];
|
|
64
|
+
self.headingAngle = radians;
|
|
65
|
+
[self setNeedsDisplay];
|
|
66
|
+
|
|
67
|
+
// 触发 RN 回调
|
|
68
|
+
if (self.onHeadingChange) {
|
|
69
|
+
self.onHeadingChange(@{@"radians": @(radians), @"degrees": @(magneticHeading)});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// MARK: - 旋转指南针视图
|
|
77
|
+
- (void)rotateCompassToAngle:(CGFloat)radians {
|
|
78
|
+
[UIView animateWithDuration:0.2 animations:^{
|
|
79
|
+
self.transform = CGAffineTransformMakeRotation(radians);
|
|
80
|
+
}];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
- (void)drawRect:(CGRect)rect {
|
|
85
|
+
[super drawRect:rect];
|
|
86
|
+
|
|
87
|
+
CGContextRef context = UIGraphicsGetCurrentContext();
|
|
88
|
+
CGContextSetShouldAntialias(context, YES);
|
|
89
|
+
|
|
90
|
+
// 基础参数计算
|
|
91
|
+
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
|
|
92
|
+
CGFloat radius = screenWidth/2 - 50;
|
|
93
|
+
CGPoint center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect));
|
|
94
|
+
|
|
95
|
+
// 绘制背景圆
|
|
96
|
+
UIBezierPath *circle = [UIBezierPath bezierPathWithArcCenter:center
|
|
97
|
+
radius:radius
|
|
98
|
+
startAngle:0
|
|
99
|
+
endAngle:M_PI*2
|
|
100
|
+
clockwise:YES];
|
|
101
|
+
[[UIColor blackColor] setFill];
|
|
102
|
+
[circle fill];
|
|
103
|
+
|
|
104
|
+
// 保存初始坐标系
|
|
105
|
+
CGContextSaveGState(context);
|
|
106
|
+
|
|
107
|
+
// 旋转坐标系(使0度位于顶部)
|
|
108
|
+
CGContextTranslateCTM(context, center.x, center.y);
|
|
109
|
+
CGContextRotateCTM(context, -M_PI_2);
|
|
110
|
+
|
|
111
|
+
// 绘制刻度系统
|
|
112
|
+
for (int i = 0; i < 180; i++) {
|
|
113
|
+
CGFloat angle = i * 2 * M_PI / 180;
|
|
114
|
+
BOOL isMajor = (i % 15) == 0; // 每30度一个大刻度
|
|
115
|
+
|
|
116
|
+
CGFloat lineLength = isMajor ? 20 : 10;
|
|
117
|
+
CGFloat lineWidth = isMajor ? 2.0 : 1.0;
|
|
118
|
+
UIColor *lineColor = [UIColor whiteColor];
|
|
119
|
+
|
|
120
|
+
CGContextSaveGState(context);
|
|
121
|
+
CGContextRotateCTM(context, angle);
|
|
122
|
+
|
|
123
|
+
UIBezierPath *tick = [UIBezierPath bezierPath];
|
|
124
|
+
[tick moveToPoint:CGPointMake(radius - lineLength, 0)];
|
|
125
|
+
[tick addLineToPoint:CGPointMake(radius, 0)];
|
|
126
|
+
|
|
127
|
+
[lineColor setStroke];
|
|
128
|
+
tick.lineWidth = lineWidth;
|
|
129
|
+
[tick stroke];
|
|
130
|
+
|
|
131
|
+
CGContextRestoreGState(context);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 恢复坐标系
|
|
135
|
+
CGContextRestoreGState(context);
|
|
136
|
+
|
|
137
|
+
// 绘制30度数字标注(圆外)
|
|
138
|
+
UIFont *degreeFont = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
139
|
+
NSDictionary *degreeAttributes = @{
|
|
140
|
+
NSFontAttributeName: degreeFont,
|
|
141
|
+
NSForegroundColorAttributeName: [UIColor colorWithWhite:0.9 alpha:0.8]
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
for (int degree = 0; degree < 360; degree += 30) {
|
|
145
|
+
CGFloat angle = degree * M_PI / 180;
|
|
146
|
+
CGFloat textRadius = radius + 28; // 位于圆外
|
|
147
|
+
|
|
148
|
+
// 计算文字位置
|
|
149
|
+
CGPoint textPosition = CGPointMake(
|
|
150
|
+
center.x + textRadius * sin(angle),
|
|
151
|
+
center.y - textRadius * cos(angle)
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
CGContextSaveGState(context);
|
|
155
|
+
CGContextTranslateCTM(context, textPosition.x, textPosition.y);
|
|
156
|
+
|
|
157
|
+
CGContextRotateCTM(context, -self.headingAngle);
|
|
158
|
+
|
|
159
|
+
NSString *degreeString = [NSString stringWithFormat:@"%d", degree];
|
|
160
|
+
CGSize textSize = [degreeString sizeWithAttributes:degreeAttributes];
|
|
161
|
+
[degreeString drawAtPoint:CGPointMake(-textSize.width/2, -textSize.height/2)
|
|
162
|
+
withAttributes:degreeAttributes];
|
|
163
|
+
|
|
164
|
+
CGContextRestoreGState(context);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// 绘制主要方向文字(北东南西)
|
|
168
|
+
NSArray *directions = @[@"北", @"东", @"南", @"西"];
|
|
169
|
+
NSArray *angles = @[@0, @90, @180, @270];
|
|
170
|
+
UIFont *directionFont = [UIFont systemFontOfSize:30 weight:UIFontWeightRegular];
|
|
171
|
+
|
|
172
|
+
for (int i = 0; i < 4; i++) {
|
|
173
|
+
CGFloat angle = [angles[i] floatValue] * M_PI / 180;
|
|
174
|
+
NSString *text = directions[i];
|
|
175
|
+
CGFloat textRadius = radius - 50;
|
|
176
|
+
|
|
177
|
+
// 计算文字位置
|
|
178
|
+
CGPoint textCenter = CGPointMake(
|
|
179
|
+
center.x + textRadius * sin(angle),
|
|
180
|
+
center.y - textRadius * cos(angle)
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
CGContextSaveGState(context);
|
|
184
|
+
CGContextTranslateCTM(context, textCenter.x, textCenter.y);
|
|
185
|
+
|
|
186
|
+
CGContextRotateCTM(context, -self.headingAngle);
|
|
187
|
+
|
|
188
|
+
NSDictionary *attrs = @{
|
|
189
|
+
NSFontAttributeName: directionFont,
|
|
190
|
+
NSForegroundColorAttributeName: [UIColor whiteColor]
|
|
191
|
+
};
|
|
192
|
+
CGSize textSize = [text sizeWithAttributes:attrs];
|
|
193
|
+
[text drawAtPoint:CGPointMake(-textSize.width/2, -textSize.height/2)
|
|
194
|
+
withAttributes:attrs];
|
|
195
|
+
|
|
196
|
+
CGContextRestoreGState(context);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@end
|
|
201
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-beidou",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "A React Native module for BeiDou Bluetooth communication.",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"types": "index.ts",
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
"android",
|
|
10
10
|
"ios",
|
|
11
11
|
"index.ts",
|
|
12
|
+
"Compass.android.tsx",
|
|
13
|
+
"Compass.ios.tsx",
|
|
14
|
+
"Compass.tsx",
|
|
12
15
|
"react-native.config.js",
|
|
13
16
|
"BeiDouAIDLTestPage.tsx",
|
|
14
17
|
"TestPage.ts"
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
package/ios/Podfile
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# 替换native_modules脚本
|
|
2
|
-
require_relative 'scripts/generate_dynamic_pod'
|
|
3
|
-
replace_native_modules
|
|
4
|
-
|
|
5
|
-
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
|
6
|
-
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
|
7
|
-
|
|
8
|
-
platform :ios, '11.0'
|
|
9
|
-
install! 'cocoapods', :deterministic_uuids => false
|
|
10
|
-
|
|
11
|
-
target 'cmcc_rn_module' do
|
|
12
|
-
config = use_native_modules!
|
|
13
|
-
|
|
14
|
-
pod 'LookinServer', :configurations => ['Debug']
|
|
15
|
-
# Flags change depending on the env values.
|
|
16
|
-
flags = get_default_flags()
|
|
17
|
-
|
|
18
|
-
use_react_native!(
|
|
19
|
-
:path => config[:reactNativePath],
|
|
20
|
-
:production => true,
|
|
21
|
-
# to enable hermes on iOS, change `false` to `true` and then install pods
|
|
22
|
-
:hermes_enabled => false,
|
|
23
|
-
:fabric_enabled => flags[:fabric_enabled],
|
|
24
|
-
# An absolute path to your application root.
|
|
25
|
-
:app_path => "#{Pod::Config.instance.installation_root}/.."
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
pod 'react-native-view-shot', :path => '../node_modules/react-native-view-shot'
|
|
29
|
-
|
|
30
|
-
pod 'react-native-webview', :path => '../node_modules/react-native-webview'
|
|
31
|
-
|
|
32
|
-
target 'cmcc_rn_moduleTests' do
|
|
33
|
-
inherit! :complete
|
|
34
|
-
# Pods for testing
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Enables Flipper.
|
|
38
|
-
#
|
|
39
|
-
# Note that if you have use_frameworks! enabled, Flipper will not work and
|
|
40
|
-
# you should disable the next line.
|
|
41
|
-
# use_flipper!()
|
|
42
|
-
|
|
43
|
-
post_install do |installer|
|
|
44
|
-
# 将脚本拷贝到对应工程
|
|
45
|
-
copy_script
|
|
46
|
-
|
|
47
|
-
react_native_post_install(installer)
|
|
48
|
-
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
|
49
|
-
|
|
50
|
-
# 修复iOS 17报错问题
|
|
51
|
-
# No template named 'unary_function' in namespace 'std'; did you mean '__unary_function'?
|
|
52
|
-
installer.pods_project.targets.each do |target|
|
|
53
|
-
target.build_configurations.each do |config|
|
|
54
|
-
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# # 修复Xcode 15 Filpper库报错问题
|
|
59
|
-
# installer.pods_project.targets.each do |target|
|
|
60
|
-
# if target.name == 'Flipper'
|
|
61
|
-
# file_path = 'Pods/Flipper/xplat/Flipper/FlipperTransportTypes.h'
|
|
62
|
-
# if !File.exist?(file_path)
|
|
63
|
-
# break
|
|
64
|
-
# end
|
|
65
|
-
#
|
|
66
|
-
# contents = File.read(file_path)
|
|
67
|
-
# if contents.include?('#include <functional>')
|
|
68
|
-
# break
|
|
69
|
-
# end
|
|
70
|
-
# mod_content = contents.gsub("#pragma once", "#pragma once\n#include <functional>")
|
|
71
|
-
# File.chmod(0755, file_path)
|
|
72
|
-
# File.open(file_path, 'w') do |file|
|
|
73
|
-
# file.puts(mod_content)
|
|
74
|
-
# end
|
|
75
|
-
# end
|
|
76
|
-
# end
|
|
77
|
-
|
|
78
|
-
end
|
|
79
|
-
end
|
package/ios/build_sdk.sh
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# param $1 开启rn脚本自动化
|
|
4
|
-
# param $2 目标工程路径
|
|
5
|
-
# param $3 react native sdk gitlab路径
|
|
6
|
-
|
|
7
|
-
if [[ $1 == true ]]; then
|
|
8
|
-
echo "\033[34m开启脚本\033[0m"
|
|
9
|
-
if [[ -n $2 ]]; then
|
|
10
|
-
echo "\033[34m[rn_dynamic_pod]目标工程路径:$2\033[0m"
|
|
11
|
-
else
|
|
12
|
-
echo "\033[31m请传入目标路径格式为: \"../../../Native/MpassCMCC_second/10086-ios-3.0,../../../Demo/Native/RNToNativeSingleBridge,../../../Demo/Native/RNToNativeMultiBridge\"\033[0m"
|
|
13
|
-
exit 1
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
|
-
if [[ -n $3 ]]; then
|
|
17
|
-
echo "\033[34m[rn_dynamic_pod] 本地sdk路径:$3\033[0m"
|
|
18
|
-
else
|
|
19
|
-
echo "\033[31m请传入react native sdk gitlab路径格式为: \"http://192.168.10.100/cmcc_rn/cmcc_rn_sdk\"\033[0m"
|
|
20
|
-
exit 1
|
|
21
|
-
fi
|
|
22
|
-
|
|
23
|
-
source reset_env.sh $1 $2 $3
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
pod install
|
|
27
|
-
|
|
28
|
-
if [[ $1 == true ]]; then
|
|
29
|
-
source reset_env.sh false
|
|
30
|
-
fi
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
#import "AppDelegate.h"
|
|
2
|
-
|
|
3
|
-
#import <React/RCTBridge.h>
|
|
4
|
-
#import <React/RCTBundleURLProvider.h>
|
|
5
|
-
#import <React/RCTRootView.h>
|
|
6
|
-
|
|
7
|
-
#import <React/RCTAppSetupUtils.h>
|
|
8
|
-
|
|
9
|
-
#if RCT_NEW_ARCH_ENABLED
|
|
10
|
-
#import <React/CoreModulesPlugins.h>
|
|
11
|
-
#import <React/RCTCxxBridgeDelegate.h>
|
|
12
|
-
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
|
|
13
|
-
#import <React/RCTSurfacePresenter.h>
|
|
14
|
-
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
|
15
|
-
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
16
|
-
|
|
17
|
-
#import <react/config/ReactNativeConfig.h>
|
|
18
|
-
|
|
19
|
-
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
|
|
20
|
-
RCTTurboModuleManager *_turboModuleManager;
|
|
21
|
-
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
|
|
22
|
-
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
|
|
23
|
-
facebook::react::ContextContainer::Shared _contextContainer;
|
|
24
|
-
}
|
|
25
|
-
@end
|
|
26
|
-
#endif
|
|
27
|
-
|
|
28
|
-
@implementation AppDelegate
|
|
29
|
-
|
|
30
|
-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
31
|
-
{
|
|
32
|
-
RCTAppSetupPrepareApp(application);
|
|
33
|
-
|
|
34
|
-
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
|
35
|
-
|
|
36
|
-
#if RCT_NEW_ARCH_ENABLED
|
|
37
|
-
_contextContainer = std::make_shared<facebook::react::ContextContainer const>();
|
|
38
|
-
_reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
|
|
39
|
-
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
|
|
40
|
-
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
|
|
41
|
-
bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
|
|
42
|
-
#endif
|
|
43
|
-
|
|
44
|
-
UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"cmcc_rn_module", nil);
|
|
45
|
-
|
|
46
|
-
if (@available(iOS 13.0, *)) {
|
|
47
|
-
rootView.backgroundColor = [UIColor systemBackgroundColor];
|
|
48
|
-
} else {
|
|
49
|
-
rootView.backgroundColor = [UIColor whiteColor];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
53
|
-
UIViewController *rootViewController = [UIViewController new];
|
|
54
|
-
rootViewController.view = rootView;
|
|
55
|
-
self.window.rootViewController = rootViewController;
|
|
56
|
-
[self.window makeKeyAndVisible];
|
|
57
|
-
return YES;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
61
|
-
{
|
|
62
|
-
#if DEBUG
|
|
63
|
-
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
|
|
64
|
-
#else
|
|
65
|
-
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
66
|
-
#endif
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
#if RCT_NEW_ARCH_ENABLED
|
|
70
|
-
|
|
71
|
-
#pragma mark - RCTCxxBridgeDelegate
|
|
72
|
-
|
|
73
|
-
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
|
74
|
-
{
|
|
75
|
-
_turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
|
|
76
|
-
delegate:self
|
|
77
|
-
jsInvoker:bridge.jsCallInvoker];
|
|
78
|
-
return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
#pragma mark RCTTurboModuleManagerDelegate
|
|
82
|
-
|
|
83
|
-
- (Class)getModuleClassFromName:(const char *)name
|
|
84
|
-
{
|
|
85
|
-
return RCTCoreModulesClassProvider(name);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
89
|
-
jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
|
|
90
|
-
{
|
|
91
|
-
return nullptr;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
|
95
|
-
initParams:
|
|
96
|
-
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
97
|
-
{
|
|
98
|
-
return nullptr;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
|
102
|
-
{
|
|
103
|
-
return RCTAppSetupDefaultModuleFromClass(moduleClass);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
#endif
|
|
107
|
-
|
|
108
|
-
@end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// CMCCAssetsLoaderModule.h
|
|
3
|
-
// ChinaMobile
|
|
4
|
-
//
|
|
5
|
-
// Created by ldd on 5/30/24.
|
|
6
|
-
// Copyright © 2024 Greenpoint. All rights reserved.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
#import <Foundation/Foundation.h>
|
|
10
|
-
|
|
11
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
-
|
|
13
|
-
@interface CMCCAssetsLoaderModule : NSObject
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
NS_ASSUME_NONNULL_END
|