From 51b4851de070e9806f5746a611d13571427b1539 Mon Sep 17 00:00:00 2001 From: Joshua Hoogstraat <34964599+jhoogstraat@users.noreply.github.com> Date: Mon, 5 Jul 2021 14:36:55 +0200 Subject: [PATCH] Rename everything to scanner --- .../lib/camera_settings/camera_settings.dart | 4 ++-- .../lib/camera_settings/type_selector.dart | 2 +- .../example/lib/scanner_screen.dart | 2 +- .../Classes/FastBarcodeScannerPlugin.swift | 2 +- .../ios/Classes/types/ScannerError.swift | 2 +- .../lib/src/camera_controller.dart | 20 +++++++++---------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fast_barcode_scanner/example/lib/camera_settings/camera_settings.dart b/fast_barcode_scanner/example/lib/camera_settings/camera_settings.dart index 5b313593..31437658 100644 --- a/fast_barcode_scanner/example/lib/camera_settings/camera_settings.dart +++ b/fast_barcode_scanner/example/lib/camera_settings/camera_settings.dart @@ -8,14 +8,14 @@ class CameraSettings extends StatefulWidget { const CameraSettings(this._currentConfiguration, {Key? key}) : super(key: key); - final CameraConfiguration _currentConfiguration; + final ScannerConfiguration _currentConfiguration; @override State createState() => _CameraSettingsState(); } class _CameraSettingsState extends State { - late CameraConfiguration _config; + late ScannerConfiguration _config; @override void initState() { diff --git a/fast_barcode_scanner/example/lib/camera_settings/type_selector.dart b/fast_barcode_scanner/example/lib/camera_settings/type_selector.dart index 7ce57040..a97d33ae 100644 --- a/fast_barcode_scanner/example/lib/camera_settings/type_selector.dart +++ b/fast_barcode_scanner/example/lib/camera_settings/type_selector.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; class BarcodeTypeSelector extends StatefulWidget { const BarcodeTypeSelector(this._config, {Key? key}) : super(key: key); - final CameraConfiguration _config; + final ScannerConfiguration _config; @override State createState() => _BarcodeTypeSelectorState(); diff --git a/fast_barcode_scanner/example/lib/scanner_screen.dart b/fast_barcode_scanner/example/lib/scanner_screen.dart index 06663f65..553bb567 100644 --- a/fast_barcode_scanner/example/lib/scanner_screen.dart +++ b/fast_barcode_scanner/example/lib/scanner_screen.dart @@ -118,7 +118,7 @@ class _ScannerScreenState extends State { ElevatedButton( onPressed: () async { final config = - CameraController.instance.state.cameraConfig; + CameraController.instance.state.scannerConfig; if (config != null) { CameraController.instance.pauseDetector(); await Navigator.push( diff --git a/fast_barcode_scanner/ios/Classes/FastBarcodeScannerPlugin.swift b/fast_barcode_scanner/ios/Classes/FastBarcodeScannerPlugin.swift index 4c81bcbd..94cd409f 100644 --- a/fast_barcode_scanner/ios/Classes/FastBarcodeScannerPlugin.swift +++ b/fast_barcode_scanner/ios/Classes/FastBarcodeScannerPlugin.swift @@ -43,7 +43,7 @@ public class FastBarcodeScannerPlugin: NSObject, FlutterPlugin { } func initialize(configArgs: Any?) throws -> PreviewConfiguration { - guard let configuration = CameraConfiguration(configArgs) else { + guard let configuration = ScannerConfiguration(configArgs) else { throw ScannerError.invalidArguments(configArgs) } diff --git a/fast_barcode_scanner/ios/Classes/types/ScannerError.swift b/fast_barcode_scanner/ios/Classes/types/ScannerError.swift index 7fae00b9..7f5b2137 100644 --- a/fast_barcode_scanner/ios/Classes/types/ScannerError.swift +++ b/fast_barcode_scanner/ios/Classes/types/ScannerError.swift @@ -22,7 +22,7 @@ extension Error { enum ScannerError: Error { case notInitialized case alreadyRunning - case noInputDeviceForConfig(CameraConfiguration) + case noInputDeviceForConfig(ScannerConfiguration) case cameraNotSuitable(Resolution, Framerate) case unauthorized case configurationError(Error) diff --git a/fast_barcode_scanner/lib/src/camera_controller.dart b/fast_barcode_scanner/lib/src/camera_controller.dart index 2fce15c7..5cfac4e1 100644 --- a/fast_barcode_scanner/lib/src/camera_controller.dart +++ b/fast_barcode_scanner/lib/src/camera_controller.dart @@ -5,8 +5,8 @@ import 'package:fast_barcode_scanner_platform_interface/fast_barcode_scanner_pla import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -class CameraConfiguration { - const CameraConfiguration( +class ScannerConfiguration { + const ScannerConfiguration( this.types, this.resolution, this.framerate, @@ -37,14 +37,14 @@ class CameraConfiguration { /// The physical position of the camera being used. final CameraPosition position; - CameraConfiguration copyWith({ + ScannerConfiguration copyWith({ List? types, Resolution? resolution, Framerate? framerate, DetectionMode? detectionMode, CameraPosition? position, }) { - return CameraConfiguration( + return ScannerConfiguration( types ?? this.types, resolution ?? this.resolution, framerate ?? this.framerate, @@ -58,7 +58,7 @@ enum CameraEvent { uninitialized, init, paused, resumed, codeFound, error } class CameraState { PreviewConfiguration? _previewConfig; - CameraConfiguration? _cameraConfig; + ScannerConfiguration? _scannerConfig; bool _torchState = false; bool _togglingTorch = false; bool _configuring = false; @@ -66,7 +66,7 @@ class CameraState { Object? get error => _error; PreviewConfiguration? get previewConfig => _previewConfig; - CameraConfiguration? get cameraConfig => _cameraConfig; + ScannerConfiguration? get scannerConfig => _scannerConfig; bool get torchState => _torchState; bool get isInitialized => _previewConfig != null; bool get hasError => error != null; @@ -116,7 +116,7 @@ class CameraController { onScan?.call(code); }); - state._cameraConfig = CameraConfiguration( + state._scannerConfig = ScannerConfiguration( types, resolution, framerate, detectionMode, position); state.eventNotifier.value = CameraEvent.resumed; @@ -207,9 +207,9 @@ class CameraController { DetectionMode? detectionMode, CameraPosition? position, }) async { - final _cameraConfig = state._cameraConfig; + final _scannerConfig = state._scannerConfig; - if (_cameraConfig != null && !state._configuring) { + if (_scannerConfig != null && !state._configuring) { state._configuring = true; try { @@ -221,7 +221,7 @@ class CameraController { position: position, ); - state._cameraConfig = _cameraConfig.copyWith( + state._scannerConfig = _scannerConfig.copyWith( types: types, resolution: resolution, framerate: framerate,