update
This commit is contained in:
parent
2931621069
commit
27f00e43a7
15 changed files with 252 additions and 104 deletions
|
|
@ -29,16 +29,20 @@ class _AddCategoryPageState extends State<AddCategoryPage> {
|
|||
|
||||
try {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
await _refCategories.postCategory(_categoryController.text.toUpperCase());
|
||||
final post = await _refCategories.postCategory(_categoryController.text.toUpperCase());
|
||||
|
||||
if (mounted) {
|
||||
showNotification(context, 'Category Saved', true);
|
||||
if (post && mounted) {
|
||||
showNotification(context, 'Category saved', true);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.push('/main');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Category not saved', false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mounted) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
|
|
@ -51,6 +53,11 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<bool> _checkExisting() async {
|
||||
final uuid = await _refGenericNames.getUUID(_nameController.text);
|
||||
return uuid.isNotEmpty;
|
||||
}
|
||||
|
||||
void autoRun() async {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
_getList();
|
||||
|
|
@ -76,18 +83,31 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
|
||||
try {
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
final existing = await _checkExisting();
|
||||
|
||||
if (existing && mounted) {
|
||||
showNotification(context, 'Generic Name already existing', false);
|
||||
return;
|
||||
}
|
||||
|
||||
_categoryUUID = await _refCategories.getUUID(_selectedCategory);
|
||||
log('_selectedCategory: $_selectedCategory');
|
||||
log('_categoryUUID: $_categoryUUID');
|
||||
|
||||
await _refGenericNames.postGeneric(_nameController.text, _categoryUUID);
|
||||
final post = await _refGenericNames.postGeneric(_nameController.text, _categoryUUID);
|
||||
|
||||
if (mounted) {
|
||||
showNotification(context, 'Generic Name Saved', true);
|
||||
if (post && mounted) {
|
||||
showNotification(context, 'Generic name saved', true);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
context.push('/main');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (mounted) {
|
||||
showNotification(context, 'Generic name not saved', false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mounted) {
|
||||
|
|
@ -172,7 +192,7 @@ class _AddGenericsPageState extends State<AddGenericsPage> {
|
|||
list: _categoryList,
|
||||
listTitle: 'category_name',
|
||||
onChanged: _updateCategory,
|
||||
value: _selectedCategory,
|
||||
// value: _selectedCategory,
|
||||
),
|
||||
const Gap(32),
|
||||
if (_isLoading)
|
||||
|
|
|
|||
82
lib/pages/add_manufactorer.dart
Normal file
82
lib/pages/add_manufactorer.dart
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:internet_connection_checker/internet_connection_checker.dart';
|
||||
import 'package:pharmacy_mobile/widgets/button_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/text_widget.dart';
|
||||
import 'package:pharmacy_mobile/widgets/title_widget.dart';
|
||||
|
||||
class AddManufactorerPage extends StatefulWidget {
|
||||
const AddManufactorerPage({super.key});
|
||||
|
||||
@override
|
||||
State<AddManufactorerPage> createState() => _AddManufactorerPageState();
|
||||
}
|
||||
|
||||
class _AddManufactorerPageState extends State<AddManufactorerPage> {
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _nameController = TextEditingController();
|
||||
final _addressController = TextEditingController();
|
||||
|
||||
late bool _isLoading = false;
|
||||
|
||||
void saveManufactorer() async {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
if (await InternetConnectionChecker.instance.hasConnection) {
|
||||
// final existing = await _checkExisting();
|
||||
}
|
||||
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_addressController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: PageBackgroundWidget(
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(96),
|
||||
const TitleWidget(
|
||||
firstTextSize: 14,
|
||||
secondTextSize: 24,
|
||||
logoSize: 90,
|
||||
),
|
||||
const Gap(32),
|
||||
const TextWidget(
|
||||
text: 'Add Manufactorer',
|
||||
title: true,
|
||||
),
|
||||
const Gap(16),
|
||||
FormBorderWidget2(
|
||||
color: 'blue',
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
InputWidget(label: 'Name', controller: _nameController),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Address', controller: _addressController),
|
||||
const Gap(32),
|
||||
if (_isLoading)
|
||||
const Center(child: CircularProgressIndicator(color: Colors.white))
|
||||
else
|
||||
ButtonWidget(text: 'Add', onPressed: saveManufactorer)
|
||||
],
|
||||
)))
|
||||
],
|
||||
),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
list: _genericNameList,
|
||||
listTitle: 'generic_name',
|
||||
onChanged: _updateGeneric,
|
||||
value: _selectedGeneric,
|
||||
// value: _selectedGeneric,
|
||||
),
|
||||
const Gap(8),
|
||||
Padding(
|
||||
|
|
@ -297,7 +297,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
list: _typeList,
|
||||
listTitle: 'type_name',
|
||||
onChanged: _updateType,
|
||||
value: _selectedType,
|
||||
// value: _selectedType,
|
||||
),
|
||||
const Gap(16),
|
||||
DropDownWidget(
|
||||
|
|
@ -305,7 +305,7 @@ class _AddMedicinePageState extends State<AddMedicinePage> {
|
|||
list: _manufactorerList,
|
||||
listTitle: 'manufactorer_name',
|
||||
onChanged: _updateManufactorer,
|
||||
value: _selectedManufactorer,
|
||||
// value: _selectedManufactorer,
|
||||
),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Barcode', controller: _barcodeController),
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class _AddStockPageState extends State<AddStockPage> with WidgetsBindingObserver
|
|||
list: _medicineList,
|
||||
listTitle: 'medicine_name',
|
||||
onChanged: _updateMedicine,
|
||||
value: _selectedMedicine,
|
||||
// value: _selectedMedicine,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class _DeleteStockPageState extends State<DeleteStockPage> {
|
|||
list: _stockList,
|
||||
listTitle: 'medicine_name',
|
||||
onChanged: _updateStock,
|
||||
value: _selectedStock,
|
||||
// value: _selectedStock,
|
||||
),
|
||||
const Gap(16),
|
||||
InputWidget(label: 'Quantity', controller: _quantityController, onChanged: _setQuantity),
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class _MainPageState extends State<MainPage> {
|
|||
resizeToAvoidBottomInset: false,
|
||||
body: SingleChildScrollView(
|
||||
child: PageBackgroundWidget(
|
||||
height: MediaQuery.of(context).size.height + 400,
|
||||
height: MediaQuery.of(context).size.height + 500,
|
||||
page: 'menu',
|
||||
child: Center(
|
||||
child: Column(
|
||||
|
|
@ -50,6 +50,14 @@ class _MainPageState extends State<MainPage> {
|
|||
title: true,
|
||||
),
|
||||
const Gap(16),
|
||||
MenuWidget(
|
||||
icon: FontAwesomeIcons.circlePlus,
|
||||
text: 'Add Manufactorer',
|
||||
description: 'Add Manufactorer to the record',
|
||||
onPressed: () => {context.push('/addmanufactorer')},
|
||||
color: 'blue',
|
||||
),
|
||||
const Gap(16),
|
||||
MenuWidget(
|
||||
icon: FontAwesomeIcons.circlePlus,
|
||||
text: 'Add Type',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue