dynamsoft-capture-vision-react-native 1.0.0 → 1.1.0

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 (31) hide show
  1. package/README.md +91 -60
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/com/dynamsoft/reactlibrary/Constants.java +23 -0
  4. package/android/src/main/java/com/dynamsoft/reactlibrary/RNDCECameraView.java +5 -26
  5. package/android/src/main/java/com/dynamsoft/reactlibrary/RNDCECameraViewManager.java +94 -42
  6. package/android/src/main/java/com/dynamsoft/reactlibrary/RNDynamsoftBarcodeReaderModule.java +32 -3
  7. package/android/src/main/java/com/dynamsoft/reactlibrary/RNDynamsoftCaptrueVisionPackage.java +13 -2
  8. package/dynamsoft-capture-vision-react-native.podspec +2 -2
  9. package/ios/RNDynamsoftCaptureVision/DYSCameraView.h +30 -26
  10. package/ios/RNDynamsoftCaptureVision/DYSCameraView.m +113 -71
  11. package/ios/RNDynamsoftCaptureVision/DYSCameraViewManager.h +17 -17
  12. package/ios/RNDynamsoftCaptureVision/DYSCameraViewManager.m +89 -77
  13. package/ios/RNDynamsoftCaptureVision/RCTDynamsoftBarcodeReader.h +14 -14
  14. package/ios/RNDynamsoftCaptureVision/RCTDynamsoftBarcodeReader.m +223 -223
  15. package/ios/RNDynamsoftCaptureVision/StaticClass.h +26 -26
  16. package/ios/RNDynamsoftCaptureVision/StaticClass.m +21 -21
  17. package/js/BarcodeResult.d.ts +25 -0
  18. package/js/BarcodeResult.js +3 -0
  19. package/js/BarcodeSettings.d.ts +52 -100
  20. package/js/BarcodeSettings.js +55 -56
  21. package/js/BasicStructures.d.ts +20 -0
  22. package/js/BasicStructures.js +3 -0
  23. package/js/CameraSettings.d.ts +11 -0
  24. package/js/CameraSettings.js +9 -0
  25. package/js/DynamsoftBarcodeReader.d.ts +4 -3
  26. package/js/DynamsoftBarcodeReader.js +60 -59
  27. package/js/DynamsoftCameraView.d.ts +31 -7
  28. package/js/DynamsoftCameraView.js +90 -83
  29. package/js/index.d.ts +3 -0
  30. package/js/index.js +23 -3
  31. package/package.json +8 -1
@@ -1,71 +1,113 @@
1
- //
2
- // DYSCameraView.m
3
- // RCTDynamsoftBarcodeReader
4
- //
5
- // Created by dynamsoft on 2022/3/16.
6
- //
7
-
8
- #import "DYSCameraView.h"
9
- #import <React/RCTLog.h>
10
- #import "StaticClass.h"
11
-
12
- @implementation DYSCameraView
13
-
14
- @synthesize overlayVisible;
15
- @synthesize scanRegionVisible = _scanRegionVisible;
16
- @synthesize scanRegion;
17
-
18
- - (instancetype)init {
19
- self = [super init];
20
- if (self) {
21
- [self addSubview:[StaticClass instance].view];
22
- }
23
- return self;
24
- }
25
-
26
- - (void)layoutSubviews {
27
- [super layoutSubviews];
28
- [StaticClass instance].view.frame = self.bounds;
29
- }
30
-
31
- - (void)setOverlayVisible:(BOOL)overlayVisible{
32
- [StaticClass instance].view.overlayVisible = overlayVisible;
33
- }
34
-
35
- - (void)setScanRegionVisible:(BOOL)scanRegionVisible{
36
- _scanRegionVisible = scanRegionVisible;
37
- [StaticClass instance].dce.scanRegionVisible = scanRegionVisible;
38
- }
39
-
40
- - (BOOL)scanRegionVisible{
41
- return _scanRegionVisible;
42
- }
43
-
44
- - (void)setScanRegion:(NSDictionary *)scanRegion{
45
- if (scanRegion) {
46
- NSNumber *regionTop = [scanRegion valueForKey:@"regionTop"];
47
- NSNumber *regionLeft = [scanRegion valueForKey:@"regionLeft"];
48
- NSNumber *regionRight = [scanRegion valueForKey:@"regionRight"];
49
- NSNumber *regionBottom = [scanRegion valueForKey:@"regionBottom"];
50
- NSNumber *regionMeasuredByPercentage = [scanRegion valueForKey:@"regionTop"];
51
- iRegionDefinition *region = [iRegionDefinition new];
52
- region.regionTop = regionTop.integerValue;
53
- region.regionLeft = regionLeft.integerValue;
54
- region.regionRight = regionRight.integerValue;
55
- region.regionBottom = regionBottom.integerValue;
56
- region.regionMeasuredByPercentage = regionMeasuredByPercentage.boolValue;
57
- NSError *err = [NSError new];
58
- [[StaticClass instance].dce setScanRegion:region error:&err];
59
- [StaticClass instance].dce.scanRegionVisible = _scanRegionVisible;
60
- }
61
- }
62
-
63
- - (void)open{
64
- [[StaticClass instance].dce open];
65
- }
66
-
67
- - (void)close{
68
- [[StaticClass instance].dce close];
69
- }
70
-
71
- @end
1
+ //
2
+ // DYSCameraView.m
3
+ // RCTDynamsoftBarcodeReader
4
+ //
5
+ // Created by dynamsoft on 2022/3/16.
6
+ //
7
+
8
+ #import "DYSCameraView.h"
9
+ #import <React/RCTLog.h>
10
+ #import "StaticClass.h"
11
+
12
+ @implementation DYSCameraView
13
+
14
+ @synthesize overlayVisible;
15
+ @synthesize scanRegionVisible = _scanRegionVisible;
16
+ @synthesize scanRegion;
17
+ @synthesize torchState;
18
+ @synthesize torchButton = _torchButton;
19
+
20
+ - (instancetype)init {
21
+ self = [super init];
22
+ if (self) {
23
+ [self addSubview:[StaticClass instance].view];
24
+ }
25
+ return self;
26
+ }
27
+
28
+ - (void)layoutSubviews {
29
+ [super layoutSubviews];
30
+ [StaticClass instance].view.frame = self.bounds;
31
+ }
32
+
33
+ - (void)setOverlayVisible:(BOOL)overlayVisible{
34
+ [StaticClass instance].view.overlayVisible = overlayVisible;
35
+ }
36
+
37
+ - (void)setScanRegionVisible:(BOOL)scanRegionVisible{
38
+ _scanRegionVisible = scanRegionVisible;
39
+ [StaticClass instance].dce.scanRegionVisible = scanRegionVisible;
40
+ }
41
+
42
+ - (BOOL)scanRegionVisible{
43
+ return _scanRegionVisible;
44
+ }
45
+
46
+ - (void)setTorchState:(int)torchState{
47
+ if (torchState == 0) {
48
+ [[StaticClass instance].dce turnOnTorch];
49
+ }else if (torchState == 1){
50
+ [[StaticClass instance].dce turnOffTorch];
51
+ }
52
+ }
53
+
54
+ - (void)setTorchButton:(NSDictionary *)torchButton{
55
+ if (torchButton) {
56
+ NSString *torchOnImageBase64 = [torchButton valueForKey:@"torchOnImageBase64"];
57
+ NSString *torchOffImageBase64 = [torchButton valueForKey:@"torchOffImageBase64"];
58
+ BOOL visible = [[torchButton valueForKey:@"visible"] boolValue];
59
+ NSDictionary *dic = [torchButton valueForKey:@"location"];
60
+ CGRect rect;
61
+ if (dic) {
62
+ NSNumber *x = [dic valueForKey:@"x"];
63
+ NSNumber *y = [dic valueForKey:@"y"];
64
+ NSNumber *width = [dic valueForKey:@"width"];
65
+ NSNumber *height = [dic valueForKey:@"height"];
66
+ rect = CGRectMake(x.floatValue, y.floatValue, width.floatValue, height.floatValue);
67
+ }else{
68
+ rect = CGRectMake(25, 100, 45, 45);
69
+ }
70
+
71
+ UIImage *torchOnImage, *torchOffImage;
72
+ if (torchOnImageBase64) {
73
+ NSData *torchOnImageData = [[NSData alloc]initWithBase64EncodedString:torchOnImageBase64 options:(NSDataBase64DecodingIgnoreUnknownCharacters)];
74
+ torchOnImage = [UIImage imageWithData: torchOnImageData];
75
+ }
76
+ if (torchOffImageBase64) {
77
+ NSData *torchOffImageData = [[NSData alloc]initWithBase64EncodedString:torchOffImageBase64 options:(NSDataBase64DecodingIgnoreUnknownCharacters)];
78
+ torchOffImage = [UIImage imageWithData: torchOffImageData];
79
+ }
80
+
81
+ [[StaticClass instance].view setTorchButton:rect torchOnImage:torchOnImage torchOffImage:torchOffImage];
82
+ [[StaticClass instance].view setTorchButtonVisible:visible];
83
+ }
84
+ }
85
+
86
+ - (void)setScanRegion:(NSDictionary *)scanRegion{
87
+ if (scanRegion) {
88
+ NSNumber *regionTop = [scanRegion valueForKey:@"regionTop"];
89
+ NSNumber *regionLeft = [scanRegion valueForKey:@"regionLeft"];
90
+ NSNumber *regionRight = [scanRegion valueForKey:@"regionRight"];
91
+ NSNumber *regionBottom = [scanRegion valueForKey:@"regionBottom"];
92
+ NSNumber *regionMeasuredByPercentage = [scanRegion valueForKey:@"regionTop"];
93
+ iRegionDefinition *region = [iRegionDefinition new];
94
+ region.regionTop = regionTop.integerValue;
95
+ region.regionLeft = regionLeft.integerValue;
96
+ region.regionRight = regionRight.integerValue;
97
+ region.regionBottom = regionBottom.integerValue;
98
+ region.regionMeasuredByPercentage = regionMeasuredByPercentage.boolValue;
99
+ NSError *err = [NSError new];
100
+ [[StaticClass instance].dce setScanRegion:region error:&err];
101
+ [StaticClass instance].dce.scanRegionVisible = _scanRegionVisible;
102
+ }
103
+ }
104
+
105
+ - (void)open{
106
+ [[StaticClass instance].dce open];
107
+ }
108
+
109
+ - (void)close{
110
+ [[StaticClass instance].dce close];
111
+ }
112
+
113
+ @end
@@ -1,17 +1,17 @@
1
- //
2
- // DYSCameraViewManager.h
3
- // RCTDynamsoftBarcodeReader
4
- //
5
- // Created by dynamsoft on 2022/3/16.
6
- //
7
-
8
- #import <React/RCTViewManager.h>
9
- #import <React/RCTBridgeModule.h>
10
-
11
- NS_ASSUME_NONNULL_BEGIN
12
-
13
- @interface DYSCameraViewManager : RCTViewManager
14
-
15
- @end
16
-
17
- NS_ASSUME_NONNULL_END
1
+ //
2
+ // DYSCameraViewManager.h
3
+ // RCTDynamsoftBarcodeReader
4
+ //
5
+ // Created by dynamsoft on 2022/3/16.
6
+ //
7
+
8
+ #import <React/RCTViewManager.h>
9
+ #import <React/RCTBridgeModule.h>
10
+
11
+ NS_ASSUME_NONNULL_BEGIN
12
+
13
+ @interface DYSCameraViewManager : RCTViewManager
14
+
15
+ @end
16
+
17
+ NS_ASSUME_NONNULL_END
@@ -1,77 +1,89 @@
1
- //
2
- // DYSCameraViewManager.m
3
- // RCTDynamsoftBarcodeReader
4
- //
5
- // Created by dynamsoft on 2022/3/16.
6
- //
7
-
8
- #import <React/RCTUIManager.h>
9
- #import "DYSCameraViewManager.h"
10
- #import "DYSCameraView.h"
11
- #import "StaticClass.h"
12
-
13
- @implementation DYSCameraViewManager
14
-
15
- RCT_EXPORT_MODULE(DYSCameraView)
16
-
17
- - (instancetype)init {
18
- self = [super init];
19
- if (self) {
20
- CGFloat heigth = UIScreen.mainScreen.bounds.size.height;
21
- CGFloat width = UIScreen.mainScreen.bounds.size.width;
22
- [StaticClass instance].view = [[DCECameraView alloc] initWithFrame:CGRectMake(0, 0, width, heigth)];
23
- [StaticClass instance].dce = [[DynamsoftCameraEnhancer alloc] initWithView:[StaticClass instance].view];
24
- }
25
- return self;
26
- }
27
-
28
- + (BOOL)requiresMainQueueSetup{
29
- return YES;
30
- }
31
-
32
- - (UIView *)view {
33
- return [[DYSCameraView alloc] init];
34
- }
35
-
36
- RCT_EXPORT_VIEW_PROPERTY(scanRegionVisible, BOOL)
37
- RCT_EXPORT_VIEW_PROPERTY(overlayVisible, BOOL)
38
- RCT_EXPORT_VIEW_PROPERTY(scanRegion, NSDictionary)
39
-
40
- RCT_EXPORT_METHOD(open:(nonnull NSNumber *)reactTag) {
41
- [self.bridge.uiManager addUIBlock:
42
- ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
43
- id view = viewRegistry[reactTag];
44
- if (!view || ![view isKindOfClass:[DYSCameraView class]]) {
45
- RCTLogError(@"Cannot find DYSCameraView with tag #%@", reactTag);
46
- } else {
47
- [((DYSCameraView *)view) open];
48
- }
49
- }];
50
- }
51
-
52
- RCT_EXPORT_METHOD(close:(nonnull NSNumber *)reactTag) {
53
- [self.bridge.uiManager addUIBlock:
54
- ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
55
- id view = viewRegistry[reactTag];
56
- if (!view || ![view isKindOfClass:[DYSCameraView class]]) {
57
- RCTLogError(@"Cannot find DYSCameraView with tag #%@", reactTag);
58
- } else {
59
- [((DYSCameraView *)view) close];
60
- }
61
- }];
62
- }
63
-
64
- RCT_EXPORT_METHOD(setScanRegion:(nonnull NSNumber *)reactTag
65
- scanRegion:(NSDictionary *)scanRegion) {
66
- [self.bridge.uiManager addUIBlock:
67
- ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
68
- id view = viewRegistry[reactTag];
69
- if (!view || ![view isKindOfClass:[DYSCameraView class]]) {
70
- RCTLogError(@"Cannot find DYSCameraView with tag #%@", reactTag);
71
- } else {
72
- [((DYSCameraView *)view) setScanRegion:scanRegion];
73
- }
74
- }];
75
- }
76
-
77
- @end
1
+ //
2
+ // DYSCameraViewManager.m
3
+ // RCTDynamsoftBarcodeReader
4
+ //
5
+ // Created by dynamsoft on 2022/3/16.
6
+ //
7
+
8
+ #import <React/RCTUIManager.h>
9
+ #import "DYSCameraViewManager.h"
10
+ #import "DYSCameraView.h"
11
+ #import "StaticClass.h"
12
+
13
+ @implementation DYSCameraViewManager
14
+
15
+ RCT_EXPORT_MODULE(DYSCameraView)
16
+
17
+ - (instancetype)init {
18
+ self = [super init];
19
+ if (self) {
20
+ CGFloat heigth = UIScreen.mainScreen.bounds.size.height;
21
+ CGFloat width = UIScreen.mainScreen.bounds.size.width;
22
+ [StaticClass instance].view = [[DCECameraView alloc] initWithFrame:CGRectMake(0, 0, width, heigth)];
23
+ [StaticClass instance].dce = [[DynamsoftCameraEnhancer alloc] initWithView:[StaticClass instance].view];
24
+ }
25
+ return self;
26
+ }
27
+
28
+ + (BOOL)requiresMainQueueSetup{
29
+ return YES;
30
+ }
31
+
32
+ - (UIView *)view {
33
+ return [[DYSCameraView alloc] init];
34
+ }
35
+
36
+ - (NSDictionary *)constantsToExport
37
+ {
38
+ return @{
39
+ @"TorchState": @{
40
+ @"off": @1,
41
+ @"on": @0
42
+ },
43
+ };
44
+ }
45
+
46
+ RCT_EXPORT_VIEW_PROPERTY(scanRegionVisible, BOOL)
47
+ RCT_EXPORT_VIEW_PROPERTY(overlayVisible, BOOL)
48
+ RCT_EXPORT_VIEW_PROPERTY(torchState, int)
49
+ RCT_EXPORT_VIEW_PROPERTY(scanRegion, NSDictionary)
50
+ RCT_EXPORT_VIEW_PROPERTY(torchButton, NSDictionary)
51
+
52
+ RCT_EXPORT_METHOD(open:(nonnull NSNumber *)reactTag) {
53
+ [self.bridge.uiManager addUIBlock:
54
+ ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
55
+ id view = viewRegistry[reactTag];
56
+ if (!view || ![view isKindOfClass:[DYSCameraView class]]) {
57
+ RCTLogError(@"Cannot find DYSCameraView with tag #%@", reactTag);
58
+ } else {
59
+ [((DYSCameraView *)view) open];
60
+ }
61
+ }];
62
+ }
63
+
64
+ RCT_EXPORT_METHOD(close:(nonnull NSNumber *)reactTag) {
65
+ [self.bridge.uiManager addUIBlock:
66
+ ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
67
+ id view = viewRegistry[reactTag];
68
+ if (!view || ![view isKindOfClass:[DYSCameraView class]]) {
69
+ RCTLogError(@"Cannot find DYSCameraView with tag #%@", reactTag);
70
+ } else {
71
+ [((DYSCameraView *)view) close];
72
+ }
73
+ }];
74
+ }
75
+
76
+ RCT_EXPORT_METHOD(setScanRegion:(nonnull NSNumber *)reactTag
77
+ scanRegion:(NSDictionary *)scanRegion) {
78
+ [self.bridge.uiManager addUIBlock:
79
+ ^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
80
+ id view = viewRegistry[reactTag];
81
+ if (!view || ![view isKindOfClass:[DYSCameraView class]]) {
82
+ RCTLogError(@"Cannot find DYSCameraView with tag #%@", reactTag);
83
+ } else {
84
+ [((DYSCameraView *)view) setScanRegion:scanRegion];
85
+ }
86
+ }];
87
+ }
88
+
89
+ @end
@@ -1,14 +1,14 @@
1
- //
2
- // RCTDynamsoftBarcodeReader.h
3
- // RCTDynamsoftBarcodeReader
4
- //
5
- // Created by dynamsoft on 2022/3/16.
6
- //
7
-
8
- #import <Foundation/Foundation.h>
9
- #import <React/RCTBridgeModule.h>
10
- #import <React/RCTEventEmitter.h>
11
-
12
- @interface RCTDynamsoftBarcodeReader : RCTEventEmitter <RCTBridgeModule>
13
-
14
- @end
1
+ //
2
+ // RCTDynamsoftBarcodeReader.h
3
+ // RCTDynamsoftBarcodeReader
4
+ //
5
+ // Created by dynamsoft on 2022/3/16.
6
+ //
7
+
8
+ #import <Foundation/Foundation.h>
9
+ #import <React/RCTBridgeModule.h>
10
+ #import <React/RCTEventEmitter.h>
11
+
12
+ @interface RCTDynamsoftBarcodeReader : RCTEventEmitter <RCTBridgeModule>
13
+
14
+ @end