diff --git a/lib/pages/CyclePages/cycle_add_screen.dart b/lib/pages/CyclePages/cycle_add_screen.dart index c328015..a9fb902 100755 --- a/lib/pages/CyclePages/cycle_add_screen.dart +++ b/lib/pages/CyclePages/cycle_add_screen.dart @@ -75,14 +75,17 @@ class _CycleAddScreenState extends State { final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; return Consumer(builder: (context, cyclesProvider, _) { - return WillPopScope( - onWillPop: () async { - cyclesProvider.resetLoadingButton(); - Navigator.pushReplacementNamed( - context, - Routes.cycleResultScreen, - ); - return true; + 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( @@ -116,254 +119,253 @@ class _CycleAddScreenState extends State { 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, - ), + ? 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, + ), + ), + 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, ), - SizedBox( - height: 20, + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, ), - 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, - ), - ), - ), - ), - ], + isDense: true, + labelText: 'Strilizer ID', + contentPadding: + EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, ), - 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( - text: 'Select Labels included', - iconColor: kPinkSub, - deviceBlockSize: _deviceBlockSize, - values: - cycleProvider.labelValues[index], - vals: cycleProvider.labelVals, - initialLabelValue: - cycleProvider.initialLabelValue, - index: index, - hasRemoveButton: - 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, - ), - 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, - ), - ], + ), + 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), + ), + 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( + text: 'Select Labels included', + iconColor: kPinkSub, + deviceBlockSize: _deviceBlockSize, + values: + cycleProvider.labelValues[index], + vals: cycleProvider.labelVals, + initialLabelValue: + cycleProvider.initialLabelValue, + index: index, + hasRemoveButton: + 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, + ), + 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(); }, ), ), ), - ), - ); + ),); }); } } diff --git a/lib/pages/CyclePages/cycle_filter_screen.dart b/lib/pages/CyclePages/cycle_filter_screen.dart index 2eddb2c..505b360 100755 --- a/lib/pages/CyclePages/cycle_filter_screen.dart +++ b/lib/pages/CyclePages/cycle_filter_screen.dart @@ -29,12 +29,15 @@ class _CycleFilterScreenState extends State { TextEditingController dateCTRL = new TextEditingController(); DateTime? dateTimeFrom; + // String dateValue; List> hospitalVals = []; + // String curhospitalVal; bool isInit = true; CycleFilterObject? filters; + @override void initState() { filters = Provider.of(context, listen: false).filters; @@ -88,13 +91,16 @@ 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 WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.cycleResultScreen, - ); - return true; + 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( @@ -104,7 +110,12 @@ class _CycleFilterScreenState extends State { child: Scaffold( appBar: AppBar( titleSpacing: -10, - title: Text('Cycles', style: TextStyle(color: Colors.white,),), + title: Text( + 'Cycles', + style: TextStyle( + color: Colors.white, + ), + ), backgroundColor: Colors.black, leading: IconButton( icon: Icon( diff --git a/lib/pages/CyclePages/cycle_scan_screen.dart b/lib/pages/CyclePages/cycle_scan_screen.dart index b91ebf7..3dda240 100755 --- a/lib/pages/CyclePages/cycle_scan_screen.dart +++ b/lib/pages/CyclePages/cycle_scan_screen.dart @@ -5,6 +5,7 @@ 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'; @@ -27,169 +28,181 @@ 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 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, + 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(), ), - 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, + 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, ), ), ), - 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; + 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, + // ); + } + }, + ); }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - 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, + ), + 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( + 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, + ), ), ), - ), - 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], + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - borderRadius: BorderRadius.circular(7), + keyboardType: TextInputType.number, ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, + ), + 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 f2c80fe..9c84222 100755 --- a/lib/pages/ItemPages/item_add_screen.dart +++ b/lib/pages/ItemPages/item_add_screen.dart @@ -115,13 +115,16 @@ class _ItemAddScreenState extends State { final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; final itemProviderObject = Provider.of(context); - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.itemResultScreen, - ); - return true; + 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( diff --git a/lib/pages/ItemPages/item_filter_screen.dart b/lib/pages/ItemPages/item_filter_screen.dart index e05189a..58e23d3 100755 --- a/lib/pages/ItemPages/item_filter_screen.dart +++ b/lib/pages/ItemPages/item_filter_screen.dart @@ -32,6 +32,7 @@ class _ItemFilterScreenState extends State { List> hospitalVals = []; bool isInit = true; ItemFilterObject? filters; + @override void initState() { filters = Provider.of(context, listen: false).filters; @@ -83,13 +84,16 @@ class _ItemFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.itemResultScreen, - ); - return true; + 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( @@ -99,7 +103,12 @@ class _ItemFilterScreenState extends State { child: Scaffold( appBar: AppBar( titleSpacing: -10, - title: Text('Items', style: TextStyle(color: Colors.white,),), + title: Text( + 'Items', + style: TextStyle( + color: Colors.white, + ), + ), backgroundColor: Colors.black, leading: IconButton( icon: Icon( diff --git a/lib/pages/ItemPages/item_scan_screen.dart b/lib/pages/ItemPages/item_scan_screen.dart index 6ccbcfd..4c74469 100755 --- a/lib/pages/ItemPages/item_scan_screen.dart +++ b/lib/pages/ItemPages/item_scan_screen.dart @@ -5,6 +5,7 @@ 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'; @@ -25,169 +26,181 @@ 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 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, + 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(), ), - 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, + 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, ), ), ), - 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; + 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, + // ); + } + }, + ); }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - 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, + ), + 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( + 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, + ), ), ), - ), - 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], + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - borderRadius: BorderRadius.circular(7), + keyboardType: TextInputType.number, ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, + ), + 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 31f90d4..b4ce28e 100755 --- a/lib/pages/LabelPages/label_add_screen.dart +++ b/lib/pages/LabelPages/label_add_screen.dart @@ -77,14 +77,17 @@ class _LabelAddScreenState extends State { // String initialLabelValue; return Consumer( builder: (context, labelsProvider, _) { - return WillPopScope( - onWillPop: () async { - labelsProvider.resetLoadingButton(); - Navigator.pushReplacementNamed( - context, - Routes.labelResultScreen, - ); - return true; + 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( diff --git a/lib/pages/LabelPages/label_filter_screen.dart b/lib/pages/LabelPages/label_filter_screen.dart index e7d337a..79a39fa 100755 --- a/lib/pages/LabelPages/label_filter_screen.dart +++ b/lib/pages/LabelPages/label_filter_screen.dart @@ -31,6 +31,7 @@ class _LabelFilterScreenState extends State { List> hospitalVals = []; bool isInit = true; LabelFilterObject? filters; + @override void initState() { filters = Provider.of(context, listen: false).filters; @@ -79,13 +80,16 @@ class _LabelFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.labelResultScreen, - ); - return true; + 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( @@ -95,7 +99,12 @@ class _LabelFilterScreenState extends State { child: Scaffold( appBar: AppBar( titleSpacing: -10, - title: Text('Labels', style: TextStyle(color: Colors.white,),), + title: Text( + 'Labels', + style: TextStyle( + color: Colors.white, + ), + ), backgroundColor: Colors.black, leading: IconButton( icon: Icon( diff --git a/lib/pages/LabelPages/label_scan_screen.dart b/lib/pages/LabelPages/label_scan_screen.dart index 738eb8f..78cdb29 100755 --- a/lib/pages/LabelPages/label_scan_screen.dart +++ b/lib/pages/LabelPages/label_scan_screen.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../config/routes.dart'; import '../../providers/connectivity.dart'; import '../../widgets/Global/internet_error.dart'; import '../../widgets/LabelScreens/Scan/input_box.dart'; import '../../widgets/LabelScreens/Scan/save_button.dart'; import '../../widgets/LabelScreens/Scan/scan_box.dart'; + // import 'package:flutter/services.dart'; // import 'package:barcode_scan2/barcode_scan2.dart'; @@ -28,67 +30,79 @@ 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 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, + 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(), ), - 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, + 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( + LabelScanBox(), + SizedBox( + height: 10, + ), + Form( + key: _form, + child: LabelScanInputBox( + idCTRL: idCTRL, + deviceBlockSize: _deviceBlockSize, + ), + ), + SizedBox( + height: 70, + ), + FilterScanSaveButton( + form: _form, idCTRL: idCTRL, deviceBlockSize: _deviceBlockSize, ), - ), - SizedBox( - height: 70, - ), - FilterScanSaveButton( - form: _form, - idCTRL: idCTRL, - deviceBlockSize: _deviceBlockSize, - ), - ], - ) - : ConnectionErrorBox(); - }, + ], + ) + : ConnectionErrorBox(); + }, + ), ), ), ), diff --git a/lib/pages/MyItemsPages/my_items_filter_screen.dart b/lib/pages/MyItemsPages/my_items_filter_screen.dart index 8e0e684..3940026 100755 --- a/lib/pages/MyItemsPages/my_items_filter_screen.dart +++ b/lib/pages/MyItemsPages/my_items_filter_screen.dart @@ -29,6 +29,7 @@ class _MyItemsFilterScreenState extends State { bool isInit = true; ItemFilterObject? filters; + @override void initState() { filters = Provider.of(context, listen: false).filters; @@ -52,13 +53,16 @@ class _MyItemsFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.myItemsResultScreen, - ); - return true; + 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( @@ -68,7 +72,12 @@ class _MyItemsFilterScreenState extends State { child: Scaffold( appBar: AppBar( titleSpacing: -10, - title: Text('My Items', style: TextStyle(color: Colors.white,),), + title: Text( + 'My Items', + style: TextStyle( + color: Colors.white, + ), + ), backgroundColor: Colors.black, leading: IconButton( icon: Icon( diff --git a/lib/pages/MyItemsPages/my_items_scan_screen.dart b/lib/pages/MyItemsPages/my_items_scan_screen.dart index b47e7b8..d842d60 100755 --- a/lib/pages/MyItemsPages/my_items_scan_screen.dart +++ b/lib/pages/MyItemsPages/my_items_scan_screen.dart @@ -5,6 +5,7 @@ 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'; @@ -25,169 +26,181 @@ 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 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, + 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(), ), - 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, + 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, ), ), ), - 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; + 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, + // ); + } + }, + ); }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - 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, + ), + 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( + 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, + ), ), ), - ), - 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], + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - borderRadius: BorderRadius.circular(7), + keyboardType: TextInputType.number, ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, + ), + 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/MyPackagesPages/my_packages_filter_screen.dart b/lib/pages/MyPackagesPages/my_packages_filter_screen.dart index 179f2d9..2a788d2 100755 --- a/lib/pages/MyPackagesPages/my_packages_filter_screen.dart +++ b/lib/pages/MyPackagesPages/my_packages_filter_screen.dart @@ -22,10 +22,12 @@ class _MyPackageFilterScreenState extends State { TextEditingController idCTRL = new TextEditingController(); TextEditingController hospitalCTRL = new TextEditingController(); TextEditingController nameCTRL = new TextEditingController(); + // TextEditingController udiCTRL = new TextEditingController(); bool isInit = true; PackageFilterObject? filters; + @override void initState() { filters = Provider.of(context, listen: false).filters; @@ -49,13 +51,16 @@ class _MyPackageFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.myPackagesResultScreen, - ); - return true; + 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( @@ -65,7 +70,12 @@ class _MyPackageFilterScreenState extends State { child: Scaffold( appBar: AppBar( titleSpacing: -10, - title: Text('My Packages', style: TextStyle(color: Colors.white,),), + title: Text( + 'My Packages', + style: TextStyle( + color: Colors.white, + ), + ), backgroundColor: Colors.black, leading: IconButton( icon: Icon( diff --git a/lib/pages/MyPackagesPages/my_packages_scan_screen.dart b/lib/pages/MyPackagesPages/my_packages_scan_screen.dart index cd13e76..c253b36 100755 --- a/lib/pages/MyPackagesPages/my_packages_scan_screen.dart +++ b/lib/pages/MyPackagesPages/my_packages_scan_screen.dart @@ -5,6 +5,7 @@ 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'; @@ -25,169 +26,181 @@ 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 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, + 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(), ), - 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, + 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, ), ), ), - 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; + 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, + // ); + } + }, + ); }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - 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, + ), + 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( + 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, + ), ), ), - ), - 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], + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - borderRadius: BorderRadius.circular(7), + keyboardType: TextInputType.number, ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, + ), + 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/PackagePages/package_add_screen.dart b/lib/pages/PackagePages/package_add_screen.dart index 10108d7..240ab75 100755 --- a/lib/pages/PackagePages/package_add_screen.dart +++ b/lib/pages/PackagePages/package_add_screen.dart @@ -66,14 +66,17 @@ class _PackageAddScreenState extends State { final double _deviceBlockSize = _devicewidth / 100; return Consumer( builder: (context, packageProvider, _) { - return WillPopScope( - onWillPop: () async { - packageProvider.resetLoadingButton(); - Navigator.pushReplacementNamed( - context, - Routes.packageResultScreen, - ); - return true; + 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( diff --git a/lib/pages/PackagePages/package_filter_screen.dart b/lib/pages/PackagePages/package_filter_screen.dart index c546a50..9e46944 100755 --- a/lib/pages/PackagePages/package_filter_screen.dart +++ b/lib/pages/PackagePages/package_filter_screen.dart @@ -22,11 +22,13 @@ class _PackageFilterScreenState extends State { TextEditingController idCTRL = new TextEditingController(); TextEditingController hospitalCTRL = new TextEditingController(); TextEditingController nameCTRL = new TextEditingController(); + // TextEditingController udiCTRL = new TextEditingController(); List> hospitalVals = []; bool isInit = true; PackageFilterObject? filters; + @override void initState() { filters = Provider.of(context, listen: false).filters; @@ -76,13 +78,16 @@ class _PackageFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.packageResultScreen, - ); - return true; + 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( @@ -92,7 +97,12 @@ class _PackageFilterScreenState extends State { child: Scaffold( appBar: AppBar( titleSpacing: -10, - title: Text('Packages', style: TextStyle(color: Colors.white,),), + title: Text( + 'Packages', + style: TextStyle( + color: Colors.white, + ), + ), backgroundColor: Colors.black, leading: IconButton( icon: Icon( diff --git a/lib/pages/PackagePages/package_scan_screen.dart b/lib/pages/PackagePages/package_scan_screen.dart index e7ee0e3..ffce36d 100755 --- a/lib/pages/PackagePages/package_scan_screen.dart +++ b/lib/pages/PackagePages/package_scan_screen.dart @@ -5,6 +5,7 @@ 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'; @@ -25,169 +26,181 @@ 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 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, + 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(), ), - 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, + 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, ), ), ), - 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; + 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, + // ); + } + }, + ); }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - 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, + ), + 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( + 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, + ), ), ), - ), - 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], + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - borderRadius: BorderRadius.circular(7), + keyboardType: TextInputType.number, ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, + ), + 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 c7c1494..a25151d 100755 --- a/lib/pages/TestPages/test_add_screen.dart +++ b/lib/pages/TestPages/test_add_screen.dart @@ -23,6 +23,7 @@ class _TestResultAddScreenState extends State { TextEditingController testCodeCTRL = new TextEditingController(); bool isInit = true; + @override void didChangeDependencies() { if (isInit) { @@ -48,19 +49,27 @@ 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 WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.testResultScreen, - ); - return true; + 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,),), + title: Text( + 'Test Results', + style: TextStyle( + color: Colors.white, + ), + ), backgroundColor: Colors.black, leading: IconButton( icon: Icon( diff --git a/lib/pages/TestPages/test_filter_screen.dart b/lib/pages/TestPages/test_filter_screen.dart index 10358ec..3d7bbee 100755 --- a/lib/pages/TestPages/test_filter_screen.dart +++ b/lib/pages/TestPages/test_filter_screen.dart @@ -128,13 +128,16 @@ 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 WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.testResultScreen, - ); - return true; + 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( diff --git a/lib/pages/TestPages/test_form_page.dart b/lib/pages/TestPages/test_form_page.dart index e9b10ea..66b7673 100755 --- a/lib/pages/TestPages/test_form_page.dart +++ b/lib/pages/TestPages/test_form_page.dart @@ -96,13 +96,16 @@ class _FormPageState extends State { @override Widget build(BuildContext context) { - return WillPopScope( - onWillPop: () async { - Navigator.pushReplacementNamed( - context, - Routes.testResultAddScreen, - ); - return true; + 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( diff --git a/lib/pages/TestPages/test_scan_screen.dart b/lib/pages/TestPages/test_scan_screen.dart index 0e6f5e1..8d87b4f 100755 --- a/lib/pages/TestPages/test_scan_screen.dart +++ b/lib/pages/TestPages/test_scan_screen.dart @@ -4,6 +4,7 @@ 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,161 +27,173 @@ 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 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, + 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(), ), - 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, + 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, ), ), ), - 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; + 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, + // ); + } + }, + ); }, - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, - ), - 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, + ), + 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( + 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, + ), ), ), - ), - 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], + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - borderRadius: BorderRadius.circular(7), + keyboardType: TextInputType.number, ), - child: Align( - alignment: Alignment.center, - child: Text( - 'Search', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, + ), + 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(); + }, + ), ), ), );