Skip to content

Commit

Permalink
Fix pauseDetector on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoogstraat committed Oct 23, 2021
1 parent c0ed12c commit a049a26
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
5 changes: 5 additions & 0 deletions fast_barcode_scanner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.4

- Fixes `pauseDetector` on iOS
- Updates CameraX (compileSdk is now 31)

## 1.1.3

- Remove references to FlutterActivity (required by local_auth package)
Expand Down
4 changes: 2 additions & 2 deletions fast_barcode_scanner/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 30
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down Expand Up @@ -53,7 +53,7 @@ android {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

def camerax_version = "1.1.0-alpha08"
def camerax_version = "1.1.0-alpha10"
def mlkit_version = "17.0.0"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
Expand Down
4 changes: 2 additions & 2 deletions fast_barcode_scanner/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -35,7 +35,7 @@ android {
defaultConfig {
applicationId "com.jhoogstraat.fast_barcode_scanner_example"
minSdkVersion 21
targetSdkVersion 30
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
16 changes: 10 additions & 6 deletions fast_barcode_scanner/ios/Classes/BarcodeReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,17 @@ class BarcodeReader: NSObject {
return captureDevice.isTorchActive
}

func pauseIfRequired() {
switch detectionMode {
case .continuous: return
case .pauseDetection:
captureSession.removeOutput(metadataOutput)
case .pauseVideo:
func pauseIfRequired(force: Bool = false) {
if force {
stop(pause: true)
} else {
switch detectionMode {
case .continuous: return
case .pauseDetection:
captureSession.removeOutput(metadataOutput)
case .pauseVideo:
stop(pause: true)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class FastBarcodeScannerPlugin: NSObject, FlutterPlugin {
}

func pause(result: @escaping FlutterResult) {
reader?.pauseIfRequired()
reader?.pauseIfRequired(force: true)
result(nil)
}

Expand Down
2 changes: 1 addition & 1 deletion fast_barcode_scanner/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.3
flutter_lints: ^1.0.4

flutter:
plugin:
Expand Down

0 comments on commit a049a26

Please sign in to comment.