rename to zxing

This commit is contained in:
Adam Velebil 2022-04-22 15:28:08 +02:00
parent 40d1cedcc1
commit be611d5f97
No known key found for this signature in database
GPG Key ID: AC6D6B9D715FC084
57 changed files with 125 additions and 122 deletions

View File

@ -1 +0,0 @@
rootProject.name = 'qrscanner_mlkit'

View File

@ -1,7 +0,0 @@
import 'qrscanner_mlkit_platform_interface.dart';
class QRScannerMLKit {
Future<String?> getPlatformVersion() {
return QRScannerMLKitPlatform.instance.getPlatformVersion();
}
}

View File

@ -1,17 +0,0 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'qrscanner_mlkit_platform_interface.dart';
/// An implementation of [QRScannerMLKitPlatform] that uses method channels.
class MethodChannelQRScannerMLKit extends QRScannerMLKitPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('qrscanner_mlkit');
@override
Future<String?> getPlatformVersion() async {
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
return version;
}
}

View File

@ -1,29 +0,0 @@
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'qrscanner_mlkit_method_channel.dart';
abstract class QRScannerMLKitPlatform extends PlatformInterface {
/// Constructs a QRScannerMLKitPlatform.
QRScannerMLKitPlatform() : super(token: _token);
static final Object _token = Object();
static QRScannerMLKitPlatform _instance = MethodChannelQRScannerMLKit();
/// The default instance of [QRScannerMLKitPlatform] to use.
///
/// Defaults to [MethodChannelQRScannerMLKit].
static QRScannerMLKitPlatform get instance => _instance;
/// Platform-specific implementations should set this with their own
/// platform-specific class that extends [QRScannerMLKitPlatform] when
/// they register themselves.
static set instance(QRScannerMLKitPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
Future<String?> getPlatformVersion() {
throw UnimplementedError('platformVersion() has not been implemented.');
}
}

View File

@ -1,26 +0,0 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:qrscanner_mlkit/qrscanner_mlkit.dart';
import 'package:qrscanner_mlkit/qrscanner_mlkit_method_channel.dart';
import 'package:qrscanner_mlkit/qrscanner_mlkit_platform_interface.dart';
class MockQRScannerMLKitPlatform with MockPlatformInterfaceMixin implements QRScannerMLKitPlatform {
@override
Future<String?> getPlatformVersion() => Future.value('42');
}
void main() {
final QRScannerMLKitPlatform initialPlatform = QRScannerMLKitPlatform.instance;
test('$MethodChannelQRScannerMLKit is the default instance', () {
expect(initialPlatform, isInstanceOf<MethodChannelQRScannerMLKit>());
});
test('getPlatformVersion', () async {
QRScannerMLKit qrscannerMlkitPlugin = QRScannerMLKit();
MockQRScannerMLKitPlatform fakePlatform = MockQRScannerMLKitPlatform();
QRScannerMLKitPlatform.instance = fakePlatform;
expect(await qrscannerMlkitPlugin.getPlatformVersion(), '42');
});
}

View File

@ -1,4 +1,4 @@
# qscanner_mlkit
# qscanner_zxing
Android-only Flutter plugin for scanning QR Codes. Implemented with ML Kit and CameraX
Android-only Flutter plugin for scanning QR Codes. Implemented with zxing and CameraX

View File

@ -1,4 +1,4 @@
group 'com.yubico.authenticator.flutter_plugins.qrscanner_mlkit'
group 'com.yubico.authenticator.flutter_plugins.qrscanner_zxing'
version '1.0-SNAPSHOT'
buildscript {

View File

@ -0,0 +1 @@
rootProject.name = 'qrscanner_zxing'

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yubico.authenticator.flutter_plugins.qrscanner_mlkit">
package="com.yubico.authenticator.flutter_plugins.qrscanner_zxing">
<uses-feature android:name="android.hardware.camera.any" />

View File

@ -1,4 +1,4 @@
package com.yubico.authenticator.flutter_plugins.qrscanner_mlkit
package com.yubico.authenticator.flutter_plugins.qrscanner_zxing
import android.Manifest
import android.app.Activity
@ -35,7 +35,6 @@ import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import kotlin.Result
class QRScannerViewFactory(
private val binaryMessenger: BinaryMessenger,
private val permissionsResultRegistrar: PermissionsResultRegistrar

View File

@ -1,4 +1,4 @@
package com.yubico.authenticator.flutter_plugins.qrscanner_mlkit
package com.yubico.authenticator.flutter_plugins.qrscanner_zxing
import androidx.annotation.NonNull
import io.flutter.embedding.engine.plugins.FlutterPlugin
@ -31,15 +31,15 @@ class PermissionsResultRegistrar {
}
}
/** QRScannerMLKitPlugin */
class QRScannerMLKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
/** QRScannerZxingPlugin */
class QRScannerZxingPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
PluginRegistry.RequestPermissionsResultListener {
private val registrar = PermissionsResultRegistrar()
private lateinit var channel: MethodChannel
override fun onAttachedToEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(binding.binaryMessenger, "qrscanner_mlkit")
channel = MethodChannel(binding.binaryMessenger, "qrscanner_zxing")
channel.setMethodCallHandler(this)
binding.platformViewRegistry

View File

@ -1,6 +1,6 @@
# qrscanner_mlkit_example
# qrscanner_zxing_example
Demonstrates how to use the qrscanner_mlkit plugin.
Demonstrates how to use the qrscanner_zxing plugin.
## Getting Started

View File

@ -44,7 +44,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.yubico.authenticator.flutter_plugins.qrscanner_mlkit_example"
applicationId "com.yubico.authenticator.flutter_plugins.qrscanner_zxing_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yubico.authenticator.flutter_plugins.qrscanner_mlkit_example">
package="com.yubico.authenticator.flutter_plugins.qrscanner_zxing_example">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.

View File

@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yubico.authenticator.flutter_plugins.qrscanner_mlkit_example">
package="com.yubico.authenticator.flutter_plugins.qrscanner_zxing_example">
<application
android:label="qrscanner_mlkit_example"
android:label="qrscanner_zxing_example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity

View File

@ -1,4 +1,4 @@
package com.yubico.authenticator.flutter_plugins.qrscanner_mlkit_example
package com.yubico.authenticator.flutter_plugins.qrscanner_zxing_example
import io.flutter.embedding.android.FlutterActivity

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yubico.authenticator.flutter_plugins.qrscanner_mlkit_example">
package="com.yubico.authenticator.flutter_plugins.qrscanner_zxing_example">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:qrscanner_mlkit/qrscanner_mlkit_view.dart';
import 'package:qrscanner_zxing/qrscanner_zxing_view.dart';
import 'cutout_overlay.dart';
@ -70,7 +70,7 @@ class QRScannerPageState extends State<QRScannerPage> {
return Scaffold(
body: Stack(
children: [
QrScannerMLKitView(onDetect: (result) {
QRScannerZxingView(onDetect: (result) {
if (currentCode == null) {
setState(() {
currentCode = result.data;

View File

@ -116,7 +116,7 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
qrscanner_mlkit:
qrscanner_zxing:
dependency: "direct main"
description:
path: ".."

View File

@ -1,5 +1,5 @@
name: qrscanner_mlkit_example
description: Demonstrates how to use the qrscanner_mlkit plugin.
name: qrscanner_zxing_example
description: Demonstrates how to use the qrscanner_zxing plugin.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
@ -10,7 +10,7 @@ dependencies:
flutter:
sdk: flutter
qrscanner_mlkit:
qrscanner_zxing:
path: ../
cupertino_icons: ^1.0.2

View File

@ -0,0 +1,7 @@
import 'qrscanner_zxing_platform_interface.dart';
class QRScannerZxing {
Future<String?> getPlatformVersion() {
return QRScannerZxingPlatform.instance.getPlatformVersion();
}
}

View File

@ -0,0 +1,18 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'qrscanner_zxing_platform_interface.dart';
/// An implementation of [QRScannerZxingPlatform] that uses method channels.
class MethodChannelQRScannerZxing extends QRScannerZxingPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('qrscanner_zxing');
@override
Future<String?> getPlatformVersion() async {
final version =
await methodChannel.invokeMethod<String>('getPlatformVersion');
return version;
}
}

View File

@ -0,0 +1,29 @@
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'qrscanner_zxing_method_channel.dart';
abstract class QRScannerZxingPlatform extends PlatformInterface {
/// Constructs a QRScannerZxingPlatform.
QRScannerZxingPlatform() : super(token: _token);
static final Object _token = Object();
static QRScannerZxingPlatform _instance = MethodChannelQRScannerZxing();
/// The default instance of [QRScannerZxingPlatform] to use.
///
/// Defaults to [MethodChannelQRScannerZxing].
static QRScannerZxingPlatform get instance => _instance;
/// Platform-specific implementations should set this with their own
/// platform-specific class that extends [QRScannerZxingPlatform] when
/// they register themselves.
static set instance(QRScannerZxingPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
Future<String?> getPlatformVersion() {
throw UnimplementedError('platformVersion() has not been implemented.');
}
}

View File

@ -11,20 +11,20 @@ class ScannedData {
ScannedData(this.data, this.location);
}
class QrScannerMLKitView extends StatefulWidget {
class QRScannerZxingView extends StatefulWidget {
final Function(ScannedData data) onDetect;
const QrScannerMLKitView({Key? key, required this.onDetect})
const QRScannerZxingView({Key? key, required this.onDetect})
: super(key: key);
@override
QrScannerMLKitViewState createState() => QrScannerMLKitViewState();
QRScannerZxingViewState createState() => QRScannerZxingViewState();
}
class QrScannerMLKitViewState extends State<QrScannerMLKitView> {
class QRScannerZxingViewState extends State<QRScannerZxingView> {
final MethodChannel channel = const MethodChannel(
"com.yubico.authenticator.flutter_plugins.qr_scanner_channel");
QrScannerMLKitViewState() : super() {
QRScannerZxingViewState() : super() {
channel.setMethodCallHandler((call) async {
try {
var barcodes = jsonDecode(call.arguments);

View File

@ -1,5 +1,5 @@
name: qrscanner_mlkit
description: Android-only QR Scanner plugin based on ML Kit and CameraX API's
name: qrscanner_zxing
description: Android-only QR Scanner plugin based on zxing and CameraX API's
version: 1.0.0
homepage:
@ -21,5 +21,5 @@ flutter:
plugin:
platforms:
android:
package: com.yubico.authenticator.flutter_plugins.qrscanner_mlkit
pluginClass: QRScannerMLKitPlugin
package: com.yubico.authenticator.flutter_plugins.qrscanner_zxing
pluginClass: QRScannerZxingPlugin

View File

@ -1,10 +1,10 @@
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:qrscanner_mlkit/qrscanner_mlkit_method_channel.dart';
import 'package:qrscanner_zxing/qrscanner_zxing_method_channel.dart';
void main() {
MethodChannelQRScannerMLKit platform = MethodChannelQRScannerMLKit();
const MethodChannel channel = MethodChannel('qrscanner_mlkit');
MethodChannelQRScannerZxing platform = MethodChannelQRScannerZxing();
const MethodChannel channel = MethodChannel('qrscanner_zxing');
TestWidgetsFlutterBinding.ensureInitialized();

View File

@ -0,0 +1,29 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:qrscanner_zxing/qrscanner_zxing.dart';
import 'package:qrscanner_zxing/qrscanner_zxing_method_channel.dart';
import 'package:qrscanner_zxing/qrscanner_zxing_platform_interface.dart';
class MockQRScannerZxingPlatform
with MockPlatformInterfaceMixin
implements QRScannerZxingPlatform {
@override
Future<String?> getPlatformVersion() => Future.value('42');
}
void main() {
final QRScannerZxingPlatform initialPlatform =
QRScannerZxingPlatform.instance;
test('$MethodChannelQRScannerZxing is the default instance', () {
expect(initialPlatform, isInstanceOf<MethodChannelQRScannerZxing>());
});
test('getPlatformVersion', () async {
QRScannerZxing qrscannerZxingPlugin = QRScannerZxing();
MockQRScannerZxingPlatform fakePlatform = MockQRScannerZxingPlatform();
QRScannerZxingPlatform.instance = fakePlatform;
expect(await qrscannerZxingPlugin.getPlatformVersion(), '42');
});
}

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:qrscanner_mlkit/qrscanner_mlkit_view.dart';
import 'package:qrscanner_zxing/qrscanner_zxing_view.dart';
import '../../app/navigation_service.dart';
import '../../oath/models.dart';
@ -53,7 +53,7 @@ class MobileScannerWrapper extends StatelessWidget {
height: size.width - 38);
return Stack(children: [
QrScannerMLKitView(onDetect: (scannedData) {
QrScannerZxingView(onDetect: (scannedData) {
onDetect.call(scannedData);
}),
ClipPath(

View File

@ -436,10 +436,10 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
qrscanner_mlkit:
qrscanner_zxing:
dependency: "direct main"
description:
path: "android/flutter_plugins/qrscanner_mlkit"
path: "android/flutter_plugins/qrscanner_zxing"
relative: true
source: path
version: "1.0.0"

View File

@ -42,8 +42,8 @@ dependencies:
json_annotation: ^4.4.0
freezed_annotation: ^1.0.0
window_manager: ^0.2.0
qrscanner_mlkit:
path: ./android/flutter_plugins/qrscanner_mlkit
qrscanner_zxing:
path: android/flutter_plugins/qrscanner_zxing
desktop_drop: ^0.3.3
dev_dependencies: