mirror of
https://github.com/simplezhli/flutter_barcode_reader.git
synced 2024-12-23 14:39:20 +08:00
BarcodeScanPlugin.m: extracted errorHandling into seperate method
This commit is contained in:
parent
616b286a5c
commit
1c34da8db9
@ -27,13 +27,17 @@
|
||||
}
|
||||
|
||||
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithResult:(NSString *)result {
|
||||
if (self.result && [result isEqualToString: @"PERMISSION_NOT_GRANTED"]){
|
||||
self.result([FlutterError errorWithCode:@"PERMISSION_NOT_GRANTED"
|
||||
message:nil
|
||||
details:nil]);
|
||||
} else if (self.result) {
|
||||
if (self.result) {
|
||||
self.result(result);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithErrorCode:(NSString *)errorCode {
|
||||
if (self.result){
|
||||
self.result([FlutterError errorWithCode:errorCode
|
||||
message:nil
|
||||
details:nil]);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -38,7 +38,7 @@
|
||||
if (success) {
|
||||
[self startScan];
|
||||
} else {
|
||||
[self.delegate barcodeScannerViewController:self didScanBarcodeWithResult:@"PERMISSION_NOT_GRANTED"];
|
||||
[self.delegate barcodeScannerViewController:self didScanBarcodeWithErrorCode:@"PERMISSION_NOT_GRANTED"];
|
||||
[self dismissViewControllerAnimated:NO completion:nil];
|
||||
}
|
||||
}];
|
||||
|
@ -9,5 +9,6 @@
|
||||
@protocol BarcodeScannerViewControllerDelegate <NSObject>
|
||||
|
||||
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithResult:(NSString *)result;
|
||||
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithErrorCode:(NSString *)errorCode;
|
||||
|
||||
@end
|
||||
@end
|
||||
|
Loading…
Reference in New Issue
Block a user