Skip to content

Commit

Permalink
Rename everything to scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoogstraat committed Jul 5, 2021
1 parent 0f6ed20 commit 51b4851
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<CameraSettings> createState() => _CameraSettingsState();
}

class _CameraSettingsState extends State<CameraSettings> {
late CameraConfiguration _config;
late ScannerConfiguration _config;

@override
void initState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BarcodeTypeSelector> createState() => _BarcodeTypeSelectorState();
Expand Down
2 changes: 1 addition & 1 deletion fast_barcode_scanner/example/lib/scanner_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class _ScannerScreenState extends State<ScannerScreen> {
ElevatedButton(
onPressed: () async {
final config =
CameraController.instance.state.cameraConfig;
CameraController.instance.state.scannerConfig;
if (config != null) {
CameraController.instance.pauseDetector();
await Navigator.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion fast_barcode_scanner/ios/Classes/types/ScannerError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions fast_barcode_scanner/lib/src/camera_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -37,14 +37,14 @@ class CameraConfiguration {
/// The physical position of the camera being used.
final CameraPosition position;

CameraConfiguration copyWith({
ScannerConfiguration copyWith({
List<BarcodeType>? types,
Resolution? resolution,
Framerate? framerate,
DetectionMode? detectionMode,
CameraPosition? position,
}) {
return CameraConfiguration(
return ScannerConfiguration(
types ?? this.types,
resolution ?? this.resolution,
framerate ?? this.framerate,
Expand All @@ -58,15 +58,15 @@ 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;
Object? _error;

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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -221,7 +221,7 @@ class CameraController {
position: position,
);

state._cameraConfig = _cameraConfig.copyWith(
state._scannerConfig = _scannerConfig.copyWith(
types: types,
resolution: resolution,
framerate: framerate,
Expand Down

0 comments on commit 51b4851

Please sign in to comment.