forked from howljs/rn-card-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Le Hau
authored and
Le Hau
committed
Jun 1, 2022
1 parent
cf490a6
commit afedf5a
Showing
13 changed files
with
213 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// CardScannerModule.h | ||
// CardScanner | ||
// | ||
// Created by Howl on 01/06/2022. | ||
// Copyright © 2022 Facebook. All rights reserved. | ||
// | ||
|
||
#import <React/RCTBridgeModule.h> | ||
|
||
@interface CardScanner : NSObject <RCTBridgeModule> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,39 @@ | ||
// | ||
// CardScannerModule.m | ||
// CardScanner | ||
// | ||
// Created by Howl on 01/06/2022. | ||
// Copyright © 2022 Facebook. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "RCTBridgeModule.h" | ||
#import "CardScannerModule.h" | ||
#import "AVFoundation/AVFoundation.h" | ||
|
||
@interface RCT_EXTERN_MODULE(CardScanner, NSObject) | ||
@implementation CardScanner | ||
|
||
RCT_EXTERN_METHOD(requestPermission: (RCTPromiseResolveBlock)resolve | ||
rejecter:(RCTPromiseRejectBlock)reject) | ||
RCT_EXPORT_MODULE(CardScanner); | ||
|
||
RCT_EXPORT_METHOD(requestPermission:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) | ||
{ | ||
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]; | ||
if(authStatus == AVAuthorizationStatusNotDetermined) | ||
{ | ||
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { | ||
if(granted){ | ||
resolve(@{@"status": @"granted"}); | ||
} else { | ||
resolve(@{@"status": @"blocked"}); | ||
} | ||
}]; | ||
} | ||
else if(authStatus == AVAuthorizationStatusDenied) | ||
{ | ||
resolve(@{@"status": @"blocked"}); | ||
} | ||
else | ||
{ | ||
resolve(@{@"status": @"granted"}); | ||
} | ||
} | ||
|
||
@end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// CardScannerView.h | ||
// CardScanner | ||
// | ||
// Created by Howl on 01/06/2022. | ||
// Copyright © 2022 Facebook. All rights reserved. | ||
// | ||
|
||
#import <React/RCTView.h> | ||
#import "UIKit/UIKit.h" | ||
#import "UIView+React.h" | ||
#import "PayCardsRecognizer/PayCardsRecognizer.h" | ||
|
||
@interface CardScannerView : UIView<PayCardsRecognizerPlatformDelegate> | ||
|
||
@property (nonatomic, weak) id<PayCardsRecognizerPlatformDelegate> delegate; | ||
|
||
@property (nonatomic, strong) PayCardsRecognizer *recognizer; | ||
|
||
@property (nonatomic, assign) UIColor *frameColor; | ||
|
||
@property (nonatomic, copy) RCTBubblingEventBlock onDidScanCard; | ||
|
||
- (void)toggleFlash; | ||
|
||
- (void)resetResult; | ||
|
||
@end | ||
|
Oops, something went wrong.