update
This commit is contained in:
parent
ecccd4a9bf
commit
2d3f5bd96e
11 changed files with 184 additions and 143 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
|
|
@ -14,6 +16,7 @@ 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/textbox_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/title_widget.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
|
|
@ -29,6 +32,7 @@ class _AddStockPageState extends State<AddStockPage> with WidgetsBindingObserver
|
|||
final _refMedicines = RefMedicines();
|
||||
final _quantityController = TextEditingController();
|
||||
final _dateController = TextEditingController();
|
||||
// final _barcodeController = TextEditingController();
|
||||
final _stocks = Stocks();
|
||||
|
||||
late bool _isLoading = false;
|
||||
|
|
@ -37,6 +41,8 @@ class _AddStockPageState extends State<AddStockPage> with WidgetsBindingObserver
|
|||
late DateTime selectedDate = DateTime.now();
|
||||
late String barcode = '';
|
||||
|
||||
final sampleBarcode = '8992185411017';
|
||||
|
||||
void _getMedicines() async {
|
||||
_medicineList = await _refMedicines.getList();
|
||||
|
||||
|
|
@ -89,21 +95,21 @@ class _AddStockPageState extends State<AddStockPage> with WidgetsBindingObserver
|
|||
|
||||
Future<void> _scanBarcode() async {
|
||||
final scannedBarcode = await barcodeScan(context);
|
||||
final meds = await _getMedicineUsingBarcode(scannedBarcode);
|
||||
|
||||
setState(() {
|
||||
_updateMedicine(scannedBarcode);
|
||||
barcode = meds;
|
||||
});
|
||||
}
|
||||
|
||||
// Future<String> _getMedicineUsingBarcode(String barcode) async {
|
||||
// final encryptedBarcode = await _refMedicines.getBarcode(barcode);
|
||||
// final barcode = decrypt(encryptedBarcode);
|
||||
// return barcode;
|
||||
// }
|
||||
Future<String> _getMedicineUsingBarcode(String barcode) async {
|
||||
final medicine = await _refMedicines.getNameUsingBarcode(barcode);
|
||||
return medicine;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_getMedicines();
|
||||
autoRun();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
|
@ -139,70 +145,70 @@ class _AddStockPageState extends State<AddStockPage> with WidgetsBindingObserver
|
|||
color: 'green',
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Center(
|
||||
child: DropdownWrapperMultiWidget(
|
||||
list: _medicineList,
|
||||
text: 'Data',
|
||||
children: [
|
||||
child: DropdownWrapperMultiWidget(
|
||||
list: _medicineList,
|
||||
text: 'Data',
|
||||
children: [
|
||||
if (barcode.isEmpty)
|
||||
DropDownWidget(
|
||||
label: 'Medicine Name',
|
||||
list: _medicineList,
|
||||
listTitle: 'medicine_name',
|
||||
onChanged: _updateMedicine,
|
||||
// value: _selectedMedicine,
|
||||
),
|
||||
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: const Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.qr_code_scanner,
|
||||
color: Colors.white,
|
||||
size: 22,
|
||||
),
|
||||
Gap(8),
|
||||
TextWidget(
|
||||
text: 'Scan Barcode',
|
||||
size: 14,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
TextboxWidget(text: barcode),
|
||||
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: const Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.qr_code_scanner,
|
||||
color: Colors.white,
|
||||
size: 22,
|
||||
),
|
||||
Gap(8),
|
||||
TextWidget(
|
||||
text: 'Scan Barcode',
|
||||
size: 14,
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Quantity', controller: _quantityController),
|
||||
const Gap(16),
|
||||
DatePickerWidget(
|
||||
label: 'Date Expiration',
|
||||
controller: _dateController,
|
||||
value: selectedDate,
|
||||
),
|
||||
const Gap(32),
|
||||
if (_isLoading)
|
||||
const Center(child: CircularProgressIndicator(color: Colors.white))
|
||||
else
|
||||
ButtonWidget(text: 'Add Stock', onPressed: _saveStock),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Quantity', controller: _quantityController),
|
||||
const Gap(16),
|
||||
DatePickerWidget(
|
||||
label: 'Date Expiration',
|
||||
controller: _dateController,
|
||||
value: selectedDate,
|
||||
),
|
||||
const Gap(32),
|
||||
if (_isLoading)
|
||||
const Center(child: CircularProgressIndicator(color: Colors.white))
|
||||
else
|
||||
ButtonWidget(text: 'Add Stock', onPressed: _saveStock),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -134,35 +134,33 @@ class _DeleteStockPageState extends State<DeleteStockPage> {
|
|||
color: 'red',
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
DropdownWrapperMultiWidget(list: _stockList, text: 'Stocks', children: [
|
||||
DropDownWidget(
|
||||
label: 'Stocks',
|
||||
list: _stockList,
|
||||
listTitle: 'medicine_name',
|
||||
onChanged: _updateStock,
|
||||
// value: _selectedStock,
|
||||
),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Quantity', controller: _quantityController, onChanged: _setQuantity),
|
||||
const Gap(32),
|
||||
if (_noStock)
|
||||
const WarningWidget(
|
||||
text: 'Removing Disabled',
|
||||
warning: 'Quantity is above sssss',
|
||||
)
|
||||
else if (_aboveQuantity)
|
||||
const WarningWidget(
|
||||
text: 'Removing Disabled',
|
||||
warning: 'Quantity is above stocked',
|
||||
)
|
||||
else
|
||||
ButtonWidget(text: 'Remove Stock', onPressed: _saveDeletion)
|
||||
])
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
DropdownWrapperMultiWidget(list: _stockList, text: 'Stocks', children: [
|
||||
DropDownWidget(
|
||||
label: 'Stocks',
|
||||
list: _stockList,
|
||||
listTitle: 'medicine_name',
|
||||
onChanged: _updateStock,
|
||||
// value: _selectedStock,
|
||||
),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Quantity', controller: _quantityController, onChanged: _setQuantity),
|
||||
const Gap(32),
|
||||
if (_noStock)
|
||||
const WarningWidget(
|
||||
text: 'Removing Disabled',
|
||||
warning: 'Quantity is above sssss',
|
||||
)
|
||||
else if (_aboveQuantity)
|
||||
const WarningWidget(
|
||||
text: 'Removing Disabled',
|
||||
warning: 'Quantity is above stocked',
|
||||
)
|
||||
else
|
||||
ButtonWidget(text: 'Remove Stock', onPressed: _saveDeletion)
|
||||
])
|
||||
],
|
||||
)))
|
||||
]))));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
|
|||
import 'package:go_router/go_router.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/widgets/button_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/buttonwithprogress_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/input_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:gap/gap.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:pharmacy_mobile/auth/auth_service.dart';
|
||||
import 'package:pharmacy_mobile/widgets/button_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/buttonwithprogress_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/input_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/page_background_widget.dart';
|
||||
|
|
|
|||
|
|
@ -45,6 +45,15 @@ class RefMedicines {
|
|||
}
|
||||
}
|
||||
|
||||
Future<String> getNameUsingBarcode(String barcode) async {
|
||||
try {
|
||||
final data = await _supabase.from('ref_medicines').select('medicine_name').eq('barcode', barcode);
|
||||
return data.first['medicine_name'];
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> postMedicine(String uuid, String name, String muuid, String guuid, String tuuid, String barcode) async {
|
||||
final medicine = {
|
||||
'ref_medicines_uuid': uuid,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ class DropDownWidget extends StatelessWidget {
|
|||
GoogleFonts.inter(fontSize: 16, fontWeight: FontWeight.w500)))),
|
||||
],
|
||||
onSelected: onChanged,
|
||||
trailingIcon: Icon(
|
||||
Icons.arrow_drop_down_sharp,
|
||||
size: 24,
|
||||
color: Colors.white,
|
||||
),
|
||||
selectedTrailingIcon: Icon(Icons.arrow_drop_up_sharp, size: 24, color: Colors.white),
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
menuHeight: MediaQuery.of(context).size.height * 0.8,
|
||||
textStyle: GoogleFonts.inter(
|
||||
|
|
|
|||
24
lib/widgets/textbox_widget.dart
Normal file
24
lib/widgets/textbox_widget.dart
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:pharmacy_mobile/widgets/text_widget.dart';
|
||||
|
||||
class TextboxWidget extends StatelessWidget {
|
||||
final String text;
|
||||
|
||||
const TextboxWidget({super.key, required this.text});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: const Color.fromRGBO(255, 255, 255, 1)),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16), // Optional: Adds padding inside the container
|
||||
child: TextWidget(
|
||||
text: text,
|
||||
size: 16,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue