Przeglądaj źródła

Merge branch 'master' into fix/flashToggle

flutter-beta
Luis Thein 7 lat temu
committed by GitHub
rodzic
commit
a3f05b8628
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 70 dodań i 5 usunięć
  1. +17
    -0
      android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt
  2. +4
    -4
      azure-pipelines.yml
  3. +25
    -1
      example/lib/main.dart
  4. +16
    -0
      ios/Classes/QRView.swift
  5. +8
    -0
      lib/qr_code_scanner.dart

+ 17
- 0
android/src/main/kotlin/net/touchcapture/qr/flutterqr/QRView.kt Wyświetl plik

@@ -89,6 +89,17 @@ class QRView(private val registrar: PluginRegistry.Registrar, id: Int) :

}

private fun pauseCamera() {
if (barcodeView!!.isPreviewActive) {
barcodeView?.pause()
}
}

private fun resumeCamera() {
if (!barcodeView!!.isPreviewActive) {
barcodeView?.resume()
}
}

private fun hasFlash(): Boolean {
return registrar.activeContext().packageManager
@@ -154,6 +165,12 @@ class QRView(private val registrar: PluginRegistry.Registrar, id: Int) :
"toggleFlash" -> {
toggleFlash()
}
"pauseCamera" -> {
pauseCamera()
}
"resumeCamera" -> {
resumeCamera()
}
}
}



+ 4
- 4
azure-pipelines.yml Wyświetl plik

@@ -17,19 +17,19 @@ pool:
steps:
- script: |
cd example
$(flutterPath)/flutter build ios
$flutterPath/flutter build ios
displayName: 'Test iOS -- Build'
env:
flutterPath: $(flutterPath)
- script: |
cd example
$(flutterPath)/flutter packages get
$(flutterPath)/flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
$flutterPath/flutter packages get
$flutterPath/flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
displayName: 'Test Android -- Build'
env:
flutterPath: $(flutterPath)
- script: |
$(flutterPath)/flutter pub pub publish --dry-run
$flutterPath/flutter pub pub publish --dry-run
displayName: 'Publish -- Dry Run'
env:
flutterPath: $(flutterPath)

+ 25
- 1
example/lib/main.dart Wyświetl plik

@@ -85,7 +85,31 @@ class _QRViewExampleState extends State<QRViewExample> {
),
)
],
)
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin: EdgeInsets.only(bottom: 8.0),
child: RaisedButton(
onPressed: () {
controller?.pauseCamera();
},
child: Text('pause', style: TextStyle(fontSize: 20)),
),
),
Container(
margin: EdgeInsets.only(bottom: 8.0),
child: RaisedButton(
onPressed: () {
controller.resumeCamera();
},
child: Text('resume', style: TextStyle(fontSize: 20)),
),
)
],
),
],
),
flex: 1,


+ 16
- 0
ios/Classes/QRView.swift Wyświetl plik

@@ -83,4 +83,20 @@ public class QRView:NSObject,FlutterPlatformView {
}
}
}
func pauseCamera() {
if let sc: MTBBarcodeScanner = scanner {
if sc.isScanning() {
sc.freezeCapture()
}
}
}
func resumeCamera() {
if let sc: MTBBarcodeScanner = scanner {
if !sc.isScanning() {
sc.unfreezeCapture()
}
}
}
}

+ 8
- 0
lib/qr_code_scanner.dart Wyświetl plik

@@ -90,4 +90,12 @@ class QRViewController {
void toggleFlash() {
channel.invokeMethod("toggleFlash");
}

void pauseCamera() {
channel.invokeMethod("pauseCamera");
}

void resumeCamera() {
channel.invokeMethod("resumeCamera");
}
}

Ładowanie…
Anuluj
Zapisz