| eb141365fb69a4e0decadd2584d53516 | |||||
| 0d1f90510e22958a585802bb59f9c570 |
| 'Release' => :release, | 'Release' => :release, | ||||
| } | } | ||||
| def parse_KV_file(file, separator='=') | |||||
| file_abs_path = File.expand_path(file) | |||||
| if !File.exists? file_abs_path | |||||
| return []; | |||||
| def flutter_root | |||||
| generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) | |||||
| unless File.exist?(generated_xcode_build_settings_path) | |||||
| raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" | |||||
| end | end | ||||
| generated_key_values = {} | |||||
| skip_line_start_symbols = ["#", "/"] | |||||
| File.foreach(file_abs_path) do |line| | |||||
| next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } | |||||
| plugin = line.split(pattern=separator) | |||||
| if plugin.length == 2 | |||||
| podname = plugin[0].strip() | |||||
| path = plugin[1].strip() | |||||
| podpath = File.expand_path("#{path}", file_abs_path) | |||||
| generated_key_values[podname] = podpath | |||||
| else | |||||
| puts "Invalid plugin specification: #{line}" | |||||
| end | |||||
| File.foreach(generated_xcode_build_settings_path) do |line| | |||||
| matches = line.match(/FLUTTER_ROOT\=(.*)/) | |||||
| return matches[1].strip if matches | |||||
| end | end | ||||
| generated_key_values | |||||
| raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" | |||||
| end | end | ||||
| require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) | |||||
| flutter_ios_podfile_setup | |||||
| target 'Runner' do | target 'Runner' do | ||||
| use_frameworks! | use_frameworks! | ||||
| use_modular_headers! | use_modular_headers! | ||||
| # Flutter Pod | |||||
| copied_flutter_dir = File.join(__dir__, 'Flutter') | |||||
| copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework') | |||||
| copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec') | |||||
| unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path) | |||||
| # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet. | |||||
| # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration. | |||||
| # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist. | |||||
| generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig') | |||||
| unless File.exist?(generated_xcode_build_settings_path) | |||||
| raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first" | |||||
| end | |||||
| generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path) | |||||
| cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR']; | |||||
| unless File.exist?(copied_framework_path) | |||||
| FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir) | |||||
| end | |||||
| unless File.exist?(copied_podspec_path) | |||||
| FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir) | |||||
| end | |||||
| end | |||||
| # Keep pod path relative so it can be checked into Podfile.lock. | |||||
| pod 'Flutter', :path => 'Flutter' | |||||
| # Plugin Pods | |||||
| # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock | |||||
| # referring to absolute paths on developers' machines. | |||||
| system('rm -rf .symlinks') | |||||
| system('mkdir -p .symlinks/plugins') | |||||
| plugin_pods = parse_KV_file('../.flutter-plugins') | |||||
| plugin_pods.each do |name, path| | |||||
| symlink = File.join('.symlinks', 'plugins', name) | |||||
| File.symlink(path, symlink) | |||||
| pod name, :path => File.join(symlink, 'ios') | |||||
| end | |||||
| flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) | |||||
| end | end | ||||
| post_install do |installer| | post_install do |installer| | ||||
| installer.pods_project.targets.each do |target| | installer.pods_project.targets.each do |target| | ||||
| target.build_configurations.each do |config| | |||||
| config.build_settings['ENABLE_BITCODE'] = 'NO' | |||||
| end | |||||
| flutter_additional_ios_build_settings(target) | |||||
| end | end | ||||
| end | end |
| - firebase_core (0.5.0): | - firebase_core (0.5.0): | ||||
| - Firebase/CoreOnly (~> 6.26.0) | - Firebase/CoreOnly (~> 6.26.0) | ||||
| - Flutter | - Flutter | ||||
| - firebase_core_web (0.1.0): | |||||
| - Flutter | |||||
| - firebase_messaging (7.0.0): | - firebase_messaging (7.0.0): | ||||
| - Firebase/CoreOnly (~> 6.26.0) | - Firebase/CoreOnly (~> 6.26.0) | ||||
| - Firebase/Messaging (~> 6.26.0) | - Firebase/Messaging (~> 6.26.0) | ||||
| - GoogleUtilities/UserDefaults (~> 6.5) | - GoogleUtilities/UserDefaults (~> 6.5) | ||||
| - Protobuf (>= 3.9.2, ~> 3.9) | - Protobuf (>= 3.9.2, ~> 3.9) | ||||
| - Flutter (1.0.0) | - Flutter (1.0.0) | ||||
| - flutter_plugin_android_lifecycle (0.0.1): | |||||
| - Flutter | |||||
| - GoogleDataTransport (7.3.0): | - GoogleDataTransport (7.3.0): | ||||
| - nanopb (~> 1.30906.0) | - nanopb (~> 1.30906.0) | ||||
| - GoogleUtilities/AppDelegateSwizzler (6.7.2): | - GoogleUtilities/AppDelegateSwizzler (6.7.2): | ||||
| - nanopb/encode (1.30906.0) | - nanopb/encode (1.30906.0) | ||||
| - package_info (0.0.1): | - package_info (0.0.1): | ||||
| - Flutter | - Flutter | ||||
| - path_provider_linux (0.0.1): | |||||
| - Flutter | |||||
| - PromisesObjC (1.2.10) | - PromisesObjC (1.2.10) | ||||
| - Protobuf (3.13.0) | - Protobuf (3.13.0) | ||||
| - shared_preferences (0.0.1): | - shared_preferences (0.0.1): | ||||
| - Flutter | - Flutter | ||||
| - shared_preferences_linux (0.0.1): | |||||
| - Flutter | |||||
| - shared_preferences_macos (0.0.1): | |||||
| - Flutter | |||||
| - shared_preferences_web (0.0.1): | |||||
| - Flutter | |||||
| - SwiftProtobuf (1.12.0) | - SwiftProtobuf (1.12.0) | ||||
| - video_player (0.0.1): | - video_player (0.0.1): | ||||
| - Flutter | - Flutter | ||||
| - video_player_web (0.0.1): | |||||
| - Flutter | |||||
| DEPENDENCIES: | DEPENDENCIES: | ||||
| - barcode_scan (from `.symlinks/plugins/barcode_scan/ios`) | - barcode_scan (from `.symlinks/plugins/barcode_scan/ios`) | ||||
| - firebase_core (from `.symlinks/plugins/firebase_core/ios`) | - firebase_core (from `.symlinks/plugins/firebase_core/ios`) | ||||
| - firebase_core_web (from `.symlinks/plugins/firebase_core_web/ios`) | |||||
| - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) | - firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`) | ||||
| - Flutter (from `Flutter`) | - Flutter (from `Flutter`) | ||||
| - flutter_plugin_android_lifecycle (from `.symlinks/plugins/flutter_plugin_android_lifecycle/ios`) | |||||
| - image_picker (from `.symlinks/plugins/image_picker/ios`) | - image_picker (from `.symlinks/plugins/image_picker/ios`) | ||||
| - package_info (from `.symlinks/plugins/package_info/ios`) | - package_info (from `.symlinks/plugins/package_info/ios`) | ||||
| - path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`) | |||||
| - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) | - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) | ||||
| - shared_preferences_linux (from `.symlinks/plugins/shared_preferences_linux/ios`) | |||||
| - shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`) | |||||
| - shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`) | |||||
| - video_player (from `.symlinks/plugins/video_player/ios`) | - video_player (from `.symlinks/plugins/video_player/ios`) | ||||
| - video_player_web (from `.symlinks/plugins/video_player_web/ios`) | |||||
| SPEC REPOS: | SPEC REPOS: | ||||
| trunk: | trunk: | ||||
| :path: ".symlinks/plugins/barcode_scan/ios" | :path: ".symlinks/plugins/barcode_scan/ios" | ||||
| firebase_core: | firebase_core: | ||||
| :path: ".symlinks/plugins/firebase_core/ios" | :path: ".symlinks/plugins/firebase_core/ios" | ||||
| firebase_core_web: | |||||
| :path: ".symlinks/plugins/firebase_core_web/ios" | |||||
| firebase_messaging: | firebase_messaging: | ||||
| :path: ".symlinks/plugins/firebase_messaging/ios" | :path: ".symlinks/plugins/firebase_messaging/ios" | ||||
| Flutter: | Flutter: | ||||
| :path: Flutter | :path: Flutter | ||||
| flutter_plugin_android_lifecycle: | |||||
| :path: ".symlinks/plugins/flutter_plugin_android_lifecycle/ios" | |||||
| image_picker: | image_picker: | ||||
| :path: ".symlinks/plugins/image_picker/ios" | :path: ".symlinks/plugins/image_picker/ios" | ||||
| package_info: | package_info: | ||||
| :path: ".symlinks/plugins/package_info/ios" | :path: ".symlinks/plugins/package_info/ios" | ||||
| path_provider_linux: | |||||
| :path: ".symlinks/plugins/path_provider_linux/ios" | |||||
| shared_preferences: | shared_preferences: | ||||
| :path: ".symlinks/plugins/shared_preferences/ios" | :path: ".symlinks/plugins/shared_preferences/ios" | ||||
| shared_preferences_linux: | |||||
| :path: ".symlinks/plugins/shared_preferences_linux/ios" | |||||
| shared_preferences_macos: | |||||
| :path: ".symlinks/plugins/shared_preferences_macos/ios" | |||||
| shared_preferences_web: | |||||
| :path: ".symlinks/plugins/shared_preferences_web/ios" | |||||
| video_player: | video_player: | ||||
| :path: ".symlinks/plugins/video_player/ios" | :path: ".symlinks/plugins/video_player/ios" | ||||
| video_player_web: | |||||
| :path: ".symlinks/plugins/video_player_web/ios" | |||||
| SPEC CHECKSUMS: | SPEC CHECKSUMS: | ||||
| barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479 | barcode_scan: a5c27959edfafaa0c771905bad0b29d6d39e4479 | ||||
| Firebase: 7cf5f9c67f03cb3b606d1d6535286e1080e57eb6 | Firebase: 7cf5f9c67f03cb3b606d1d6535286e1080e57eb6 | ||||
| firebase_core: 3134fe79d257d430f163b558caf52a10a87efe8a | firebase_core: 3134fe79d257d430f163b558caf52a10a87efe8a | ||||
| firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1 | |||||
| firebase_messaging: 6061cbdfe4463502a0d4d7049820c25d1757a095 | firebase_messaging: 6061cbdfe4463502a0d4d7049820c25d1757a095 | ||||
| FirebaseAnalyticsInterop: 3f86269c38ae41f47afeb43ebf32a001f58fcdae | FirebaseAnalyticsInterop: 3f86269c38ae41f47afeb43ebf32a001f58fcdae | ||||
| FirebaseCore: f42e5e5f382cdcf6b617ed737bf6c871a6947b17 | FirebaseCore: f42e5e5f382cdcf6b617ed737bf6c871a6947b17 | ||||
| FirebaseInstanceID: cef67c4967c7cecb56ea65d8acbb4834825c587b | FirebaseInstanceID: cef67c4967c7cecb56ea65d8acbb4834825c587b | ||||
| FirebaseMessaging: 29543feb343b09546ab3aa04d008ee8595b43c44 | FirebaseMessaging: 29543feb343b09546ab3aa04d008ee8595b43c44 | ||||
| Flutter: 0e3d915762c693b495b44d77113d4970485de6ec | Flutter: 0e3d915762c693b495b44d77113d4970485de6ec | ||||
| flutter_plugin_android_lifecycle: dc0b544e129eebb77a6bfb1239d4d1c673a60a35 | |||||
| GoogleDataTransport: e85fb700c9b027079ce182c3d08e12e0f9618bb4 | GoogleDataTransport: e85fb700c9b027079ce182c3d08e12e0f9618bb4 | ||||
| GoogleUtilities: 7f2f5a07f888cdb145101d6042bc4422f57e70b3 | GoogleUtilities: 7f2f5a07f888cdb145101d6042bc4422f57e70b3 | ||||
| image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 | image_picker: 9c3312491f862b28d21ecd8fdf0ee14e601b3f09 | ||||
| MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb | MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb | ||||
| nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc | nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc | ||||
| package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 | package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 | ||||
| path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4 | |||||
| PromisesObjC: b14b1c6b68e306650688599de8a45e49fae81151 | PromisesObjC: b14b1c6b68e306650688599de8a45e49fae81151 | ||||
| Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748 | Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748 | ||||
| shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d | shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d | ||||
| shared_preferences_linux: afefbfe8d921e207f01ede8b60373d9e3b566b78 | |||||
| shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087 | |||||
| shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9 | |||||
| SwiftProtobuf: 4ef85479c18ca85b5482b343df9c319c62bda699 | SwiftProtobuf: 4ef85479c18ca85b5482b343df9c319c62bda699 | ||||
| video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e | video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e | ||||
| video_player_web: da8cadb8274ed4f8dbee8d7171b420dedd437ce7 | |||||
| PODFILE CHECKSUM: c34e2287a9ccaa606aeceab922830efb9a6ff69a | |||||
| PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c | |||||
| COCOAPODS: 1.9.3 | COCOAPODS: 1.9.3 |
| import 'package:barcode_scan/barcode_scan.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot_detail/bloc/plot_detail_bloc.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | |||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| import 'package:flutter/services.dart'; | |||||
| import 'package:flutter_bloc/flutter_bloc.dart'; | |||||
| import 'package:get/route_manager.dart'; | |||||
| import 'package:rflutter_alert/rflutter_alert.dart'; | |||||
| import 'app.dart'; | import 'app.dart'; | ||||
| import 'custom_model/CropPlot.dart'; | |||||
| import 'data/repository/authentication_repository.dart'; | import 'data/repository/authentication_repository.dart'; | ||||
| import 'data/repository/repository.dart'; | |||||
| void main() { | void main() { | ||||
| runApp(App(authenticationRepository: AuthenticationRepository())); | runApp(App(authenticationRepository: AuthenticationRepository())); | ||||
| // Or do other work. | // Or do other work. | ||||
| } | } | ||||
| Future scan(BuildContext context) async { | |||||
| var _aspectTolerance = 0.00; | |||||
| var _selectedCamera = -1; | |||||
| var _useAutoFocus = true; | |||||
| var _autoEnableFlash = false; | |||||
| try { | |||||
| var options = ScanOptions( | |||||
| strings: { | |||||
| "cancel": "Huỷ", | |||||
| "flash_on": "Bật flash", | |||||
| "flash_off": "Tắt flash", | |||||
| }, | |||||
| useCamera: _selectedCamera, | |||||
| autoEnableFlash: _autoEnableFlash, | |||||
| android: AndroidOptions( | |||||
| aspectTolerance: _aspectTolerance, | |||||
| useAutoFocus: _useAutoFocus, | |||||
| ), | |||||
| ); | |||||
| var result = await BarcodeScanner.scan(options: options); | |||||
| print(result.toString()); | |||||
| if (result.type == ResultType.Cancelled) { | |||||
| print("canncel"); | |||||
| } else if (result.type == ResultType.Error) { | |||||
| print("error"); | |||||
| } else { | |||||
| _showAlertCheckCropCode(context, result.rawContent); | |||||
| } | |||||
| } on PlatformException catch (e) { | |||||
| var result = ScanResult( | |||||
| type: ResultType.Error, | |||||
| format: BarcodeFormat.unknown, | |||||
| ); | |||||
| print("error: ${e.message}"); | |||||
| } | |||||
| } | |||||
| _showAlertCheckCropCode(BuildContext context, String cropCode) { | |||||
| Alert( | |||||
| context: context, | |||||
| title: "", | |||||
| style: AlertStyle(isCloseButton: false, isOverlayTapDismiss: false), | |||||
| content: BlocProvider<PlotDetailBloc>( | |||||
| create: (context) => PlotDetailBloc(repository: Repository()) | |||||
| ..add(DataFetched(cropCode: cropCode)), | |||||
| child: BlocBuilder<PlotDetailBloc, PlotDetailState>( | |||||
| builder: (context, state) { | |||||
| if (state is PlotDetailInitial) { | |||||
| return Center( | |||||
| child: Text("PlotDetailInitial"), | |||||
| ); | |||||
| } else if (state is PlotDetailFailure) { | |||||
| return Center( | |||||
| child: Column( | |||||
| children: [ | |||||
| Text("Lô không tồn tại"), | |||||
| SizedBox( | |||||
| height: 16, | |||||
| ), | |||||
| DialogButton( | |||||
| onPressed: () { | |||||
| Get.back(); | |||||
| scan(context); | |||||
| }, | |||||
| child: Text( | |||||
| "Quét lại", | |||||
| style: TextStyle(color: Colors.white, fontSize: 20), | |||||
| ), | |||||
| ) | |||||
| ], | |||||
| ), | |||||
| ); | |||||
| } else if (state is PlotDetailSuccess) { | |||||
| var result = state.ownerItem as CropPlot; | |||||
| WidgetsBinding.instance.addPostFrameCallback((_) { | |||||
| Get.back(); | |||||
| Get.to(PlotDetailScreen( | |||||
| cropId: result.tbCropDTO.id, | |||||
| initialIndex: 1, | |||||
| )); | |||||
| }); | |||||
| return Center(child: Text("")); | |||||
| } else { | |||||
| return Center( | |||||
| child: Column( | |||||
| children: [ | |||||
| CircularProgressIndicator(), | |||||
| SizedBox( | |||||
| height: 8, | |||||
| ), | |||||
| Text("Kiểm tra thông tin lô ....") | |||||
| ], | |||||
| ), | |||||
| ); | |||||
| } | |||||
| })), | |||||
| buttons: []).show(); | |||||
| } |
| import 'package:farm_tpf/data/repository/repository.dart'; | import 'package:farm_tpf/data/repository/repository.dart'; | ||||
| import 'package:farm_tpf/main.dart'; | |||||
| import 'package:farm_tpf/models/index.dart'; | import 'package:farm_tpf/models/index.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot/widget_search.dart'; | import 'package:farm_tpf/presentation/screens/plot/widget_search.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_detail.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/plot_detail/sc_plot_information.dart'; | |||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| import 'package:flutter_bloc/flutter_bloc.dart'; | import 'package:flutter_bloc/flutter_bloc.dart'; | ||||
| import 'package:farm_tpf/utils/const_string.dart'; | import 'package:farm_tpf/utils/const_string.dart'; | ||||
| import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | ||||
| import 'package:farm_tpf/utils/formatter.dart'; | import 'package:farm_tpf/utils/formatter.dart'; | ||||
| import 'package:get/get.dart'; | |||||
| import 'bloc/plot_bloc.dart'; | import 'bloc/plot_bloc.dart'; | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return Scaffold( | return Scaffold( | ||||
| key: _scaffoldKey, | key: _scaffoldKey, | ||||
| appBar: AppBar(centerTitle: true, title: Text("Danh sách lô")), | |||||
| appBar: AppBar( | |||||
| centerTitle: true, | |||||
| title: Text("Danh sách lô"), | |||||
| actions: <Widget>[ | |||||
| IconButton( | |||||
| icon: Icon(FontAwesomeIcons.qrcode), | |||||
| onPressed: () { | |||||
| scan(context); | |||||
| }) | |||||
| ], | |||||
| ), | |||||
| body: InfinityView()); | body: InfinityView()); | ||||
| } | } | ||||
| } | } |
| import 'package:bloc/bloc.dart'; | import 'package:bloc/bloc.dart'; | ||||
| import 'package:equatable/equatable.dart'; | import 'package:equatable/equatable.dart'; | ||||
| import 'package:farm_tpf/custom_model/CropPlot.dart'; | |||||
| import 'package:farm_tpf/data/api/app_exception.dart'; | import 'package:farm_tpf/data/api/app_exception.dart'; | ||||
| import 'package:farm_tpf/data/repository/repository.dart'; | import 'package:farm_tpf/data/repository/repository.dart'; | ||||
| import 'package:meta/meta.dart'; | import 'package:meta/meta.dart'; | ||||
| if (event.cropId != null) { | if (event.cropId != null) { | ||||
| response = await repository.getPlotDetail(event.cropId, | response = await repository.getPlotDetail(event.cropId, | ||||
| page: 0, size: pageSize); | page: 0, size: pageSize); | ||||
| yield PlotDetailSuccess( | |||||
| items: response.activities, | |||||
| page: 0, | |||||
| hasReachedMax: | |||||
| response.activities.length < pageSize ? true : false); | |||||
| } else { | } else { | ||||
| response = await repository.getPlotDetailByCode(event.cropCode, | |||||
| page: 0, size: pageSize); | |||||
| CropPlot response = await repository | |||||
| .getPlotDetailByCode(event.cropCode, page: 0, size: pageSize); | |||||
| yield PlotDetailSuccess( | |||||
| ownerItem: response, | |||||
| items: response.activities, | |||||
| page: 0, | |||||
| hasReachedMax: true); | |||||
| } | } | ||||
| yield PlotDetailSuccess( | |||||
| items: response.activities, | |||||
| page: 0, | |||||
| hasReachedMax: | |||||
| response.activities.length < pageSize ? true : false); | |||||
| } | } | ||||
| if (state is PlotDetailSuccess) { | if (state is PlotDetailSuccess) { | ||||
| final currentState = state as PlotDetailSuccess; | final currentState = state as PlotDetailSuccess; | ||||
| if (event.cropId != null) { | if (event.cropId != null) { | ||||
| response = await repository.getPlotDetail(event.cropId, | response = await repository.getPlotDetail(event.cropId, | ||||
| page: page, size: pageSize); | page: page, size: pageSize); | ||||
| yield response.activities.isEmpty | |||||
| ? currentState.copyWith(hasReachedMax: true) | |||||
| : PlotDetailSuccess( | |||||
| items: currentState.items + response.activities, | |||||
| page: currentState.page + 1, | |||||
| hasReachedMax: false); | |||||
| } else { | } else { | ||||
| response = await repository.getPlotDetailByCode(event.cropCode, | |||||
| page: page, size: pageSize); | |||||
| CropPlot response = await repository.getPlotDetailByCode( | |||||
| event.cropCode, | |||||
| page: page, | |||||
| size: pageSize); | |||||
| yield PlotDetailSuccess( | |||||
| ownerItem: response, | |||||
| items: response.activities, | |||||
| page: 0, | |||||
| hasReachedMax: true); | |||||
| } | } | ||||
| yield response.activities.isEmpty | |||||
| ? currentState.copyWith(hasReachedMax: true) | |||||
| : PlotDetailSuccess( | |||||
| items: currentState.items + response.activities, | |||||
| page: currentState.page + 1, | |||||
| hasReachedMax: false); | |||||
| } | } | ||||
| } catch (e) { | } catch (e) { | ||||
| var errorString = AppException.handleError(e); | var errorString = AppException.handleError(e); |
| } | } | ||||
| class PlotDetailSuccess<T> extends PlotDetailState { | class PlotDetailSuccess<T> extends PlotDetailState { | ||||
| final T ownerItem; | |||||
| final List<T> items; | final List<T> items; | ||||
| final int page; | final int page; | ||||
| final bool hasReachedMax; | final bool hasReachedMax; | ||||
| const PlotDetailSuccess({this.items, this.page, this.hasReachedMax}); | |||||
| const PlotDetailSuccess( | |||||
| {this.ownerItem, this.items, this.page, this.hasReachedMax}); | |||||
| PlotDetailSuccess copyWith({List<T> items, int page, bool hasReachedMax}) { | PlotDetailSuccess copyWith({List<T> items, int page, bool hasReachedMax}) { | ||||
| return PlotDetailSuccess( | return PlotDetailSuccess( |
| import 'dart:io' show Platform; | |||||
| import 'package:barcode_scan/barcode_scan.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/home/home.dart'; | |||||
| import 'package:flutter/material.dart'; | |||||
| import 'package:flutter/services.dart'; | |||||
| import 'package:fluttertoast/fluttertoast.dart'; | |||||
| class ScanBarcodeScreen extends StatefulWidget { | |||||
| @override | |||||
| _ScanBarcodeScreenState createState() => _ScanBarcodeScreenState(); | |||||
| } | |||||
| class _ScanBarcodeScreenState extends State<ScanBarcodeScreen> { | |||||
| ScanResult scanResult; | |||||
| var _aspectTolerance = 0.00; | |||||
| var _selectedCamera = -1; | |||||
| var _useAutoFocus = true; | |||||
| var _autoEnableFlash = false; | |||||
| final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); | |||||
| FlutterToast flutterToast; | |||||
| @override | |||||
| // ignore: type_annotate_public_apis | |||||
| initState() { | |||||
| super.initState(); | |||||
| flutterToast = FlutterToast(context); | |||||
| scan(); | |||||
| } | |||||
| @override | |||||
| Widget build(BuildContext context) { | |||||
| return Scaffold( | |||||
| key: _scaffoldKey, | |||||
| appBar: AppBar( | |||||
| title: Text("Quét mã QR"), | |||||
| ), | |||||
| body: Center( | |||||
| child: scanResult == null ? Container() : Text(scanResult?.rawContent), | |||||
| ), | |||||
| ); | |||||
| } | |||||
| Future scan() async { | |||||
| try { | |||||
| var options = ScanOptions( | |||||
| strings: { | |||||
| "cancel": "Huỷ", | |||||
| "flash_on": "Bật flash", | |||||
| "flash_off": "Tắt flash", | |||||
| }, | |||||
| useCamera: _selectedCamera, | |||||
| autoEnableFlash: _autoEnableFlash, | |||||
| android: AndroidOptions( | |||||
| aspectTolerance: _aspectTolerance, | |||||
| useAutoFocus: _useAutoFocus, | |||||
| ), | |||||
| ); | |||||
| var result = await BarcodeScanner.scan(options: options); | |||||
| setState(() { | |||||
| scanResult = result; | |||||
| if (1 == 1) { | |||||
| Navigator.of(context).pop(); | |||||
| Navigator.of(context) | |||||
| .push(MaterialPageRoute(builder: (_) => HomePage())); | |||||
| } else { | |||||
| flutterToast.showToast( | |||||
| child: | |||||
| WidgetToast(message: "Mã QR không đúng", color: Colors.red)); | |||||
| Navigator.of(context).pop(); | |||||
| } | |||||
| }); | |||||
| } on PlatformException catch (e) { | |||||
| var result = ScanResult( | |||||
| type: ResultType.Error, | |||||
| format: BarcodeFormat.unknown, | |||||
| ); | |||||
| if (e.code == BarcodeScanner.cameraAccessDenied) { | |||||
| setState(() { | |||||
| result.rawContent = 'Vui lòng cấp quyền truy cập camera'; | |||||
| }); | |||||
| } else { | |||||
| result.rawContent = 'Vui lòng cấp quyền truy cập camera.'; | |||||
| } | |||||
| setState(() { | |||||
| scanResult = result; | |||||
| }); | |||||
| flutterToast.showToast( | |||||
| child: WidgetToast( | |||||
| message: "Vui lòng cấp quyền truy cập camera.", | |||||
| color: Colors.red)); | |||||
| Navigator.of(context).pop(); | |||||
| } | |||||
| } | |||||
| } |
| import 'package:farm_tpf/main.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/control_device/sc_control_device.dart'; | import 'package:farm_tpf/presentation/screens/control_device/sc_control_device.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/home/home.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/plot/sc_plot.dart'; | import 'package:farm_tpf/presentation/screens/plot/sc_plot.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/scan_barcode/sc_scan_barcode.dart'; | |||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
| }); | }); | ||||
| } else if (drawerIndex == DrawerIndex.ScanBarcode) { | } else if (drawerIndex == DrawerIndex.ScanBarcode) { | ||||
| setState(() { | setState(() { | ||||
| Navigator.of(context) | |||||
| .push(MaterialPageRoute(builder: (_) => ScanBarcodeScreen())); | |||||
| scan(context); | |||||
| }); | }); | ||||
| } else { | } else { | ||||
| //do in your way...... | //do in your way...... |
| url: "https://pub.dartlang.org" | url: "https://pub.dartlang.org" | ||||
| source: hosted | source: hosted | ||||
| version: "1.3.7+6" | version: "1.3.7+6" | ||||
| rflutter_alert: | |||||
| dependency: "direct main" | |||||
| description: | |||||
| name: rflutter_alert | |||||
| url: "https://pub.dartlang.org" | |||||
| source: hosted | |||||
| version: "1.1.0" | |||||
| rxdart: | rxdart: | ||||
| dependency: "direct main" | dependency: "direct main" | ||||
| description: | description: |
| # analyzer: ^0.39.14 | # analyzer: ^0.39.14 | ||||
| http: ^0.12.2 | http: ^0.12.2 | ||||
| http_parser: ^3.1.4 | http_parser: ^3.1.4 | ||||
| rflutter_alert: ^1.1.0 | |||||
| dev_dependencies: | dev_dependencies: | ||||
| flutter_test: | flutter_test: |