From 41651ae44701d14cbca1cb4326870402845b49ca Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Tue, 25 Feb 2025 17:22:13 +0800 Subject: [PATCH] update --- .../arm64-v8a/configure_fingerprint.bin | 24 ++-- .../armeabi-v7a/configure_fingerprint.bin | 24 ++-- .../14495r4k/x86/configure_fingerprint.bin | 24 ++-- .../14495r4k/x86_64/configure_fingerprint.bin | 24 ++-- android/app/src/main/AndroidManifest.xml | 6 +- android/app/src/profile/AndroidManifest.xml | 4 + android/gradle.properties | 1 + lib/functions/barcode_scan_function.dart | 19 +++ lib/pages/add_medicine_page.dart | 90 ++++++------- lib/pages/add_stock_page.dart | 122 ++++++++++++++---- lib/security/key_pair.dart | 17 +++ lib/tables/ref_medicines.dart | 5 + lib/widgets/dropdown_widget.dart | 2 +- 13 files changed, 237 insertions(+), 125 deletions(-) create mode 100644 lib/functions/barcode_scan_function.dart create mode 100644 lib/security/key_pair.dart diff --git a/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/configure_fingerprint.bin b/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/configure_fingerprint.bin index 27defba..5efbdc9 100644 --- a/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/configure_fingerprint.bin +++ b/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/configure_fingerprint.bin @@ -2,27 +2,27 @@ C/C++ Structured Log  /home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/additional_project_files.txtC A -?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  퇏2 +?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  퇏2 ~ -|/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/android_gradle_build.json  2 퇏2 +|/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/android_gradle_build.json  2 퇏2  -/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/android_gradle_build_mini.json  2 퇏2r +/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/android_gradle_build_mini.json  2 퇏2r p -n/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/build.ninja  2ߺ 퇏2v +n/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/build.ninja  2ߺ 퇏2v t -r/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/build.ninja.txt  2{ +r/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/build.ninja.txt  2{ y -w/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/build_file_index.txt  2 ^ 퇏2| +w/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/build_file_index.txt  2 ^ 퇏2| z -x/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/compile_commands.json  2 +x/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/compile_commands.json  2 ~ -|/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/compile_commands.json.bin  2  +|/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/compile_commands.json.bin  2   -/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/metadata_generation_command.txt  2 +/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/metadata_generation_command.txt  2  퇏2y w -u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/prefab_config.json  2  ( 퇏2~ +u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/prefab_config.json  2  ( 퇏2~ | -z/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/symbol_folder_index.txt  2  q 퇏2b +z/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/arm64-v8a/symbol_folder_index.txt  2  q 퇏2b ` -^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file +^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file diff --git a/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/configure_fingerprint.bin b/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/configure_fingerprint.bin index 014e0f1..a540a05 100644 --- a/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/configure_fingerprint.bin +++ b/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/configure_fingerprint.bin @@ -2,27 +2,27 @@ C/C++ Structured Log  /home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/additional_project_files.txtC A -?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2 +?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2  -~/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/android_gradle_build.json  2 2 +~/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/android_gradle_build.json  2 2  -/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/android_gradle_build_mini.json  2 2t +/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/android_gradle_build_mini.json  2 2t r -p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/build.ninja  2 2x +p/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/build.ninja  2 2x v -t/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/build.ninja.txt  2} +t/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/build.ninja.txt  2} { -y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/build_file_index.txt  2 ^ 2~ +y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/build_file_index.txt  2 ^ 2~ | -z/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/compile_commands.json  2 +z/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/compile_commands.json  2  -~/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/compile_commands.json.bin  2  +~/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/compile_commands.json.bin  2   -/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/metadata_generation_command.txt  2 +/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/metadata_generation_command.txt  2  2{ y -w/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/prefab_config.json  2  ( 2 +w/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/prefab_config.json  2  ( 2 ~ -|/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/symbol_folder_index.txt  2  s 2b +|/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/armeabi-v7a/symbol_folder_index.txt  2  s 2b ` -^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file +^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file diff --git a/android/app/.cxx/RelWithDebInfo/14495r4k/x86/configure_fingerprint.bin b/android/app/.cxx/RelWithDebInfo/14495r4k/x86/configure_fingerprint.bin index 4b9c4af..36798ec 100644 --- a/android/app/.cxx/RelWithDebInfo/14495r4k/x86/configure_fingerprint.bin +++ b/android/app/.cxx/RelWithDebInfo/14495r4k/x86/configure_fingerprint.bin @@ -2,27 +2,27 @@ C/C++ Structured Log} { y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/additional_project_files.txtC A -?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2z +?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2z x -v/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/android_gradle_build.json  2 2 +v/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/android_gradle_build.json  2 2 } -{/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/android_gradle_build_mini.json  2 2l +{/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/android_gradle_build_mini.json  2 2l j -h/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/build.ninja  2 2p +h/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/build.ninja  2 2p n -l/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/build.ninja.txt  2u +l/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/build.ninja.txt  2u s -q/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/build_file_index.txt  2 ^ 2v +q/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/build_file_index.txt  2 ^ 2v t -r/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/compile_commands.json  2z +r/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/compile_commands.json  2z x -v/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/compile_commands.json.bin  2  +v/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/compile_commands.json.bin  2  ~ -|/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/metadata_generation_command.txt  2 +|/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/metadata_generation_command.txt  2  2s q -o/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/prefab_config.json  2  ( 2x +o/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/prefab_config.json  2  ( 2x v -t/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/symbol_folder_index.txt  2  k 2b +t/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86/symbol_folder_index.txt  2  k 2b ` -^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file +^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file diff --git a/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/configure_fingerprint.bin b/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/configure_fingerprint.bin index 934e152..56f3dfd 100644 --- a/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/configure_fingerprint.bin +++ b/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/configure_fingerprint.bin @@ -2,27 +2,27 @@ C/C++ Structured Log ~ |/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/additional_project_files.txtC A -?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2} +?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  2  2} { -y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/android_gradle_build.json  2 2 +y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/android_gradle_build.json  2 2  -~/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/android_gradle_build_mini.json  2 2o +~/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/android_gradle_build_mini.json  2 2o m -k/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/build.ninja  2к 2s +k/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/build.ninja  2к 2s q -o/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/build.ninja.txt  2x +o/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/build.ninja.txt  2x v -t/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/build_file_index.txt  2 ^ 2y +t/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/build_file_index.txt  2 ^ 2y w -u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/compile_commands.json  2} +u/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/compile_commands.json  2} { -y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/compile_commands.json.bin  2  +y/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/compile_commands.json.bin  2   -/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/metadata_generation_command.txt  2 +/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/metadata_generation_command.txt  2  2v t -r/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/prefab_config.json  2  ( 2{ +r/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/prefab_config.json  2  ( 2{ y -w/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/symbol_folder_index.txt  2  n 2b +w/home/patrick/Documents/WebApps/pharmacy_mobile/android/app/.cxx/RelWithDebInfo/14495r4k/x86_64/symbol_folder_index.txt  2  n 2b ` -^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file +^/home/patrick/fvm/versions/3.29.0/packages/flutter_tools/gradle/src/main/groovy/CMakeLists.txt  2  ȼ2 \ No newline at end of file diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index acb9adb..69f12a2 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,9 +1,9 @@ - - + diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index a3c2a68..deae15c 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -3,6 +3,10 @@ the Flutter tool needs it to communicate with the running application to allow setting breakpoints, to provide hot reload, etc. --> + + + diff --git a/android/gradle.properties b/android/gradle.properties index 2597170..d21ab09 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,4 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true + diff --git a/lib/functions/barcode_scan_function.dart b/lib/functions/barcode_scan_function.dart new file mode 100644 index 0000000..9a65ec2 --- /dev/null +++ b/lib/functions/barcode_scan_function.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:simple_barcode_scanner/simple_barcode_scanner.dart'; + +Future barcodeScan(BuildContext context) 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, + ); + return barcode != '-1' ? barcode ?? '' : ''; +} diff --git a/lib/pages/add_medicine_page.dart b/lib/pages/add_medicine_page.dart index 57862f1..5a93e3e 100644 --- a/lib/pages/add_medicine_page.dart +++ b/lib/pages/add_medicine_page.dart @@ -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 { 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 { 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 compressFile(XFile file) async { // var result = await FlutterImageCompress.compressWithFile( @@ -85,28 +82,32 @@ class _AddMedicinePageState extends State { // return result; // } - void _getGenerics() async { + Future _getGenerics() async { _genericNameList = await _refGenericNames.getList(); - _checkResult(_genericNameList, 'Generics'); + setState(() { + checkResult(context, _genericNameList, 'Generics'); + }); } - void _getTypes() async { + Future _getTypes() async { _typeList = await _refTypes.getList(); - _checkResult(_typeList, 'Types'); + setState(() { + checkResult(context, _typeList, 'Types'); + }); } - void _getManufactorer() async { + Future _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 { } Future _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 { @override void dispose() { _nameController.dispose(); - _focusNode.dispose(); _barcodeController.dispose(); _genericNameList = []; diff --git a/lib/pages/add_stock_page.dart b/lib/pages/add_stock_page.dart index ff0a035..5faf3bb 100644 --- a/lib/pages/add_stock_page.dart +++ b/lib/pages/add_stock_page.dart @@ -1,17 +1,25 @@ import 'dart:developer'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:gap/gap.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_medicines.dart'; import 'package:pharmacy_mobile/tables/stocks.dart'; import 'package:pharmacy_mobile/widgets/button_widget.dart'; import 'package:pharmacy_mobile/widgets/datepicker_widget.dart'; import 'package:pharmacy_mobile/widgets/dropdown_widget.dart'; +import 'package:pharmacy_mobile/widgets/dropdown_wrappermulti_widget.dart'; import 'package:pharmacy_mobile/widgets/form_border_widget2.dart'; import 'package:pharmacy_mobile/widgets/input_widget.dart'; import 'package:pharmacy_mobile/widgets/page_background_widget.dart'; +import 'package:pharmacy_mobile/widgets/snackbar_widget.dart'; import 'package:pharmacy_mobile/widgets/text_widget.dart'; import 'package:pharmacy_mobile/widgets/title_widget.dart'; +import 'package:go_router/go_router.dart'; import 'package:simple_barcode_scanner/simple_barcode_scanner.dart'; class AddStockPage extends StatefulWidget { @@ -23,10 +31,10 @@ class AddStockPage extends StatefulWidget { class _AddStockPageState extends State with WidgetsBindingObserver { final _formKey = GlobalKey(); - final FocusNode _focusNode = FocusNode(); final _refMedicines = RefMedicines(); final _quantityController = TextEditingController(); final _dateController = TextEditingController(); + final _medicineController = TextEditingController(); final _stocks = Stocks(); final bool _isLoading = false; @@ -36,10 +44,42 @@ class _AddStockPageState extends State with WidgetsBindingObserver late DateTime selectedDate = DateTime.now(); late String barcode = ''; - void autoRun() async { - _medicineList = await _refMedicines.getList(); + // void autoRun() async { + // _medicineList = await _refMedicines.getList(); + // } + + void _getMedicines() async { + _medicineList = await _refMedicines.getList2(); + + setState(() { + checkResult(context, _medicineList, 'Medicines'); + }); } + void autoRun() async { + if (await InternetConnectionChecker.instance.hasConnection) { + _getMedicines(); + } else { + if (mounted) { + showNotification(context, 'Error: No Internet Connection', false); + + WidgetsBinding.instance.addPostFrameCallback((_) { + context.push('/main'); + }); + } + } + } + + // Future _getMedicines() async { + // late bool? result; + // _medicineList = await _refMedicines.getList(); + // if (mounted) { + // result = await checkResult(context, _medicineList, 'Medicines'); + // log(result.toString()); + // } + // return result ?? false; + // } + void _updateMedicine(dynamic medicine) { _selectedMedicine = medicine; } @@ -52,15 +92,24 @@ class _AddStockPageState extends State with WidgetsBindingObserver await _stocks.postStock(stockNameUUID, stockExpiration, stockQuantity); } + Future _scanBarcode() async { + _selectedMedicine = await barcodeScan(context); + } + + Future _getMedicineUsingBarcode(String name) async { + final encryptedBarcode = await _refMedicines.getBarcode(name); + final barcode = decrypt(encryptedBarcode); + return barcode; + } + @override void initState() { - autoRun(); + _getMedicines(); super.initState(); } @override void dispose() { - _focusNode.dispose(); _medicineList = []; _selectedMedicine = ''; _quantityController.dispose(); @@ -89,13 +138,52 @@ class _AddStockPageState extends State with WidgetsBindingObserver child: Form( key: _formKey, child: Center( - child: Column( + child: DropdownWrapperMultiWidget( + list: _medicineList, + text: 'Data', children: [ DropDownWidget( label: 'Medicine Name', list: _medicineList, listTitle: 'medicine_name', onChanged: _updateMedicine), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + GestureDetector( + onTap: _scanBarcode, + child: Container( + padding: const EdgeInsets.only(top: 8), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + // color: const Color.fromARGB(0, 36, 18, 58), + // boxShadow: [ + // BoxShadow( + // color: Colors.black26, + // blurRadius: 5.0, + // offset: Offset(0, 2), + // ), + // ], + ), + child: Row( + children: [ + Icon( + Icons.qr_code_scanner, + color: Colors.white, + size: 22, + ), + const Gap(8), + TextWidget( + text: 'Scan Barcode', + size: 14, + color: Colors.white, + ), + ], + ), + ), + ), + ], + ), const Gap(16), InputWidget(label: 'Quantity', controller: _quantityController), const Gap(16), @@ -107,28 +195,6 @@ class _AddStockPageState extends State with WidgetsBindingObserver const Gap(32), ButtonWidget(text: 'Add Stock', onPressed: _saveStock), const Gap(16), - ButtonWidget( - text: 'Barcode', - onPressed: () async { - String? bc = 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, - ); - setState(() { - barcode = bc as String; - }); - }, - ), - const Gap(16), TextWidget( text: barcode, size: 14, diff --git a/lib/security/key_pair.dart b/lib/security/key_pair.dart new file mode 100644 index 0000000..79f030e --- /dev/null +++ b/lib/security/key_pair.dart @@ -0,0 +1,17 @@ +import 'package:lazyxchacha/keypair.dart' as kp; + +class KeyPairSingleton { + static final KeyPairSingleton _instance = KeyPairSingleton._internal(); + late kp.KeyPair _keyPair; + + factory KeyPairSingleton() { + return _instance; + } + + KeyPairSingleton._internal() { + // Initialize the KeyPair instance here + _keyPair = kp.KeyPair(); + } + + kp.KeyPair get keyPair => _keyPair; +} diff --git a/lib/tables/ref_medicines.dart b/lib/tables/ref_medicines.dart index 8d17369..dd1fdc9 100644 --- a/lib/tables/ref_medicines.dart +++ b/lib/tables/ref_medicines.dart @@ -29,6 +29,11 @@ class RefMedicines { return data.first['ref_medicines_uuid']; } + Future getBarcode(String name) async { + final data = await _supabase.from('ref_medicines').select('barcode').eq('medicine_name', name); + return data.first['barcode']; + } + Future postMedicine(String uuid, String name, String muuid, String guuid, String tuuid, String barcode) async { final medicine = { 'ref_medicines_uuid': uuid, diff --git a/lib/widgets/dropdown_widget.dart b/lib/widgets/dropdown_widget.dart index 3d2568e..bf9a8fc 100644 --- a/lib/widgets/dropdown_widget.dart +++ b/lib/widgets/dropdown_widget.dart @@ -52,7 +52,7 @@ class DropDownWidget extends StatelessWidget { textStyle: GoogleFonts.outfit(textStyle: const TextStyle(color: Color.fromRGBO(255, 255, 255, 1), fontSize: 16)), menuStyle: MenuStyle( - backgroundColor: WidgetStateProperty.all(const Color.fromRGBO(13, 21, 42, 0.663)), + backgroundColor: WidgetStateProperty.all(const Color.fromRGBO(21, 13, 35, 0.902)), padding: WidgetStateProperty.all(const EdgeInsets.symmetric(vertical: 16, horizontal: 8)), shape: WidgetStateProperty.all(RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), // Set the border radius for the dropdown menu