Skip to content

Commit

Permalink
feat: add capture method back
Browse files Browse the repository at this point in the history
  • Loading branch information
Tweenkie committed Dec 18, 2019
1 parent 237d173 commit 7dec270
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ios/RNPdfScannerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ - (dispatch_queue_t)methodQueue
RCT_EXPORT_VIEW_PROPERTY(brightness, float)
RCT_EXPORT_VIEW_PROPERTY(contrast, float)

RCT_EXPORT_METHOD(capture:(nonnull NSNumber *)reactTag)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, DocumentScannerView *> *viewRegistry) {
DocumentScannerView *view = viewRegistry[reactTag];
if (![view isKindOfClass:[DocumentScannerView class]]) {
RCTLogError(@"Invalid view returned from registry, expecting DocumentScannerView, got: %@", view);
} else {
[view capture];
}
}];
}

- (UIView*) view {
return [DocumentScannerView new];
}
Expand Down
7 changes: 7 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,16 @@ class PdfScanner extends React.Component<PdfScannerProps> {
}
}

capture () {
let native: any = this.ref.current
if (native) { native.capture() }
}

ref = React.createRef();
render () {
return (
<RNPdfScanner
ref={this.ref}
{...this.props}
onPictureTaken={this.sendOnPictureTakenEvent.bind(this)}
onRectangleDetect={this.sendOnRectangleDetectEvent.bind(this)}
Expand Down

0 comments on commit 7dec270

Please sign in to comment.