Compare commits

...

24 Commits

Author SHA1 Message Date
weilu 234183a26a 同步代码 2020-04-10 15:11:30 +08:00
weilu d36a12a9c6 Merge remote-tracking branch 'upstream/master' into dev
# Conflicts:
#	android/build.gradle
#	android/src/main/kotlin/com/apptreesoftware/barcodescan/BarcodeScanPlugin.kt
#	example/.gitignore
#	example/android/app/src/main/AndroidManifest.xml
#	example/android/gradle.properties
#	pubspec.yaml
2020-04-10 13:43:52 +08:00
Julian Finkler a4a010ca31
Update README.md 2020-02-20 01:01:32 +01:00
Julian Finkler 941e172376 Fixed wrong build.gradle 2020-02-20 00:20:46 +01:00
Julian Finkler 1e98233091
Update CHANGELOG.md 2020-02-19 23:44:01 +01:00
Julian Finkler 0c5899977e
Merge pull request #183 from mintware-de/prepare-release
Features:
- [Add-to-app support](https://github.com/mintware-de/flutter_barcode_reader/pull/168) - @santiihoyos
- Changed overlay to full screen in iOS 13

Bugfixes:
- [Fixed rotation on iOS](https://github.com/mintware-de/flutter_barcode_reader/pull/167) - @mintware-de
  - [#61 Rotating orientation on iPhones only shows half the screen](https://github.com/mintware-de/flutter_barcode_reader/issues/61)

Changes:
- [Fix compile warning](https://github.com/mintware-de/flutter_barcode_reader/pull/127) - @lookfirst
- [Upgrade gradle](https://github.com/mintware-de/flutter_barcode_reader/pull/142) - @SuuSoJeat
  - `com.android.tools.build:gradle`: 3.3.1 -> 3.5.0
  - `org.jetbrains.kotlin:kotlin-gradle-plugin`: 1.3.20 -> 1.3.50
  - `compileSdkVersion`: 28 -> 29
  - `targetSdkVersion`: 28 -> 29
  - `gradle`: 4.10.2 -> 5.4.1
- [Package description updated](https://github.com/mintware-de/flutter_barcode_reader/pull/180) - @connectety
- README.md and LICENSE.md updated
- Since the project owner has been changed, the package names are different. Checkout the [UPGRADE.md](./UPGRADE.md) for details.
2020-02-19 23:42:40 +01:00
Julian Finkler d96581e552 Version updated and dartdocs added 2020-02-19 23:36:18 +01:00
Julian Finkler 14a744d0af Owner changes:
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
2020-02-19 23:19:14 +01:00
Julian Finkler fd166d9915
Update CHANGELOG.md 2020-02-19 21:49:23 +01:00
Julian Finkler 0ef78bb112
Merge pull request #167 from mintware-de/fix_issue_61
Fix rotation in iOS
2020-02-19 21:46:24 +01:00
Julian Finkler 807d18fe55
Merge pull request #180 from connectety/master
Extend description to increase pub.dev score.
2020-02-19 21:36:46 +01:00
Julian Finkler 0a25923ae2
Merge pull request #168 from AreaSeys-Team/master
Supporting add-to-app feature
2020-02-19 21:35:21 +01:00
Julian Finkler 750da9f248
Merge pull request #142 from SuuSoJeat/master
Upgrade gradle
  - `com.android.tools.build:gradle`: 3.3.1 -> 3.5.0
  - `org.jetbrains.kotlin:kotlin-gradle-plugin`: 1.3.20 -> 1.3.50
  - `compileSdkVersion`: 28 -> 29
  - `targetSdkVersion`: 28 -> 29
  - `gradle`: 4.10.2 -> 5.4.1
2020-02-19 21:25:06 +01:00
Julian Finkler 5ba94159a1
Merge pull request #127 from lookfirst/patch-1
Using copy instead of retain attribute for `FlutterResult result`
2020-02-19 21:07:10 +01:00
Julian Finkler 49cab03d37
Removed "unmaintained" notice 2020-02-19 17:10:45 +01:00
Matthew Smith ac4fbd2cf9
Update README.md 2020-02-12 09:17:12 -08:00
Connectety-T e0c461d139
Added tiny addition in description to bring the length over 60.
This brings the maintenance score up to 100, which will increase the overall score.
See https://pub.dev/packages/barcode_scan#-analysis-tab- under Maintenance suggestions.
2020-02-09 21:42:15 +01:00
Julian Finkler 770bb47d6c Fixed the position of the scan line 2020-01-12 12:34:25 +01:00
Julian Finkler e0cc5c3bc2 Fixed the size of the preview overlay 2020-01-12 12:18:48 +01:00
@SantiiHoyos 24d5067a8a
Merge pull request #1 from santiihoyos/master
avoid use Registrar.activity() beforr Flutter engine attached to any activity
2019-12-19 10:33:08 +01:00
Santi Hoyos 2a2a3e0899 avoid use Registrar.activity() before flutter engine is attached to android Activity
this add support for use this plugin in apps with add-to-app feature
2019-12-18 17:43:01 +01:00
Julian Finkler 06f38e0b53 Fix for Issue #61
While the iOS device is rotating the bounds of the previewView will be recalculated
and the scanRect will be reinitialized

Changes in the WorkspaceSettings are necessary to run the example app
2019-12-16 20:59:07 +01:00
Eterna 4fe1075fa6 upgrade gradle 2019-08-27 10:51:15 +07:00
Jon Stevens 81edea7935
fix compile warning
https://stackoverflow.com/questions/18039275/retained-block-property-does-not-copy-the-block-use-copy-attribute-instead

"Retain'ed block property does not copy the block - use copy attribute instead"

Not sure if this should be `copy` or `strong`.
2019-07-05 16:32:46 +07:00
22 changed files with 209 additions and 117 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ build/
ios/.generated/
packages
pubspec.lock
example/ios/Podfile.lock

View File

@ -1,35 +1,62 @@
## [1.0.0] - 8/30/18
## v2.0.1 - 2020-02-19
Bugfixes:
- Fixed wrong build.gradle
## v2.0.0 - 2020-02-19
Features:
- [Add-to-app support](https://github.com/mintware-de/flutter_barcode_reader/pull/168) - @santiihoyos
- Changed overlay to full screen in iOS 13
Bugfixes:
- [Fixed rotation on iOS](https://github.com/mintware-de/flutter_barcode_reader/pull/167) - @mintware-de
- [#61 Rotating orientation on iPhones only shows half the screen](https://github.com/mintware-de/flutter_barcode_reader/issues/61)
Changes:
- [Fix compile warning](https://github.com/mintware-de/flutter_barcode_reader/pull/127) - @lookfirst
- [Upgrade gradle](https://github.com/mintware-de/flutter_barcode_reader/pull/142) - @SuuSoJeat
- `com.android.tools.build:gradle`: 3.3.1 -> 3.5.0
- `org.jetbrains.kotlin:kotlin-gradle-plugin`: 1.3.20 -> 1.3.50
- `compileSdkVersion`: 28 -> 29
- `targetSdkVersion`: 28 -> 29
- `gradle`: 4.10.2 -> 5.4.1
- [Package description updated](https://github.com/mintware-de/flutter_barcode_reader/pull/180) - @connectety
- README.md and LICENSE.md updated
- Since the project owner has been changed, the package names are different. Checkout the [UPGRADE.md](./UPGRADE.md) for details.
## v1.0.0 - 2018-08-30
Breaking Change: Adds support for AndroidX
## [0.0.8] - 8/30/18
## v0.0.8 - 2018-08-30
* Fixes [iOS: pressing cancel doesn't stop scanning](https://github.com/apptreesoftware/flutter_barcode_reader/issues/60) thanks to @tgezginis.
* Fixes [iOS: pressing cancel doesn't stop scanning](https://github.com/mintware-de/flutter_barcode_reader/issues/60) thanks to @tgezginis.
## [0.0.7] - 8/30/18
## v0.0.7 - 2018-08-30
* Fix iOS barcodes not scanning
## [0.0.6] - 8/29/18
## v0.0.6 - 2018-08-29
* Fix android dependencies
* iOS scanner now looks like Android thanks to @dustin-graham
## [0.0.4] - 2/8/18
## v0.0.4 - 2018-02-8
* Fix missing gradle dependency (thanks to [toteto](https://github.com/apptreesoftware/flutter_barcode_reader/pull/15))
* Fix missing gradle dependency (thanks to [toteto](https://github.com/mintware-de/flutter_barcode_reader/pull/15))
* Update gradle dependencies
## [0.0.3] - 2/8/17
## v0.0.3 - 2017-02-8
* Improved permission handling (thanks to [BenSower](https://github.com/BenSower))
* Added MIT license
## [0.0.2] - 11/7/17
## v0.0.2 - 2017-11-7
* Rewrite iOS scanner in Objective-C to avoid Swift use_frameworks! conflicts with other plugins (see https://github.com/flutter/flutter/issues/10968)
## [0.0.1] - 10/29/17
## v0.0.1 - 2017-10-29
* Supports 2D & QR Codes
* Control flash while scanning

View File

@ -1,6 +1,7 @@
The MIT License
Copyright (c) 2018 AppTree Software http://www.apptreesoftware.com
Copyright (c) 2020 Julian Finkler https://www.mintware.de
Copyright (c) 2018-2019 AppTree Software http://www.apptreesoftware.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,3 +1,8 @@
[![GitHub license](https://img.shields.io/github/license/mintware-de/flutter_barcode_reader.svg)](https://github.com/mintware-de/flutter_barcode_reader/blob/master/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/mintware-de/flutter_barcode_reader)](https://github.com/mintware-de/flutter_barcode_reader/stargazers)
[![Pub](https://img.shields.io/pub/v/barcode_scan.svg)](https://pub.dartlang.org/packages/barcode_scan)
[![GitHub forks](https://img.shields.io/github/forks/mintware-de/flutter_barcode_reader)](https://github.com/mintware-de/flutter_barcode_reader/network)
# Barcode Scanner
A flutter plugin for scanning 2D barcodes and QR codes.
@ -13,7 +18,6 @@ Android: https://github.com/dm77/barcodescanner
- [x] Scan QR codes
- [x] Control the flash while scanning
- [x] Permission handling
- [ ] Support multiple barcode libraries
## Getting Started
@ -24,44 +28,55 @@ For Android, you must do the following before you can use the plugin:
`<uses-permission android:name="android.permission.CAMERA" />`
* Add the BarcodeScanner activity to your AndroidManifest.xml. Do NOT modify the name.
`<activity android:name="com.apptreesoftware.barcodescan.BarcodeScannerActivity"/>`
* This plugin is written in Kotlin. Therefore, you need to add Kotlin support to your project. See [installing the Kotlin plugin](https://kotlinlang.org/docs/tutorials/kotlin-android.html#installing-the-kotlin-plugin).
Edit your project-level build.gradle file to look like this:
buildscript {
ext.kotlin_version = '1.3.21'
...
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
...
```groovy
buildscript {
ext.kotlin_version = '1.3.61'
// ...
dependencies {
// ...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
// ...
```
Edit your app-level build.gradle file to look like this:
apply plugin: 'kotlin-android'
...
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
...
}
```groovy
apply plugin: 'kotlin-android'
// ...
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// ...
}
```
Now you can depend on the barcode_scan plugin in your pubspec.yaml file:
dependencies:
...
barcode_scan: any
```yaml
dependencies:
# ...
barcode_scan: any
```
Click "Packages get" in Android Studio or run `flutter packages get` in your project folder.
### iOS
To use on iOS, you must add the the camera usage description to your Info.plist
```xml
<dict>
<!-- ... -->
<key>NSCameraUsageDescription</key>
<string>Camera permission is required for barcode scanning.</string>
<!-- ... -->
</dict>
```
## Common problems
### Android "Could not find org.jetbrains.kotlin:kotlin-stdlib-jre..."
Change `org.jetbrains.kotlin:kotlin-stdlib-jre` to `org.jetbrains.kotlin:kotlin-stdlib-jdk`
([StackOverflow](https://stackoverflow.com/a/53358817))

25
UPGRADE.md Normal file
View File

@ -0,0 +1,25 @@
# Upgrade from 1.0.0 to 2.0.0
The simples way for upgrading is by replacing:
- `com.apptreesoftware.barcodescan`
- `com.yourcompany.barcodescan`
- `com.apptreesoftware.barcode_scan`
With: `de.mintware.barcode_scan`
Detailed changes:
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`

View File

@ -1,6 +1,6 @@
#Wed Jan 30 20:42:57 BRST 2019
#Tue Aug 27 10:46:28 ICT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

View File

@ -1,9 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.barcodescan">
package="de.mintware.barcodescan">
<uses-permission android:name="android.permission.CAMERA" />
<application>
<activity android:name="com.apptreesoftware.barcodescan.BarcodeScannerActivity" />
<activity android:name="de.mintware.barcode_scan.BarcodeScannerActivity" />
</application>
</manifest>

View File

@ -1,4 +1,4 @@
package com.apptreesoftware.barcodescan
package de.mintware.barcode_scan
import android.app.Activity
import android.content.Intent
@ -25,7 +25,7 @@ class BarcodeScanPlugin(): MethodCallHandler, PluginRegistry.ActivityResultListe
companion object {
@JvmStatic
fun registerWith(registrar: Registrar) {
val channel = MethodChannel(registrar.messenger(), "com.apptreesoftware.barcode_scan")
val channel = MethodChannel(registrar.messenger(), "de.mintware.barcode_scan")
if (registrar.activity() != null) {
val plugin = BarcodeScanPlugin(registrar.activity())
channel.setMethodCallHandler(plugin)
@ -65,7 +65,7 @@ class BarcodeScanPlugin(): MethodCallHandler, PluginRegistry.ActivityResultListe
}
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(binding.binaryMessenger, "com.apptreesoftware.barcode_scan")
channel = MethodChannel(binding.binaryMessenger, "de.mintware.barcode_scan")
}
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {

View File

@ -1,4 +1,4 @@
package com.apptreesoftware.barcodescan
package de.mintware.barcode_scan
import android.Manifest
import android.app.Activity

4
example/.gitignore vendored
View File

@ -9,3 +9,7 @@ packages
pubspec.lock
.flutter-plugins
.flutter-plugins-dependencies
ios/Flutter.podspec
ios/Flutter/Flutter.podspec
ios/Flutter/flutter_export_environment.sh
ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

View File

@ -29,12 +29,12 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.yourcompany.barcodescanexample"
applicationId "de.mintware.barcode_scan_example"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.barcodescanexample">
package="com.apptreesoftware.barcodescanexample">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
@ -20,7 +20,7 @@
android:hardwareAccelerated="true"
android:exported="true"
android:launchMode="singleTop"
android:name="com.apptreesoftware.barcodescanexample.EmbeddingV1Activity"
android:name=".EmbeddingV1Activity"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
@ -33,7 +33,7 @@
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:name="com.apptreesoftware.barcodescanexample.MainActivity"
android:name=".MainActivity"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<!-- Specify that the launch screen should continue being displayed -->

View File

@ -1,6 +1,6 @@
package com.apptreesoftware.barcodescanexample
import com.apptreesoftware.barcodescan.BarcodeScanPlugin
import de.mintware.barcode_scan.BarcodeScanPlugin
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine

View File

@ -38,4 +38,4 @@ Icon?
/Flutter/Generated.xcconfig
/ServiceDefinitions.json
Pods/
Pods/

View File

@ -1,29 +0,0 @@
PODS:
- barcode_scan (0.0.1):
- Flutter
- MTBBarcodeScanner
- Flutter (1.0.0)
- MTBBarcodeScanner (5.0.11)
DEPENDENCIES:
- barcode_scan (from `/Users/matthew/AppTree/plugins/barcode_scan/ios`)
- Flutter (from `/Users/matthew/Library/flutter/bin/cache/artifacts/engine/ios`)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
- MTBBarcodeScanner
EXTERNAL SOURCES:
barcode_scan:
:path: "/Users/matthew/AppTree/plugins/barcode_scan/ios"
Flutter:
:path: "/Users/matthew/Library/flutter/bin/cache/artifacts/engine/ios"
SPEC CHECKSUMS:
barcode_scan: 33f586d02270046fc6559135038b34b5754eaa4f
Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
PODFILE CHECKSUM: 407db753d18e8726329521f96a8fa0bebaef3f42
COCOAPODS: 1.6.1

View File

@ -180,7 +180,6 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = RTZBJSE8E8;
LastSwiftMigration = 0830;
};
};
@ -274,7 +273,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../../../../../../Library/flutter/bin/cache/artifacts/engine/ios/Flutter.framework",
"${PODS_ROOT}/../../../../../development/flutter/bin/cache/artifacts/engine/ios/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
@ -416,7 +415,6 @@
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = RTZBJSE8E8;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -428,7 +426,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.apptreesoftware.barcode.plugin.example;
PRODUCT_BUNDLE_IDENTIFIER = de.mintware.barcode_scan.plugin.example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@ -443,7 +441,6 @@
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEVELOPMENT_TEAM = RTZBJSE8E8;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -455,7 +452,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.apptreesoftware.barcode.plugin.example;
PRODUCT_BUNDLE_IDENTIFIER = de.mintware.barcode_scan.plugin.example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 4.0;

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>

View File

@ -3,7 +3,7 @@
@implementation BarcodeScanPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:@"com.apptreesoftware.barcode_scan"
FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:@"de.mintware.barcode_scan"
binaryMessenger:registrar.messenger];
BarcodeScanPlugin *instance = [BarcodeScanPlugin new];
instance.hostViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
@ -22,10 +22,12 @@
- (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);

View File

@ -10,6 +10,35 @@
@implementation BarcodeScannerViewController {
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
CGRect bounds = [UIScreen mainScreen].bounds;
CGRect reversedBounds = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.width);
self.previewView.bounds = reversedBounds;
self.previewView.frame = reversedBounds;
[self.scanRect stopAnimating];
[self.scanRect removeFromSuperview];
[self setupScanRect:reversedBounds];
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
- (void)setupScanRect:(CGRect)bounds {
self.scanRect = [[ScannerOverlay alloc] initWithFrame:bounds];
self.scanRect.translatesAutoresizingMaskIntoConstraints = NO;
self.scanRect.backgroundColor = UIColor.clearColor;
[self.view addSubview:_scanRect];
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:[scanRect]"
options:NSLayoutFormatAlignAllBottom
metrics:nil
views:@{@"scanRect": _scanRect}]];
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:[scanRect]"
options:NSLayoutFormatAlignAllBottom
metrics:nil
views:@{@"scanRect": _scanRect}]];
[_scanRect startAnimating];
}
- (void)viewDidLoad {
[super viewDidLoad];
@ -26,21 +55,7 @@
options:NSLayoutFormatAlignAllBottom
metrics:nil
views:@{@"previewView": _previewView}]];
self.scanRect = [[ScannerOverlay alloc] initWithFrame:self.view.bounds];
self.scanRect.translatesAutoresizingMaskIntoConstraints = NO;
self.scanRect.backgroundColor = UIColor.clearColor;
[self.view addSubview:_scanRect];
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:[scanRect]"
options:NSLayoutFormatAlignAllBottom
metrics:nil
views:@{@"scanRect": _scanRect}]];
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:[scanRect]"
options:NSLayoutFormatAlignAllBottom
metrics:nil
views:@{@"scanRect": _scanRect}]];
[_scanRect startAnimating];
[self setupScanRect:self.view.bounds];
self.scanner = [[MTBBarcodeScanner alloc] initWithPreviewView:_previewView];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)];
[self updateFlashButton];

View File

@ -83,19 +83,31 @@
}
- (CGRect)scanRect {
CGRect rect = self.frame;
CGFloat heightMultiplier = 3.0/4.0; // 4:3 aspect ratio
CGFloat scanRectWidth = rect.size.width * 0.8f;
CGFloat scanRectHeight = scanRectWidth * heightMultiplier;
CGFloat scanRectOriginX = (rect.size.width / 2) - (scanRectWidth / 2);
CGFloat scanRectOriginY = (rect.size.height / 2) - (scanRectHeight / 2);
return CGRectMake(scanRectOriginX, scanRectOriginY, scanRectWidth, scanRectHeight);
CGRect rect = self.frame;
CGFloat frameWidth = rect.size.width;
CGFloat frameHeight = rect.size.height;
BOOL isLandscape = frameWidth > frameHeight;
CGFloat widthOnPortrait = isLandscape ? frameHeight : frameWidth;
CGFloat scanRectWidth = widthOnPortrait * 0.8f;
CGFloat aspectRatio = 3.0/4.0;
CGFloat scanRectHeight = scanRectWidth * aspectRatio;
if(isLandscape) {
CGFloat navbarHeight = 32;
frameHeight += navbarHeight;
}
CGFloat scanRectOriginX = (frameWidth - scanRectWidth) / 2;
CGFloat scanRectOriginY = (frameHeight - scanRectHeight) / 2;
return CGRectMake(scanRectOriginX, scanRectOriginY, scanRectWidth, scanRectHeight);
}
- (CGRect)scanLineRect {
CGRect scanRect = [self scanRect];
CGRect rect = self.frame;
return CGRectMake(scanRect.origin.x, rect.size.height / 2, scanRect.size.width, 1);
CGFloat positionY = scanRect.origin.y + (scanRect.size.height / 2);
return CGRectMake(scanRect.origin.x, positionY, scanRect.size.width, 1);
}
@end

View File

@ -2,10 +2,22 @@ import 'dart:async';
import 'package:flutter/services.dart';
/// Barcode scanner plugin
/// Simply call `var barcode = await BarcodeScanner.scan()` to scan a barcode
class BarcodeScanner {
/// If the user has not granted the access to the camera this code is thrown.
static const CameraAccessDenied = 'PERMISSION_NOT_GRANTED';
/// If the user cancel the scan an exception with this code is thrown.
static const UserCanceled = 'USER_CANCELED';
/// The method channel
static const MethodChannel _channel =
const MethodChannel('com.apptreesoftware.barcode_scan');
const MethodChannel('de.mintware.barcode_scan');
/// Starts the camera for scanning the barcode, shows a preview window and
/// returns the barcode if one was scanned.
/// Can throw an exception.
/// See also [CameraAccessDenied] and [UserCanceled]
static Future<String> scan() async => await _channel.invokeMethod('scan');
}

View File

@ -1,6 +1,6 @@
name: barcode_scan
description: A flutter plugin for scanning 2D barcodes and QRCodes.
version: 1.0.0
description: A flutter plugin for scanning 2D barcodes and QRCodes via camera.
version: 2.0.0
author: Matthew Smith<matthew.smith@apptreesoftware.com>
homepage: https://github.com/apptreesoftware/flutter_barcode_reader
@ -20,7 +20,7 @@ flutter:
plugin:
platforms:
android:
package: com.apptreesoftware.barcodescan
package: de.mintware.barcode_scan
pluginClass: BarcodeScanPlugin
ios:
pluginClass: BarcodeScanPlugin