Skip to content

Commit 7dec270

Browse files
committed
feat: add capture method back
1 parent 237d173 commit 7dec270

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ios/RNPdfScannerManager.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ - (dispatch_queue_t)methodQueue
3131
RCT_EXPORT_VIEW_PROPERTY(brightness, float)
3232
RCT_EXPORT_VIEW_PROPERTY(contrast, float)
3333

34+
RCT_EXPORT_METHOD(capture:(nonnull NSNumber *)reactTag)
35+
{
36+
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, DocumentScannerView *> *viewRegistry) {
37+
DocumentScannerView *view = viewRegistry[reactTag];
38+
if (![view isKindOfClass:[DocumentScannerView class]]) {
39+
RCTLogError(@"Invalid view returned from registry, expecting DocumentScannerView, got: %@", view);
40+
} else {
41+
[view capture];
42+
}
43+
}];
44+
}
45+
3446
- (UIView*) view {
3547
return [DocumentScannerView new];
3648
}

src/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,16 @@ class PdfScanner extends React.Component<PdfScannerProps> {
9090
}
9191
}
9292

93+
capture () {
94+
let native: any = this.ref.current
95+
if (native) { native.capture() }
96+
}
97+
98+
ref = React.createRef();
9399
render () {
94100
return (
95101
<RNPdfScanner
102+
ref={this.ref}
96103
{...this.props}
97104
onPictureTaken={this.sendOnPictureTakenEvent.bind(this)}
98105
onRectangleDetect={this.sendOnRectangleDetectEvent.bind(this)}

0 commit comments

Comments
 (0)