diff --git a/lib/pages/ItemPages/item_add_screen.dart b/lib/pages/ItemPages/item_add_screen.dart index a4aa655..c89c9a5 100755 --- a/lib/pages/ItemPages/item_add_screen.dart +++ b/lib/pages/ItemPages/item_add_screen.dart @@ -33,6 +33,7 @@ class _ItemAddScreenState extends State { final batchId = randomString(10); int curLabelVal = 1; + @override void initState() { descriptionCTRL.text = ''; @@ -43,46 +44,62 @@ class _ItemAddScreenState extends State { 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(() { isLoading = false; }); - if (!_form.currentState!.validate()) { - return; + if (!_form.currentState!.validate()) { + return; + } + Provider.of(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: [ + 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: [ + TextButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ); } - Provider.of(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: [ - TextButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then((value) => Navigator.of(context) - .popAndPushNamed(Routes.itemResultScreen)); - } - }, - ); + }, + ); } @override @@ -129,7 +146,12 @@ class _ItemAddScreenState extends State { child: Scaffold( appBar: AppBar( titleSpacing: -10, - title: Text('Items', style: TextStyle(color: Colors.white,),), + title: Text( + 'Items', + style: TextStyle( + color: Colors.white, + ), + ), backgroundColor: Colors.black, leading: IconButton( icon: Icon( @@ -360,13 +382,13 @@ class _ItemAddScreenState extends State { height: 70, ), ItemAddSaveButton( - onTap: (){ + onTap: () { _saveForm( - nameCTRL.text, - sizeCTRL.text, - specificCTRL.text, - udiCTRL.text, - descriptionCTRL.text, + nameCTRL.text, + sizeCTRL.text, + specificCTRL.text, + udiCTRL.text, + descriptionCTRL.text, ); }, deviceBlockSize: _deviceBlockSize, diff --git a/lib/providers/items.dart b/lib/providers/items.dart index 734b057..966df66 100755 --- a/lib/providers/items.dart +++ b/lib/providers/items.dart @@ -239,7 +239,24 @@ class ItemProvider extends ChangeNotifier { items = []; searchBoxValue = value; 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); } }); @@ -289,7 +306,7 @@ class ItemProvider extends ChangeNotifier { userName: item['user'] != null ? item['user']['name'] : '', status: item['status'], udi: item['udi'], - packageId: item['package_id'], + packageId: item['package_id'].toString(), ), ); } diff --git a/lib/providers/packages.dart b/lib/providers/packages.dart index 315c23a..cb630d1 100755 --- a/lib/providers/packages.dart +++ b/lib/providers/packages.dart @@ -247,7 +247,24 @@ class PackageProvider extends ChangeNotifier { items = []; searchBoxValue = value; 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); } }); diff --git a/lib/providers/test_results.dart b/lib/providers/test_results.dart index 7124d47..56d2496 100755 --- a/lib/providers/test_results.dart +++ b/lib/providers/test_results.dart @@ -88,8 +88,10 @@ class TestResultsProvider with ChangeNotifier { } int pageNumber = 1; + void resetPageNumber() => pageNumber = 1; bool isloading = false; + void resetLoading() { isloading = false; notifyListeners(); @@ -109,7 +111,24 @@ class TestResultsProvider with ChangeNotifier { items = []; searchBoxValue = value; 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); } }); @@ -333,9 +352,9 @@ class TestResultsProvider with ChangeNotifier { .firstWhere((element) => element.id == data['id'].toString()) .result, //az api safheye asli estefade mishavad 'description': - data['inputs']['Note'] != null ? data['inputs']['Note'] : '', + data['inputs']['Note'] != null ? data['inputs']['Note'] : '', 'test_type_name': - data['test_type']['name'] != null ? data['test_type']['name'] : '', + data['test_type']['name'] != null ? data['test_type']['name'] : '', 'hospital': originalItems! .firstWhere((element) => element.id == data['id'].toString()) .hospital, // az api safheye asli estefade mi shavad diff --git a/lib/widgets/ItemScreens/Result/item_data_box.dart b/lib/widgets/ItemScreens/Result/item_data_box.dart index 7078519..d9462b2 100755 --- a/lib/widgets/ItemScreens/Result/item_data_box.dart +++ b/lib/widgets/ItemScreens/Result/item_data_box.dart @@ -88,7 +88,7 @@ class ItemItemBox extends StatelessWidget { ), ), Container( - width: 33 * _deviceBlockSize, + width: 50 * _deviceBlockSize, child: Row( children: [ Text(