From 58cd3d9f3f945892b9789d17155f55d0c57d6ce9 Mon Sep 17 00:00:00 2001 From: "hanie.khodkari" Date: Wed, 19 Mar 2025 18:38:40 +0330 Subject: [PATCH] Improve back button function in all screens --- lib/pages/CyclePages/cycle_add_screen.dart | 517 +++++++------- lib/pages/CyclePages/cycle_detail_screen.dart | 77 +-- lib/pages/CyclePages/cycle_filter_screen.dart | 510 +++++++------- lib/pages/CyclePages/cycle_result_screen.dart | 2 +- lib/pages/CyclePages/cycle_scan_screen.dart | 307 +++++---- lib/pages/ItemPages/item_add_screen.dart | 534 +++++++-------- lib/pages/ItemPages/item_filter_screen.dart | 636 +++++++++--------- lib/pages/ItemPages/item_result_screen.dart | 2 +- lib/pages/ItemPages/item_scan_screen.dart | 308 +++++---- lib/pages/LabelPages/label_add_screen.dart | 590 ++++++++-------- lib/pages/LabelPages/label_detail_screen.dart | 77 +-- lib/pages/LabelPages/label_filter_screen.dart | 490 +++++++------- lib/pages/LabelPages/label_scan_screen.dart | 125 ++-- .../MyItemsPages/my_items_detail_screen.dart | 89 ++- .../MyItemsPages/my_items_filter_screen.dart | 614 +++++++++-------- .../MyItemsPages/my_items_scan_screen.dart | 307 +++++---- .../my_items_transfer_screen.dart | 462 +++++++------ .../my_packages_detail_screen.dart | 89 ++- .../my_packages_filter_screen.dart | 488 +++++++------- .../my_packages_scan_screen.dart | 307 +++++---- .../my_packages_transfer_screen.dart | 398 ++++++----- .../PackagePages/package_add_screen.dart | 443 ++++++------ .../PackagePages/package_detail_screen.dart | 99 ++- .../PackagePages/package_filter_screen.dart | 424 ++++++------ .../PackagePages/package_result_screen.dart | 2 +- .../PackagePages/package_scan_screen.dart | 307 +++++---- lib/pages/TestPages/test_add_screen.dart | 423 ++++++------ lib/pages/TestPages/test_detail_screen.dart | 71 +- lib/pages/TestPages/test_filter_screen.dart | 544 ++++++++------- lib/pages/TestPages/test_form_page.dart | 180 +++-- lib/pages/TestPages/test_result_screen.dart | 2 +- lib/pages/TestPages/test_scan_screen.dart | 291 ++++---- lib/widgets/CycleScreens/Result/banner.dart | 2 +- .../LabelScreens/Result/floating_buttons.dart | 2 +- .../Main/floating_button.dart | 3 +- 35 files changed, 4715 insertions(+), 5007 deletions(-) diff --git a/lib/pages/CyclePages/cycle_add_screen.dart b/lib/pages/CyclePages/cycle_add_screen.dart index a9fb902..32a7e5a 100755 --- a/lib/pages/CyclePages/cycle_add_screen.dart +++ b/lib/pages/CyclePages/cycle_add_screen.dart @@ -75,297 +75,276 @@ class _CycleAddScreenState extends State { final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; return Consumer(builder: (context, cyclesProvider, _) { - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // cyclesProvider.resetLoadingButton(); - // Navigator.pushReplacementNamed( - // context, - // Routes.cycleResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Cycles', - style: TextStyle( - color: Colors.white, - ), - ), - backgroundColor: Colors.black, - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - color: Colors.white, - size: 35, - ), - onPressed: () { - cyclesProvider.resetLoadingButton(); - Navigator.of(context) - .pushReplacementNamed(Routes.cycleResultScreen); - }, + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Cycles', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Form( - key: _form, - child: Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Add a Cycle', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () { + cyclesProvider.resetLoadingButton(); + Navigator.of(context) + .pushReplacementNamed(Routes.cycleResultScreen); + }, + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Strilizer ID required!'; - } - return null; - }, - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons - .sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Strilizer ID', - contentPadding: - EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Add a Cycle', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, ), ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + SizedBox( + height: 20, ), - keyboardType: - TextInputType.visiblePassword, - textInputAction: - TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus( - _cycleNumberFocusNode); - }, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == - 'error') { - print('error'); - } else if (result == - 'access') { - print('access'); - } else { - print(result); - striizerIdCTRL.text = - result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Strilizer ID required!'; + } + return null; + }, + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Strilizer ID', + contentPadding: + EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: + TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context).requestFocus( + _cycleNumberFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + striizerIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Cycle number required!'; + } + return null; + }, + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Cycle Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocosNode); + }, + ), + SizedBox( + height: 30, + ), + CycleAddDatePicker( + dateCTRL: dateCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 20.0, + ), + Container( + margin: EdgeInsets.symmetric(vertical: 10), + child: Text( + 'Labels included', + style: TextStyle( + color: kPink, + letterSpacing: 2, + fontSize: 5 * _deviceBlockSize, + ), ), ), - ), - ), - ], - ), - SizedBox( - height: 20, - ), - TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Cycle number required!'; - } - return null; - }, - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Cycle Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus( - _descriptionFocosNode); - }, - ), - SizedBox( - height: 30, - ), - CycleAddDatePicker( - dateCTRL: dateCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 20.0, - ), - Container( - margin: - EdgeInsets.symmetric(vertical: 10), - child: Text( - 'Labels included', - style: TextStyle( - color: kPink, - letterSpacing: 2, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - Consumer( - builder: (ctx, cycleProvider, _) => - ListView.builder( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (ctx, index) => - AddLabelBox( + Consumer( + builder: (ctx, cycleProvider, _) => + ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (ctx, index) => AddLabelBox( text: 'Select Labels included', iconColor: kPinkSub, deviceBlockSize: _deviceBlockSize, values: - cycleProvider.labelValues[index], + cycleProvider.labelValues[index], vals: cycleProvider.labelVals, initialLabelValue: - cycleProvider.initialLabelValue, + cycleProvider.initialLabelValue, index: index, hasRemoveButton: - cycleProvider.labelValues.length > - 1 - ? true - : false, + cycleProvider.labelValues.length > 1 + ? true + : false, ), - itemCount: - cycleProvider.labelValues.length, - ), - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: descriptionCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * _deviceBlockSize, + itemCount: + cycleProvider.labelValues.length, + ), + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocosNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 70, + ), + CycleAddSaveButton( + form: _form, + labelValues: Provider.of( + context, + listen: false, + ).labelValues, + cycleNumberCTRL: cycleNumberCTRL, + dateValue: dateCTRL.text, + descriptionCTRL: descriptionCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Description', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.multiline, - focusNode: _descriptionFocosNode, - minLines: 1, - maxLines: 5, - ), - SizedBox( - height: 70, - ), - CycleAddSaveButton( - form: _form, - labelValues: Provider.of( - context, - listen: false, - ).labelValues, - cycleNumberCTRL: cycleNumberCTRL, - dateValue: dateCTRL.text, - descriptionCTRL: descriptionCTRL, - striizerIdCTRL: striizerIdCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ), - ) - : ConnectionErrorBox(); - }, - ), + ) + : ConnectionErrorBox(); + }, ), ), - ),); + ), + ); }); } } diff --git a/lib/pages/CyclePages/cycle_detail_screen.dart b/lib/pages/CyclePages/cycle_detail_screen.dart index e9b5acb..99c8ddf 100755 --- a/lib/pages/CyclePages/cycle_detail_screen.dart +++ b/lib/pages/CyclePages/cycle_detail_screen.dart @@ -52,51 +52,44 @@ class _CycleDetailScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Cycles', - 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(), + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Cycles', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : isEmpty - ? Center( - child: Text('This Cycle doesnt exists!'), - ) - : CycleDetailsDataBox( - datas: datas!, - deviceBlockSize: _deviceBlockSize, - ) - : ConnectionErrorBox(); - }), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), ), + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Cycle doesnt exists!'), + ) + : CycleDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + ) + : ConnectionErrorBox(); + }), ), ); } diff --git a/lib/pages/CyclePages/cycle_filter_screen.dart b/lib/pages/CyclePages/cycle_filter_screen.dart index 505b360..a9bbb9d 100755 --- a/lib/pages/CyclePages/cycle_filter_screen.dart +++ b/lib/pages/CyclePages/cycle_filter_screen.dart @@ -91,271 +91,259 @@ class _CycleFilterScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.cycleResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Cycles', - 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) - .pushReplacementNamed(Routes.cycleResultScreen), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Cycles', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Filter Cycles', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: cycleIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cycle ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus( - _cycleNumberFocusNode); - }, - ), - ), - // Spacer(), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - cycleIdCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cycle Number', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_strilizerIdFocusNode); - }, - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextField( - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Strilizer ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _strilizerIdFocusNode, - keyboardType: - TextInputType.visiblePassword, - textInputAction: TextInputAction.done, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - striizerIdCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 20, - ), - FilterHospitalBox( - deviceBlockSize: _deviceBlockSize, - hospitalCTRL: hospitalCTRL, - hospitalVals: hospitalVals, - label: 'Hospital', - ), - SizedBox( - height: 20, - ), - CycleFilterDatePicker( - dateCTRL: dateCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 70, - ), - CycleFilterSaveButton( - hospitalVals: hospitalVals, - hospitalCTRL: hospitalCTRL, - cycleIdCTRL: cycleIdCTRL, - cycleNumberCTRL: cycleNumberCTRL, - striizerIdCTRL: striizerIdCTRL, - dateCTRL: dateCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.cycleResultScreen), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Filter Cycles', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: cycleIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cycle ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context).requestFocus( + _cycleNumberFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + cycleIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cycle Number', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_strilizerIdFocusNode); + }, + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextField( + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Strilizer ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _strilizerIdFocusNode, + keyboardType: + TextInputType.visiblePassword, + textInputAction: TextInputAction.done, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + striizerIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 20, + ), + FilterHospitalBox( + deviceBlockSize: _deviceBlockSize, + hospitalCTRL: hospitalCTRL, + hospitalVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 20, + ), + CycleFilterDatePicker( + dateCTRL: dateCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 70, + ), + CycleFilterSaveButton( + hospitalVals: hospitalVals, + hospitalCTRL: hospitalCTRL, + cycleIdCTRL: cycleIdCTRL, + cycleNumberCTRL: cycleNumberCTRL, + striizerIdCTRL: striizerIdCTRL, + dateCTRL: dateCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/CyclePages/cycle_result_screen.dart b/lib/pages/CyclePages/cycle_result_screen.dart index b03498d..4f0fc3c 100755 --- a/lib/pages/CyclePages/cycle_result_screen.dart +++ b/lib/pages/CyclePages/cycle_result_screen.dart @@ -323,7 +323,7 @@ class CycleResultFloatingButton extends StatelessWidget { InkWell( customBorder: CircleBorder(), onTap: () { - Navigator.of(context).pushReplacementNamed(Routes.cycleAddScreen); + Navigator.of(context).pushNamed(Routes.cycleAddScreen); }, child: Container( padding: EdgeInsets.all(_deviceBlockSize), diff --git a/lib/pages/CyclePages/cycle_scan_screen.dart b/lib/pages/CyclePages/cycle_scan_screen.dart index 3dda240..890c2fb 100755 --- a/lib/pages/CyclePages/cycle_scan_screen.dart +++ b/lib/pages/CyclePages/cycle_scan_screen.dart @@ -28,181 +28,174 @@ class _CycleScanScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Cycles', - 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(), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Cycles', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'Looking for a Cycle?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Cycle?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, ), ), - GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Cycle Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/Cycle/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ), - SizedBox( - height: 10.0, - ), - Form( - key: _form, - child: TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Cycle Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Or enter a cycle ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), + letterSpacing: 3, ), + textAlign: TextAlign.center, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, ), ), - SizedBox( - height: 70, - ), - InkWell( - onTap: () { - if (!_form.currentState!.validate()) { - return; + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Cycle/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; } - launch( - 'https://cssd-doc.com/Show/Cycle/${idCTRL.text}', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: idCTRL.text, - // ); + return null; }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, ), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [kPink, kPinkSub], + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter a cycle ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, ), - borderRadius: BorderRadius.circular(7), ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Cycle/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPink, kPinkSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, ), ), ), ), - ], - ) - : ConnectionErrorBox(); - }, - ), + ), + ], + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/ItemPages/item_add_screen.dart b/lib/pages/ItemPages/item_add_screen.dart index 9c84222..6e7c57c 100755 --- a/lib/pages/ItemPages/item_add_screen.dart +++ b/lib/pages/ItemPages/item_add_screen.dart @@ -115,283 +115,271 @@ class _ItemAddScreenState extends State { final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; final itemProviderObject = Provider.of(context); - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.itemResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - 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) - .pushReplacementNamed(Routes.itemResultScreen), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Items', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isLoading - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Form( - key: _form, - child: Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'Add an Item', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - SizedBox( - height: 20, - ), - TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Name required!'; - } - return null; - }, - controller: nameCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Item Name', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemSizeFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Size required!'; - } - return null; - }, - controller: sizeCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Size', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemSizeFocusNode, - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemSpecificFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Specific required!'; - } - return null; - }, - controller: specificCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Specific', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemSpecificFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemUdiFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'UDI required!'; - } - return null; - }, - controller: udiCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'UDI', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemUdiFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_descriptionFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: descriptionCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Description', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.multiline, - focusNode: _descriptionFocusNode, - minLines: 1, - maxLines: 5, - ), - SizedBox( - height: 30.0, - ), - UploaderImage( - deviceBlockSize: _deviceBlockSize, - providerObject: itemProviderObject, - ), - SizedBox( - height: 70, - ), - ItemAddSaveButton( - onTap: () { - _saveForm( - nameCTRL.text, - sizeCTRL.text, - specificCTRL.text, - udiCTRL.text, - descriptionCTRL.text, - itemProviderObject); - }, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ), - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.itemResultScreen), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Add an Item', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Name required!'; + } + return null; + }, + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Item Name', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSizeFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Size required!'; + } + return null; + }, + controller: sizeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Size', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSizeFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSpecificFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Specific required!'; + } + return null; + }, + controller: specificCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Specific', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSpecificFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemUdiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'UDI required!'; + } + return null; + }, + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'UDI', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemUdiFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocusNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 30.0, + ), + UploaderImage( + deviceBlockSize: _deviceBlockSize, + providerObject: itemProviderObject, + ), + SizedBox( + height: 70, + ), + ItemAddSaveButton( + onTap: () { + _saveForm( + nameCTRL.text, + sizeCTRL.text, + specificCTRL.text, + udiCTRL.text, + descriptionCTRL.text, + itemProviderObject); + }, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/ItemPages/item_filter_screen.dart b/lib/pages/ItemPages/item_filter_screen.dart index 58e23d3..2c007d7 100755 --- a/lib/pages/ItemPages/item_filter_screen.dart +++ b/lib/pages/ItemPages/item_filter_screen.dart @@ -84,334 +84,322 @@ class _ItemFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.itemResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - 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) - .pushReplacementNamed(Routes.itemResultScreen), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Items', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'Filter Items', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Item ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemNameFocusNode); - }, - ), - ), - // Spacer(), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - idCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: nameCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Item Name', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemNameFocusNode, - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemUdiFocusNode); - }, - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: udiCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'UDI', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemUdiFocusNode, - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemSizeFocusNode); - }, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - udiCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 30.0, - ), - TextFormField( - controller: sizeCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Size', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemSizeFocusNode, - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemSpecificFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: specificCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Specific', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemSpecificFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - ), - SizedBox( - height: 30, - ), - FilterHospitalBox( - deviceBlockSize: _deviceBlockSize, - hospitalCTRL: hospitalCTRL, - hospitalVals: hospitalVals, - label: 'Hospital', - ), - SizedBox( - height: 90, - ), - ItemFilterSaveButton( - hospitalVals: hospitalVals, - hospitalCTRL: hospitalCTRL, - idCTRL: idCTRL, - nameCTRL: nameCTRL, - udiCTRL: udiCTRL, - sizeCTRL: sizeCTRL, - specificCTRL: specificCTRL, - deviceBlockSize: _deviceBlockSize, - firstColor: kBlue, - secondColor: kBlueSub, - push: Routes.itemResultScreen, - ), - SizedBox( - height: 100, - ), - ], - ), - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.itemResultScreen), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Filter Items', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Item ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemNameFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Item Name', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemNameFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemUdiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'UDI', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemUdiFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSizeFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + udiCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30.0, + ), + TextFormField( + controller: sizeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Size', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSizeFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSpecificFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: specificCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Specific', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSpecificFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + ), + SizedBox( + height: 30, + ), + FilterHospitalBox( + deviceBlockSize: _deviceBlockSize, + hospitalCTRL: hospitalCTRL, + hospitalVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 90, + ), + ItemFilterSaveButton( + hospitalVals: hospitalVals, + hospitalCTRL: hospitalCTRL, + idCTRL: idCTRL, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + sizeCTRL: sizeCTRL, + specificCTRL: specificCTRL, + deviceBlockSize: _deviceBlockSize, + firstColor: kBlue, + secondColor: kBlueSub, + push: Routes.itemResultScreen, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/ItemPages/item_result_screen.dart b/lib/pages/ItemPages/item_result_screen.dart index 8ee2b09..f23723f 100755 --- a/lib/pages/ItemPages/item_result_screen.dart +++ b/lib/pages/ItemPages/item_result_screen.dart @@ -352,7 +352,7 @@ class ItemResultFloatingButton extends StatelessWidget { InkWell( customBorder: CircleBorder(), onTap: () { - Navigator.of(context).pushReplacementNamed(Routes.itemAddScreen); + Navigator.of(context).pushNamed(Routes.itemAddScreen); }, child: Container( padding: EdgeInsets.all(_deviceBlockSize), diff --git a/lib/pages/ItemPages/item_scan_screen.dart b/lib/pages/ItemPages/item_scan_screen.dart index 4c74469..7a4bf96 100755 --- a/lib/pages/ItemPages/item_scan_screen.dart +++ b/lib/pages/ItemPages/item_scan_screen.dart @@ -5,7 +5,6 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; -import '../../config/routes.dart'; import '../../providers/connectivity.dart'; import '../../widgets/Global/internet_error.dart'; @@ -26,181 +25,174 @@ class _ItemScanScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - 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(), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Items', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'Looking for an Item?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for an Item?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, ), ), - GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Item Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/Item/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ), - SizedBox( - height: 10.0, - ), - Form( - key: _form, - child: TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Item Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Or enter an Item ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), + letterSpacing: 3, ), + textAlign: TextAlign.center, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, ), ), - SizedBox( - height: 70, - ), - InkWell( - onTap: () { - if (!_form.currentState!.validate()) { - return; + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Item/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; } - launch( - 'https://cssd-doc.com/Show/Item/${idCTRL.text}', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: idCTRL.text, - // ); + return null; }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, ), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [kBlue, kBlueSub], + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter an Item ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, ), - borderRadius: BorderRadius.circular(7), ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Item/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kBlue, kBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, ), ), ), ), - ], - ) - : ConnectionErrorBox(); - }, - ), + ), + ], + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/LabelPages/label_add_screen.dart b/lib/pages/LabelPages/label_add_screen.dart index b4ce28e..1cebcf9 100755 --- a/lib/pages/LabelPages/label_add_screen.dart +++ b/lib/pages/LabelPages/label_add_screen.dart @@ -77,314 +77,298 @@ class _LabelAddScreenState extends State { // String initialLabelValue; return Consumer( builder: (context, labelsProvider, _) { - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // labelsProvider.resetLoadingButton(); - // Navigator.pushReplacementNamed( - // context, - // Routes.labelResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Labels', - style: TextStyle( - color: Colors.white, - ), - ), - backgroundColor: Colors.black, - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - color: Colors.white, - size: 35, - ), - onPressed: () { - labelsProvider.resetLoadingButton(); - Navigator.of(context) - .pushReplacementNamed(Routes.labelResultScreen); - }, + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Labels', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Form( - key: _form, - child: Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'Add a Label', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - onChanged: (val) { - setState(() { - lotNumberCTRL.text = val + - ' - ' + - cycleNumberCTRL.text; - }); - }, - validator: (val) { - if (val!.isEmpty) { - return 'Strilizer ID required!'; - } - return null; - }, - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons - .sortNumericDown, - size: 7 * _deviceBlockSize), - isDense: true, - labelText: 'Strilizer ID', - contentPadding: - EdgeInsets.symmetric( - vertical: 2, - horizontal: 3), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: - 4 * _deviceBlockSize, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: - TextInputType.visiblePassword, - textInputAction: - TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus( - _cycleNumberFocusNode); - }, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == - 'error') { - print('error'); - } else if (result == - 'access') { - print('access'); - } else { - print(result); - striizerIdCTRL.text = - result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 20, - ), - TextFormField( - onChanged: (val) { - setState( - () { - lotNumberCTRL.text = - striizerIdCTRL.text + - ' - ' + - val; - }, - ); - }, - validator: (val) { - if (val!.isEmpty) { - return 'Cycle number required!'; - } - return null; - }, - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Cycle Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.number, - textInputAction: TextInputAction.done, - ), - SizedBox( - height: 20, - ), - TextFormField( - readOnly: true, - controller: lotNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Lot Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: - TextInputType.visiblePassword, - ), - SizedBox( - height: 20, - ), - Container( - margin: - EdgeInsets.symmetric(vertical: 10), - child: Text( - 'Packages included', - style: TextStyle( - color: kLightBlue, - letterSpacing: 2, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - Consumer( - builder: (ctx, labelProvider, _) { - return ListView.builder( - physics: - NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (ctx, index) => - AddPackageBox( - text: 'Package ID', - iconColor: kLightBlueSub, - deviceBlockSize: _deviceBlockSize, - values: labelProvider - .packageValues[index], - vals: labelProvider.packageVals, - initialLabelValue: labelProvider - .initialPackageValue, - index: index, - ), - itemCount: labelProvider - .packageValues.length, - ); - }), - SizedBox( - height: 10, - ), - LabelAddDatePicker( - dateCTRL: sDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Sterile Date', - ), - SizedBox( - height: 20, - ), - LabelAddDatePicker( - dateCTRL: eDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Expire Date', - ), - SizedBox( - height: 70, - ), - LabelAddSaveButton( - form: _form, - lotNumberCTRL: lotNumberCTRL, - cycleNumberCTRL: cycleNumberCTRL, - sDateCTRL: sDateCTRL, - packageValue: - Provider.of( - context, - listen: false, - ).packageValues, - eDateCTRL: eDateCTRL, - striizerIdCTRL: striizerIdCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ), - ) - : ConnectionErrorBox(); + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () { + labelsProvider.resetLoadingButton(); + Navigator.of(context) + .pushReplacementNamed(Routes.labelResultScreen); }, ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Add a Label', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + onChanged: (val) { + setState(() { + lotNumberCTRL.text = val + + ' - ' + + cycleNumberCTRL.text; + }); + }, + validator: (val) { + if (val!.isEmpty) { + return 'Strilizer ID required!'; + } + return null; + }, + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons + .sortNumericDown, + size: 7 * _deviceBlockSize), + isDense: true, + labelText: 'Strilizer ID', + contentPadding: + EdgeInsets.symmetric( + vertical: 2, + horizontal: 3), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: + TextInputType.visiblePassword, + textInputAction: + TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus( + _cycleNumberFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == + 'error') { + print('error'); + } else if (result == + 'access') { + print('access'); + } else { + print(result); + striizerIdCTRL.text = + result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 20, + ), + TextFormField( + onChanged: (val) { + setState( + () { + lotNumberCTRL.text = + striizerIdCTRL.text + + ' - ' + + val; + }, + ); + }, + validator: (val) { + if (val!.isEmpty) { + return 'Cycle number required!'; + } + return null; + }, + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Cycle Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, + ), + SizedBox( + height: 20, + ), + TextFormField( + readOnly: true, + controller: lotNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Lot Number', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: + TextInputType.visiblePassword, + ), + SizedBox( + height: 20, + ), + Container( + margin: + EdgeInsets.symmetric(vertical: 10), + child: Text( + 'Packages included', + style: TextStyle( + color: kLightBlue, + letterSpacing: 2, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + Consumer( + builder: (ctx, labelProvider, _) { + return ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (ctx, index) => + AddPackageBox( + text: 'Package ID', + iconColor: kLightBlueSub, + deviceBlockSize: _deviceBlockSize, + values: labelProvider + .packageValues[index], + vals: labelProvider.packageVals, + initialLabelValue: + labelProvider.initialPackageValue, + index: index, + ), + itemCount: + labelProvider.packageValues.length, + ); + }), + SizedBox( + height: 10, + ), + LabelAddDatePicker( + dateCTRL: sDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Sterile Date', + ), + SizedBox( + height: 20, + ), + LabelAddDatePicker( + dateCTRL: eDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Expire Date', + ), + SizedBox( + height: 70, + ), + LabelAddSaveButton( + form: _form, + lotNumberCTRL: lotNumberCTRL, + cycleNumberCTRL: cycleNumberCTRL, + sDateCTRL: sDateCTRL, + packageValue: Provider.of( + context, + listen: false, + ).packageValues, + eDateCTRL: eDateCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/LabelPages/label_detail_screen.dart b/lib/pages/LabelPages/label_detail_screen.dart index c782965..c959a95 100755 --- a/lib/pages/LabelPages/label_detail_screen.dart +++ b/lib/pages/LabelPages/label_detail_screen.dart @@ -52,51 +52,44 @@ class _LabelDetailScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Labels', - 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(), + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Labels', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : isEmpty - ? Center( - child: Text('This Label dos\'nt exists!'), - ) - : LabelDetailsDataBox( - datas: datas!, - deviceBlockSize: _deviceBlockSize, - ) - : ConnectionErrorBox(); - }), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), ), + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Label dos\'nt exists!'), + ) + : LabelDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + ) + : ConnectionErrorBox(); + }), ), ); } diff --git a/lib/pages/LabelPages/label_filter_screen.dart b/lib/pages/LabelPages/label_filter_screen.dart index 79a39fa..31cf88c 100755 --- a/lib/pages/LabelPages/label_filter_screen.dart +++ b/lib/pages/LabelPages/label_filter_screen.dart @@ -80,261 +80,249 @@ class _LabelFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.labelResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Labels', - 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) - .pushReplacementNamed(Routes.labelResultScreen), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Labels', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'Filter Labels', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: labelIdCTRl, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Label ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus( - _cycleNumberFocusNode); - }, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - labelIdCTRl.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: cycleNumberCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Cycle Number', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _cycleNumberFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_strilizerIdFocusNode); - }, - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: striizerIdCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Strilizer ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - textInputAction: TextInputAction.done, - keyboardType: - TextInputType.visiblePassword, - focusNode: _strilizerIdFocusNode, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - striizerIdCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - LabelFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - hospitalCTRL: hospitalCTRL, - hospitalVals: hospitalVals, - ), - SizedBox( - height: 70, - ), - LabelFilterSaveButton( - hospitalVals: hospitalVals, - hospitalCTRL: hospitalCTRL, - labelIdCTRl: labelIdCTRl, - cycleNumberCTRL: cycleNumberCTRL, - striizerIdCTRL: striizerIdCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 50, - ), - // DropDownBox(values: ['Washer ID']), - ], - ), - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.labelResultScreen), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Filter Labels', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: labelIdCTRl, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Label ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context).requestFocus( + _cycleNumberFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + labelIdCTRl.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: cycleNumberCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cycle Number', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_strilizerIdFocusNode); + }, + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: striizerIdCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Strilizer ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + textInputAction: TextInputAction.done, + keyboardType: + TextInputType.visiblePassword, + focusNode: _strilizerIdFocusNode, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + striizerIdCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + LabelFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + hospitalCTRL: hospitalCTRL, + hospitalVals: hospitalVals, + ), + SizedBox( + height: 70, + ), + LabelFilterSaveButton( + hospitalVals: hospitalVals, + hospitalCTRL: hospitalCTRL, + labelIdCTRl: labelIdCTRl, + cycleNumberCTRL: cycleNumberCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 50, + ), + // DropDownBox(values: ['Washer ID']), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/LabelPages/label_scan_screen.dart b/lib/pages/LabelPages/label_scan_screen.dart index 78cdb29..72cfa95 100755 --- a/lib/pages/LabelPages/label_scan_screen.dart +++ b/lib/pages/LabelPages/label_scan_screen.dart @@ -30,79 +30,72 @@ class _LabelScanScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Labels', - 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(), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Labels', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'Looking for a Label?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Label?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, ), ), - LabelScanBox(), - SizedBox( - height: 10, - ), - Form( - key: _form, - child: LabelScanInputBox( - idCTRL: idCTRL, - deviceBlockSize: _deviceBlockSize, - ), - ), - SizedBox( - height: 70, - ), - FilterScanSaveButton( - form: _form, + ), + LabelScanBox(), + SizedBox( + height: 10, + ), + Form( + key: _form, + child: LabelScanInputBox( idCTRL: idCTRL, deviceBlockSize: _deviceBlockSize, ), - ], - ) - : ConnectionErrorBox(); - }, - ), + ), + SizedBox( + height: 70, + ), + FilterScanSaveButton( + form: _form, + idCTRL: idCTRL, + deviceBlockSize: _deviceBlockSize, + ), + ], + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/MyItemsPages/my_items_detail_screen.dart b/lib/pages/MyItemsPages/my_items_detail_screen.dart index f843ae3..7ed9119 100755 --- a/lib/pages/MyItemsPages/my_items_detail_screen.dart +++ b/lib/pages/MyItemsPages/my_items_detail_screen.dart @@ -52,58 +52,51 @@ class _MyItemsDetailScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'My 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(), + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'My Items', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : isEmpty - ? Center( - child: Text('This Item does\'nt exists!'), - ) - : MyItemsDetailsDataBox( - datas: datas!, - deviceBlockSize: _deviceBlockSize, - push: () { - Navigator.pushNamed( - context, Routes.itemsTransferScreen, - arguments: datas); - }, - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Item does\'nt exists!'), + ) + : MyItemsDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + push: () { + Navigator.pushNamed( + context, Routes.itemsTransferScreen, + arguments: datas); + }, + ) + : ConnectionErrorBox(); + }, + ), ), ); } diff --git a/lib/pages/MyItemsPages/my_items_filter_screen.dart b/lib/pages/MyItemsPages/my_items_filter_screen.dart index 3940026..c41651d 100755 --- a/lib/pages/MyItemsPages/my_items_filter_screen.dart +++ b/lib/pages/MyItemsPages/my_items_filter_screen.dart @@ -53,323 +53,311 @@ class _MyItemsFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.myItemsResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'My 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) - .pushReplacementNamed(Routes.myItemsResultScreen), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'My Items', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'Filter My Items', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Item ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemNameFocusNode); - }, - ), - ), - // Spacer(), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - idCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: nameCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Item Name', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemNameFocusNode, - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemUdiFocusNode); - }, - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: udiCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'UDI', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemUdiFocusNode, - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemSizeFocusNode); - }, - ), - ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - idCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ), - ], - ), - SizedBox( - height: 30.0, - ), - TextFormField( - controller: sizeCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Size', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemSizeFocusNode, - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_itemSpecificFocusNode); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: specificCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Specific', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _itemSpecificFocusNode, - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - ), - SizedBox( - height: 90, - ), - MyItemFilterSaveButton( - idCTRL: idCTRL, - nameCTRL: nameCTRL, - udiCTRL: udiCTRL, - sizeCTRL: sizeCTRL, - specificCTRL: specificCTRL, - deviceBlockSize: _deviceBlockSize, - firstColor: kDarkBlue, - secondColor: kDarkBlueSub, - push: Routes.myItemsResultScreen, - ), - SizedBox( - height: 100, - ), - ], - ), - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.myItemsResultScreen), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Filter My Items', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Item ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemNameFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Item Name', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemNameFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemUdiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: udiCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'UDI', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemUdiFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSizeFocusNode); + }, + ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ), + ], + ), + SizedBox( + height: 30.0, + ), + TextFormField( + controller: sizeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Size', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSizeFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_itemSpecificFocusNode); + }, + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: specificCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Specific', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _itemSpecificFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + ), + SizedBox( + height: 90, + ), + MyItemFilterSaveButton( + idCTRL: idCTRL, + nameCTRL: nameCTRL, + udiCTRL: udiCTRL, + sizeCTRL: sizeCTRL, + specificCTRL: specificCTRL, + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkBlue, + secondColor: kDarkBlueSub, + push: Routes.myItemsResultScreen, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/MyItemsPages/my_items_scan_screen.dart b/lib/pages/MyItemsPages/my_items_scan_screen.dart index d842d60..879819f 100755 --- a/lib/pages/MyItemsPages/my_items_scan_screen.dart +++ b/lib/pages/MyItemsPages/my_items_scan_screen.dart @@ -26,181 +26,174 @@ class _MyItemsScanScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _deviceWidth = _media.size.width; final double _deviceBlockSize = _deviceWidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'My 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(), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'My Items', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'Looking for an Item?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for an Item?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, ), ), - GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Item Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/Item/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ), - SizedBox( - height: 10.0, - ), - Form( - key: _form, - child: TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Item Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Or enter an Item ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), + letterSpacing: 3, ), + textAlign: TextAlign.center, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, ), ), - SizedBox( - height: 70, - ), - InkWell( - onTap: () { - if (!_form.currentState!.validate()) { - return; + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Item/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; } - launch( - 'https://cssd-doc.com/Show/Item/${idCTRL.text}', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: idCTRL.text, - // ); + return null; }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, ), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [kDarkBlue, kDarkBlueSub], + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter an Item ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, ), - borderRadius: BorderRadius.circular(7), ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Item/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kDarkBlue, kDarkBlueSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, ), ), ), ), - ], - ) - : ConnectionErrorBox(); - }, - ), + ), + ], + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/MyItemsPages/my_items_transfer_screen.dart b/lib/pages/MyItemsPages/my_items_transfer_screen.dart index a10f7b0..4a7cebc 100755 --- a/lib/pages/MyItemsPages/my_items_transfer_screen.dart +++ b/lib/pages/MyItemsPages/my_items_transfer_screen.dart @@ -79,250 +79,240 @@ class _ItemsTransferScreenState extends State { final _media = MediaQuery.of(context); final double _deviceWidth = _media.size.width; final double _deviceBlockSize = _deviceWidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Item Details', - 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(), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Item Details', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? Padding( - padding: EdgeInsets.only( - top: 20, - right: 20, - bottom: 40, - left: 20, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ResultBanner( - deviceBlockSize: _deviceBlockSize, - text: 'Transfer to', - hasFilterObject: false, - push: Routes.myItemsFilterScreen, - ), - SizedBox( - height: 20.0, - ), - ResultSearchBox( - searchCTRL: searchCTRL, - text: 'user', - text2: 'name or ID', - deviceBlockSize: _deviceBlockSize, - textInputType: TextInputType.visiblePassword, - onChanged: (value) { - Provider.of(context, - listen: false) - .searchUsers(value); - }, - ), - SizedBox( - height: 20, - ), - Expanded( - child: Consumer( - builder: (context, userResults, _) { - return userResults.isLoading - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : userResults.usersBox?.length != null - ? ListView.builder( - controller: sc, - itemBuilder: (context, index) { - return TransferDataBox( - deviceBlockSize: - _deviceBlockSize, - user: userResults - .usersBox?[index], - clickColor: kDarkBlue, - isClicked: userResults - .selectedUserIndex == - index, - onTap: (userId) { - Provider.of( - context, - listen: false, - ).selectUser(index); - print(userId); - Provider.of( - context, - listen: false) - .saveUserId = userId; - Provider.of( - context, - listen: false) - .selectedUserForItems = - userResults - .usersBox?[index]; - }, - ); - }, - itemCount: - userResults.usersBox?.length, - shrinkWrap: true, - ) - : Container( - child: Center( - child: Text( - "There is no user to show."), - ), - ); - }, - ), - ), - TransferDestroyButton( - deviceBlockSize: _deviceBlockSize, - firstColor: kDarkBlue, - secondColor: kDarkBlueSub, - onTap: () { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text( - 'Are you sure to transfer this Item?', - style: TextStyle( - fontSize: 4 * _deviceBlockSize, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 40, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Transfer to', + hasFilterObject: false, + push: Routes.myItemsFilterScreen, + ), + SizedBox( + height: 20.0, + ), + ResultSearchBox( + searchCTRL: searchCTRL, + text: 'user', + text2: 'name or ID', + deviceBlockSize: _deviceBlockSize, + textInputType: TextInputType.visiblePassword, + onChanged: (value) { + Provider.of(context, listen: false) + .searchUsers(value); + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, userResults, _) { + return userResults.isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, ), - ), - content: SizedBox( - width: _deviceBlockSize, - height: 320, - child: Column( - children: [ - Text( - 'By approving, your item will be transferred the specified user. It can be undone unless the user reject the transfer.', - style: TextStyle( - fontSize: 3 * _deviceBlockSize, - ), - ), - SizedBox( - height: 10.0, - ), - ItemCard( - _deviceBlockSize, itemData!), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Spacer(), - Text('To'), - SizedBox( - width: 5.0, - ), - TransferDataBox( - deviceBlockSize: - _deviceBlockSize, - user: Provider.of< - UsersProvider>( - context) - .selectedUserForItems, - ) - ], - ), - SizedBox( - height: 20.0, - ), - Consumer( - builder: - (context, myItemProvider, _) { - return TransferDestroyButton( - deviceBlockSize: - _deviceBlockSize, - firstColor: kDarkBlue, - secondColor: kDarkBlueSub, - onTap: () async { - myItemProvider - .setLoadingButton(); - await Provider.of< - MyItemProvider>( - context, - listen: false, - ).transferItems( - itemData!.id, - await Provider.of< - UsersProvider>( + ) + : userResults.usersBox?.length != null + ? ListView.builder( + controller: sc, + itemBuilder: (context, index) { + return TransferDataBox( + deviceBlockSize: + _deviceBlockSize, + user: userResults + .usersBox?[index], + clickColor: kDarkBlue, + isClicked: userResults + .selectedUserIndex == + index, + onTap: (userId) { + Provider.of( + context, + listen: false, + ).selectUser(index); + print(userId); + Provider.of( + context, + listen: false) + .saveUserId = userId; + Provider.of( context, listen: false) - .saveUserId!, - ); - Navigator.of(context).pop(); - Navigator.of(context).pop(); - Navigator.of(context).pop(); - myItemProvider - .resetLoadingButton(); - Fluttertoast.showToast( - msg: - "The item is transferred.", - toastLength: - Toast.LENGTH_SHORT, - gravity: - ToastGravity.BOTTOM, - ); - }, - text: 'Transfer', - isLoadingButton: - myItemProvider - .isloadingButton, - ); - }, + .selectedUserForItems = + userResults + .usersBox?[index]; + }, + ); + }, + itemCount: + userResults.usersBox?.length, + shrinkWrap: true, + ) + : Container( + child: Center( + child: Text( + "There is no user to show."), ), - SizedBox( - height: 5.0, - ), - CancelTransferButton( - deviceBlockSize: _deviceBlockSize, - color: kPink, - onTap: () { - Navigator.pop(context); - }, - ), - ], - ), - ), - ); - }, - ); + ); }, - text: 'Transfer', ), - ], - ), - ) - : ConnectionErrorBox(); - }, - ), + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkBlue, + secondColor: kDarkBlueSub, + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + 'Are you sure to transfer this Item?', + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + content: SizedBox( + width: _deviceBlockSize, + height: 320, + child: Column( + children: [ + Text( + 'By approving, your item will be transferred the specified user. It can be undone unless the user reject the transfer.', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + ), + SizedBox( + height: 10.0, + ), + ItemCard(_deviceBlockSize, itemData!), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Spacer(), + Text('To'), + SizedBox( + width: 5.0, + ), + TransferDataBox( + deviceBlockSize: + _deviceBlockSize, + user: + Provider.of( + context) + .selectedUserForItems, + ) + ], + ), + SizedBox( + height: 20.0, + ), + Consumer( + builder: + (context, myItemProvider, _) { + return TransferDestroyButton( + deviceBlockSize: + _deviceBlockSize, + firstColor: kDarkBlue, + secondColor: kDarkBlueSub, + onTap: () async { + myItemProvider + .setLoadingButton(); + await Provider.of< + MyItemProvider>( + context, + listen: false, + ).transferItems( + itemData!.id, + await Provider.of< + UsersProvider>( + context, + listen: false) + .saveUserId!, + ); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + Navigator.of(context).pop(); + myItemProvider + .resetLoadingButton(); + Fluttertoast.showToast( + msg: + "The item is transferred.", + toastLength: + Toast.LENGTH_SHORT, + gravity: + ToastGravity.BOTTOM, + ); + }, + text: 'Transfer', + isLoadingButton: myItemProvider + .isloadingButton, + ); + }, + ), + SizedBox( + height: 5.0, + ), + CancelTransferButton( + deviceBlockSize: _deviceBlockSize, + color: kPink, + onTap: () { + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }, + ); + }, + text: 'Transfer', + ), + ], + ), + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/MyPackagesPages/my_packages_detail_screen.dart b/lib/pages/MyPackagesPages/my_packages_detail_screen.dart index 182e307..59ce82c 100755 --- a/lib/pages/MyPackagesPages/my_packages_detail_screen.dart +++ b/lib/pages/MyPackagesPages/my_packages_detail_screen.dart @@ -52,58 +52,51 @@ class _MyPackagesDetailScreenState extends State { final _media = MediaQuery.of(context); final double _deviceWidth = _media.size.width; final double _deviceBlockSize = _deviceWidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'My Packages', - 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(), + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'My Packages', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : isEmpty - ? Center( - child: Text('This Package does\'nt exists!'), - ) - : MyPackageDetailsDataBox( - datas: datas!, - deviceBlockSize: _deviceBlockSize, - push: () { - Navigator.pushNamed( - context, Routes.packagesTransferScreen, - arguments: datas); - }, - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Package does\'nt exists!'), + ) + : MyPackageDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + push: () { + Navigator.pushNamed( + context, Routes.packagesTransferScreen, + arguments: datas); + }, + ) + : ConnectionErrorBox(); + }, + ), ), ); } diff --git a/lib/pages/MyPackagesPages/my_packages_filter_screen.dart b/lib/pages/MyPackagesPages/my_packages_filter_screen.dart index 2a788d2..1437a23 100755 --- a/lib/pages/MyPackagesPages/my_packages_filter_screen.dart +++ b/lib/pages/MyPackagesPages/my_packages_filter_screen.dart @@ -51,260 +51,248 @@ class _MyPackageFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.myPackagesResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'My Packages', - 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) - .pushReplacementNamed(Routes.myPackagesResultScreen), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'My Packages', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Filter My Packages', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Package ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_nameFocusNode); - }, - ), - ), - // Spacer(), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - idCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: nameCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Package Name', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _nameFocusNode, - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_udiFocusNode); - }, - ), - // SizedBox( - // height: 30, - // ), - // Row( - // children: [ - // Flexible( - // flex: 8, - // child: TextFormField( - // controller: udiCTRL, - // decoration: InputDecoration( - // icon: Icon( - // FontAwesomeIcons.alignLeft, - // size: 6 * _deviceBlockSize, - // ), - // labelStyle: TextStyle( - // fontWeight: FontWeight.w100, - // fontSize: 4 * _deviceBlockSize, - // ), - // labelText: 'UDI', - // isDense: true, - // contentPadding: EdgeInsets.symmetric( - // vertical: 2, - // horizontal: 3, - // ), - // ), - // style: TextStyle( - // fontWeight: FontWeight.w700, - // fontSize: 5 * _deviceBlockSize, - // ), - // focusNode: _udiFocusNode, - // keyboardType: TextInputType.text, - // textInputAction: TextInputAction.next, - // ), - // ), - // Flexible( - // flex: 1, - // child: InkWell( - // onTap: () { - // scan().then( - // (String result) { - // if (result == 'cancel') { - // print('cancel'); - // } else if (result == 'error') { - // print('error'); - // } else if (result == 'access') { - // print('access'); - // } else { - // print(result); - // idCTRL.text = result; - // } - // }, - // ); - // }, - // child: Container( - // padding: EdgeInsets.all(8), - // decoration: BoxDecoration( - // shape: BoxShape.circle, - // color: Colors.black, - // ), - // child: Icon( - // Icons.qr_code_scanner, - // size: 5 * _deviceBlockSize, - // color: Colors.white, - // ), - // ), - // ), - // ) - // ], - // ), - SizedBox( - height: 90, - ), - MyPackagesFilterSaveButton( - idCTRL: idCTRL, - nameCTRL: nameCTRL, - // udiCTRL: udiCTRL, - deviceBlockSize: _deviceBlockSize, - firstColor: kDarkPurple, - secondColor: kDarkPurpleSub, - push: Routes.myPackagesResultScreen, - ), - SizedBox( - height: 100, - ), - ], - ), - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.myPackagesResultScreen), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Filter My Packages', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Package ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_nameFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ) + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Package Name', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _nameFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_udiFocusNode); + }, + ), + // SizedBox( + // height: 30, + // ), + // Row( + // children: [ + // Flexible( + // flex: 8, + // child: TextFormField( + // controller: udiCTRL, + // decoration: InputDecoration( + // icon: Icon( + // FontAwesomeIcons.alignLeft, + // size: 6 * _deviceBlockSize, + // ), + // labelStyle: TextStyle( + // fontWeight: FontWeight.w100, + // fontSize: 4 * _deviceBlockSize, + // ), + // labelText: 'UDI', + // isDense: true, + // contentPadding: EdgeInsets.symmetric( + // vertical: 2, + // horizontal: 3, + // ), + // ), + // style: TextStyle( + // fontWeight: FontWeight.w700, + // fontSize: 5 * _deviceBlockSize, + // ), + // focusNode: _udiFocusNode, + // keyboardType: TextInputType.text, + // textInputAction: TextInputAction.next, + // ), + // ), + // Flexible( + // flex: 1, + // child: InkWell( + // onTap: () { + // scan().then( + // (String result) { + // if (result == 'cancel') { + // print('cancel'); + // } else if (result == 'error') { + // print('error'); + // } else if (result == 'access') { + // print('access'); + // } else { + // print(result); + // idCTRL.text = result; + // } + // }, + // ); + // }, + // child: Container( + // padding: EdgeInsets.all(8), + // decoration: BoxDecoration( + // shape: BoxShape.circle, + // color: Colors.black, + // ), + // child: Icon( + // Icons.qr_code_scanner, + // size: 5 * _deviceBlockSize, + // color: Colors.white, + // ), + // ), + // ), + // ) + // ], + // ), + SizedBox( + height: 90, + ), + MyPackagesFilterSaveButton( + idCTRL: idCTRL, + nameCTRL: nameCTRL, + // udiCTRL: udiCTRL, + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkPurple, + secondColor: kDarkPurpleSub, + push: Routes.myPackagesResultScreen, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/MyPackagesPages/my_packages_scan_screen.dart b/lib/pages/MyPackagesPages/my_packages_scan_screen.dart index c253b36..be58089 100755 --- a/lib/pages/MyPackagesPages/my_packages_scan_screen.dart +++ b/lib/pages/MyPackagesPages/my_packages_scan_screen.dart @@ -26,181 +26,174 @@ class _MyPackagesScanScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _deviceWidth = _media.size.width; final double _deviceBlockSize = _deviceWidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'My Packages', - 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(), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'My Packages', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'Looking for a Package?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Package?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, ), ), - GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Package Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/Package/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ), - SizedBox( - height: 10.0, - ), - Form( - key: _form, - child: TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Package Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Or enter a Package ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), + letterSpacing: 3, ), + textAlign: TextAlign.center, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, ), ), - SizedBox( - height: 70, - ), - InkWell( - onTap: () { - if (!_form.currentState!.validate()) { - return; + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Package/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; } - launch( - 'https://cssd-doc.com/Show/Package/${idCTRL.text}', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: idCTRL.text, - // ); + return null; }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, ), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [kDarkPurple, kDarkPurpleSub], + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter a Package ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, ), - borderRadius: BorderRadius.circular(7), ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Package/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kDarkPurple, kDarkPurpleSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, ), ), ), ), - ], - ) - : ConnectionErrorBox(); - }, - ), + ), + ], + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/MyPackagesPages/my_packages_transfer_screen.dart b/lib/pages/MyPackagesPages/my_packages_transfer_screen.dart index 736d62b..97657d8 100755 --- a/lib/pages/MyPackagesPages/my_packages_transfer_screen.dart +++ b/lib/pages/MyPackagesPages/my_packages_transfer_screen.dart @@ -74,220 +74,208 @@ class _PackageTransferScreenState extends State { final _media = MediaQuery.of(context); final double _deviceWidth = _media.size.width; final double _deviceBlockSize = _deviceWidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Package Details', - 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(), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Package Details', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? Padding( - padding: EdgeInsets.only( - top: 20, - right: 20, - bottom: 40, - left: 20, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ResultBanner( - deviceBlockSize: _deviceBlockSize, - text: 'Transfer to', - hasFilterObject: false, - push: Routes.myItemsFilterScreen, - ), - SizedBox( - height: 20.0, - ), - ResultSearchBox( - searchCTRL: searchCTRL, - text: 'user', - text2: 'name or ID', - deviceBlockSize: _deviceBlockSize, - textInputType: TextInputType.visiblePassword, - onChanged: (value) { - Provider.of(context, - listen: false) - .searchUsers(value); + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? Padding( + padding: EdgeInsets.only( + top: 20, + right: 20, + bottom: 40, + left: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResultBanner( + deviceBlockSize: _deviceBlockSize, + text: 'Transfer to', + hasFilterObject: false, + push: Routes.myItemsFilterScreen, + ), + SizedBox( + height: 20.0, + ), + ResultSearchBox( + searchCTRL: searchCTRL, + text: 'user', + text2: 'name or ID', + deviceBlockSize: _deviceBlockSize, + textInputType: TextInputType.visiblePassword, + onChanged: (value) { + Provider.of(context, listen: false) + .searchUsers(value); + }, + ), + SizedBox( + height: 20, + ), + Expanded( + child: Consumer( + builder: (context, userResults, _) { + return userResults.isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView.builder( + controller: sc, + itemBuilder: (context, index) { + return TransferDataBox( + deviceBlockSize: _deviceBlockSize, + user: userResults.usersBox?[index], + clickColor: kDarkPurple, + isClicked: + userResults.selectedUserIndex == + index, + onTap: (userId) { + Provider.of( + context, + listen: false, + ).selectUser(index); + print(userId); + Provider.of( + context, + listen: false) + .saveUserId = userId; + Provider.of( + context, + listen: false) + .selectedUserForPackages = + userResults.usersBox?[index]; + }, + ); + }, + itemCount: userResults.usersBox?.length, + shrinkWrap: true, + ); }, ), - SizedBox( - height: 20, - ), - Expanded( - child: Consumer( - builder: (context, userResults, _) { - return userResults.isLoading - ? Center( - child: CircularProgressIndicator( - color: Colors.black, + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkPurple, + secondColor: kDarkPurpleSub, + onTap: () { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text( + 'Are you sure to transfer this Package?', + style: TextStyle( + fontSize: 4 * _deviceBlockSize, + ), + ), + content: SizedBox( + width: _deviceBlockSize, + height: 300, + child: Column( + children: [ + Text( + 'By approving, all items in your package will be transferred the specified user. it can be undone unless the user reject the transfer.', + style: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), ), - ) - : ListView.builder( - controller: sc, - itemBuilder: (context, index) { - return TransferDataBox( - deviceBlockSize: _deviceBlockSize, - user: - userResults.usersBox?[index], - clickColor: kDarkPurple, - isClicked: userResults - .selectedUserIndex == - index, - onTap: (userId) { - Provider.of( - context, - listen: false, - ).selectUser(index); - print(userId); + SizedBox( + height: 10.0, + ), + PackageCard( + _deviceBlockSize, packageData!), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Spacer(), + Text('To'), + SizedBox( + width: 5.0, + ), + TransferDataBox( + deviceBlockSize: + _deviceBlockSize, + user: Provider.of< + UsersProvider>(context) + .selectedUserForPackages, + ) + ], + ), + SizedBox( + height: 20.0, + ), + TransferDestroyButton( + deviceBlockSize: _deviceBlockSize, + firstColor: kDarkPurple, + secondColor: kDarkPurpleSub, + onTap: () { + Provider.of( + context, + listen: false, + ).transferPackage( + packageData!.id, Provider.of( context, listen: false) - .saveUserId = userId; - Provider.of( - context, - listen: false) - .selectedUserForPackages = - userResults - .usersBox?[index]; - }, - ); - }, - itemCount: - userResults.usersBox?.length, - shrinkWrap: true, - ); + .saveUserId!, + ); + Navigator.of(context).pop(); + Navigator.of(context) + .popAndPushNamed(Routes + .myPackagesResultScreen); + }, + text: 'Transfer', + ), + SizedBox( + height: 5.0, + ), + CancelTransferButton( + deviceBlockSize: _deviceBlockSize, + color: kPink, + onTap: () { + Navigator.pop(context); + }, + ), + ], + ), + ), + ); }, - ), - ), - TransferDestroyButton( - deviceBlockSize: _deviceBlockSize, - firstColor: kDarkPurple, - secondColor: kDarkPurpleSub, - onTap: () { - showDialog( - context: context, - builder: (context) { - return AlertDialog( - title: Text( - 'Are you sure to transfer this Package?', - style: TextStyle( - fontSize: 4 * _deviceBlockSize, - ), - ), - content: SizedBox( - width: _deviceBlockSize, - height: 300, - child: Column( - children: [ - Text( - 'By approving, all items in your package will be transferred the specified user. it can be undone unless the user reject the transfer.', - style: TextStyle( - fontSize: 3 * _deviceBlockSize, - ), - ), - SizedBox( - height: 10.0, - ), - PackageCard( - _deviceBlockSize, packageData!), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Spacer(), - Text('To'), - SizedBox( - width: 5.0, - ), - TransferDataBox( - deviceBlockSize: - _deviceBlockSize, - user: Provider.of< - UsersProvider>( - context) - .selectedUserForPackages, - ) - ], - ), - SizedBox( - height: 20.0, - ), - TransferDestroyButton( - deviceBlockSize: _deviceBlockSize, - firstColor: kDarkPurple, - secondColor: kDarkPurpleSub, - onTap: () { - Provider.of( - context, - listen: false, - ).transferPackage( - packageData!.id, - Provider.of( - context, - listen: false) - .saveUserId!, - ); - Navigator.of(context).pop(); - Navigator.of(context) - .popAndPushNamed(Routes - .myPackagesResultScreen); - }, - text: 'Transfer', - ), - SizedBox( - height: 5.0, - ), - CancelTransferButton( - deviceBlockSize: _deviceBlockSize, - color: kPink, - onTap: () { - Navigator.pop(context); - }, - ), - ], - ), - ), - ); - }, - ); - }, - text: 'Transfer', - ), - ], - ), - ) - : ConnectionErrorBox(); - }, - ), + ); + }, + text: 'Transfer', + ), + ], + ), + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/PackagePages/package_add_screen.dart b/lib/pages/PackagePages/package_add_screen.dart index 0b45afe..e1e66fd 100755 --- a/lib/pages/PackagePages/package_add_screen.dart +++ b/lib/pages/PackagePages/package_add_screen.dart @@ -66,241 +66,224 @@ class _PackageAddScreenState extends State { final double _deviceBlockSize = _devicewidth / 100; return Consumer( builder: (context, packageProvider, _) { - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // packageProvider.resetLoadingButton(); - // Navigator.pushReplacementNamed( - // context, - // Routes.packageResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Packages', - style: TextStyle( - color: Colors.white, - ), - ), - backgroundColor: Colors.black, - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - color: Colors.white, - size: 35, - ), - onPressed: () { - packageProvider.resetLoadingButton(); - Navigator.of(context) - .pushReplacementNamed(Routes.packageResultScreen); - }, + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Packages', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Form( - key: _form, - child: Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'Add a Package', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 6 * _deviceBlockSize, - letterSpacing: 3, - ), - ), - SizedBox( - height: 20, - ), - TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Name required!'; - } - return null; - }, - controller: nameCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Package Name', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus( - _packageUdiFocusNode); - }, - ), - SizedBox( - height: 30, - ), - // TextFormField( - // validator: (val) { - // if (val!.isEmpty) { - // return 'UDI required!'; - // } - // return null; - // }, - // controller: udiCTRL, - // decoration: InputDecoration( - // icon: Icon( - // FontAwesomeIcons.alignLeft, - // size: 7 * _deviceBlockSize, - // ), - // labelStyle: TextStyle( - // fontWeight: FontWeight.w100, - // fontSize: 4 * _deviceBlockSize, - // ), - // isDense: true, - // labelText: 'UDI', - // contentPadding: EdgeInsets.symmetric( - // vertical: 2, horizontal: 3), - // ), - // style: TextStyle( - // fontWeight: FontWeight.w700, - // fontSize: 5 * _deviceBlockSize, - // ), - // focusNode: _packageUdiFocusNode, - // keyboardType: TextInputType.visiblePassword, - // textInputAction: TextInputAction.next, - // onFieldSubmitted: (_) { - // FocusScope.of(context) - // .requestFocus(_descriptionFocusNode); - // }, - // ), - // SizedBox( - // height: 20, - // ), - Container( - margin: - EdgeInsets.symmetric(vertical: 5), - child: Text( - 'Items included', - style: TextStyle( - color: kPurple, - letterSpacing: 2, - fontSize: 5 * _deviceBlockSize, - ), - ), - ), - Consumer( - builder: (ctx, packageProvider, _) => - ListView.builder( - physics: - NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (ctx, index) => - AddItemBox( - text: 'Select Items Included', - iconColor: kPurpleSub, - deviceBlockSize: _deviceBlockSize, - values: packageProvider - .itemValues[index], - vals: packageProvider.itemVals, - initialItemValue: packageProvider - .initialItemValue, - index: index, - hasRemoveButton: packageProvider - .itemValues.length > - 1 - ? true - : false, - ), - itemCount: - packageProvider.itemValues.length, - ), - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: descriptionCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 7 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Description', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.multiline, - focusNode: _descriptionFocusNode, - minLines: 1, - maxLines: 5, - ), - SizedBox( - height: 70, - ), - PackageAddSaveButton( - form: _form, - itemValues: - Provider.of( - context, - listen: false, - ).itemValues, - nameCTRL: nameCTRL, - // udiCTRL: udiCTRL, - dateValue: dateCTRL.text, - descriptionCTRL: descriptionCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ), - ) - : ConnectionErrorBox(); + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () { + packageProvider.resetLoadingButton(); + Navigator.of(context) + .pushReplacementNamed(Routes.packageResultScreen); }, ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Add a Package', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Name required!'; + } + return null; + }, + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Package Name', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_packageUdiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + // TextFormField( + // validator: (val) { + // if (val!.isEmpty) { + // return 'UDI required!'; + // } + // return null; + // }, + // controller: udiCTRL, + // decoration: InputDecoration( + // icon: Icon( + // FontAwesomeIcons.alignLeft, + // size: 7 * _deviceBlockSize, + // ), + // labelStyle: TextStyle( + // fontWeight: FontWeight.w100, + // fontSize: 4 * _deviceBlockSize, + // ), + // isDense: true, + // labelText: 'UDI', + // contentPadding: EdgeInsets.symmetric( + // vertical: 2, horizontal: 3), + // ), + // style: TextStyle( + // fontWeight: FontWeight.w700, + // fontSize: 5 * _deviceBlockSize, + // ), + // focusNode: _packageUdiFocusNode, + // keyboardType: TextInputType.visiblePassword, + // textInputAction: TextInputAction.next, + // onFieldSubmitted: (_) { + // FocusScope.of(context) + // .requestFocus(_descriptionFocusNode); + // }, + // ), + // SizedBox( + // height: 20, + // ), + Container( + margin: EdgeInsets.symmetric(vertical: 5), + child: Text( + 'Items included', + style: TextStyle( + color: kPurple, + letterSpacing: 2, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + Consumer( + builder: (ctx, packageProvider, _) => + ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (ctx, index) => AddItemBox( + text: 'Select Items Included', + iconColor: kPurpleSub, + deviceBlockSize: _deviceBlockSize, + values: + packageProvider.itemValues[index], + vals: packageProvider.itemVals, + initialItemValue: + packageProvider.initialItemValue, + index: index, + hasRemoveButton: packageProvider + .itemValues.length > + 1 + ? true + : false, + ), + itemCount: + packageProvider.itemValues.length, + ), + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: descriptionCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 7 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Description', + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.multiline, + focusNode: _descriptionFocusNode, + minLines: 1, + maxLines: 5, + ), + SizedBox( + height: 70, + ), + PackageAddSaveButton( + form: _form, + itemValues: Provider.of( + context, + listen: false, + ).itemValues, + nameCTRL: nameCTRL, + // udiCTRL: udiCTRL, + dateValue: dateCTRL.text, + descriptionCTRL: descriptionCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/PackagePages/package_detail_screen.dart b/lib/pages/PackagePages/package_detail_screen.dart index 24905a5..7194a90 100755 --- a/lib/pages/PackagePages/package_detail_screen.dart +++ b/lib/pages/PackagePages/package_detail_screen.dart @@ -47,63 +47,56 @@ class _PackageDetailScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pop(); - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Packages', - 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(), + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Packages', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : isEmpty - ? Center( - child: Text('This Package does\'nt exists!'), - ) - : PackageDetailsDataBox( - datas: datas!, - deviceBlockSize: _deviceBlockSize, - goToAddLabelPage: () { - Navigator.pushNamed( - context, - Routes.labelAddScreen, - arguments: { - "id": datas!.id, - "name": datas!.name - }, - ); - }, - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : isEmpty + ? Center( + child: Text('This Package does\'nt exists!'), + ) + : PackageDetailsDataBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + goToAddLabelPage: () { + Navigator.pushNamed( + context, + Routes.labelAddScreen, + arguments: { + "id": datas!.id, + "name": datas!.name + }, + ); + }, + ) + : ConnectionErrorBox(); + }, + ), ), ); } diff --git a/lib/pages/PackagePages/package_filter_screen.dart b/lib/pages/PackagePages/package_filter_screen.dart index 9e46944..5fcedec 100755 --- a/lib/pages/PackagePages/package_filter_screen.dart +++ b/lib/pages/PackagePages/package_filter_screen.dart @@ -78,228 +78,216 @@ class _PackageFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.packageResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Packages', - 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) - .pushReplacementNamed(Routes.packageResultScreen), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Packages', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Filter Packages', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Package ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_nameFocusNode); - }, - ), - ), - // Spacer(), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - idCTRL.text = result; - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), - ) - ], - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: nameCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.alignLeft, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Package Name', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - focusNode: _nameFocusNode, - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_udiFocusNode); - }, - ), - SizedBox( - height: 30, - ), - // TextFormField( - // controller: udiCTRL, - // decoration: InputDecoration( - // icon: Icon( - // FontAwesomeIcons.alignLeft, - // size: 6 * _deviceBlockSize, - // ), - // labelStyle: TextStyle( - // fontWeight: FontWeight.w100, - // fontSize: 4 * _deviceBlockSize, - // ), - // labelText: 'UDI', - // isDense: true, - // contentPadding: EdgeInsets.symmetric( - // vertical: 2, - // horizontal: 3, - // ), - // ), - // style: TextStyle( - // fontWeight: FontWeight.w700, - // fontSize: 5 * _deviceBlockSize, - // ), - // focusNode: _udiFocusNode, - // keyboardType: TextInputType.text, - // textInputAction: TextInputAction.next, - // ), - // SizedBox( - // height: 30.0, - // ), - FilterHospitalBox( - deviceBlockSize: _deviceBlockSize, - hospitalCTRL: hospitalCTRL, - hospitalVals: hospitalVals, - label: 'Hospital', - ), - SizedBox( - height: 90, - ), - PackageFilterSaveButton( - hospitalVals: hospitalVals, - hospitalCTRL: hospitalCTRL, - idCTRL: idCTRL, - nameCTRL: nameCTRL, - // udiCTRL: udiCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], - ), - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.packageResultScreen), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Filter Packages', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Package ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_nameFocusNode); + }, + ), + ), + // Spacer(), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ) + ], + ), + SizedBox( + height: 30, + ), + TextFormField( + controller: nameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.alignLeft, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Package Name', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _nameFocusNode, + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_udiFocusNode); + }, + ), + SizedBox( + height: 30, + ), + // TextFormField( + // controller: udiCTRL, + // decoration: InputDecoration( + // icon: Icon( + // FontAwesomeIcons.alignLeft, + // size: 6 * _deviceBlockSize, + // ), + // labelStyle: TextStyle( + // fontWeight: FontWeight.w100, + // fontSize: 4 * _deviceBlockSize, + // ), + // labelText: 'UDI', + // isDense: true, + // contentPadding: EdgeInsets.symmetric( + // vertical: 2, + // horizontal: 3, + // ), + // ), + // style: TextStyle( + // fontWeight: FontWeight.w700, + // fontSize: 5 * _deviceBlockSize, + // ), + // focusNode: _udiFocusNode, + // keyboardType: TextInputType.text, + // textInputAction: TextInputAction.next, + // ), + // SizedBox( + // height: 30.0, + // ), + FilterHospitalBox( + deviceBlockSize: _deviceBlockSize, + hospitalCTRL: hospitalCTRL, + hospitalVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 90, + ), + PackageFilterSaveButton( + hospitalVals: hospitalVals, + hospitalCTRL: hospitalCTRL, + idCTRL: idCTRL, + nameCTRL: nameCTRL, + // udiCTRL: udiCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), ), ), ); diff --git a/lib/pages/PackagePages/package_result_screen.dart b/lib/pages/PackagePages/package_result_screen.dart index 22e894d..17fb656 100755 --- a/lib/pages/PackagePages/package_result_screen.dart +++ b/lib/pages/PackagePages/package_result_screen.dart @@ -327,7 +327,7 @@ class PackageResultFloatingButton extends StatelessWidget { InkWell( customBorder: CircleBorder(), onTap: () { - Navigator.of(context).pushReplacementNamed(Routes.packageAddScreen); + Navigator.of(context).pushNamed(Routes.packageAddScreen); }, child: Container( padding: EdgeInsets.all(_deviceBlockSize), diff --git a/lib/pages/PackagePages/package_scan_screen.dart b/lib/pages/PackagePages/package_scan_screen.dart index ffce36d..8edb115 100755 --- a/lib/pages/PackagePages/package_scan_screen.dart +++ b/lib/pages/PackagePages/package_scan_screen.dart @@ -26,181 +26,174 @@ class _PackageScanScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Packages', - 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(), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Packages', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'Looking for a Package?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Package?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, ), ), - GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Package Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/Package/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ), - SizedBox( - height: 10.0, - ), - Form( - key: _form, - child: TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Package Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Or enter a Package ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), + letterSpacing: 3, ), + textAlign: TextAlign.center, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, ), ), - SizedBox( - height: 70, - ), - InkWell( - onTap: () { - if (!_form.currentState!.validate()) { - return; + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/Package/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; } - launch( - 'https://cssd-doc.com/Show/Package/${idCTRL.text}', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: idCTRL.text, - // ); + return null; }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, ), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [kPurple, kPurpleSub], + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter a Package ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, ), - borderRadius: BorderRadius.circular(7), ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/Package/${idCTRL.text}', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: idCTRL.text, + // ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [kPurple, kPurpleSub], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, ), ), ), ), - ], - ) - : ConnectionErrorBox(); - }, - ), + ), + ], + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/TestPages/test_add_screen.dart b/lib/pages/TestPages/test_add_screen.dart index a25151d..aeee385 100755 --- a/lib/pages/TestPages/test_add_screen.dart +++ b/lib/pages/TestPages/test_add_screen.dart @@ -49,244 +49,229 @@ class _TestResultAddScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.testResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Test Results', - style: TextStyle( - color: Colors.white, - ), - ), - backgroundColor: Colors.black, - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - color: Colors.white, - size: 35, - ), - // padding: EdgeInsets.all(0), - onPressed: () => Navigator.of(context) - .popAndPushNamed(Routes.testResultScreen), + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Test Results', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : ListView( - padding: EdgeInsets.symmetric( - horizontal: 20, vertical: 20), - children: [ - Container( - padding: EdgeInsets.only( - top: 10, - ), - child: Text( - 'Add a Test Result', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, - fontWeight: FontWeight.w700, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + // padding: EdgeInsets.all(0), + onPressed: () => + Navigator.of(context).popAndPushNamed(Routes.testResultScreen), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : ListView( + padding: + EdgeInsets.symmetric(horizontal: 20, vertical: 20), + children: [ + Container( + padding: EdgeInsets.only( + top: 10, + ), + child: Text( + 'Add a Test Result', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, ), ), - GestureDetector( - child: Container( - margin: EdgeInsets.only(top: 5, bottom: 30), - padding: EdgeInsets.all(10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'PLease Scan The Test Barcode', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.grey, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), + ), + GestureDetector( + child: Container( + margin: EdgeInsets.only(top: 5, bottom: 30), + padding: EdgeInsets.all(10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'PLease Scan The Test Barcode', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.grey, + fontSize: 5 * _deviceBlockSize, + fontWeight: FontWeight.w100, + letterSpacing: 3, ), ), ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - Provider.of( - context, - listen: false, - ).testCode = result; - Navigator.pushNamed( - context, - Routes.formTestResultScreen, - arguments: result, - ); - } - }, - ); - }, ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: 70 * _deviceBlockSize, - child: TestResultAddSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: testTypeCTRL, - dataVals: testTypeVals, - label: 'Choose a Test Type', - ), + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + Provider.of( + context, + listen: false, + ).testCode = result; + Navigator.pushNamed( + context, + Routes.formTestResultScreen, + arguments: result, + ); + } + }, + ); + }, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 70 * _deviceBlockSize, + child: TestResultAddSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: testTypeCTRL, + dataVals: testTypeVals, + label: 'Choose a Test Type', ), - Row( - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - 'OR', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 7 * _deviceBlockSize, - ), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + 'OR', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 7 * _deviceBlockSize, ), - SizedBox( - width: 8 * _deviceBlockSize, - ), - Container( - width: 50 * _deviceBlockSize, - child: TextFormField( - onChanged: (val) { - if (val != '') { - setState( - () { - testTypeCTRL.text = ''; - }, - ); - } else { - setState( - () { - testTypeCTRL.text = - testTypeVals[0]; - }, - ); - } - }, - controller: testCodeCTRL, - decoration: InputDecoration( - isDense: true, - icon: Icon( - FontAwesomeIcons - .sortNumericDown, - ), - labelText: 'Enter a Test Code', - labelStyle: TextStyle( - fontSize: 3 * _deviceBlockSize, - ), - contentPadding: EdgeInsets.only( - bottom: 5, - top: 5, - ), - ), - keyboardType: - TextInputType.visiblePassword, - ), - ), - ], - ), - SizedBox( - height: 40.0, - ), - Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, ), - width: 50 * _deviceBlockSize, - decoration: BoxDecoration( - color: Colors.black, - borderRadius: BorderRadius.circular(7), + SizedBox( + width: 8 * _deviceBlockSize, ), - child: Align( - alignment: Alignment.center, - child: TextButton( - child: Text( - 'Select', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), - ), - onPressed: () { - if (testCodeCTRL.text != '') { - Provider.of( - context, - listen: false, - ).testCode = testCodeCTRL.text; - Navigator.pushNamed( - context, - Routes.formTestResultScreen, - arguments: testCodeCTRL.text, + Container( + width: 50 * _deviceBlockSize, + child: TextFormField( + onChanged: (val) { + if (val != '') { + setState( + () { + testTypeCTRL.text = ''; + }, ); - } else if (testTypeCTRL.text != - '') { - Provider.of( - context, - listen: false, - ).testType = testTypeCTRL.text; - Navigator.pushReplacementNamed( - context, - Routes.formTestResultScreen, - arguments: testTypeCTRL.text, + } else { + setState( + () { + testTypeCTRL.text = + testTypeVals[0]; + }, ); } - // print(testCode); }, + controller: testCodeCTRL, + decoration: InputDecoration( + isDense: true, + icon: Icon( + FontAwesomeIcons.sortNumericDown, + ), + labelText: 'Enter a Test Code', + labelStyle: TextStyle( + fontSize: 3 * _deviceBlockSize, + ), + contentPadding: EdgeInsets.only( + bottom: 5, + top: 5, + ), + ), + keyboardType: + TextInputType.visiblePassword, ), ), + ], + ), + SizedBox( + height: 40.0, + ), + Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, ), - ], - ), - SizedBox( - width: 5 * _deviceBlockSize, - ), - ], - ), - ], - ) - : ConnectionErrorBox(); - }, - ), + width: 50 * _deviceBlockSize, + decoration: BoxDecoration( + color: Colors.black, + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: TextButton( + child: Text( + 'Select', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + onPressed: () { + if (testCodeCTRL.text != '') { + Provider.of( + context, + listen: false, + ).testCode = testCodeCTRL.text; + Navigator.pushNamed( + context, + Routes.formTestResultScreen, + arguments: testCodeCTRL.text, + ); + } else if (testTypeCTRL.text != '') { + Provider.of( + context, + listen: false, + ).testType = testTypeCTRL.text; + Navigator.pushReplacementNamed( + context, + Routes.formTestResultScreen, + arguments: testTypeCTRL.text, + ); + } + // print(testCode); + }, + ), + ), + ), + ], + ), + SizedBox( + width: 5 * _deviceBlockSize, + ), + ], + ), + ], + ) + : ConnectionErrorBox(); + }, ), ), ); diff --git a/lib/pages/TestPages/test_detail_screen.dart b/lib/pages/TestPages/test_detail_screen.dart index 957f614..0d3f61a 100755 --- a/lib/pages/TestPages/test_detail_screen.dart +++ b/lib/pages/TestPages/test_detail_screen.dart @@ -44,49 +44,42 @@ class _TestDetailsScreenState extends State { final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; // print(datas); - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Test Results', - 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(), + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Test Results', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : DatasBox( - datas: datas!, - deviceBlockSize: _deviceBlockSize, - ) - : ConnectionErrorBox(); - }, + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), ), ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : DatasBox( + datas: datas!, + deviceBlockSize: _deviceBlockSize, + ) + : ConnectionErrorBox(); + }, + ), ), ); } diff --git a/lib/pages/TestPages/test_filter_screen.dart b/lib/pages/TestPages/test_filter_screen.dart index 3d7bbee..222e820 100755 --- a/lib/pages/TestPages/test_filter_screen.dart +++ b/lib/pages/TestPages/test_filter_screen.dart @@ -128,299 +128,287 @@ class _TestFilterScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.testResultScreen, - // ); - // return true; - }, - child: SafeArea( - child: GestureDetector( - onTap: () { - FocusManager.instance.primaryFocus?.unfocus(); - }, - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Test Results', - 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).popAndPushNamed( - Routes.testResultScreen, - ), + return SafeArea( + child: GestureDetector( + onTap: () { + FocusManager.instance.primaryFocus?.unfocus(); + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Test Results', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'Filter Test Results', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).popAndPushNamed( + Routes.testResultScreen, + ), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Filter Test Results', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - SizedBox( - height: 20, - ), - Row( - children: [ - Flexible( - flex: 8, - child: TextFormField( - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'ID', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), + ), + SizedBox( + height: 20, + ), + Row( + children: [ + Flexible( + flex: 8, + child: TextFormField( + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, ), - keyboardType: TextInputType.text, - textInputAction: TextInputAction.next, - // onFieldSubmitted: (_) { - // FocusScope.of(context) - // .requestFocus(_cycleNumberFocusNode); - // }, + labelText: 'ID', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.text, + textInputAction: TextInputAction.next, + // onFieldSubmitted: (_) { + // FocusScope.of(context) + // .requestFocus(_cycleNumberFocusNode); + // }, ), - Flexible( - flex: 1, - child: InkWell( - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - print(result); - idCTRL.text = result; - // Navigator.of(context).pushNamed( - // CycleDetailScreen.route, - // arguments: result, - // ); - } - }, - ); - }, - child: Container( - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - Icons.qr_code_scanner, - size: 5 * _deviceBlockSize, - color: Colors.white, - ), + ), + Flexible( + flex: 1, + child: InkWell( + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + print(result); + idCTRL.text = result; + // Navigator.of(context).pushNamed( + // CycleDetailScreen.route, + // arguments: result, + // ); + } + }, + ); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, ), - ), - ), - ], - ), - - SizedBox( - height: 25, - ), - TestResultFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: labelIdCTRL, - dataVals: labelIDVals, - label: 'Label ID', - ), - SizedBox( - height: 25, - ), - - TextFormField( - controller: usernameCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - labelText: 'Username', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - // onFieldSubmitted: (_) { - // FocusScope.of(context) - // .requestFocus(_cycleNumberFocusNode); - // }, - ), - SizedBox( - height: 25, - ), - TestResultFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: testTypeCTRL, - dataVals: testTypeVals, - label: 'Test Type', - ), - SizedBox( - height: 25, - ), - userData['roles']?.contains('User') ?? false - ? Container() - : Column( - children: [ - TestResultFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: hospitalCTRL, - dataVals: hospitalVals, - label: 'Hospital', - ), - SizedBox( - height: 25, - ), - ], - ), - TestResultFilterDatePicker( - dateCTRL: fDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Date From', - ), - SizedBox( - height: 25, - ), - TestResultFilterDatePicker( - dateCTRL: uDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Date Until', - ), - SizedBox( - height: 70, - ), - InkWell( - onTap: () { - Provider.of(context, - listen: false) - .setFilters( - idCTRL.text, - labelIdCTRL.text != '' - ? labelIdCTRL.text - : '', - usernameCTRL.text, - testTypeCTRL.text != '' - ? testTypes![testTypeCTRL.text] - : '', - hospitalCTRL.text != '' - ? hospitals[hospitalCTRL.text] - : '', - fDateCTRL.text, - uDateCTRL.text, - ); - // showDialog( - // context: context, - // builder: (ctx) => AlertDialog( - // content: Text('Filters changed.'), - // actions: [ - // TextButton( - // onPressed: () { - // Navigator.of(ctx).pop(); - // // Navigator.of(context).pop(); - // }, - // child: Text('Ok'), - // ) - // ], - // ), - // ).then( - // (_) => - // Navigator.of(context).popAndPushNamed( - // Routes.testResultScreen, - // ), - // ); - Navigator.of(context).popAndPushNamed( - Routes.testResultScreen, - ); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.black, Colors.black87], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Filter', - style: TextStyle( + child: Icon( + Icons.qr_code_scanner, + size: 5 * _deviceBlockSize, color: Colors.white, - fontSize: 5 * _deviceBlockSize, ), ), ), ), + ], + ), + + SizedBox( + height: 25, + ), + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: labelIdCTRL, + dataVals: labelIDVals, + label: 'Label ID', + ), + SizedBox( + height: 25, + ), + + TextFormField( + controller: usernameCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Username', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), ), - SizedBox( - height: 70, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - // DropDownBox(values: ['Washer ID']), - ], - ), - ) - : ConnectionErrorBox(); - }, - ), + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + // onFieldSubmitted: (_) { + // FocusScope.of(context) + // .requestFocus(_cycleNumberFocusNode); + // }, + ), + SizedBox( + height: 25, + ), + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: testTypeCTRL, + dataVals: testTypeVals, + label: 'Test Type', + ), + SizedBox( + height: 25, + ), + userData['roles']?.contains('User') ?? false + ? Container() + : Column( + children: [ + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: hospitalCTRL, + dataVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 25, + ), + ], + ), + TestResultFilterDatePicker( + dateCTRL: fDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Date From', + ), + SizedBox( + height: 25, + ), + TestResultFilterDatePicker( + dateCTRL: uDateCTRL, + deviceBlockSize: _deviceBlockSize, + label: 'Date Until', + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + Provider.of(context, + listen: false) + .setFilters( + idCTRL.text, + labelIdCTRL.text != '' + ? labelIdCTRL.text + : '', + usernameCTRL.text, + testTypeCTRL.text != '' + ? testTypes![testTypeCTRL.text] + : '', + hospitalCTRL.text != '' + ? hospitals[hospitalCTRL.text] + : '', + fDateCTRL.text, + uDateCTRL.text, + ); + // showDialog( + // context: context, + // builder: (ctx) => AlertDialog( + // content: Text('Filters changed.'), + // actions: [ + // TextButton( + // onPressed: () { + // Navigator.of(ctx).pop(); + // // Navigator.of(context).pop(); + // }, + // child: Text('Ok'), + // ) + // ], + // ), + // ).then( + // (_) => + // Navigator.of(context).popAndPushNamed( + // Routes.testResultScreen, + // ), + // ); + Navigator.of(context).popAndPushNamed( + Routes.testResultScreen, + ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.black, Colors.black87], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Filter', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ), + SizedBox( + height: 70, + ), + // DropDownBox(values: ['Washer ID']), + ], + ), + ) + : ConnectionErrorBox(); + }, ), ), ), diff --git a/lib/pages/TestPages/test_form_page.dart b/lib/pages/TestPages/test_form_page.dart index 66b7673..766ff4b 100755 --- a/lib/pages/TestPages/test_form_page.dart +++ b/lib/pages/TestPages/test_form_page.dart @@ -96,105 +96,93 @@ class _FormPageState extends State { @override Widget build(BuildContext context) { - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - // Navigator.pushReplacementNamed( - // context, - // Routes.testResultAddScreen, - // ); - // return true; - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text( - 'Add Test Result', - style: TextStyle( - color: Colors.white, - ), - ), - backgroundColor: Colors.black, - actions: [ - _isLoadingButton - ? Center( - child: CircularProgressIndicator( - color: Colors.white, - ), - ) - : IconButton( - icon: Icon( - Icons.save, - color: Colors.white, - ), - onPressed: () { - _saveForm(); - }, - ) - ], - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - color: Colors.white, - size: 35, - ), - onPressed: () { - Navigator.of(context).popAndPushNamed(Routes.testResultScreen); - }, + return SafeArea( + child: Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text( + 'Add Test Result', + style: TextStyle( + color: Colors.white, ), ), - body: SingleChildScrollView( - child: Column( - children: [ - _isLoading - ? Center( - child: CircularProgressIndicator( - color: Colors.black, - ), - ) - : Form( - key: _form, - child: Consumer( - builder: (context, inputs, _) { - formInputs = inputs.inputItems; - print(formInputs); - return formInputs.length != 0 - ? FormCreator( - form: formInputs, - onChanged: (value) { - formInputs = value; - }, - ) - : Center( - child: Text('Something went wrong!!!'), - ); - }, - ), - ), - // https://www.cssd-doc.com/api/GetInfo - // InkWell( - // onTap: () { - // _saveForm(); - // }, - // child: Container( - // padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15), - // margin: EdgeInsets.symmetric(vertical: 20, horizontal: 50), - // decoration: BoxDecoration( - // gradient: LinearGradient(colors: [Colors.blue, Colors.green]), - // borderRadius: BorderRadius.circular(10), - // ), - // child: Text( - // 'Save', - // style: TextStyle(color: Colors.white, fontSize: 17), - // textAlign: TextAlign.center, - // ), - // ), - // ), - ], + backgroundColor: Colors.black, + actions: [ + _isLoadingButton + ? Center( + child: CircularProgressIndicator( + color: Colors.white, + ), + ) + : IconButton( + icon: Icon( + Icons.save, + color: Colors.white, + ), + onPressed: () { + _saveForm(); + }, + ) + ], + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, ), + onPressed: () { + Navigator.of(context).popAndPushNamed(Routes.testResultScreen); + }, + ), + ), + body: SingleChildScrollView( + child: Column( + children: [ + _isLoading + ? Center( + child: CircularProgressIndicator( + color: Colors.black, + ), + ) + : Form( + key: _form, + child: Consumer( + builder: (context, inputs, _) { + formInputs = inputs.inputItems; + print(formInputs); + return formInputs.length != 0 + ? FormCreator( + form: formInputs, + onChanged: (value) { + formInputs = value; + }, + ) + : Center( + child: Text('Something went wrong!!!'), + ); + }, + ), + ), + // https://www.cssd-doc.com/api/GetInfo + // InkWell( + // onTap: () { + // _saveForm(); + // }, + // child: Container( + // padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15), + // margin: EdgeInsets.symmetric(vertical: 20, horizontal: 50), + // decoration: BoxDecoration( + // gradient: LinearGradient(colors: [Colors.blue, Colors.green]), + // borderRadius: BorderRadius.circular(10), + // ), + // child: Text( + // 'Save', + // style: TextStyle(color: Colors.white, fontSize: 17), + // textAlign: TextAlign.center, + // ), + // ), + // ), + ], ), ), ), diff --git a/lib/pages/TestPages/test_result_screen.dart b/lib/pages/TestPages/test_result_screen.dart index a0505dc..383381f 100755 --- a/lib/pages/TestPages/test_result_screen.dart +++ b/lib/pages/TestPages/test_result_screen.dart @@ -128,7 +128,7 @@ class _TestResultScreenState extends State { InkWell( onTap: () { Navigator.of(context) - .popAndPushNamed(Routes.testFilterScreen); + .pushNamed(Routes.testFilterScreen); }, child: Container( padding: EdgeInsets.all(7), diff --git a/lib/pages/TestPages/test_scan_screen.dart b/lib/pages/TestPages/test_scan_screen.dart index 8d87b4f..844da54 100755 --- a/lib/pages/TestPages/test_scan_screen.dart +++ b/lib/pages/TestPages/test_scan_screen.dart @@ -27,173 +27,166 @@ class _TestScanScreenState extends State { // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return PopScope( - canPop: false, - onPopInvoked: (didPop) { - if (didPop) return; - Navigator.of(context).pushNamed(Routes.homePage); - }, - child: SafeArea( - child: Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text( - 'Test Results', - 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(), + return SafeArea( + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text( + 'Test Results', + style: TextStyle( + color: Colors.white, ), ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? ListView( - padding: EdgeInsets.symmetric(horizontal: 20), - children: [ - Container( - padding: EdgeInsets.only(top: 30), - child: Text( - 'Looking for a Test Result?', - textAlign: TextAlign.left, - style: TextStyle( - color: Colors.black, - fontSize: 5.5 * _deviceBlockSize, - fontWeight: FontWeight.w700, - letterSpacing: 3, - ), + backgroundColor: Colors.black, + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + color: Colors.white, + size: 35, + ), + onPressed: () => Navigator.of(context).pop(), + ), + ), + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.only(top: 30), + child: Text( + 'Looking for a Test Result?', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5.5 * _deviceBlockSize, + fontWeight: FontWeight.w700, + letterSpacing: 3, ), ), - GestureDetector( - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - height: 200, - decoration: BoxDecoration(border: Border.all()), - child: Center( - child: Text( - 'Please Scan The Test Result Barcode', - style: TextStyle( - color: Colors.black, - fontSize: 5 * _deviceBlockSize, - fontWeight: FontWeight.w100, - letterSpacing: 3, - ), - textAlign: TextAlign.center, - ), - ), - ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - launch( - 'https://cssd-doc.com/Show/TestResult/$result', - ); - // Navigator.of(context).pushNamed( - // Routes.cycleDetailScreen, - // arguments: result, - // ); - } - }, - ); - }, - ), - SizedBox( - height: 10.0, - ), - Form( - key: _form, - child: TextFormField( - validator: (val) { - if (val!.isEmpty) { - return 'Id required!!'; - } - return null; - }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - labelStyle: TextStyle( + ), + GestureDetector( + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + height: 200, + decoration: BoxDecoration(border: Border.all()), + child: Center( + child: Text( + 'Please Scan The Test Result Barcode', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, - ), - isDense: true, - labelText: 'Or enter a Test Result ID', - contentPadding: EdgeInsets.symmetric( - vertical: 2, - horizontal: 3, - ), - focusedBorder: UnderlineInputBorder( - // borderRadius: BorderRadius.only(Radius.circular(4)), - borderSide: BorderSide( - color: Colors.grey, - ), + letterSpacing: 3, ), + textAlign: TextAlign.center, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - keyboardType: TextInputType.number, ), ), - SizedBox( - height: 70, - ), - InkWell( - onTap: () { - if (!_form.currentState!.validate()) { - return; + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + launch( + 'https://cssd-doc.com/Show/TestResult/$result', + ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); + } + }, + ); + }, + ), + SizedBox( + height: 10.0, + ), + Form( + key: _form, + child: TextFormField( + validator: (val) { + if (val!.isEmpty) { + return 'Id required!!'; } - launch( - 'https://cssd-doc.com/Show/TestResult/${idCTRL.text}', - ); + return null; }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, + controller: idCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.sortNumericDown, + size: 6 * _deviceBlockSize, ), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.black, Colors.black87], + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + isDense: true, + labelText: 'Or enter a Test Result ID', + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + focusedBorder: UnderlineInputBorder( + // borderRadius: BorderRadius.only(Radius.circular(4)), + borderSide: BorderSide( + color: Colors.grey, ), - borderRadius: BorderRadius.circular(7), ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, - ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.number, + ), + ), + SizedBox( + height: 70, + ), + InkWell( + onTap: () { + if (!_form.currentState!.validate()) { + return; + } + launch( + 'https://cssd-doc.com/Show/TestResult/${idCTRL.text}', + ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.black, Colors.black87], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'Search', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, ), ), ), ), - ], - ) - : ConnectionErrorBox(); - }, - ), + ), + ], + ) + : ConnectionErrorBox(); + }, ), ), ); diff --git a/lib/widgets/CycleScreens/Result/banner.dart b/lib/widgets/CycleScreens/Result/banner.dart index d8499d6..bd2d2ba 100755 --- a/lib/widgets/CycleScreens/Result/banner.dart +++ b/lib/widgets/CycleScreens/Result/banner.dart @@ -34,7 +34,7 @@ class ResultBanner extends StatelessWidget { InkWell( customBorder: CircleBorder(), onTap: () { - Navigator.of(context).popAndPushNamed(push); + Navigator.of(context).pushNamed(push); }, child: Container( padding: EdgeInsets.all(5), diff --git a/lib/widgets/LabelScreens/Result/floating_buttons.dart b/lib/widgets/LabelScreens/Result/floating_buttons.dart index 79aa5c5..26a0182 100755 --- a/lib/widgets/LabelScreens/Result/floating_buttons.dart +++ b/lib/widgets/LabelScreens/Result/floating_buttons.dart @@ -41,7 +41,7 @@ class LabelFloatingButtons extends StatelessWidget { InkWell( customBorder: CircleBorder(), onTap: () { - Navigator.of(context).pushReplacementNamed(Routes.labelAddScreen); + Navigator.of(context).pushNamed(Routes.labelAddScreen); }, child: Container( padding: EdgeInsets.all(5), diff --git a/lib/widgets/TestResultScreens/Main/floating_button.dart b/lib/widgets/TestResultScreens/Main/floating_button.dart index f9056d3..d07ff00 100755 --- a/lib/widgets/TestResultScreens/Main/floating_button.dart +++ b/lib/widgets/TestResultScreens/Main/floating_button.dart @@ -41,8 +41,7 @@ class TestResultFloatingButton extends StatelessWidget { InkWell( customBorder: CircleBorder(), onTap: () { - Navigator.of(context) - .pushReplacementNamed(Routes.testResultAddScreen); + Navigator.of(context).pushNamed(Routes.testResultAddScreen); }, child: Container( padding: EdgeInsets.all(_deviceBlockSize),