This commit is contained in:
Patrick Alvin Alcala 2025-02-25 17:48:49 +08:00
parent 947c19c401
commit cbf2ff062f
9 changed files with 110 additions and 61 deletions

View file

@ -17,6 +17,7 @@ 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/scanbarcode_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';
@ -231,7 +232,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
Widget build(BuildContext context) {
return Scaffold(
body: PageBackgroundWidget(
height: MediaQuery.of(context).size.height + 400,
height: MediaQuery.of(context).size.height + 600,
child: Center(
child: Column(children: [
const Gap(96),
@ -272,9 +273,8 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
onChanged: _updateManufactorer),
const Gap(16),
InputWidget(label: 'Barcode', controller: _barcodeController),
const Gap(8),
ButtonWidget(text: 'Scan Barcode', onPressed: _scanBarcode),
const Gap(32),
ScanbarcodeWidget(onTap: _scanBarcode),
const Gap(16),
if (imageUrl.isNotEmpty)
Center(
child: ClipRRect(

View file

@ -93,18 +93,18 @@ class _AddStockPageState extends State<AddStockPage> with WidgetsBindingObserver
}
Future<void> _scanBarcode() async {
final medicine = await barcodeScan(context);
final scannedBarcode = await barcodeScan(context);
setState(() {
_selectedMedicine = medicine;
_selectedMedicine = scannedBarcode;
});
}
Future<String> _getMedicineUsingBarcode(String name) async {
final encryptedBarcode = await _refMedicines.getBarcode(name);
final barcode = decrypt(encryptedBarcode);
return barcode;
}
// Future<String> _getMedicineUsingBarcode(String barcode) async {
// final encryptedBarcode = await _refMedicines.getBarcode(barcode);
// final barcode = decrypt(encryptedBarcode);
// return barcode;
// }
@override
void initState() {

View file

@ -0,0 +1,49 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:pharmacy_mobile/widgets/text_widget.dart';
class ScanbarcodeWidget extends StatelessWidget {
final GestureTapCallback onTap;
const ScanbarcodeWidget({super.key, required this.onTap});
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
GestureDetector(
onTap: onTap,
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,
),
],
),
),
),
],
);
}
}