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.
- package/README.md +91 -60
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/dynamsoft/reactlibrary/Constants.java +23 -0
- package/android/src/main/java/com/dynamsoft/reactlibrary/RNDCECameraView.java +5 -26
- package/android/src/main/java/com/dynamsoft/reactlibrary/RNDCECameraViewManager.java +94 -42
- package/android/src/main/java/com/dynamsoft/reactlibrary/RNDynamsoftBarcodeReaderModule.java +32 -3
- package/android/src/main/java/com/dynamsoft/reactlibrary/RNDynamsoftCaptrueVisionPackage.java +13 -2
- package/dynamsoft-capture-vision-react-native.podspec +2 -2
- package/ios/RNDynamsoftCaptureVision/DYSCameraView.h +30 -26
- package/ios/RNDynamsoftCaptureVision/DYSCameraView.m +113 -71
- package/ios/RNDynamsoftCaptureVision/DYSCameraViewManager.h +17 -17
- package/ios/RNDynamsoftCaptureVision/DYSCameraViewManager.m +89 -77
- package/ios/RNDynamsoftCaptureVision/RCTDynamsoftBarcodeReader.h +14 -14
- package/ios/RNDynamsoftCaptureVision/RCTDynamsoftBarcodeReader.m +223 -223
- package/ios/RNDynamsoftCaptureVision/StaticClass.h +26 -26
- package/ios/RNDynamsoftCaptureVision/StaticClass.m +21 -21
- package/js/BarcodeResult.d.ts +25 -0
- package/js/BarcodeResult.js +3 -0
- package/js/BarcodeSettings.d.ts +52 -100
- package/js/BarcodeSettings.js +55 -56
- package/js/BasicStructures.d.ts +20 -0
- package/js/BasicStructures.js +3 -0
- package/js/CameraSettings.d.ts +11 -0
- package/js/CameraSettings.js +9 -0
- package/js/DynamsoftBarcodeReader.d.ts +4 -3
- package/js/DynamsoftBarcodeReader.js +60 -59
- package/js/DynamsoftCameraView.d.ts +31 -7
- package/js/DynamsoftCameraView.js +90 -83
- package/js/index.d.ts +3 -0
- package/js/index.js +23 -3
- 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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[[
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
RCT_EXPORT_METHOD(
|
|
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)
|
|
60
|
-
}
|
|
61
|
-
}];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
RCT_EXPORT_METHOD(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|