This commit is contained in:
unknown
2023-12-07 13:45:51 +03:30
parent a7f57688a7
commit 6464557956
67 changed files with 456 additions and 275 deletions
+60 -15
View File
@@ -4,7 +4,6 @@ import 'package:cssd/widgets/ItemScreens/Add/item_save_button.dart';
import 'package:cssd/widgets/ItemScreens/Add/upload_image.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:random_string/random_string.dart';
@@ -27,9 +26,9 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
TextEditingController nameCTRL = new TextEditingController();
TextEditingController specificCTRL = new TextEditingController();
TextEditingController sizeCTRL = new TextEditingController();
TextEditingController dateCTRL = new TextEditingController();
final _form = GlobalKey<FormState>();
bool isInit = true;
bool isLoading = false;
ItemFilterObject? filters;
final batchId = randomString(10);
@@ -41,25 +40,70 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
nameCTRL.text = '';
sizeCTRL.text = '';
specificCTRL.text = '';
dateCTRL.text = DateFormat('y-M-d').format(DateTime.now());
super.initState();
}
void _saveForm(String name, String size, String specific, String udi,String description) {
setState(() {
isLoading = true;
});
if (!_form.currentState!.validate()) {
return;
}
Provider.of<ItemProvider>(context, listen: false)
.createItemResult(
name,
size,
specific,
udi,
description,
batchId,
)
.then(
(result) {
setState(() {
isLoading = false;
});
if (result == 'done') {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
content: Text('Item added.'),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('Ok'),
)
],
),
).then((value) => Navigator.of(context)
.popAndPushNamed(Routes.itemResultScreen));
}
},
);
}
@override
void didChangeDependencies() async {
if (isInit) {
setState(() {
isLoading = true;
});
var itemProviderObject = Provider.of<ItemProvider>(context);
itemProviderObject.catchImages.clear();
itemProviderObject.getItemResults().then(
(result) {
setState(
() {
isInit = false;
isLoading = false;
},
);
},
);
}
isInit = false;
super.didChangeDependencies();
}
@@ -85,11 +129,12 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text('Items'),
title: Text('Items', style: TextStyle(color: Colors.white,),),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context)
@@ -99,7 +144,7 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? isInit
? isLoading
? Center(
child: CircularProgressIndicator(
color: Colors.black,
@@ -315,16 +360,16 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
height: 70,
),
ItemAddSaveButton(
form: _form,
nameCTRL: nameCTRL,
udiCTRL: udiCTRL,
descriptionCTRL: descriptionCTRL,
sizeCTRL: sizeCTRL,
specificCTRL: specificCTRL,
batchId: batchId,
dateValue: dateCTRL.text,
onTap: (){
_saveForm(
nameCTRL.text,
sizeCTRL.text,
specificCTRL.text,
udiCTRL.text,
descriptionCTRL.text,
);
},
deviceBlockSize: _deviceBlockSize,
isLoading: isInit,
),
SizedBox(
height: 100,
+2 -1
View File
@@ -54,11 +54,12 @@ class _ItemDetailScreenState extends State<ItemDetailScreen> {
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text('Items'),
title: Text('Items', style: TextStyle(color: Colors.white,),),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
+2 -1
View File
@@ -99,11 +99,12 @@ class _ItemFilterScreenState extends State<ItemFilterScreen> {
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text('Items'),
title: Text('Items', style: TextStyle(color: Colors.white,),),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context)
+4 -1
View File
@@ -74,11 +74,12 @@ class _ItemResultScreenState extends State<ItemResultScreen> {
),
appBar: AppBar(
titleSpacing: -10,
title: Text('Home'),
title: Text('Home', style: TextStyle(color: Colors.white,),),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
@@ -191,6 +192,8 @@ class _ItemResultScreenState extends State<ItemResultScreen> {
searchCTRL: searchCTRL,
text: 'item',
deviceBlockSize: _deviceBlockSize,
textInputType: TextInputType.visiblePassword,
text2: "Udi",
onChanged: (value) {
Provider.of<ItemProvider>(context, listen: false)
.search(value);
+2 -1
View File
@@ -33,11 +33,12 @@ class _ItemScanScreenState extends State<ItemScanScreen> {
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
title: Text('Items'),
title: Text('Items', style: TextStyle(color: Colors.white,),),
backgroundColor: Colors.black,
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context).pop(),
+2 -1
View File
@@ -84,10 +84,11 @@ class _ItemUpdateScreenState extends State<ItemUpdateScreen> {
appBar: AppBar(
titleSpacing: -10,
backgroundColor: Colors.black,
title: Text('Items'),
title: Text('Items', style: TextStyle(color: Colors.white,),),
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context)