fix bugs!

This commit is contained in:
fhkhd
2024-01-02 21:15:50 +03:30
parent d0eb9cd185
commit ec905fa4b7
5 changed files with 125 additions and 50 deletions
+65 -43
View File
@@ -33,6 +33,7 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
final batchId = randomString(10); final batchId = randomString(10);
int curLabelVal = 1; int curLabelVal = 1;
@override @override
void initState() { void initState() {
descriptionCTRL.text = ''; descriptionCTRL.text = '';
@@ -43,46 +44,62 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
super.initState(); super.initState();
} }
void _saveForm(String name, String size, String specific, String udi,String description) { void _saveForm(String name, String size, String specific, String udi,
String description) {
setState(() { setState(() {
isLoading = false; isLoading = false;
}); });
if (!_form.currentState!.validate()) { if (!_form.currentState!.validate()) {
return; 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));
} else if (result == 'error') {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
content: Text('error.'),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: Text('Ok'),
)
],
),
);
} }
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 @override
@@ -129,7 +146,12 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
child: Scaffold( child: Scaffold(
appBar: AppBar( appBar: AppBar(
titleSpacing: -10, titleSpacing: -10,
title: Text('Items', style: TextStyle(color: Colors.white,),), title: Text(
'Items',
style: TextStyle(
color: Colors.white,
),
),
backgroundColor: Colors.black, backgroundColor: Colors.black,
leading: IconButton( leading: IconButton(
icon: Icon( icon: Icon(
@@ -360,13 +382,13 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
height: 70, height: 70,
), ),
ItemAddSaveButton( ItemAddSaveButton(
onTap: (){ onTap: () {
_saveForm( _saveForm(
nameCTRL.text, nameCTRL.text,
sizeCTRL.text, sizeCTRL.text,
specificCTRL.text, specificCTRL.text,
udiCTRL.text, udiCTRL.text,
descriptionCTRL.text, descriptionCTRL.text,
); );
}, },
deviceBlockSize: _deviceBlockSize, deviceBlockSize: _deviceBlockSize,
+19 -2
View File
@@ -239,7 +239,24 @@ class ItemProvider extends ChangeNotifier {
items = []; items = [];
searchBoxValue = value; searchBoxValue = value;
originalItems!.forEach((result) { originalItems!.forEach((result) {
if (result.udi.toString().contains(searchBoxValue)) { if (
result.udi
.toString()
.toLowerCase()
.contains(searchBoxValue.toLowerCase()) ||
result.udi
.toString()
.toUpperCase()
.contains(searchBoxValue.toUpperCase()) ||
result.udi
.toString()
.toLowerCase()
.contains(searchBoxValue.toUpperCase()) ||
result.udi
.toString()
.toUpperCase()
.contains(searchBoxValue.toLowerCase())
) {
items!.add(result); items!.add(result);
} }
}); });
@@ -289,7 +306,7 @@ class ItemProvider extends ChangeNotifier {
userName: item['user'] != null ? item['user']['name'] : '', userName: item['user'] != null ? item['user']['name'] : '',
status: item['status'], status: item['status'],
udi: item['udi'], udi: item['udi'],
packageId: item['package_id'], packageId: item['package_id'].toString(),
), ),
); );
} }
+18 -1
View File
@@ -247,7 +247,24 @@ class PackageProvider extends ChangeNotifier {
items = []; items = [];
searchBoxValue = value; searchBoxValue = value;
originalItems!.forEach((result) { originalItems!.forEach((result) {
if (result.id.toString().contains(searchBoxValue)) { if (
result.id
.toString()
.toLowerCase()
.contains(searchBoxValue.toLowerCase()) ||
result.id
.toString()
.toUpperCase()
.contains(searchBoxValue.toUpperCase()) ||
result.id
.toString()
.toLowerCase()
.contains(searchBoxValue.toUpperCase()) ||
result.id
.toString()
.toUpperCase()
.contains(searchBoxValue.toLowerCase())
) {
items!.add(result); items!.add(result);
} }
}); });
+22 -3
View File
@@ -88,8 +88,10 @@ class TestResultsProvider with ChangeNotifier {
} }
int pageNumber = 1; int pageNumber = 1;
void resetPageNumber() => pageNumber = 1; void resetPageNumber() => pageNumber = 1;
bool isloading = false; bool isloading = false;
void resetLoading() { void resetLoading() {
isloading = false; isloading = false;
notifyListeners(); notifyListeners();
@@ -109,7 +111,24 @@ class TestResultsProvider with ChangeNotifier {
items = []; items = [];
searchBoxValue = value; searchBoxValue = value;
originalItems!.forEach((result) { originalItems!.forEach((result) {
if (result.name.toString().contains(searchBoxValue)) { if (
result.name
.toString()
.toLowerCase()
.contains(searchBoxValue.toLowerCase()) ||
result.name
.toString()
.toUpperCase()
.contains(searchBoxValue.toUpperCase()) ||
result.name
.toString()
.toLowerCase()
.contains(searchBoxValue.toUpperCase()) ||
result.name
.toString()
.toUpperCase()
.contains(searchBoxValue.toLowerCase())
) {
items!.add(result); items!.add(result);
} }
}); });
@@ -333,9 +352,9 @@ class TestResultsProvider with ChangeNotifier {
.firstWhere((element) => element.id == data['id'].toString()) .firstWhere((element) => element.id == data['id'].toString())
.result, //az api safheye asli estefade mishavad .result, //az api safheye asli estefade mishavad
'description': 'description':
data['inputs']['Note'] != null ? data['inputs']['Note'] : '', data['inputs']['Note'] != null ? data['inputs']['Note'] : '',
'test_type_name': 'test_type_name':
data['test_type']['name'] != null ? data['test_type']['name'] : '', data['test_type']['name'] != null ? data['test_type']['name'] : '',
'hospital': originalItems! 'hospital': originalItems!
.firstWhere((element) => element.id == data['id'].toString()) .firstWhere((element) => element.id == data['id'].toString())
.hospital, // az api safheye asli estefade mi shavad .hospital, // az api safheye asli estefade mi shavad
@@ -88,7 +88,7 @@ class ItemItemBox extends StatelessWidget {
), ),
), ),
Container( Container(
width: 33 * _deviceBlockSize, width: 50 * _deviceBlockSize,
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text( Text(