mirror of
https://github.com/simplezhli/flutter_barcode_reader.git
synced 2024-12-23 15:49:23 +08:00
14a744d0af
Android: Kotlin Package: `com.apptreesoftware.barcodescan` -> `de.mintware.barcode_scan` Manifest-Package: `com.yourcompany.barcodescan` -> `de.mintware.barcodescan` Activity: `com.apptreesoftware.barcodescan.BarcodeScannerActivity` -> `de.mintware.barcode_scan.BarcodeScannerActivity` iOS: Bundle ID: `com.apptreesoftware.barcode.plugin.example` -> `de.mintware.barcode_scan.plugin.example` Flutter: Method channel: `com.apptreesoftware.barcode_scan` -> `de.mintware.barcode_scan` pubspec.yaml: - homepage updated - deprecated author entry removed - comments removed - flutter.plugin.androidPackage: `com.apptreesoftware.barcode_scan` -> `de.mintware.barcode_scan` README.md updated and UPGRADE.md added
46 lines
1.9 KiB
Objective-C
46 lines
1.9 KiB
Objective-C
#import "BarcodeScanPlugin.h"
|
|
#import "BarcodeScannerViewController.h"
|
|
|
|
@implementation BarcodeScanPlugin
|
|
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
|
|
FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:@"de.mintware.barcode_scan"
|
|
binaryMessenger:registrar.messenger];
|
|
BarcodeScanPlugin *instance = [BarcodeScanPlugin new];
|
|
instance.hostViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
|
|
[registrar addMethodCallDelegate:instance channel:channel];
|
|
}
|
|
|
|
- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
|
|
if ([@"scan" isEqualToString:call.method]) {
|
|
self.result = result;
|
|
[self showBarcodeView];
|
|
} else {
|
|
result(FlutterMethodNotImplemented);
|
|
}
|
|
}
|
|
|
|
- (void)showBarcodeView {
|
|
BarcodeScannerViewController *scannerViewController = [[BarcodeScannerViewController alloc] init];
|
|
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:scannerViewController];
|
|
if (@available(iOS 13.0, *)) {
|
|
[navigationController setModalPresentationStyle:UIModalPresentationFullScreen];
|
|
}
|
|
scannerViewController.delegate = self;
|
|
[self.hostViewController presentViewController:navigationController animated:NO completion:nil];
|
|
}
|
|
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didScanBarcodeWithResult:(NSString *)result {
|
|
if (self.result) {
|
|
self.result(result);
|
|
}
|
|
}
|
|
|
|
- (void)barcodeScannerViewController:(BarcodeScannerViewController *)controller didFailWithErrorCode:(NSString *)errorCode {
|
|
if (self.result){
|
|
self.result([FlutterError errorWithCode:errorCode
|
|
message:nil
|
|
details:nil]);
|
|
}
|
|
}
|
|
|
|
@end
|