Browse Source

minor imrovements

pull/38/head
Khoren Markosyan 2 years ago
parent
commit
d201f967c7
  1. 14
      example/pubspec.lock
  2. 2
      example/pubspec.yaml
  3. 29
      lib/src/ui/reader_widget.dart
  4. 3
      zxscanner/lib/generated/intl/messages_en_US.dart
  5. 1
      zxscanner/lib/models/code.dart
  6. 1
      zxscanner/lib/models/encode.dart
  7. 55
      zxscanner/pubspec.lock
  8. 14
      zxscanner/pubspec.yaml

14
example/pubspec.lock

@ -35,7 +35,7 @@ packages:
name: camera_android name: camera_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.10.0+1" version: "0.10.0+2"
camera_avfoundation: camera_avfoundation:
dependency: transitive dependency: transitive
description: description:
@ -84,7 +84,7 @@ packages:
name: cross_file name: cross_file
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.3+1" version: "0.3.3+2"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -141,14 +141,14 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.8.0" version: "0.8.1"
font_awesome_flutter: font_awesome_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
name: font_awesome_flutter name: font_awesome_flutter
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "10.1.0" version: "10.2.1"
http: http:
dependency: transitive dependency: transitive
description: description:
@ -183,7 +183,7 @@ packages:
name: image_picker_android name: image_picker_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.5+2" version: "0.8.5+3"
image_picker_for_web: image_picker_for_web:
dependency: transitive dependency: transitive
description: description:
@ -197,7 +197,7 @@ packages:
name: image_picker_ios name: image_picker_ios
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.6" version: "0.8.6+1"
image_picker_platform_interface: image_picker_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -260,7 +260,7 @@ packages:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.2" version: "2.1.3"
quiver: quiver:
dependency: transitive dependency: transitive
description: description:

2
example/pubspec.yaml

@ -11,7 +11,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_zxing: flutter_zxing:
path: ../ path: ../
font_awesome_flutter: ^10.1.0 font_awesome_flutter: ^10.2.1
image: ^3.2.0 image: ^3.2.0
image_picker: ^0.8.5 image_picker: ^0.8.5

29
lib/src/ui/reader_widget.dart

@ -26,7 +26,8 @@ class ReaderWidget extends StatefulWidget {
this.scanDelaySuccess = const Duration(milliseconds: 1000), // 1000ms delay this.scanDelaySuccess = const Duration(milliseconds: 1000), // 1000ms delay
this.cropPercent = 0.5, // 50% of the screen this.cropPercent = 0.5, // 50% of the screen
this.resolution = ResolutionPreset.high, this.resolution = ResolutionPreset.high,
this.loading = const DecoratedBox(decoration: BoxDecoration(color: Colors.black)), this.loading =
const DecoratedBox(decoration: BoxDecoration(color: Colors.black)),
}); });
final Function(CodeResult) onScan; final Function(CodeResult) onScan;
@ -46,7 +47,8 @@ class ReaderWidget extends StatefulWidget {
State<ReaderWidget> createState() => _ReaderWidgetState(); State<ReaderWidget> createState() => _ReaderWidgetState();
} }
class _ReaderWidgetState extends State<ReaderWidget> with TickerProviderStateMixin, WidgetsBindingObserver { class _ReaderWidgetState extends State<ReaderWidget>
with TickerProviderStateMixin, WidgetsBindingObserver {
List<CameraDescription> cameras = <CameraDescription>[]; List<CameraDescription> cameras = <CameraDescription>[];
CameraController? controller; CameraController? controller;
bool _cameraOn = false; bool _cameraOn = false;
@ -89,7 +91,6 @@ class _ReaderWidgetState extends State<ReaderWidget> with TickerProviderStateMix
if (cameras.isNotEmpty && !_cameraOn) { if (cameras.isNotEmpty && !_cameraOn) {
onNewCameraSelected(cameras.first); onNewCameraSelected(cameras.first);
} }
break; break;
case AppLifecycleState.inactive: case AppLifecycleState.inactive:
break; break;
@ -131,7 +132,8 @@ class _ReaderWidgetState extends State<ReaderWidget> with TickerProviderStateMix
cameraDescription, cameraDescription,
widget.resolution, widget.resolution,
enableAudio: false, enableAudio: false,
imageFormatGroup: isAndroid() ? ImageFormatGroup.yuv420 : ImageFormatGroup.bgra8888, imageFormatGroup:
isAndroid() ? ImageFormatGroup.yuv420 : ImageFormatGroup.bgra8888,
); );
if (controller == null) { if (controller == null) {
return; return;
@ -144,6 +146,8 @@ class _ReaderWidgetState extends State<ReaderWidget> with TickerProviderStateMix
controller!.startImageStream(processImageStream); controller!.startImageStream(processImageStream);
} on CameraException catch (e) { } on CameraException catch (e) {
debugPrint('${e.code}: ${e.description}'); debugPrint('${e.code}: ${e.description}');
} catch (e) {
debugPrint('Error: $e');
} }
controller!.addListener(rebuildOnMount); controller!.addListener(rebuildOnMount);
@ -179,7 +183,10 @@ class _ReaderWidgetState extends State<ReaderWidget> with TickerProviderStateMix
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final bool isCameraReady = cameras.isNotEmpty && _cameraOn && controller != null && controller!.value.isInitialized; final bool isCameraReady = cameras.isNotEmpty &&
_cameraOn &&
controller != null &&
controller!.value.isInitialized;
final Size size = MediaQuery.of(context).size; final Size size = MediaQuery.of(context).size;
final double cameraMaxSize = max(size.width, size.height); final double cameraMaxSize = max(size.width, size.height);
final double cropSize = min(size.width, size.height) * widget.cropPercent; final double cropSize = min(size.width, size.height) * widget.cropPercent;
@ -224,29 +231,29 @@ class _ReaderWidgetState extends State<ReaderWidget> with TickerProviderStateMix
_zoom = _scaleFactor; _zoom = _scaleFactor;
}, },
onScaleUpdate: (ScaleUpdateDetails details) { onScaleUpdate: (ScaleUpdateDetails details) {
_scaleFactor = (_zoom * details.scale).clamp(_minZoomLevel, _maxZoomLevel); _scaleFactor =
(_zoom * details.scale).clamp(_minZoomLevel, _maxZoomLevel);
controller?.setZoomLevel(_scaleFactor); controller?.setZoomLevel(_scaleFactor);
}, },
), ),
if (widget.showFlashlight) if (widget.showFlashlight && isCameraReady)
Positioned( Positioned(
bottom: 20, bottom: 20,
left: 20, left: 20,
child: FloatingActionButton( child: FloatingActionButton(
onPressed: () { onPressed: () {
if (controller != null) {
FlashMode mode = controller!.value.flashMode; FlashMode mode = controller!.value.flashMode;
if (mode == FlashMode.torch) { if (mode == FlashMode.torch) {
mode = FlashMode.off; mode = FlashMode.off;
} else { } else {
mode = FlashMode.torch; mode = FlashMode.torch;
} }
controller!.setFlashMode(mode); controller?.setFlashMode(mode);
setState(() {}); setState(() {});
}
}, },
backgroundColor: Colors.black26, backgroundColor: Colors.black26,
child: _FlashIcon(flashMode: controller!.value.flashMode)), child: _FlashIcon(
flashMode: controller?.value.flashMode ?? FlashMode.off)),
), ),
], ],
); );

3
zxscanner/lib/generated/intl/messages_en_US.dart

@ -20,7 +20,8 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'en_US'; String get localeName => 'en_US';
final Map<String, Function> messages = _notInlinedMessages(_notInlinedMessages); final Map<String, Function> messages =
_notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"settingsAppBarTitle": MessageLookupByLibrary.simpleMessage("Settings"), "settingsAppBarTitle": MessageLookupByLibrary.simpleMessage("Settings"),
"settingsLanguageTitle": "settingsLanguageTitle":

1
zxscanner/lib/models/code.dart

@ -5,7 +5,6 @@ part 'code.g.dart';
@HiveType(typeId: 0) @HiveType(typeId: 0)
class Code extends HiveObject { class Code extends HiveObject {
Code(); Code();
Code.fromCodeResult(CodeResult result) { Code.fromCodeResult(CodeResult result) {

1
zxscanner/lib/models/encode.dart

@ -7,7 +7,6 @@ part 'encode.g.dart';
@HiveType(typeId: 1) @HiveType(typeId: 1)
class Encode extends HiveObject { class Encode extends HiveObject {
Encode(); Encode();
Encode.fromEncodeResult(EncodeResult result, Uint8List? bytes) { Encode.fromEncodeResult(EncodeResult result, Uint8List? bytes) {

55
zxscanner/pubspec.lock

@ -49,7 +49,7 @@ packages:
name: build name: build
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.3.0" version: "2.3.1"
build_config: build_config:
dependency: transitive dependency: transitive
description: description:
@ -70,21 +70,21 @@ packages:
name: build_resolvers name: build_resolvers
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.9" version: "2.0.10"
build_runner: build_runner:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: build_runner name: build_runner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.0" version: "2.2.1"
build_runner_core: build_runner_core:
dependency: transitive dependency: transitive
description: description:
name: build_runner_core name: build_runner_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "7.2.3" version: "7.2.4"
built_collection: built_collection:
dependency: transitive dependency: transitive
description: description:
@ -141,13 +141,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.1" version: "1.2.1"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
checked_yaml: checked_yaml:
dependency: transitive dependency: transitive
description: description:
@ -168,7 +161,7 @@ packages:
name: code_builder name: code_builder
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.2.0" version: "4.3.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
@ -189,14 +182,14 @@ packages:
name: convex_bottom_bar name: convex_bottom_bar
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.1.0+1"
cross_file: cross_file:
dependency: transitive dependency: transitive
description: description:
name: cross_file name: cross_file
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.3+1" version: "0.3.3+2"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -224,7 +217,7 @@ packages:
name: dart_style name: dart_style
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.3" version: "2.2.4"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -259,7 +252,7 @@ packages:
name: flex_color_scheme name: flex_color_scheme
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.0" version: "6.0.1"
flex_seed_scheme: flex_seed_scheme:
dependency: transitive dependency: transitive
description: description:
@ -290,14 +283,14 @@ packages:
name: flutter_markdown name: flutter_markdown
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.10+5" version: "0.6.12"
flutter_mobx: flutter_mobx:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_mobx name: flutter_mobx
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.6+1" version: "2.0.6+4"
flutter_native_splash: flutter_native_splash:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -328,7 +321,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "0.8.0" version: "0.8.1"
font_awesome_flutter: font_awesome_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
@ -447,7 +440,7 @@ packages:
name: image_picker_ios name: image_picker_ios
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.6" version: "0.8.6+1"
image_picker_platform_interface: image_picker_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -482,7 +475,7 @@ packages:
name: json_annotation name: json_annotation
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.6.0" version: "4.7.0"
lint: lint:
dependency: transitive dependency: transitive
description: description:
@ -510,7 +503,7 @@ packages:
name: markdown name: markdown
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "5.0.0" version: "6.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
@ -545,14 +538,14 @@ packages:
name: mobx name: mobx
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.7+5" version: "2.1.0"
mobx_codegen: mobx_codegen:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: mobx_codegen name: mobx_codegen
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.7" version: "2.0.7+3"
package_config: package_config:
dependency: transitive dependency: transitive
description: description:
@ -636,7 +629,7 @@ packages:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.2" version: "2.1.3"
pool: pool:
dependency: transitive dependency: transitive
description: description:
@ -678,7 +671,7 @@ packages:
name: share_plus name: share_plus
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.0" version: "4.4.0"
share_plus_linux: share_plus_linux:
dependency: transitive dependency: transitive
description: description:
@ -776,7 +769,7 @@ packages:
name: shelf name: shelf
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.2" version: "1.4.0"
shelf_web_socket: shelf_web_socket:
dependency: transitive dependency: transitive
description: description:
@ -795,14 +788,14 @@ packages:
name: source_gen name: source_gen
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.2" version: "1.2.5"
source_helper: source_helper:
dependency: transitive dependency: transitive
description: description:
name: source_helper name: source_helper
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.2" version: "1.3.3"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@ -886,7 +879,7 @@ packages:
name: url_launcher_android name: url_launcher_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.18" version: "6.0.19"
url_launcher_ios: url_launcher_ios:
dependency: transitive dependency: transitive
description: description:
@ -979,5 +972,5 @@ packages:
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.18.0 <3.0.0" dart: ">=2.18.1 <3.0.0"
flutter: ">=3.3.0" flutter: ">=3.3.0"

14
zxscanner/pubspec.yaml

@ -5,17 +5,17 @@ publish_to: "none"
version: 1.0.3+8 version: 1.0.3+8
environment: environment:
sdk: ">=2.18.0 <3.0.0" sdk: ">=2.18.1 <3.0.0"
dependencies: dependencies:
convex_bottom_bar: ^3.0.0 convex_bottom_bar: ^3.1.0
cupertino_icons: ^1.0.5 cupertino_icons: ^1.0.5
flex_color_scheme: ^6.0.0 flex_color_scheme: ^6.0.1
flutter: flutter:
sdk: flutter sdk: flutter
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
flutter_markdown: ^0.6.10 flutter_markdown: ^0.6.12
flutter_mobx: ^2.0.6 flutter_mobx: ^2.0.6
flutter_zxing: flutter_zxing:
path: ../ path: ../
@ -25,9 +25,9 @@ dependencies:
image: ^3.2.0 image: ^3.2.0
image_picker: ^0.8.5 image_picker: ^0.8.5
intl: ^0.17.0 intl: ^0.17.0
mobx: ^2.0.7 mobx: ^2.1.0
path_provider: ^2.0.11 path_provider: ^2.0.11
share_plus: ^4.1.0 share_plus: ^4.4.0
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
url_launcher: ^6.1.5 url_launcher: ^6.1.5
@ -36,7 +36,7 @@ flutter_intl:
enabled: true enabled: true
dev_dependencies: dev_dependencies:
build_runner: ^2.2.0 build_runner: ^2.2.1
# espresso: ^0.2.0+2 # espresso: ^0.2.0+2
flutter_lints: ^2.0.1 flutter_lints: ^2.0.1
flutter_native_splash: ^2.2.9 # flutter pub run flutter_native_splash:create flutter_native_splash: ^2.2.9 # flutter pub run flutter_native_splash:create

Loading…
Cancel
Save