update
This commit is contained in:
parent
11fc5c43bf
commit
41651ae447
13 changed files with 237 additions and 125 deletions
|
|
@ -1,11 +1,9 @@
|
|||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:pharmacy_mobile/functions/barcode_scan_function.dart';
|
||||
import 'package:pharmacy_mobile/functions/checkresult_function.dart';
|
||||
import 'package:pharmacy_mobile/security/encryption.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_categories.dart';
|
||||
import 'package:pharmacy_mobile/tables/ref_generic_names.dart';
|
||||
|
|
@ -44,7 +42,6 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
final _storage = Storage();
|
||||
final _nameController = TextEditingController();
|
||||
final _barcodeController = TextEditingController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
bool _isLoading = false;
|
||||
|
||||
late List _genericNameList = [];
|
||||
|
|
@ -58,21 +55,21 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
late bool imageUploaded = false;
|
||||
late String imageUrl = '';
|
||||
|
||||
void _checkResult(List list, String name) {
|
||||
if (list.isEmpty) {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Error: No $name Found', false);
|
||||
// void _checkResult(List list, String name) {
|
||||
// if (list.isEmpty) {
|
||||
// if (mounted) {
|
||||
// showNotification(context, 'Error: No $name Found', false);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.push('/main');
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setState(() => {});
|
||||
}
|
||||
}
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// if (mounted) {
|
||||
// context.push('/main');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// } else {
|
||||
// setState(() => {});
|
||||
// }
|
||||
// }
|
||||
|
||||
// Future<Uint8List> compressFile(XFile file) async {
|
||||
// var result = await FlutterImageCompress.compressWithFile(
|
||||
|
|
@ -85,28 +82,32 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
// return result;
|
||||
// }
|
||||
|
||||
void _getGenerics() async {
|
||||
Future<void> _getGenerics() async {
|
||||
_genericNameList = await _refGenericNames.getList();
|
||||
_checkResult(_genericNameList, 'Generics');
|
||||
setState(() {
|
||||
checkResult(context, _genericNameList, 'Generics');
|
||||
});
|
||||
}
|
||||
|
||||
void _getTypes() async {
|
||||
Future<void> _getTypes() async {
|
||||
_typeList = await _refTypes.getList();
|
||||
_checkResult(_typeList, 'Types');
|
||||
setState(() {
|
||||
checkResult(context, _typeList, 'Types');
|
||||
});
|
||||
}
|
||||
|
||||
void _getManufactorer() async {
|
||||
Future<void> _getManufactorer() async {
|
||||
_manufactorerList = await _refManufactorer.getList();
|
||||
_checkResult(_manufactorerList, 'Manufactorer');
|
||||
setState(() {
|
||||
checkResult(context, _manufactorerList, 'Manufactorer');
|
||||
});
|
||||
}
|
||||
|
||||
void autoRun() async {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
_getGenerics();
|
||||
_getTypes();
|
||||
_getManufactorer();
|
||||
|
||||
setState(() {});
|
||||
await _getGenerics();
|
||||
await _getTypes();
|
||||
await _getManufactorer();
|
||||
|
||||
// final sample = await _refMedicines.getList2();
|
||||
} else {
|
||||
|
|
@ -139,20 +140,20 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
}
|
||||
|
||||
Future<void> _scanBarcode() async {
|
||||
String? barcode = await SimpleBarcodeScanner.scanBarcode(
|
||||
context,
|
||||
// barcodeAppBar: const BarcodeAppBar(
|
||||
// // appBarTitle: 'Test',
|
||||
// // centerTitle: false,
|
||||
// // enableBackButton: false,
|
||||
// // backButtonIcon: Icon(Icons.arrow_back_ios),
|
||||
// ),
|
||||
// isShowFlashIcon: true,
|
||||
delayMillis: 2000,
|
||||
scanType: ScanType.barcode,
|
||||
cameraFace: CameraFace.back,
|
||||
);
|
||||
_barcodeController.text = barcode != '-1' ? barcode ?? '' : '';
|
||||
// String? barcode = await SimpleBarcodeScanner.scanBarcode(
|
||||
// context,
|
||||
// // barcodeAppBar: const BarcodeAppBar(
|
||||
// // // appBarTitle: 'Test',
|
||||
// // // centerTitle: false,
|
||||
// // // enableBackButton: false,
|
||||
// // // backButtonIcon: Icon(Icons.arrow_back_ios),
|
||||
// // ),
|
||||
// // isShowFlashIcon: true,
|
||||
// delayMillis: 2000,
|
||||
// scanType: ScanType.barcode,
|
||||
// cameraFace: CameraFace.back,
|
||||
// );
|
||||
_barcodeController.text = await barcodeScan(context);
|
||||
}
|
||||
|
||||
void _saveMedicine() async {
|
||||
|
|
@ -214,7 +215,6 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_focusNode.dispose();
|
||||
_barcodeController.dispose();
|
||||
|
||||
_genericNameList = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue