diff --git a/android/app/build.gradle b/android/app/build.gradle index 1333a9f..49865d4 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -39,7 +39,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.cssd" - minSdkVersion 18 + minSdkVersion 21 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 702af6d..5d8f11e 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -9,7 +9,7 @@ FlutterApplication and put your custom class here. --> HomePage(), Routes.loginScreen: (ctx) => LoginScreen(), + Routes.forgetPassScreen: (ctx) => ForgetPassScreen(), Routes.myInfoScreen: (ctx) => MyInfoScreen(), Routes.testResultScreen: (ctx) => TestResultScreen(), Routes.testDetailsScreen: (ctx) => TestDetailsScreen(), @@ -122,9 +129,14 @@ class MyApp extends StatelessWidget { Routes.labelScanScreen: (ctx) => LabelScanScreen(), Routes.cycleAddScreen: (ctx) => CycleAddScreen(), Routes.labelAddScreen: (ctx) => LabelAddScreen(), + Routes.labelUpdateScreen: (ctx) => LabelUpdateScreen(), Routes.labelResultScreen: (ctx) => LabelResultScreen(), Routes.cycleResultScreen: (ctx) => CycleResultScreen(), Routes.testVerifyScreen: (ctx) => TestVerifyScreen(), + Routes.testScanScreen: (ctx) => TestScanScreen(), + Routes.sendCodeScreen: (ctx) => VerifyPassScreen(), + Routes.rePassScreen: (ctx) => RePassScreen(), + Routes.captureImageScreen: (ctx) => CaptureImage(), }, ); }, diff --git a/lib/models/cycles_models.dart b/lib/models/cycles_models.dart index f75b9be..4d18e2c 100644 --- a/lib/models/cycles_models.dart +++ b/lib/models/cycles_models.dart @@ -13,18 +13,21 @@ class CycleResultObject { } class CycleDetailObject { - final String id; // - final String description; // - final String createDate; // - final String date; // - final String sterileId; // - final String cycleNumber; // + final String id; + final String description; + final String createDate; + final String hospitalName; + + final String date; + final String sterileId; + final String cycleNumber; final List labels; CycleDetailObject({ @required this.id, @required this.description, @required this.createDate, + @required this.hospitalName, @required this.date, @required this.sterileId, @required this.cycleNumber, diff --git a/lib/models/label_models.dart b/lib/models/label_models.dart index f3a2a1f..550ca37 100644 --- a/lib/models/label_models.dart +++ b/lib/models/label_models.dart @@ -3,11 +3,13 @@ import 'package:flutter/cupertino.dart'; class LabelResultObject { final String id; final String package; + final String packageId; final String expireDate; LabelResultObject({ @required this.id, @required this.package, + @required this.packageId, @required this.expireDate, }); } @@ -15,6 +17,9 @@ class LabelResultObject { class LabelDetailsObject { final String id; final String package; + final String packageId; + final String hospitalName; + final String createDate; final String expireDate; final String sterileDate; @@ -25,6 +30,8 @@ class LabelDetailsObject { LabelDetailsObject({ @required this.id, @required this.package, + @required this.packageId, + @required this.hospitalName, @required this.createDate, @required this.expireDate, @required this.sterileDate, diff --git a/lib/models/test_result_models.dart b/lib/models/test_result_models.dart index f9332a5..9a5b30b 100644 --- a/lib/models/test_result_models.dart +++ b/lib/models/test_result_models.dart @@ -7,6 +7,7 @@ class TestResultObject { final String result; final String date; final String hospital; + final String verified; TestResultObject({ @required this.id, @@ -15,7 +16,7 @@ class TestResultObject { @required this.result, @required this.date, @required this.hospital, - + @required this.verified, }); } @@ -28,7 +29,6 @@ class TestResultFilterObject { final String fDate; final String uDate; - TestResultFilterObject({ @required this.id, @required this.labelID, @@ -37,6 +37,5 @@ class TestResultFilterObject { @required this.testType, @required this.fDate, @required this.uDate, - }); } diff --git a/lib/pages/cycle_add_screen.dart b/lib/pages/cycle_add_screen.dart index 1c84829..8176a70 100644 --- a/lib/pages/cycle_add_screen.dart +++ b/lib/pages/cycle_add_screen.dart @@ -5,7 +5,7 @@ import 'package:cssd/providers/cycles.dart'; import 'package:cssd/widgets/CycleScreens/Add/add_label_box.dart'; import 'package:cssd/widgets/CycleScreens/Add/date_picker.dart'; import 'package:cssd/widgets/CycleScreens/Add/save_button.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -76,202 +76,211 @@ class _CycleAddScreenState 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 Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Cycles'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.cycleResultScreen, + ); + return true; + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Cycles'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.cycleResultScreen), ), - onPressed: () => Navigator.of(context) - .pushReplacementNamed(Routes.cycleResultScreen), ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : 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, - ), - - 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); - }, - ), - SizedBox( - height: 30, - ), - 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: 20, - ), - Container( - margin: EdgeInsets.symmetric(vertical: 10), - child: Text( - 'LABELS INCLUDED', + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'ADD A CYCLE', style: TextStyle( - color: Colors.deepOrange, - letterSpacing: 2, + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + + 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); + }, ), - ), - Consumer( - builder: (ctx, cycleProvider, _) => - ListView.builder( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - itemBuilder: (ctx, index) => CycleAddLabelBox( - deviceBlockSize: _deviceBlockSize, - labelValues: cycleProvider.labelValues[index], - labelVals: cycleProvider.labelVals, - initialLabelValue: - cycleProvider.initialLabelValue, - index: index, + SizedBox( + height: 30, + ), + 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), ), - itemCount: cycleProvider.labelValues.length, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_descriptionFocosNode); + }, ), - ), - CycleAddDatePicker( - dateCTRL: dateCTRL, - deviceBlockSize: _deviceBlockSize), - 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), + SizedBox( + height: 20, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + Container( + margin: EdgeInsets.symmetric(vertical: 10), + child: Text( + 'LABELS INCLUDED', + style: TextStyle( + color: Colors.deepOrange, + letterSpacing: 2, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + Consumer( + builder: (ctx, cycleProvider, _) => + ListView.builder( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (ctx, index) => CycleAddLabelBox( + deviceBlockSize: _deviceBlockSize, + labelValues: cycleProvider.labelValues[index], + labelVals: cycleProvider.labelVals, + initialLabelValue: + cycleProvider.initialLabelValue, + index: index, + ), + itemCount: cycleProvider.labelValues.length, + ), ), - 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, - ), - // DropDownBox(values: ['Washer ID']), - ], + CycleAddDatePicker( + dateCTRL: dateCTRL, + deviceBlockSize: _deviceBlockSize), + 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, + ), + + // DropDownBox(values: ['Washer ID']), + ], + ), ), - ), - ) - : ConnectionErrorBox(); - }), + ) + : ConnectionErrorBox(); + }), + ), ); } } diff --git a/lib/pages/cycle_detail_screen.dart b/lib/pages/cycle_detail_screen.dart index 0c050bf..caa9734 100644 --- a/lib/pages/cycle_detail_screen.dart +++ b/lib/pages/cycle_detail_screen.dart @@ -2,7 +2,7 @@ import 'package:cssd/models/cycles_models.dart'; import 'package:cssd/providers/connectivity.dart'; import 'package:cssd/providers/cycles.dart'; import 'package:cssd/widgets/CycleScreens/Details/datas_box.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/lib/pages/cycle_filter_screen.dart b/lib/pages/cycle_filter_screen.dart index 308d912..f1df39b 100644 --- a/lib/pages/cycle_filter_screen.dart +++ b/lib/pages/cycle_filter_screen.dart @@ -1,16 +1,16 @@ -import 'package:cssd/config/routes.dart'; -import 'package:cssd/models/cycles_models.dart'; -import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/providers/cycles.dart'; -import 'package:cssd/widgets/CycleScreens/Filter/date_picker.dart'; -import 'package:cssd/widgets/CycleScreens/Filter/save_button.dart'; -import 'package:cssd/widgets/CycleScreens/Filter/selector_box.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; -import 'package:flutter/cupertino.dart'; + +import '../config/routes.dart'; +import '../models/cycles_models.dart'; +import '../providers/connectivity.dart'; +import '../providers/cycles.dart'; +import '../widgets/CycleScreens/Filter/date_picker.dart'; +import '../widgets/CycleScreens/Filter/save_button.dart'; +import '../widgets/CycleScreens/Filter/selector_box.dart'; +import '../widgets/Global/internet_error.dart'; class CycleFilterScreen extends StatefulWidget { // static const route = '/CycleFilterScreen'; @@ -40,7 +40,8 @@ class _CycleFilterScreenState extends State { filters = Provider.of(context, listen: false).filters; cycleIdCTRL.text = filters.id; cycleNumberCTRL.text = filters.cycleNumber; - dateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + // dateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + dateCTRL.text = ''; striizerIdCTRL.text = filters.sterilizerId; // dateValue = DateFormat('y-M-d').format(DateTime.now()); super.initState(); @@ -56,7 +57,12 @@ class _CycleFilterScreenState extends State { (result) { setState( () { - hospitalVals = result; + hospitalVals = [ + {'id': '', 'name': ''} + ]; + for (var hospital in result) { + hospitalVals.add(hospital); + } filters.hospital == '' ? hospitalCTRL.text = hospitalVals[0]['name'] : hospitalVals.forEach( @@ -82,160 +88,170 @@ 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 Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Cycles'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.cycleResultScreen, + ); + return true; + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Cycles'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.cycleResultScreen), ), - onPressed: () => Navigator.of(context) - .pushReplacementNamed(Routes.cycleResultScreen), ), + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'FILTER RESULTS', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + ), + SizedBox( + height: 20, + ), + 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); + }, + ), + 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, + ), + 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, + ), + SizedBox( + height: 20, + ), + CycleFilterSelectorBox( + 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(); + }), ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'FILTER RESULTS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - 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); - }, - ), - 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, - ), - 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, - ), - SizedBox( - height: 20, - ), - CycleFilterSelectorBox( - deviceBlockSize: _deviceBlockSize, - hospitalCTRL: hospitalCTRL, - hospitalVals: hospitalVals, - ), - 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/cycle_result_screen.dart b/lib/pages/cycle_result_screen.dart index 9279b9d..cbcc02a 100644 --- a/lib/pages/cycle_result_screen.dart +++ b/lib/pages/cycle_result_screen.dart @@ -5,7 +5,7 @@ import 'package:cssd/widgets/CycleScreens/Result/banner.dart'; import 'package:cssd/widgets/CycleScreens/Result/data_box.dart'; import 'package:cssd/widgets/CycleScreens/Result/filter_objects.dart'; import 'package:cssd/widgets/CycleScreens/Result/search_box.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import '../providers/cycles.dart'; diff --git a/lib/pages/cycle_scan_screen.dart b/lib/pages/cycle_scan_screen.dart index 98fa41a..745461f 100644 --- a/lib/pages/cycle_scan_screen.dart +++ b/lib/pages/cycle_scan_screen.dart @@ -1,12 +1,12 @@ -import 'package:cssd/config/routes.dart'; import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:barcode_scan/barcode_scan.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; class CycleScanScreen extends StatefulWidget { // static const route = '/cycleScanScreen'; @@ -86,10 +86,13 @@ class _CycleScanScreenState extends State { } else if (result == 'access') { print('access'); } else { - Navigator.of(context).pushNamed( - Routes.cycleDetailScreen, - arguments: result, + launch( + 'https://cssd-doc.com/Show/Cycle/$result', ); + // Navigator.of(context).pushNamed( + // Routes.cycleDetailScreen, + // arguments: result, + // ); } }, ); @@ -149,17 +152,20 @@ class _CycleScanScreenState extends State { if (!_form.currentState.validate()) { return; } - Navigator.of(context).pushNamed( - Routes.cycleDetailScreen, - arguments: idCTRL.text, + 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, ), - margin: EdgeInsets.symmetric(horizontal: 20), + margin: EdgeInsets.only(bottom: 50,left: 20,right: 20), decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.red, Colors.orange], diff --git a/lib/pages/forget_pass_screen.dart b/lib/pages/forget_pass_screen.dart new file mode 100644 index 0000000..8db1d38 --- /dev/null +++ b/lib/pages/forget_pass_screen.dart @@ -0,0 +1,198 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../config/routes.dart'; +import '../providers/auth.dart'; +import '../providers/connectivity.dart'; +import '../widgets/Global/internet_error.dart'; + +class ForgetPassScreen extends StatefulWidget { + // static const route = '/HomeScreen'; + + @override + State createState() { + return _ForgetPassScreenState(); + } +} + +class _ForgetPassScreenState extends State { + final _form = GlobalKey(); + bool _isLoading = false; + final cellNumberController = TextEditingController(); + + + @override + void initState() { + cellNumberController.text = ''; + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void _showDialog(String message) { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Error'), + content: Text(message), + actions: [ + FlatButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ); + } + + void _requestCode() async { + if (!_form.currentState.validate()) { + return; + } + _form.currentState.save(); + setState(() { + _isLoading = true; + }); + // try { + await Provider.of(context) + .requestCode( + cellNumberController.text, + ) + .then( + (result) { + if (result == 'NotUser') { + _showDialog('User Not Found!!!'); + setState( + () { + _isLoading = false; + }, + ); + } else{ + // _showDialog('User or password incorrect!'); + Navigator.of(context).popAndPushNamed(Routes.sendCodeScreen); + // setState( + // () { + // _isLoading = false; + // }, + // ); + } + }, + ); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('CSSD'), + ), + body: Selector( + builder: (ctx, value, _) => value != 'offline' + ? _isLoading + ? Center( + child: CircularProgressIndicator(), + ) + : Form( + key: _form, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text( + 'FORGET PASSWORD', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, + ), + ), + ), + TextFormField( + validator: (value) { + if (value.isEmpty) { + return 'Cell number is required.'; + } + RegExp regExp = + RegExp(r'^09[0,1,2,3,9]{1}[0-9]{8}$'); + if (!regExp.hasMatch(value)) { + return 'Enter a valid cell number'; + } + return null; + }, + controller: cellNumberController, + decoration: InputDecoration( + icon: Icon( + Icons.call, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Cell Number', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + keyboardType: TextInputType.phone, + textInputAction: TextInputAction.next, + + onSaved: (value) { + cellNumberController.text = value; + }, + ), + SizedBox(height: 40), + Row( + children: [ + InkWell( + onTap: () => _requestCode(), + child: Container( + width: 40 * _deviceBlockSize, + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blue, Colors.green], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Text( + 'Request Code', + style: TextStyle(color: Colors.white), + ), + ), + ), + Spacer(), + ], + ), + SizedBox(height: 10), + ], + ), + ) + : ConnectionErrorBox(), + selector: (_, connectivity) => connectivity.conStatus, + ), + ); + } +} diff --git a/lib/pages/home_screen.dart b/lib/pages/home_screen.dart index a5b969c..38a13d3 100644 --- a/lib/pages/home_screen.dart +++ b/lib/pages/home_screen.dart @@ -1,16 +1,17 @@ -import 'package:cssd/pages/cycle_result_screen.dart'; -import 'package:cssd/pages/label_result_screen.dart'; -// import 'package:cssd/pages/my_test_result.dart'; -import 'package:cssd/pages/test_result_screen.dart'; -import 'package:cssd/providers/auth.dart'; -import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/widgets/Global/drawer.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; import 'package:double_back_to_close_app/double_back_to_close_app.dart'; import 'package:flutter/material.dart'; import 'package:flutter_phoenix/flutter_phoenix.dart'; import 'package:provider/provider.dart'; + import './my_info_screen.dart'; +import '../providers/auth.dart'; +import '../providers/connectivity.dart'; +import '../widgets/Global/drawer.dart'; +import '../widgets/Global/internet_error.dart'; +import 'cycle_result_screen.dart'; +import 'label_result_screen.dart'; +import 'test_result_screen.dart'; +import 'test_verify_screen.dart'; class HomePage extends StatelessWidget { // 09338736511 @@ -18,7 +19,8 @@ class HomePage extends StatelessWidget { // static const route = '/HomeScreen'; @override Widget build(BuildContext context) { - final userData = Provider.of(context).user; + final userData = Provider.of(context,listen: false).user; + // print(userData['roles']); return Scaffold( resizeToAvoidBottomPadding: false, drawer: Selector( @@ -84,8 +86,8 @@ class HomePage extends StatelessWidget { child: Container( margin: EdgeInsets.only( top: 0, bottom: 10, left: 20, right: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( margin: EdgeInsets.only(top: 20, bottom: 10), @@ -134,16 +136,22 @@ class HomePage extends StatelessWidget { secondLine: 'List, Details & Add a one', onTap: CycleResultScreen(), ), - userData['roles'].contains('Admin') + // SelectionItem( + // startColor: Color(0xFFA7CCE1), + // endColor: Color(0xFFECF7ED), + // firstLine: 'image', + // secondLine: 'image', + // onTap: CaptureImage(), + // ), + userData['roles'].contains('User') ? Container() - // SelectionItem( - // startColor: Color(0xFFA7CCE1), - // endColor: Color(0xFFECF7ED), - // firstLine: 'TEST TO VERIFY', - // secondLine: 'List, Details & Add a one', - // onTap: TestVerifyScreen(), - // ) - : Container(), + : SelectionItem( + startColor: Color(0xFFA7CCE1), + endColor: Color(0xFFECF7ED), + firstLine: 'TEST TO VERIFY', + secondLine: 'List, Details & Add a one', + onTap: TestVerifyScreen(), + ), ], ), ), diff --git a/lib/pages/label_add_screen.dart b/lib/pages/label_add_screen.dart index c3ca9d1..686a836 100644 --- a/lib/pages/label_add_screen.dart +++ b/lib/pages/label_add_screen.dart @@ -1,15 +1,16 @@ -import 'package:cssd/config/routes.dart'; -import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/providers/labels.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; -import 'package:cssd/widgets/LabelScreens/Add/date_picker.dart'; -import 'package:cssd/widgets/LabelScreens/Add/save_button.dart'; -import 'package:cssd/widgets/LabelScreens/Add/selector_box.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:intl/intl.dart' as DateEditor; import 'package:provider/provider.dart'; +import '../config/routes.dart'; +import '../providers/connectivity.dart'; +import '../providers/labels.dart'; +import '../widgets/Global/internet_error.dart'; +import '../widgets/LabelScreens/Add/date_picker.dart'; +import '../widgets/LabelScreens/Add/save_button.dart'; +import '../widgets/LabelScreens/Add/selector_box.dart'; + class LabelAddScreen extends StatefulWidget { // static const route = '/LabelAddScreen'; @@ -75,194 +76,204 @@ class _LabelAddScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Labels'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.labelResultScreen, + ); + return true; + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Labels'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.labelResultScreen), ), - onPressed: () => Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen), ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : 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, - ), - 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, + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(), + ) + : 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, ), ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + SizedBox( + height: 20, ), - keyboardType: TextInputType.visiblePassword, - textInputAction: TextInputAction.next, - onFieldSubmitted: (_) { - FocusScope.of(context) - .requestFocus(_cycleNumberFocusNode); - }, - ), - SizedBox( - height: 20, - ), - TextFormField( - onChanged: (val) { - setState( - () { + 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, + 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, + ), ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - isDense: true, - labelText: 'Cycle Number', - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_cycleNumberFocusNode); + }, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + SizedBox( + height: 20, ), - 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, + 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), ), - 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, ), + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + SizedBox( + height: 20, ), - keyboardType: TextInputType.visiblePassword, - ), - SizedBox( - height: 20, - ), - LabelAddSelectorBox( - deviceBlockSize: _deviceBlockSize, - packageCTRL: packageCTRL, - packageVals: packageVals, - packageValue: packageValue, - ), - SizedBox( - height: 10, - ), - LabelAddDatePicker( - dateCTRL: sDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Sterile Date', - ), - SizedBox( - height: 20, - ), - LabelAddDatePicker( - dateCTRL: eDateCTRL, - deviceBlockSize: _deviceBlockSize, - label: 'Sterile Date', - ), - SizedBox( - height: 70, - ), - LabelAddSaveButton( - form: _form, - lotNumberCTRL: lotNumberCTRL, - cycleNumberCTRL: cycleNumberCTRL, - sDateCTRL: sDateCTRL, - packageValue: packageValue, - eDateCTRL: eDateCTRL, - striizerIdCTRL: striizerIdCTRL, - deviceBlockSize: _deviceBlockSize, - ), - SizedBox( - height: 100, - ), - ], + 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, + ), + LabelAddSelectorBox( + deviceBlockSize: _deviceBlockSize, + packageCTRL: packageCTRL, + packageVals: packageVals, + packageValue: packageValue, + ), + 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: packageValue, + eDateCTRL: eDateCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), ), - ), - ) - : ConnectionErrorBox(); - }), + ) + : ConnectionErrorBox(); + }), + ), ); } } diff --git a/lib/pages/label_detail_screen.dart b/lib/pages/label_detail_screen.dart index e72dc48..885fb22 100644 --- a/lib/pages/label_detail_screen.dart +++ b/lib/pages/label_detail_screen.dart @@ -1,7 +1,7 @@ import 'package:cssd/models/label_models.dart'; import 'package:cssd/providers/connectivity.dart'; import 'package:cssd/providers/labels.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:cssd/widgets/LabelScreens/Detail/datas_box.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/lib/pages/label_filter_screen.dart b/lib/pages/label_filter_screen.dart index bc7121c..93c3309 100644 --- a/lib/pages/label_filter_screen.dart +++ b/lib/pages/label_filter_screen.dart @@ -2,7 +2,7 @@ import 'package:cssd/config/routes.dart'; import 'package:cssd/models/label_models.dart'; import 'package:cssd/providers/connectivity.dart'; import 'package:cssd/providers/labels.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:cssd/widgets/LabelScreens/Filter/save_button.dart'; import 'package:cssd/widgets/LabelScreens/Filter/selector_box.dart'; import 'package:flutter/material.dart'; @@ -50,7 +50,13 @@ class _LabelFilterScreenState extends State { (result) { setState( () { - hospitalVals = result; + hospitalVals = [ + {'id': '', 'name': ''} + ]; + for (var hospital in result) { + hospitalVals.add(hospital); + } + // hospitalVals = result; filters.hospital == '' ? hospitalCTRL.text = hospitalVals[0]['name'] : hospitalVals.forEach( @@ -74,154 +80,163 @@ class _LabelFilterScreenState extends State { final _media = MediaQuery.of(context); final double _devicewidth = _media.size.width; final double _deviceBlockSize = _devicewidth / 100; - return Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Labels'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.labelResultScreen, + ); + return true; + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Labels'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.labelResultScreen), ), - onPressed: () => Navigator.of(context) - .pushReplacementNamed(Routes.labelResultScreen), ), - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - children: [ - Text( - 'FILTER RESULTS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - TextFormField( - controller: labelIdCTRl, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'FILTER RESULTS', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, + ), + SizedBox( + height: 20, + ), + 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), ), - 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); - }, - ), - SizedBox( - height: 30, - ), - TextFormField( - controller: cycleNumberCTRL, - 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.number, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_cycleNumberFocusNode); + }, + ), + 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), ), - 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, - ), - TextFormField( - controller: striizerIdCTRL, - 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, + focusNode: _cycleNumberFocusNode, + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + onFieldSubmitted: (_) { + FocusScope.of(context) + .requestFocus(_strilizerIdFocusNode); + }, + ), + SizedBox( + height: 30, + ), + 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), ), - 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, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + SizedBox( + height: 30, ), - textInputAction: TextInputAction.done, - keyboardType: TextInputType.visiblePassword, - focusNode: _strilizerIdFocusNode, - ), - 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(); - }, + 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/label_result_screen.dart b/lib/pages/label_result_screen.dart index 9d5d371..16949e2 100644 --- a/lib/pages/label_result_screen.dart +++ b/lib/pages/label_result_screen.dart @@ -1,7 +1,7 @@ import 'package:cssd/config/routes.dart'; import 'package:cssd/providers/connectivity.dart'; import 'package:cssd/widgets/Global/page_header.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:cssd/widgets/LabelScreens/Result/data_box.dart'; import 'package:cssd/widgets/LabelScreens/Result/filter_chip_box.dart'; import 'package:cssd/widgets/LabelScreens/Result/floating_buttons.dart'; diff --git a/lib/pages/label_scan_screen.dart b/lib/pages/label_scan_screen.dart index 3b9f5cc..81c98be 100644 --- a/lib/pages/label_scan_screen.dart +++ b/lib/pages/label_scan_screen.dart @@ -1,5 +1,5 @@ import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:cssd/widgets/LabelScreens/Scan/input_box.dart'; import 'package:cssd/widgets/LabelScreens/Scan/save_button.dart'; import 'package:cssd/widgets/LabelScreens/Scan/scan_box.dart'; diff --git a/lib/pages/label_update_screen.dart b/lib/pages/label_update_screen.dart new file mode 100644 index 0000000..42b5adf --- /dev/null +++ b/lib/pages/label_update_screen.dart @@ -0,0 +1,303 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:intl/intl.dart' as DateEditor; +import 'package:provider/provider.dart'; + +import '../config/routes.dart'; +import '../models/label_models.dart'; +import '../providers/connectivity.dart'; +import '../providers/labels.dart'; +import '../widgets/Global/internet_error.dart'; +import '../widgets/LabelScreens/Add/date_picker.dart'; +import '../widgets/LabelScreens/Add/selector_box.dart'; +import '../widgets/LabelScreens/Add/update_button.dart'; + +class LabelUpdateScreen extends StatefulWidget { + // static const route = '/LabelUpdateScreen'; + + @override + _LabelUpdateScreenState createState() => _LabelUpdateScreenState(); +} + +class _LabelUpdateScreenState extends State { + final _cycleNumberFocusNode = FocusNode(); + TextEditingController lotNumberCTRL = new TextEditingController(); + TextEditingController cycleNumberCTRL = new TextEditingController(); + TextEditingController striizerIdCTRL = new TextEditingController(); + TextEditingController sDateCTRL = new TextEditingController(); + TextEditingController eDateCTRL = new TextEditingController(); + TextEditingController packageCTRL = new TextEditingController(); + + DateTime dateTimeS; + // String sDateValue; + // String eDateValue; + + final _form = GlobalKey(); + + List> packageVals = []; + List packageValue = []; + bool isEmpty = false; + bool isInit = true; + LabelDetailsObject datas; + // CycleFilterObject filters; + + List labelsCTRL = [TextEditingController()]; + int curLabelVal = 1; + @override + void initState() { + sDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + // sDateValue = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + eDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + // eDateValue = DateEditor.DateFormat('y-M-d').format(DateTime.now()); + super.initState(); + } + + @override + void didChangeDependencies() async { + if (isInit) { + var _id = ModalRoute.of(context).settings.arguments; + await Provider.of(context, listen: false) + .showLabelResult(_id.toString()) + .then( + (result) { + setState( + () { + // if (result.id == 'null') { + // isEmpty = true; + // } + datas = result; + lotNumberCTRL.text = datas.lotNumber; + cycleNumberCTRL.text = datas.cycleNumber; + striizerIdCTRL.text = datas.sterileId; + sDateCTRL.text = datas.sterileDate; + eDateCTRL.text = datas.expireDate; + packageValue.add(datas.packageId); + packageValue.add(datas.package); + packageCTRL.text = datas.package; + }, + ); + }, + ); + Provider.of(context, listen: false) + .getPackageFilters() + .then( + (result) { + setState( + () { + packageVals = result; + isInit = false; + }, + ); + }, + ); + } + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + 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; + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Labels'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context) + .pushReplacementNamed(Routes.labelResultScreen), + ), + ), + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(), + ) + : Form( + key: _form, + child: Padding( + padding: EdgeInsets.all(20), + child: ListView( + children: [ + Text( + 'Update A LABEL', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 20, + ), + 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); + }, + ), + 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, + ), + LabelAddSelectorBox( + deviceBlockSize: _deviceBlockSize, + packageCTRL: packageCTRL, + packageVals: packageVals, + packageValue: packageValue, + ), + 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, + ), + LabelUpdateButton( + form: _form, + id: datas.id, + lotNumberCTRL: lotNumberCTRL, + cycleNumberCTRL: cycleNumberCTRL, + sDateCTRL: sDateCTRL, + packageValue: packageValue, + eDateCTRL: eDateCTRL, + striizerIdCTRL: striizerIdCTRL, + deviceBlockSize: _deviceBlockSize, + ), + SizedBox( + height: 100, + ), + ], + ), + ), + ) + : ConnectionErrorBox(); + }), + ), + ); + } +} diff --git a/lib/pages/login_screen.dart b/lib/pages/login_screen.dart index 408d5a3..04dd8c5 100644 --- a/lib/pages/login_screen.dart +++ b/lib/pages/login_screen.dart @@ -1,6 +1,7 @@ +import 'package:cssd/config/routes.dart'; import 'package:cssd/providers/auth.dart'; import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; @@ -281,7 +282,8 @@ class _LoginScreenState extends State { ), ), ), - onPressed: () {}, + onPressed: () => Navigator.of(context) + .pushNamed(Routes.forgetPassScreen), ), ], ), diff --git a/lib/pages/my_info_screen.dart b/lib/pages/my_info_screen.dart index f9eedf1..f18ebd6 100644 --- a/lib/pages/my_info_screen.dart +++ b/lib/pages/my_info_screen.dart @@ -1,6 +1,6 @@ // import 'package:cssd/widgets/LabelScreens/LabelDetails/header.dart'; import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:cssd/widgets/LabelScreens/Detail/header.dart'; import 'package:cssd/widgets/MyInfo/input_box.dart'; import 'package:flutter/material.dart'; @@ -73,6 +73,7 @@ class _MyInfoScreenState extends State { deviceBlockSize: _deviceBlockSize, label: 'Full Name', icon: FontAwesomeIcons.sortNumericDown, + inputType: TextInputType.text, ), SizedBox( height: 20, @@ -110,6 +111,7 @@ class _MyInfoScreenState extends State { deviceBlockSize: _deviceBlockSize, label: 'Email Address', icon: FontAwesomeIcons.envelope, + inputType: TextInputType.emailAddress, ), SizedBox( height: 40, @@ -138,10 +140,28 @@ class _MyInfoScreenState extends State { onTap: () async { await Provider.of(context, listen: false) .setUserData( - user['id'], - usernameCTRL.text, - emailCTRL.text, - ); + user['id'], + usernameCTRL.text, + emailCTRL.text, + ) + .then( + (value) async => await showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text( + 'Info changed successfully.', + ), + actions: [ + FlatButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ), + ); Navigator.of(context).pop(); }, ), diff --git a/lib/pages/rePass_screen.dart b/lib/pages/rePass_screen.dart new file mode 100644 index 0000000..b9983ef --- /dev/null +++ b/lib/pages/rePass_screen.dart @@ -0,0 +1,240 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +import '../providers/auth.dart'; +import '../providers/connectivity.dart'; +import '../widgets/Global/internet_error.dart'; + +class RePassScreen extends StatefulWidget { + // static const route = '/HomeScreen'; + + @override + State createState() { + return _RePassScreenState(); + } +} + +class _RePassScreenState extends State { + final _form = GlobalKey(); + bool _isLoading = false; + // final cellNumberController = TextEditingController(); + final passwordController = new TextEditingController(); + final rePasswordController = new TextEditingController(); + String token = 'Bearer '; + // String token = 'Bearer '; + + bool _hidePass = true; + bool _hideRePass = true; + bool isInit = true; + + @override + void didChangeDependencies() { + if (isInit) { + token += ModalRoute.of(context).settings.arguments; + isInit = false; + } + super.didChangeDependencies(); + } + + Future _showDialog(String message) async{ + await showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text(message), + actions: [ + FlatButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ); + } + + void _sendRePass() async { + if (!_form.currentState.validate()) { + return; + } + _form.currentState.save(); + setState(() { + _isLoading = true; + }); + await Provider.of(context) + .sendRePass(passwordController.text, token) + .then((value) async{ + if (value == 'done') { + await _showDialog('Password changed successfully.Now login to your account.'); + Navigator.of(context).pop(); + } + }); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('CSSD'), + ), + body: Selector( + builder: (ctx, value, _) => value != 'offline' + ? _isLoading + ? Center( + child: CircularProgressIndicator(), + ) + : Form( + key: _form, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text( + 'CHANGE PASSWORD', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 6 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, + ), + ), + ), + TextFormField( + validator: (value) { + if (value.isEmpty) { + return 'Password is required.'; + } + if (value.length < 8) { + return 'Password at least is 8 characters.'; + } + return null; + }, + obscureText: _hidePass, + controller: passwordController, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.starOfLife, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Password', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + suffixIcon: InkWell( + child: Icon(FontAwesomeIcons.eye), + onTap: () { + setState(() { + _hidePass = !_hidePass; + }); + }, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + _sendRePass(); + }, + keyboardType: TextInputType.visiblePassword, + ), + SizedBox( + height: 30, + ), + TextFormField( + validator: (value) { + if (value.length < 8) { + return 'Password at least is 8 characters.'; + } + if (value != passwordController.text) { + return 'Password doesnt match!'; + } + return null; + }, + obscureText: _hideRePass, + controller: rePasswordController, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.starOfLife, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Confirm Password', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, horizontal: 3), + suffixIcon: InkWell( + child: Icon(FontAwesomeIcons.eye), + onTap: () { + setState(() { + _hideRePass = !_hideRePass; + }); + }, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + ), + textInputAction: TextInputAction.done, + onFieldSubmitted: (_) { + _sendRePass(); + }, + keyboardType: TextInputType.visiblePassword, + ), + SizedBox(height: 40), + Row( + children: [ + InkWell( + onTap: () => _sendRePass(), + child: Container( + width: 40 * _deviceBlockSize, + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blue, Colors.green], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Text( + 'Change', + style: TextStyle( + color: Colors.white, + ), + textAlign: TextAlign.center, + ), + ), + ), + Spacer(), + ], + ), + SizedBox(height: 10), + ], + ), + ) + : ConnectionErrorBox(), + selector: (_, connectivity) => connectivity.conStatus, + )); + } +} diff --git a/lib/pages/test_add_screen.dart b/lib/pages/test_add_screen.dart index 7fcab39..43a8f50 100644 --- a/lib/pages/test_add_screen.dart +++ b/lib/pages/test_add_screen.dart @@ -1,6 +1,6 @@ import 'package:cssd/config/routes.dart'; import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:cssd/widgets/TestResultScreens/Add/selector_box.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -51,203 +51,215 @@ 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 Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Test Results'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.testResultScreen, + ); + return true; + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Test Results'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + // padding: EdgeInsets.all(0), + onPressed: () => + Navigator.of(context).popAndPushNamed(Routes.testResultScreen), ), - // padding: EdgeInsets.all(0), - onPressed: () => - Navigator.of(context).popAndPushNamed(Routes.testResultScreen), ), - ), - body: Consumer(builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : 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, + body: Consumer(builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(), + ) + : ListView( + padding: + EdgeInsets.symmetric(horizontal: 20, vertical: 20), + children: [ + Container( + padding: EdgeInsets.only( + top: 10, ), - ), - ), - 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, - ), + child: Text( + 'ADD A TEST RESULT', + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, ), ), ), - onTap: () { - scan().then( - (String result) { - if (result == 'cancel') { - print('cancel'); - } else if (result == 'error') { - print('error'); - } else if (result == 'access') { - print('access'); - } else { - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) { - return FormPage( - uniqueCode: result, - ); - }, - ), - ); - } - }, - ); - }, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 70 * _deviceBlockSize, - child: TestResultAddSelectorBox( - deviceBlockSize: _deviceBlockSize, - dataCTRL: testTypeCTRL, - dataVals: testTypeVals, - label: 'Choose a Test Type'), + 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, + ), ), - 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]; - }); - } + ), + ), + onTap: () { + scan().then( + (String result) { + if (result == 'cancel') { + print('cancel'); + } else if (result == 'error') { + print('error'); + } else if (result == 'access') { + print('access'); + } else { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) { + return FormPage( + uniqueCode: result, + ); }, - controller: testIdCTRL, - 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.number, ), - ), - ], - ) - ], - ), - SizedBox( - width: 5 * _deviceBlockSize, - ), - Expanded( - child: Container( - height: 100, - child: FlatButton( - padding: EdgeInsets.all(0), - color: Color(0xFFEB4A64), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), + ); + } + }, + ); + }, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 70 * _deviceBlockSize, + child: TestResultAddSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: testTypeCTRL, + dataVals: testTypeVals, + label: 'Choose a Test Type'), ), - child: Text( - 'GO', - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 6 * _deviceBlockSize, - fontWeight: FontWeight.w700), - ), - onPressed: () { - if (testIdCTRL.text != '') { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return FormPage( - uniqueCode: testIdCTRL.text); - }, + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text( + 'OR', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 7 * _deviceBlockSize, ), - ); - } else if (testTypeCTRL.text != '') { - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) { - return FormPage( - name: testTypeCTRL.text, - ); + ), + SizedBox( + width: 8 * _deviceBlockSize, + ), + Container( + width: 50 * _deviceBlockSize, + child: TextFormField( + onChanged: (val) { + if (val != '') { + setState(() { + testTypeCTRL.text = ''; + }); + } else { + setState(() { + testTypeCTRL.text = + testTypeVals[0]; + }); + } }, + controller: testIdCTRL, + 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.number, ), - ); - } - // print(testCode); - }, - ), + ), + ], + ) + ], ), - ) - ], - ), - ], - ) - : ConnectionErrorBox(); - }), + SizedBox( + width: 5 * _deviceBlockSize, + ), + Expanded( + child: Container( + height: 100, + margin: EdgeInsets.only(bottom: 50), + child: FlatButton( + padding: EdgeInsets.all(0), + color: Color(0xFFEB4A64), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + child: Text( + 'GO', + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 6 * _deviceBlockSize, + fontWeight: FontWeight.w700), + ), + onPressed: () { + if (testIdCTRL.text != '') { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return FormPage( + uniqueCode: testIdCTRL.text); + }, + ), + ); + } else if (testTypeCTRL.text != '') { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) { + return FormPage( + name: testTypeCTRL.text, + ); + }, + ), + ); + } + // print(testCode); + }, + ), + ), + ) + ], + ), + ], + ) + : ConnectionErrorBox(); + }), + ), ); } diff --git a/lib/pages/test_detail_screen.dart b/lib/pages/test_detail_screen.dart index 07046a9..999f012 100644 --- a/lib/pages/test_detail_screen.dart +++ b/lib/pages/test_detail_screen.dart @@ -1,6 +1,6 @@ import 'package:cssd/providers/connectivity.dart'; import 'package:cssd/providers/test_results.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:cssd/widgets/TestResultScreens/Details/datas_box.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/lib/pages/test_filter_screen.dart b/lib/pages/test_filter_screen.dart index 7018893..31a122b 100644 --- a/lib/pages/test_filter_screen.dart +++ b/lib/pages/test_filter_screen.dart @@ -1,16 +1,15 @@ -import 'package:cssd/config/routes.dart'; -import 'package:cssd/models/test_result_models.dart'; -import 'package:cssd/providers/connectivity.dart'; -import 'package:cssd/providers/test_results.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; -import 'package:cssd/widgets/TestResultScreens/Filter/date_picker.dart'; -import 'package:cssd/widgets/TestResultScreens/Filter/selector_box.dart'; - +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; -import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; -import 'package:flutter/cupertino.dart'; + +import '../config/routes.dart'; +import '../models/test_result_models.dart'; +import '../providers/connectivity.dart'; +import '../providers/test_results.dart'; +import '../widgets/Global/internet_error.dart'; +import '../widgets/TestResultScreens/Filter/date_picker.dart'; +import '../widgets/TestResultScreens/Filter/selector_box.dart'; class TestFilterScreen extends StatefulWidget { // static const route = '/TestFilterScreen'; @@ -34,8 +33,9 @@ class _TestFilterScreenState extends State { DateTime dateTimeUntil; final List labelIDVals = [ + '', 'Washer ID', - 'Autocleave ID', + 'Autoclave ID', 'Sterilizer ID', 'Seal Machine ID', 'Patiant ID', @@ -44,8 +44,8 @@ class _TestFilterScreenState extends State { 'OR ID', 'Insrtument ID', 'Basket ID', - 'Impalent ID', - 'None', + 'Implant ID', + // 'None', ]; // String curLabelIDVal; @@ -53,7 +53,7 @@ class _TestFilterScreenState extends State { Map testTypes; final List hospitalVals = []; - Map hospitals; + Map hospitals = {}; // String curhospitalVal; bool isInit = true; @@ -71,8 +71,10 @@ class _TestFilterScreenState extends State { @override void didChangeDependencies() { if (isInit) { - fDateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); - uDateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + // fDateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + // uDateCTRL.text = DateFormat('y-M-d').format(DateTime.now()); + fDateCTRL.text = ''; + uDateCTRL.text = ''; var testResultProviderObject = Provider.of(context, listen: false); TestResultFilterObject filters = testResultProviderObject.filters; @@ -85,10 +87,11 @@ class _TestFilterScreenState extends State { testResultProviderObject.getFilterItems().then((result) { hospitals = result[0]; testTypes = result[1]; - + hospitalVals.add(''); for (var hospital in result[0].keys) { hospitalVals.add(hospital); } + testTypeVals.add(''); for (var testType in result[1].keys) { testTypeVals.add(testType); } @@ -118,219 +121,228 @@ 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 Scaffold( - appBar: AppBar( - titleSpacing: -10, - title: Text('Tests'), - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, - ), - onPressed: () => Navigator.of(context).popAndPushNamed( - Routes.testResultScreen, + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.testResultScreen, + ); + return true; + }, + child: Scaffold( + appBar: AppBar( + titleSpacing: -10, + title: Text('Tests'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), + onPressed: () => Navigator.of(context).popAndPushNamed( + Routes.testResultScreen, + ), ), ), - ), - body: Consumer( - builder: (ct, connection, _) { - return connection.conStatus != 'offline' - ? isInit - ? Center( - child: CircularProgressIndicator(), - ) - : Padding( - padding: EdgeInsets.all(20), - child: ListView( - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'FILTER RESULTS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - ), - ), - SizedBox( - height: 20, - ), - TextFormField( - controller: idCTRL, - decoration: InputDecoration( - icon: Icon( - FontAwesomeIcons.sortNumericDown, - size: 6 * _deviceBlockSize, + body: Consumer( + builder: (ct, connection, _) { + return connection.conStatus != 'offline' + ? isInit + ? Center( + child: CircularProgressIndicator(), + ) + : Padding( + padding: EdgeInsets.all(20), + child: ListView( + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'FILTER RESULTS', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, + ), + SizedBox( + height: 20, + ), + 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), ), - 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); + // }, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + SizedBox( + height: 25, + ), + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: labelIdCTRL, + dataVals: labelIDVals, + label: 'Label ID', + ), + SizedBox( + height: 25, ), - keyboardType: TextInputType.number, - textInputAction: TextInputAction.next, - // onFieldSubmitted: (_) { - // FocusScope.of(context) - // .requestFocus(_cycleNumberFocusNode); - // }, - ), - 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, + 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), ), - labelStyle: TextStyle( - fontWeight: FontWeight.w100, - fontSize: 4 * _deviceBlockSize, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, ), - labelText: 'Username', - isDense: true, - contentPadding: EdgeInsets.symmetric( - vertical: 2, horizontal: 3), + keyboardType: TextInputType.visiblePassword, + textInputAction: TextInputAction.next, + // onFieldSubmitted: (_) { + // FocusScope.of(context) + // .requestFocus(_cycleNumberFocusNode); + // }, ), - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, + SizedBox( + height: 25, + ), + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: testTypeCTRL, + dataVals: testTypeVals, + label: 'Test Type', + ), + SizedBox( + height: 25, + ), + TestResultFilterSelectorBox( + deviceBlockSize: _deviceBlockSize, + dataCTRL: hospitalCTRL, + dataVals: hospitalVals, + label: 'Hospital', + ), + SizedBox( + height: 25, ), - 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, - ), - 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) - .setFilters( - idCTRL.text, - labelIdCTRL.text != 'None' - ? labelIdCTRL.text - : '', - usernameCTRL.text, - testTypeCTRL.text != 'None' - ? testTypes[testTypeCTRL.text] - : '', - hospitalCTRL.text != 'None' - ? hospitals[hospitalCTRL.text] - : '', - fDateCTRL.text, - uDateCTRL.text, - ); - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Filters changed.'), - actions: [ - FlatButton( - onPressed: () { - Navigator.of(ctx).pop(); - // Navigator.of(context).pop(); - }, - child: Text('Ok'), - ) - ], + 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) + .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: [ + FlatButton( + onPressed: () { + Navigator.of(ctx).pop(); + // Navigator.of(context).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then( + (_) => Navigator.of(context).popAndPushNamed( + Routes.testResultScreen, + ), + ); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, ), - ).then( - (_) => Navigator.of(context).popAndPushNamed( - Routes.testResultScreen, + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blue, Colors.green], + ), + borderRadius: BorderRadius.circular(7), ), - ); - }, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 5 * _deviceBlockSize, - vertical: 10, - ), - // margin: - // EdgeInsets.symmetric(horizontal: 35, vertical: 15), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Colors.blue, Colors.green], - ), - borderRadius: BorderRadius.circular(7), - ), - child: Align( - alignment: Alignment.center, - child: Text( - 'FILTER', - style: TextStyle( - color: Colors.white, - fontSize: 5 * _deviceBlockSize, + child: Align( + alignment: Alignment.center, + child: Text( + 'FILTER', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), ), ), ), ), - ), - SizedBox( - height: 70, - ), - // DropDownBox(values: ['Washer ID']), - ], - ), - ) - : ConnectionErrorBox(); - }, + SizedBox( + height: 70, + ), + // DropDownBox(values: ['Washer ID']), + ], + ), + ) + : ConnectionErrorBox(); + }, + ), ), ); } diff --git a/lib/pages/test_form_page.dart b/lib/pages/test_form_page.dart index 9ea7ff8..5618e09 100644 --- a/lib/pages/test_form_page.dart +++ b/lib/pages/test_form_page.dart @@ -4,6 +4,7 @@ import 'package:cssd/providers/test_results.dart'; import 'package:cssd/widgets/TestResultScreens/Add/form_creator.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:random_string/random_string.dart'; class FormPage extends StatefulWidget { final String name; @@ -26,39 +27,41 @@ class _FormPageState extends State { List> formInputs; void _saveForm() { + final batchId = randomString(10); formatData(formInputs); - if (this.widget.testResultId != null && this.widget.testResultId !=''){ + var prvObject = Provider.of(context, listen: false); + if (this.widget.testResultId != null && this.widget.testResultId != '') { values['_method'] = 'put'; - TestResultsProvider.updateTestResult(this.widget.testResultId, values).then((_){ + TestResultsProvider.updateTestResult(this.widget.testResultId, values) + .then((_) { Navigator.of(context).pop(); }); } else { setState(() { _isLoading = true; }); - TestResultsProvider.createTestResult(values).then((_) { + prvObject.createTestResult(values, batchId).then((result) { setState(() { _isLoading = false; }); - showDialog( - context: context, - builder: (ctx) => AlertDialog( - content: Text('Test added.'), - actions: [ - FlatButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('Ok'), - ) - ], - ), - ).then((_) { - Navigator.of(context).popAndPushNamed(Routes.testResultScreen); - }); + if (result == 'done') { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Test added.'), + actions: [ + FlatButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((value) => + Navigator.of(context).popAndPushNamed(Routes.testResultScreen)); + } }); - - } } @@ -70,11 +73,10 @@ class _FormPageState extends State { }); Provider.of(context) .getInputs( - testResultId: this.widget.testResultId ?? "", - name: this.widget.name ?? "", - uniqueCode: this.widget.uniqueCode ?? "", - testTypeId: this.widget.testTypeId ?? "" - ) + testResultId: this.widget.testResultId ?? "", + name: this.widget.name ?? "", + uniqueCode: this.widget.uniqueCode ?? "", + testTypeId: this.widget.testTypeId ?? "") .then((_) { setState(() { _isLoading = false; @@ -87,81 +89,93 @@ class _FormPageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - centerTitle: true, - title: Text('Add Test Result'), - actions: [ - IconButton( - icon: Icon(Icons.save), + return WillPopScope( + onWillPop: () async { + Navigator.pushReplacementNamed( + context, + Routes.testResultAddScreen, + ); + return true; + }, + child: Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('Add Test Result'), + actions: [ + IconButton( + icon: Icon(Icons.save), + onPressed: () { + _saveForm(); + }, + ) + ], + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + size: 35, + ), onPressed: () { - _saveForm(); + Navigator.of(context).popAndPushNamed(Routes.testResultScreen); }, - ) - ], - leading: IconButton( - icon: Icon( - Icons.keyboard_arrow_left, - size: 35, ), - onPressed: () { - Navigator.of(context).popAndPushNamed(Routes.testResultScreen); - }, ), - ), - body: Column( - children: [ - Expanded( - child: _isLoading - ? Center(child: CircularProgressIndicator()) - : Form( - key: _form, - child: Consumer( - builder: (context, inputs, _) { - formInputs = inputs.inputItems; - // print(formInputs); - return formInputs.length != 0 ? FormCreator( - form: inputs.inputItems, - onChanged: (value) { - formInputs = value; - }, - ) : Center(child: Text('An error happen!!!'),); - }, + body: Column( + children: [ + Expanded( + child: _isLoading + ? Center(child: CircularProgressIndicator()) + : Form( + key: _form, + child: Consumer( + builder: (context, inputs, _) { + formInputs = inputs.inputItems; + return formInputs.length != 0 + ? FormCreator( + form: inputs.inputItems, + onChanged: (value) { + formInputs = value; + }, + ) + : Center( + child: Text('An error happen!!!'), + ); + }, + ), ), - ), - ), - // 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, - // ), - // ), - // ), - ], - )); + ), + // 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, + // ), + // ), + // ), + ], + )), + ); } void formatData(inputs) { for (var input in inputs) { - if(input['type'] != 'Form') { - if(input['key'] == 'result') { + if (input['type'] != 'Form') { + if (input['key'] == 'result') { values[input["key"]] = input["value"] ? "Accept" : "Reject"; // print('${input["key"]} : ${input["value"] ? "Accept" : "Reject"}'); - } else if(input['key'] == 'date') { + } else if (input['key'] == 'date') { var date = input["value"]; - + values[input["key"]] = "${date.year}-${date.month}-${date.day}"; } else { values[input["key"]] = input["value"]; @@ -172,7 +186,6 @@ class _FormPageState extends State { formatData(input['children']); } } - print(values); - + print(values); } } diff --git a/lib/pages/test_result_screen.dart b/lib/pages/test_result_screen.dart index da8f0aa..8ec1d02 100644 --- a/lib/pages/test_result_screen.dart +++ b/lib/pages/test_result_screen.dart @@ -3,7 +3,7 @@ import 'package:cssd/models/test_result_models.dart'; import 'package:cssd/providers/connectivity.dart'; // import 'package:cssd/providers/test_result.dart'; import 'package:cssd/providers/test_results.dart'; -import 'package:cssd/widgets/Global/splash_screen%20copy.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; import 'package:cssd/widgets/TestResultScreens/Main/filter_chip_box.dart'; import 'package:cssd/widgets/TestResultScreens/Main/floating_button.dart'; import 'package:cssd/widgets/TestResultScreens/Main/search_box.dart'; @@ -342,10 +342,10 @@ class TestItemBox extends StatelessWidget { SizedBox( height: 15, ), - item.result == 'Verified' + item.result == 'Accepted' ? Text( - 'Verified', - style: TextStyle(color: Colors.blueAccent), + 'Accepted', + style: TextStyle(color: Colors.green), ) : Text( 'Rejected', @@ -366,56 +366,56 @@ class TestItemBox extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - item.result != 'Verified' - ? InkWell( - onTap: () { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text('Delete'), - content: Text( - 'Are you sure for delete this test?'), - actions: [ - FlatButton( - onPressed: () { - Provider.of( - context) - .removeTestResult( - item.id.toString()) - .then((_) { - Navigator.of(ctx).pop(); - }); - }, - child: Text('Yes'), - ), - FlatButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('No'), - ), - ], - ), - ); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.red, - ), - child: Icon( - Icons.delete, - size: 6 * _deviceBlockSize, - color: Colors.white, - ), - ), - ) - : Container(), - SizedBox( - width: _deviceBlockSize, - ), + // item.result != 'Accepted' + // ? InkWell( + // onTap: () { + // showDialog( + // context: context, + // builder: (ctx) => AlertDialog( + // title: Text('Delete'), + // content: Text( + // 'Are you sure for delete this test?'), + // actions: [ + // FlatButton( + // onPressed: () { + // Provider.of( + // context) + // .removeTestResult( + // item.id.toString()) + // .then((_) { + // Navigator.of(ctx).pop(); + // }); + // }, + // child: Text('Yes'), + // ), + // FlatButton( + // onPressed: () { + // Navigator.of(ctx).pop(); + // }, + // child: Text('No'), + // ), + // ], + // ), + // ); + // }, + // child: Container( + // padding: EdgeInsets.all(7), + // width: 10 * _deviceBlockSize, + // decoration: BoxDecoration( + // shape: BoxShape.circle, + // color: Colors.red, + // ), + // child: Icon( + // Icons.delete, + // size: 6 * _deviceBlockSize, + // color: Colors.white, + // ), + // ), + // ) + // : Container(), + // SizedBox( + // width: _deviceBlockSize, + // ), InkWell( onTap: () { Navigator.of(context).pushNamed( diff --git a/lib/pages/test_scan_screen.dart b/lib/pages/test_scan_screen.dart new file mode 100644 index 0000000..f531ff4 --- /dev/null +++ b/lib/pages/test_scan_screen.dart @@ -0,0 +1,213 @@ +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:barcode_scan/barcode_scan.dart'; + +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class TestScanScreen extends StatefulWidget { + // static const route = '/TestScanScreen'; + @override + State createState() { + return _TestScanScreenState(); + } +} + +class _TestScanScreenState extends State { + String testCode = ""; + TextEditingController idCTRL = new TextEditingController(); + final _form = GlobalKey(); + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return Scaffold( + appBar: AppBar( + centerTitle: true, + titleSpacing: -10, + title: Text('CSSD'), + leading: IconButton( + icon: Icon( + Icons.keyboard_arrow_left, + 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, + // ); + } + }, + ); + }, + ), + 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: 40, + ), + Divider( + color: Colors.black, + thickness: 3, + ), + SizedBox( + height: 30, + ), + 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, + ), + margin: EdgeInsets.only(bottom: 50, left: 20, right: 20), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.red, Colors.orange], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'GO!', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ), + ], + ) + : ConnectionErrorBox(); + }), + ); + } + + Future scan() async { + try { + var barcode = await BarcodeScanner.scan(); + if (barcode.type.name == 'Cancelled') { + return 'cancel'; + } else if (barcode.type.name == 'Failed') { + return 'error'; + } + try { + var id = barcode.rawContent.contains('www.cssd-doc.com') + ? barcode.rawContent.split('/')[5] + : barcode.rawContent; + + return id; + } catch (_) { + return 'null'; + } + } on PlatformException catch (_) { + return 'access'; + } catch (_) { + return 'error'; + } + } +} diff --git a/lib/pages/test_verify_screen.dart b/lib/pages/test_verify_screen.dart index 6c4d004..db0b7f8 100644 --- a/lib/pages/test_verify_screen.dart +++ b/lib/pages/test_verify_screen.dart @@ -1,18 +1,17 @@ -import 'package:cssd/config/routes.dart'; -import 'package:cssd/models/test_result_models.dart'; -// import 'package:cssd/providers/test_result.dart'; import 'package:cssd/providers/test_results.dart'; -import 'package:cssd/widgets/TestResultScreens/Main/filter_chip_box.dart'; import 'package:cssd/widgets/TestResultScreens/Main/search_box.dart'; import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; +import '../config/routes.dart'; +import '../models/test_result_models.dart'; +import '../providers/auth.dart'; + class TestVerifyScreen extends StatefulWidget { // static const route = '/TestVerifyScreen'; - final bool isAdmin; + // final bool isAdmin; - TestVerifyScreen({this.isAdmin}); + // TestVerifyScreen({this.isAdmin}); @override _TestVerifyScreenState createState() => _TestVerifyScreenState(); @@ -41,6 +40,7 @@ class _TestVerifyScreenState extends State { var testResults = Provider.of(context, listen: false); testResults.setLoading(); + testResults.resetFilters(); testResults.resetPageNumber(); testResults.getTestResults().then((_) { testResults.resetLoading(); @@ -64,6 +64,8 @@ class _TestVerifyScreenState extends State { @override Widget build(BuildContext context) { + final userData = Provider.of(context, listen: false).user; + final _media = MediaQuery.of(context); // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); final double _devicewidth = _media.size.width; @@ -101,153 +103,153 @@ class _TestVerifyScreenState extends State { ), ), ), - Spacer(), - InkWell( - onTap: () { - Navigator.of(context) - .popAndPushNamed(Routes.testFilterScreen); - }, - child: Container( - padding: EdgeInsets.all(7), - child: Icon( - FontAwesomeIcons.filter, - size: 7 * _deviceBlockSize, - ), - ), - ), + // Spacer(), + // InkWell( + // onTap: () { + // Navigator.of(context) + // .popAndPushNamed(Routes.testFilterScreen); + // }, + // child: Container( + // padding: EdgeInsets.all(7), + // child: Icon( + // FontAwesomeIcons.filter, + // size: 7 * _deviceBlockSize, + // ), + // ), + // ), ], ), SizedBox( height: 20, ), - Consumer( - builder: (context, testResult, _) { - return Container( - height: 50, - child: ListView( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - children: [ - InkWell( - onTap: () { - Navigator.of(context) - .popAndPushNamed(Routes.testFilterScreen); - }, - child: Chip( - backgroundColor: Colors.black, - label: Text( - 'Filters', - style: TextStyle( - color: Colors.white, - ), - ), - deleteIcon: Icon( - FontAwesomeIcons.filter, - color: Colors.white, - size: 4 * _deviceBlockSize, - ), - onDeleted: () { - Navigator.of(context) - .popAndPushNamed(Routes.testFilterScreen); - }, - ), - ), - testResult.filters.id != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'ID', - id: '', - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.labelID != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Label ID', - id: testResult.filters.id, - labelID: '', - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.testType != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Test Type', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: '', - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.hospital != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Hospital', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: '', - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.userName != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Username', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: '', - fDate: testResult.filters.fDate, - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.fDate != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'From Date', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: '', - uDate: testResult.filters.uDate, - ) - : Container(), - testResult.filters.uDate != '' - ? TestResultChip( - deviceBlockSize: _deviceBlockSize, - label: 'Until Date', - id: testResult.filters.id, - labelID: testResult.filters.labelID, - testType: testResult.filters.testType, - hospital: testResult.filters.hospital, - username: testResult.filters.userName, - fDate: testResult.filters.fDate, - uDate: '', - ) - : Container(), - ], - ), - ); - }, - ), + // Consumer( + // builder: (context, testResult, _) { + // return Container( + // height: 50, + // child: ListView( + // scrollDirection: Axis.horizontal, + // shrinkWrap: true, + // children: [ + // InkWell( + // onTap: () { + // Navigator.of(context) + // .popAndPushNamed(Routes.testFilterScreen); + // }, + // child: Chip( + // backgroundColor: Colors.black, + // label: Text( + // 'Filters', + // style: TextStyle( + // color: Colors.white, + // ), + // ), + // deleteIcon: Icon( + // FontAwesomeIcons.filter, + // color: Colors.white, + // size: 4 * _deviceBlockSize, + // ), + // onDeleted: () { + // Navigator.of(context) + // .popAndPushNamed(Routes.testFilterScreen); + // }, + // ), + // ), + // testResult.filters.id != '' + // ? TestResultChip( + // deviceBlockSize: _deviceBlockSize, + // label: 'ID', + // id: '', + // labelID: testResult.filters.labelID, + // testType: testResult.filters.testType, + // hospital: testResult.filters.hospital, + // username: testResult.filters.userName, + // fDate: testResult.filters.fDate, + // uDate: testResult.filters.uDate, + // ) + // : Container(), + // testResult.filters.labelID != '' + // ? TestResultChip( + // deviceBlockSize: _deviceBlockSize, + // label: 'Label ID', + // id: testResult.filters.id, + // labelID: '', + // testType: testResult.filters.testType, + // hospital: testResult.filters.hospital, + // username: testResult.filters.userName, + // fDate: testResult.filters.fDate, + // uDate: testResult.filters.uDate, + // ) + // : Container(), + // testResult.filters.testType != '' + // ? TestResultChip( + // deviceBlockSize: _deviceBlockSize, + // label: 'Test Type', + // id: testResult.filters.id, + // labelID: testResult.filters.labelID, + // testType: '', + // hospital: testResult.filters.hospital, + // username: testResult.filters.userName, + // fDate: testResult.filters.fDate, + // uDate: testResult.filters.uDate, + // ) + // : Container(), + // testResult.filters.hospital != '' + // ? TestResultChip( + // deviceBlockSize: _deviceBlockSize, + // label: 'Hospital', + // id: testResult.filters.id, + // labelID: testResult.filters.labelID, + // testType: testResult.filters.testType, + // hospital: '', + // username: testResult.filters.userName, + // fDate: testResult.filters.fDate, + // uDate: testResult.filters.uDate, + // ) + // : Container(), + // testResult.filters.userName != '' + // ? TestResultChip( + // deviceBlockSize: _deviceBlockSize, + // label: 'Username', + // id: testResult.filters.id, + // labelID: testResult.filters.labelID, + // testType: testResult.filters.testType, + // hospital: testResult.filters.hospital, + // username: '', + // fDate: testResult.filters.fDate, + // uDate: testResult.filters.uDate, + // ) + // : Container(), + // testResult.filters.fDate != '' + // ? TestResultChip( + // deviceBlockSize: _deviceBlockSize, + // label: 'From Date', + // id: testResult.filters.id, + // labelID: testResult.filters.labelID, + // testType: testResult.filters.testType, + // hospital: testResult.filters.hospital, + // username: testResult.filters.userName, + // fDate: '', + // uDate: testResult.filters.uDate, + // ) + // : Container(), + // testResult.filters.uDate != '' + // ? TestResultChip( + // deviceBlockSize: _deviceBlockSize, + // label: 'Until Date', + // id: testResult.filters.id, + // labelID: testResult.filters.labelID, + // testType: testResult.filters.testType, + // hospital: testResult.filters.hospital, + // username: testResult.filters.userName, + // fDate: testResult.filters.fDate, + // uDate: '', + // ) + // : Container(), + // ], + // ), + // ); + // }, + // ), TestResultSearchBox( searchCTRL: searchCTRL, deviceBlockSize: _deviceBlockSize, @@ -264,11 +266,18 @@ class _TestVerifyScreenState extends State { ) : ListView.builder( controller: sc, - itemBuilder: (context, index) => TestItemBox( - deviceBlockSize: _deviceBlockSize, - item: testResults.items[index], - id: testResults.items[index].id, - ), + itemBuilder: (context, index) => + (testResults.items[index].verified == 'None' && + userData['roles'] + .contains('Supervisor')) || + userData['roles'].contains('Admin') + ? TestItemBox( + deviceBlockSize: _deviceBlockSize, + item: testResults.items[index], + id: testResults.items[index].id, + userData: userData, + ) + : Container(), // Column( // children: [ // Text(testResults.items[index].name), @@ -303,11 +312,12 @@ class TestItemBox extends StatelessWidget { Key key, @required String id, @required double deviceBlockSize, - this.item, + @required this.item, + @required this.userData, }) : _deviceBlockSize = deviceBlockSize, // _id = id, super(key: key); - + final Map userData; final double _deviceBlockSize; // final String _id; @@ -348,17 +358,24 @@ class TestItemBox extends StatelessWidget { SizedBox( height: 15, ), - item.result == 'Verified' + item.verified == 'None' ? Text( - 'Verified', - style: TextStyle(color: Colors.blueAccent), - ) - : Text( 'Awaiting Verification', - style: TextStyle( - color: Colors.orange, - ), - ), + style: TextStyle(color: Colors.orange), + ) + : item.verified == 'Verified' + ? Text( + 'Verified', + style: TextStyle( + color: Colors.blueAccent, + ), + ) + : Text( + 'Rejected', + style: TextStyle( + color: Colors.red, + ), + ), ], ), Spacer(), @@ -372,85 +389,117 @@ class TestItemBox extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - item.result != 'Verified' - ? InkWell( - onTap: () { - showDialog( - context: context, - builder: (ctx) => AlertDialog( - title: Text('Verify'), - content: Text( - 'Are you sure for verify this test?'), - actions: [ - FlatButton( - onPressed: () { - // TestResultsProvider.updateTestResult( - // _id, - // {}) - // .then((_) { - // Navigator.of(context).pop(); - // }); - // Provider.of( - // context) - // .removeTestResult( - // item.id.toString()) - // .then((_) { - // Navigator.of(ctx).pop(); - // }); + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Verify'), + content: Text( + 'Are you sure for verify this test?'), + actions: [ + FlatButton( + onPressed: () async { + Provider.of( + context) + .changeVerification( + item.id, 'Verified') + .then((result) { + if (result) { + print('true'); + } Navigator.of(ctx).pop(); - }, - child: Text('Yes'), - ), - FlatButton( - onPressed: () { - Navigator.of(ctx).pop(); - }, - child: Text('No'), - ), - ], - ), - ); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Color.fromRGBO(0, 190, 190, 1), - ), - child: Icon( - Icons.check, - size: 6 * _deviceBlockSize, - color: Colors.white, + Navigator.of(context).popAndPushNamed( + Routes.testVerifyScreen); + }); + }, + child: Text('Yes'), + ), + FlatButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('No'), + ), + ], ), + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 10 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Color.fromRGBO(0, 190, 190, 1), ), - ) - : Container(), + child: Icon( + Icons.check, + size: 6 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox( + width: 3, + ), + InkWell( + onTap: () { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Reject'), + content: Text( + 'Are you sure for reject this test?'), + actions: [ + FlatButton( + onPressed: () async { + await Provider.of( + context) + .changeVerification( + item.id, 'NotVerified') + .then((result) { + if (result) { + print('true'); + } + Navigator.of(ctx).pop(); + Navigator.of(context).popAndPushNamed( + Routes.testVerifyScreen); + }); + }, + child: Text('Yes'), + ), + FlatButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('No'), + ), + ], + ), + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 10 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red, + ), + child: Icon( + Icons.close, + size: 6 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], + ), SizedBox( width: _deviceBlockSize, ), - InkWell( - onTap: () { - Navigator.of(context).pushNamed( - Routes.testDetailsScreen, - arguments: item.id, - ); - // TestDetail(testResultId: item.id.toString()); - }, - child: Container( - padding: EdgeInsets.all(7), - width: 10 * _deviceBlockSize, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.black, - ), - child: Icon( - FontAwesomeIcons.fileAlt, - size: 6 * _deviceBlockSize, - color: Colors.white, - ), - ), - ), ], ) ], diff --git a/lib/pages/verify_pass_screen.dart b/lib/pages/verify_pass_screen.dart new file mode 100644 index 0000000..55838d6 --- /dev/null +++ b/lib/pages/verify_pass_screen.dart @@ -0,0 +1,194 @@ +import 'package:cssd/config/routes.dart'; +import 'package:cssd/providers/auth.dart'; +import 'package:cssd/providers/connectivity.dart'; +import 'package:cssd/widgets/Global/internet_error.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:provider/provider.dart'; + +class VerifyPassScreen extends StatefulWidget { + // static const route = '/HomeScreen'; + + @override + State createState() { + return _VerifyPassScreenState(); + } +} + +class _VerifyPassScreenState extends State { + final _form = GlobalKey(); + bool _isLoading = false; + final codeCTRL = TextEditingController(); + + + @override + void initState() { + codeCTRL.text = ''; + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + void _showDialog(String message) { + showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: Text('Error'), + content: Text(message), + actions: [ + FlatButton( + child: Text('Ok'), + onPressed: () { + Navigator.of(ctx).pop(); + }, + ), + ], + ), + ); + } + + void _sendCode() async { + if (!_form.currentState.validate()) { + return; + } + _form.currentState.save(); + setState(() { + _isLoading = true; + }); + // try { + await Provider.of(context) + .sendCode( + codeCTRL.text, + ) + .then( + (result) { + if (result == 'wrong') { + _showDialog('Code is wrong!!!'); + setState( + () { + _isLoading = false; + }, + ); + } else { + Navigator.of(context) + .popAndPushNamed(Routes.rePassScreen, arguments: result); + } + }, + ); + } + + @override + Widget build(BuildContext context) { + final _media = MediaQuery.of(context); + // final double _pixelRatio = (_media.size.height / _media.size.width * 7 / 5); + final double _devicewidth = _media.size.width; + final double _deviceBlockSize = _devicewidth / 100; + return Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text('CSSD'), + ), + body: Selector( + builder: (ctx, value, _) => value != 'offline' + ? _isLoading + ? Center( + child: CircularProgressIndicator(), + ) + : Form( + key: _form, + child: ListView( + padding: EdgeInsets.symmetric(horizontal: 20), + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 20), + child: Text( + 'Send Verification Code', + textAlign: TextAlign.left, + style: TextStyle( + color: Colors.black, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + fontWeight: FontWeight.w700, + ), + ), + ), + TextFormField( + validator: (value) { + if (value.isEmpty) { + return 'Code is required.'; + } + if (value.length != 6) { + return 'Code most be 6 characters'; + } + return null; + }, + controller: codeCTRL, + decoration: InputDecoration( + icon: Icon( + FontAwesomeIcons.starOfLife, + size: 6 * _deviceBlockSize, + ), + labelStyle: TextStyle( + fontWeight: FontWeight.w100, + fontSize: 4 * _deviceBlockSize, + ), + labelText: 'Code', + isDense: true, + contentPadding: EdgeInsets.symmetric( + vertical: 2, + horizontal: 3, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + keyboardType: TextInputType.number, + onSaved: (value) { + codeCTRL.text = value; + }, + maxLength: 6, + ), + SizedBox(height: 40), + Row( + children: [ + InkWell( + onTap: () => _sendCode(), + child: Container( + width: 40 * _deviceBlockSize, + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blue, Colors.green], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Text( + 'Send Code', + textAlign: TextAlign.center, + style: TextStyle(color: Colors.white), + ), + ), + ), + Spacer(), + ], + ), + SizedBox(height: 10), + ], + ), + ) + : ConnectionErrorBox(), + selector: (_, connectivity) => connectivity.conStatus, + ), + ); + } +} diff --git a/lib/providers/auth.dart b/lib/providers/auth.dart index 92d6e2c..743d154 100644 --- a/lib/providers/auth.dart +++ b/lib/providers/auth.dart @@ -30,6 +30,78 @@ class Auth with ChangeNotifier { return {..._user}; } + Future requestCode(String cellNumber) async { + final response = await http.post( + Url.requestResetPass, + body: { + 'cell_number': cellNumber, + }, + // headers: {'X-Requested-With': 'XMLHttpRequest'}, + ); + final responseData = json.decode(response.body); + if (responseData['status'] == 'Faild') { + return 'NotUser'; + } else { + return 'Done'; + } + // print(responseData); + } + + Future sendCode(String code) async { + final response = await http.post( + Url.verifyResetPass, + body: { + 'code': code, + }, + // headers: {'X-Requested-With': 'XMLHttpRequest'}, + ); + final responseData = json.decode(response.body); + // if (responseData['status']=='Faild') { + // return 'NotUser'; + // } else { + // return 'Done'; + // } + print(responseData); + if (responseData['status']=='Faild') { + return 'wrong'; + } + else{ + return responseData['access_token']; + + } + } + + Future sendRePass(String password, String token) async { + print(password); + print(token); + + final response = await http.post( + Url.sendResetPass, + body: { + 'password': password, + 'password_confirmation': password, + }, + headers: { + 'Authorization': token, + 'X-Requested-With': 'XMLHttpRequest' + }, + // headers: {'X-Requested-With': 'XMLHttpRequest'}, + ); + final responseData = json.decode(response.body); + // if (responseData['status']=='Faild') { + // return 'NotUser'; + // } else { + // return 'Done'; + // } + print(responseData); + if (responseData['status']=='Success') { + return 'done'; + } + else{ + return 'error'; + } + } + Future login(String cellNumber, String password) async { final response = await http.post( Url.login, @@ -40,12 +112,11 @@ class Auth with ChangeNotifier { // headers: {'X-Requested-With': 'XMLHttpRequest'}, ); final responseData = json.decode(response.body); - // print(responseData); + print(responseData); if (response.statusCode == 401) { if (responseData['message'] == 'The user credentials were incorrect.') { return 'badinput'; // incorrect user or pass - } - else{ + } else { return 'error'; } } diff --git a/lib/providers/cycles.dart b/lib/providers/cycles.dart index ca267b0..3f9308c 100644 --- a/lib/providers/cycles.dart +++ b/lib/providers/cycles.dart @@ -222,6 +222,7 @@ class CyclesProvider extends ChangeNotifier { id: 'null', description: 'null', createDate: 'null', + hospitalName: 'null', date: '2020-01-01', sterileId: 'null', cycleNumber: 'null', @@ -233,10 +234,12 @@ class CyclesProvider extends ChangeNotifier { for (var label in data['labels']) { lablesList.add(label['id'].toString()); } + print(data); result = CycleDetailObject( id: data['id'].toString(), description: data['note'] != null ? data['note'] : '', createDate: data['created_at'] != null ? data['created_at'] : '', + hospitalName: data['user']['medical_center']['name'], date: data['date'] != null ? data['date'] : '', sterileId: data['sterilizer_id'] != null ? data['sterilizer_id'] : '', cycleNumber: data['cycle_number'] != null ? data['cycle_number'] : '', diff --git a/lib/providers/input.dart b/lib/providers/input.dart index 0f49ef1..8ce5e70 100644 --- a/lib/providers/input.dart +++ b/lib/providers/input.dart @@ -6,16 +6,21 @@ import 'package:cssd/config/urls.dart'; import 'package:cssd/config/user.dart'; class Inputs with ChangeNotifier { - List> inputItems = []; - Future getInputs({String testResultId = "", String name = "", String uniqueCode = "", String testTypeId = ""}) async { - print({ - 'test_type_id': testTypeId, - 'test_result_id': testResultId, - 'name': name, - 'unique_code': uniqueCode, - },); + Future getInputs( + {String testResultId = "", + String name = "", + String uniqueCode = "", + String testTypeId = ""}) async { + print( + { + 'test_type_id': testTypeId, + 'test_result_id': testResultId, + 'name': name, + 'unique_code': uniqueCode, + }, + ); var response = await http.post( Url.getInputs, body: { @@ -35,15 +40,13 @@ class Inputs with ChangeNotifier { return false; } final responseData = json.decode(response.body); - + // print(responseData); - + Map values; if (testResultId.isNotEmpty) { response = await http.get(Url.testResultFormValues(testResultId), - headers: { - 'Authorization': User.token - }); + headers: {'Authorization': User.token}); values = json.decode(response.body)['data']; } @@ -56,20 +59,41 @@ class Inputs with ChangeNotifier { String deviceLabel; if (values != null && values.isNotEmpty) { result = values['result'] == 'Accept' ? true : false; - dateTime = values['date'] == null ? DateTime.now() : DateTime.parse(values['date']); + dateTime = values['date'] == null + ? DateTime.now() + : DateTime.parse(values['date']); deviceLabel = values['device_id'] ?? ''; } - inputItems.add({'type': 'Label', 'key': 'test_type_id', 'name': general['name'], 'value': general['id']}); + inputItems.add({ + 'type': 'Label', + 'key': 'test_type_id', + 'name': general['name'], + 'value': general['id'] + }); + + inputItems.add({ + 'type': 'Text', + 'key': 'device_id', + 'name': general['device_label'], + 'value': deviceLabel + }); + inputItems.add( + {'type': 'Date', 'key': 'date', 'name': 'date', 'value': dateTime}); + inputItems.add( + {'type': 'Switch', 'key': 'result', 'name': 'Result', 'value': result}); - inputItems.add({'type': 'Text', 'key': 'device_id', 'name': general['device_label'], 'value': deviceLabel}); - inputItems.add({'type': 'Date', 'key': 'date' , 'name': 'date', 'value': dateTime}); - inputItems.add({'type': 'Switch', 'key': 'result', 'name': 'Result', 'value': result}); - setValues(inputs, values); for (var input in inputs) { inputItems.add(input as Map); } + inputItems.add({ + 'type': 'Image', + 'key': 'test_type_id', + 'name': general['name'], + 'value': general['id'] + }); + notifyListeners(); return true; } @@ -81,13 +105,17 @@ class Inputs with ChangeNotifier { } var key = "${input['name']}_${input['id']}"; input['key'] = key; - if(values != null && values.isNotEmpty && values.containsKey(key)) { - if (input['type'] == 'Range' || input['type'] == 'Temperature' || input['type'] == 'Pressure') { + if (values != null && values.isNotEmpty && values.containsKey(key)) { + if (input['type'] == 'Range' || + input['type'] == 'Temperature' || + input['type'] == 'Pressure') { input['value'] = double.parse(values[key]); - } else if (input['type'] == 'Switch'){ + } else if (input['type'] == 'Switch') { input['value'] = values[key] == "1" ? true : false; - } else if (input['type'] == 'Time'){ - input['value'] = values[key] == null ? '' : values[key].substring(0, 2) + ":" + values[key].substring(2, 4); + } else if (input['type'] == 'Time') { + input['value'] = values[key] == null + ? '' + : values[key].substring(0, 2) + ":" + values[key].substring(2, 4); } else { input['value'] = values[key]; } diff --git a/lib/providers/labels.dart b/lib/providers/labels.dart index 133ce00..f71df06 100644 --- a/lib/providers/labels.dart +++ b/lib/providers/labels.dart @@ -102,6 +102,41 @@ class LabelsProvider extends ChangeNotifier { print(response.body); } + Future updateLabelResult( + id, + lotNumber, + cycleNumber, + sterileDate, + package, + expireDate, + sterilizerId, + ) async { + // print(labs); + var response = await http.put(Url.updateLabelResult(id), + body: json.encode( + { + 'sterile_date': sterileDate, + 'expire_date': expireDate, + 'sterilizer_id': sterilizerId, + 'cycle_number': cycleNumber, + 'lot_number': lotNumber, + 'package_id': package['id'] + // 'package': { + // 'id': package['id'], + // 'name': package['name'], + // }, + }, + ), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }); + + print(response.body); + } + void setFilters(id, cycleNumber, sterilizerId, hospital) { pageNumber = 1; filters = LabelFilterObject( @@ -165,11 +200,13 @@ class LabelsProvider extends ChangeNotifier { } for (var item in testResultData['data']['data']) { + // print(item); originalItems.add( LabelResultObject( expireDate: item['expire_date'], id: item['id'].toString(), package: item['package']['name'], + packageId: item['package']['id'].toString(), ), ); } @@ -188,6 +225,8 @@ class LabelsProvider extends ChangeNotifier { return LabelDetailsObject( id: 'null', package: 'null', + packageId: 'null', + hospitalName: 'null', createDate: 'null', expireDate: 'null', sterileDate: 'null', @@ -198,9 +237,14 @@ class LabelsProvider extends ChangeNotifier { } var data = json.decode(response.body)['data']; + print(data); result = LabelDetailsObject( id: data['id'].toString(), package: data['package']['name'] != null ? data['package']['name'] : '', + packageId: data['package']['id'].toString() != 'null' + ? data['package']['id'].toString() + : '', + hospitalName: data['user']['medical_center']['name'], createDate: data['created_at'] != null ? data['created_at'] : '', expireDate: data['expire_date'] != null ? data['expire_date'] : '', sterileDate: data['sterile_date'] != null ? data['sterile_date'] : '', diff --git a/lib/providers/test_results.dart b/lib/providers/test_results.dart index e677e33..500c24a 100644 --- a/lib/providers/test_results.dart +++ b/lib/providers/test_results.dart @@ -1,4 +1,8 @@ import 'dart:convert'; +import 'dart:io'; +import 'dart:typed_data'; +// import 'dart:typed_data'; +import 'package:dio/dio.dart' as di; import 'package:cssd/config/urls.dart'; import 'package:cssd/config/user.dart'; @@ -6,8 +10,47 @@ import 'package:cssd/models/test_result_models.dart'; // import 'package:cssd/providers/test_result.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; +import 'package:random_string/random_string.dart'; +// import 'package:multi_image_picker/multi_image_picker.dart'; class TestResultsProvider with ChangeNotifier { + List catchImages = []; + List images = []; + + setImages() async { + images = []; + for (var image in catchImages) { + var result = image.readAsBytesSync(); + // final batchId = randomString(10); + // addImage(batchId, result, image.path); + images.add(result.buffer + .asUint8List(result.offsetInBytes, result.lengthInBytes)); + } + notifyListeners(); + } + + setCatchImages(List images) { + catchImages = images; + notifyListeners(); + } + + removeImage(int index) { + catchImages.removeAt(index); + notifyListeners(); + } + + // Future addImage() async { + // Map imgs = {}; + // var counter = 0; + // for (var image in images) { + // imgs[counter.toString()] = + // di.MultipartFile.fromBytes(image, filename: 'test$counter.jpg'); + // counter += 1; + // } + + // return 'True'; + // } + String searchBoxValue = ''; bool filterOn = false; List items; @@ -157,14 +200,16 @@ class TestResultsProvider with ChangeNotifier { items = []; } for (var item in testResultData['data']['data']) { + // print(item); originalItems.add( TestResultObject( id: item['id'].toString(), name: item['test_type']['name'], deviceId: item['device_id'].toString(), - result: item['verified'] == 'Verified' ? 'Verified' : 'Not Verified', - date: item['date'], + result: item['result'] == 'Accept' ? 'Accepted' : 'Not Accepted', + date: item['created_at'].toString().substring(0, 10), hospital: item['user']['medical_center']['name'], + verified: item['verified'].toString(), ), ); } @@ -187,16 +232,75 @@ class TestResultsProvider with ChangeNotifier { print(response.body); } - static Future createTestResult(values) async { - var response = await http - .post(Url.createTestResult, body: json.encode(values), headers: { + Future addImage(String batchId, dynamic file, String fileName) async { + var imageListInt = file.cast(); + var dio = new di.Dio(); + dio.options.headers = { 'Authorization': User.token, 'X-Requested-With': 'XMLHttpRequest', - "Content-Type": "application/json", - "Accept": "application/json" + 'Content-Type': 'application/json', + }; + di.FormData formData = new di.FormData.fromMap({ + "batch_id": batchId, + 'model_type': 'TestResult', + "file": di.MultipartFile.fromBytes(imageListInt, filename: fileName) }); - print(response.body); + var response = await dio.post( + Url.addImage, + data: formData, + ); + // print(response.statusCode); + // print(response.statusMessage); + // print(response.data); + + return 'Added'; + } + + Future createTestResult(values, batchId) async { + final batchId = randomString(10); + + for (var image in catchImages) { + await addImage(batchId, image.readAsBytesSync(), image.path); + } + dynamic vals = values; + vals['file_batch_id'] = batchId; + + // int counter = 0; + // if (images.length != 0) { + // for (var image in images) { + // vals['imgs'][counter.toString()] = base64Encode( + // image, + // ); + // counter += 1; + // } + // } + + var dio = new di.Dio(); + dio.options.headers = { + 'Authorization': User.token, + // 'X-Requested-With': 'XMLHttpRequest' + }; + var response = await dio.post( + Url.createTestResult, + data: vals, + ); + print(response.data); + if (response.data['status'] == 'Success') { + catchImages = []; + return 'done'; + } else { + return 'error'; + } + // var response = await http + // .post(Url.createTestResult, body: json.encode(values), headers: { + // 'Authorization': User.token, + // 'X-Requested-With': 'XMLHttpRequest', + // "Content-Type": "application/json", + // "Accept": "application/json" + // }); + + // print(response.body); } Future> showTestResult(String id) async { @@ -213,11 +317,16 @@ class TestResultsProvider with ChangeNotifier { : '', 'test_code': data['test_type_id'] != null ? data['test_type_id'] : '', 'date': data['created_at'] != null ? data['created_at'] : '', - 'verified': data['verified'] != null ? data['verified'] : '', + 'accepted': originalItems + .firstWhere((element) => element.id == data['id'].toString()) + .result, //az api safheye asli estefade mishavad 'description': data['inputs']['Note'] != null ? data['inputs']['Note'] : '', 'test_type_name': data['test_type']['name'] != null ? data['test_type']['name'] : '', + 'hospital': originalItems + .firstWhere((element) => element.id == data['id'].toString()) + .hospital // az api safheye asli estefade mi shavad }; return result; } @@ -238,4 +347,28 @@ class TestResultsProvider with ChangeNotifier { notifyListeners(); return true; } + + Future changeVerification(String id, String value) async { + print(id); + print(value); + var response = await http.post( + Url.testResultVerification(id, value), + headers: { + 'Authorization': User.token, + 'X-Requested-With': 'XMLHttpRequest', + "Content-Type": "application/json", + "Accept": "application/json" + }, + ); + var testResultData = json.decode(response.body); + // print(response.body); + try { + if (testResultData['status'] == 'Success') { + return true; + } else { + return false; + } + } catch (e) {} + return false; + } } diff --git a/lib/widgets/CycleScreens/Details/datas_box.dart b/lib/widgets/CycleScreens/Details/datas_box.dart index 8787cbf..e6a62ec 100644 --- a/lib/widgets/CycleScreens/Details/datas_box.dart +++ b/lib/widgets/CycleScreens/Details/datas_box.dart @@ -1,6 +1,8 @@ -import 'package:cssd/models/cycles_models.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../../models/cycles_models.dart'; class CycleDetailsDataBox extends StatelessWidget { const CycleDetailsDataBox({ @@ -17,215 +19,273 @@ class CycleDetailsDataBox extends StatelessWidget { Widget build(BuildContext context) { return Padding( padding: EdgeInsets.all(20), - child: ListView(children: [ - SizedBox( - height: 10, - ), - Text( - 'CYCLE DETAILS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, + child: ListView( + children: [ + SizedBox( + height: 10, ), - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Color.fromRGBO(235, 235, 235, 1), - border: Border( - left: BorderSide( - color: Colors.black54, - width: 2, + Text( + 'CYCLE DETAILS', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, + ), + ), + SizedBox( + height: 10, + ), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(235, 235, 235, 1), + border: Border( + left: BorderSide( + color: Colors.black54, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas.createDate, + ), + ), + style: TextStyle( + color: Colors.red, + ), + ), + Divider(), + Text( + 'ID: ${datas.id}', + style: TextStyle( + color: Colors.red, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Sterilizer ID', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.sterileId.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Cycle Number', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.cycleNumber.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('d-M-y').format( + DateTime.parse( + datas.date, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Description', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.description.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.hospitalName, + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 30, + ), + Text( + 'LABELS INCLUDED', + style: TextStyle( + color: Colors.orange, + letterSpacing: 3, + fontWeight: FontWeight.w700, + fontSize: 4.5 * _deviceBlockSize, + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + border: Border.all( + color: Colors.grey, + ), + ), + child: ListView.separated( + shrinkWrap: true, + itemBuilder: (ctx, index) => RichText( + text: TextSpan( + text: 'Label ID ', + style: TextStyle( + color: Colors.grey, + fontFamily: 'montserrat', + ), + // style: DefaultTextStyle.of(context).style, + children: [ + TextSpan( + text: datas.labels[index], + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.orange, + ), + ), + ], + ), + ), + separatorBuilder: (ctx, index) => Divider(), + itemCount: datas.labels.length, + ), + ), + SizedBox( + height: 50, + ) + ], + ), + ), + SizedBox(height: 20,), + InkWell( + onTap: () async=> await launch( + 'https://cssd-doc.com/Show/Cycle/${datas.id.toString()}', + // forceSafariVC: true, + // forceWebView: true, + // headers: {'my_header_key': 'my_header_value'}, + // child: Text('Show Full Details'), + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), ), ), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - DateFormat.yMMMd().format( - DateTime.parse( - datas.createDate, - ), - ), - style: TextStyle( - color: Colors.red, - ), - ), - Divider(), - Text( - 'ID: ${datas.id}', - style: TextStyle( - color: Colors.red, - fontWeight: FontWeight.w700, - ), - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Sterilizer ID', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.sterileId.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Cycle Number', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.cycleNumber.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Date', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - DateFormat('d-M-y').format( - DateTime.parse( - datas.date, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Description', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.description.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 30, - ), - Text( - 'LABELS INCLUDED', - style: TextStyle( - color: Colors.orange, - letterSpacing: 3, - fontWeight: FontWeight.w700, - fontSize: 4.5 * _deviceBlockSize, - ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - border: Border.all( - color: Colors.grey, - ), - ), - child: ListView.separated( - shrinkWrap: true, - itemBuilder: (ctx, index) => RichText( - text: TextSpan( - text: 'Label ID ', - style: TextStyle(color: Colors.grey,fontFamily: 'montserrat',), - // style: DefaultTextStyle.of(context).style, - children: [ - TextSpan( - text: datas.labels[index], - style: TextStyle( - fontWeight: FontWeight.bold, - color: Colors.orange, - ), - ), - ], - ), - ), - separatorBuilder: (ctx, index) => Divider(), - itemCount: datas.labels.length, - ), - - ), - SizedBox(height: 50,) - ], - ), - ), - ]), + SizedBox(height: 30,) + ], + ), ); } } diff --git a/lib/widgets/CycleScreens/Filter/selector_box.dart b/lib/widgets/CycleScreens/Filter/selector_box.dart index af04f21..8d92960 100644 --- a/lib/widgets/CycleScreens/Filter/selector_box.dart +++ b/lib/widgets/CycleScreens/Filter/selector_box.dart @@ -1,17 +1,21 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + class CycleFilterSelectorBox extends StatefulWidget { - const CycleFilterSelectorBox({ - Key key, - @required double deviceBlockSize, - @required this.hospitalCTRL, - @required this.hospitalVals, - }) : _deviceBlockSize = deviceBlockSize, + const CycleFilterSelectorBox( + {Key key, + @required double deviceBlockSize, + @required this.hospitalCTRL, + @required this.hospitalVals, + @required String label}) + : _deviceBlockSize = deviceBlockSize, + _label = label, super(key: key); final double _deviceBlockSize; final TextEditingController hospitalCTRL; final List> hospitalVals; + final String _label; @override _CycleFilterSelectorBoxState createState() => _CycleFilterSelectorBoxState(); @@ -47,7 +51,7 @@ class _CycleFilterSelectorBoxState extends State { width: widget._deviceBlockSize, ), Text( - 'Package', + widget._label, style: TextStyle( fontSize: 3.5 * widget._deviceBlockSize, color: Colors.grey, diff --git a/lib/widgets/Global/splash_screen copy.dart b/lib/widgets/Global/internet_error.dart similarity index 100% rename from lib/widgets/Global/splash_screen copy.dart rename to lib/widgets/Global/internet_error.dart diff --git a/lib/widgets/LabelScreens/Add/selector_box.dart b/lib/widgets/LabelScreens/Add/selector_box.dart index 61b439e..0aba8c1 100644 --- a/lib/widgets/LabelScreens/Add/selector_box.dart +++ b/lib/widgets/LabelScreens/Add/selector_box.dart @@ -72,8 +72,7 @@ class _LabelAddSelectorBoxState extends State { color: Colors.black, ), isExpanded: true, - hint: - Container( + hint: Container( // width: 100, height: 70, padding: const EdgeInsets.symmetric(horizontal: 0), @@ -84,9 +83,10 @@ class _LabelAddSelectorBoxState extends State { style: TextStyle( fontWeight: FontWeight.w700, color: Colors.black, - fontSize: 5 * widget._deviceBlockSize + fontSize: 5 * widget._deviceBlockSize, ), - ),), + ), + ), // Container( // // width: 100, // height: 70, @@ -111,9 +111,12 @@ class _LabelAddSelectorBoxState extends State { child: Container( child: Text( val['name'], + textDirection: TextDirection.rtl, + overflow: TextOverflow.ellipsis, style: TextStyle( - // color: _mainFontColor, - fontSize: 4 * widget._deviceBlockSize, + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 5 * widget._deviceBlockSize, ), ), ), diff --git a/lib/widgets/LabelScreens/Add/update_button.dart b/lib/widgets/LabelScreens/Add/update_button.dart new file mode 100644 index 0000000..77641b6 --- /dev/null +++ b/lib/widgets/LabelScreens/Add/update_button.dart @@ -0,0 +1,93 @@ +import 'package:cssd/config/routes.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:cssd/providers/labels.dart'; + +class LabelUpdateButton extends StatelessWidget { + const LabelUpdateButton({ + Key key, + @required GlobalKey form, + @required this.id, + @required this.lotNumberCTRL, + @required this.cycleNumberCTRL, + @required this.sDateCTRL, + @required this.packageValue, + @required this.eDateCTRL, + @required this.striizerIdCTRL, + @required double deviceBlockSize, + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); + + final GlobalKey _form; + final String id; + final TextEditingController lotNumberCTRL; + final TextEditingController cycleNumberCTRL; + final TextEditingController sDateCTRL; + final List packageValue; + final TextEditingController eDateCTRL; + final TextEditingController striizerIdCTRL; + final double _deviceBlockSize; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + if (!_form.currentState.validate()) { + return; + } + Provider.of(context).updateLabelResult( + id, + lotNumberCTRL.text, + cycleNumberCTRL.text, + sDateCTRL.text, + // sDateValue, + {'id': packageValue[0], 'name': packageValue[1]}, + eDateCTRL.text, + // eDateValue, + striizerIdCTRL.text, + ); + showDialog( + context: context, + builder: (ctx) => AlertDialog( + content: Text('Label updated.'), + actions: [ + FlatButton( + onPressed: () { + Navigator.of(ctx).pop(); + }, + child: Text('Ok'), + ) + ], + ), + ).then((_) { + Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen); + }); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 5 * _deviceBlockSize, + vertical: 10, + ), + // margin: + // EdgeInsets.symmetric(horizontal: 35, vertical: 15), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.blue, Colors.green], + ), + borderRadius: BorderRadius.circular(7), + ), + child: Align( + alignment: Alignment.center, + child: Text( + 'UPDATE', + style: TextStyle( + color: Colors.white, + fontSize: 5 * _deviceBlockSize, + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/LabelScreens/Detail/datas_box.dart b/lib/widgets/LabelScreens/Detail/datas_box.dart index f95d731..ffd110e 100644 --- a/lib/widgets/LabelScreens/Detail/datas_box.dart +++ b/lib/widgets/LabelScreens/Detail/datas_box.dart @@ -1,6 +1,8 @@ -import 'package:cssd/models/label_models.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; + +import '../../../models/label_models.dart'; class LabelDetailsDataBox extends StatelessWidget { const LabelDetailsDataBox({ @@ -17,227 +19,282 @@ class LabelDetailsDataBox extends StatelessWidget { Widget build(BuildContext context) { return Padding( padding: EdgeInsets.all(20), - child: ListView(children: [ - SizedBox( - height: 10, - ), - Text( - 'LABEL DETAILS', - style: TextStyle( - fontWeight: FontWeight.w700, - fontSize: 5 * _deviceBlockSize, - letterSpacing: 3, + child: ListView( + children: [ + SizedBox( + height: 10, ), - ), - SizedBox( - height: 10, - ), - Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Color.fromRGBO(235, 235, 235, 1), - border: Border( - left: BorderSide( - color: Colors.black54, - width: 2, - ), + Text( + 'LABEL DETAILS', + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 5 * _deviceBlockSize, + letterSpacing: 3, ), ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - DateFormat.yMMMd().format( - DateTime.parse( - datas.createDate, - ), - ), - style: TextStyle( - color: Colors.red, - ), - ), - Divider(), - Text( - 'ID: ${datas.id}', - style: TextStyle( - color: Colors.red, - fontWeight: FontWeight.w700, - ), - ), - SizedBox( - height: 30, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Sterilizer ID', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.sterileId.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Cycle Number', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.cycleNumber.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Lot Number', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.lotNumber.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Sterile Date', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - DateFormat('y-M-d').format( - DateTime.parse( - datas.sterileDate, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Expire Date', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - DateFormat('y-M-d').format( - DateTime.parse( - datas.expireDate, - ), - ), - style: TextStyle( - fontWeight: FontWeight.w700, color: Colors.red), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Package', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas.package.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - ], + SizedBox( + height: 10, ), - ), - ]), + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(235, 235, 235, 1), + border: Border( + left: BorderSide( + color: Colors.black54, + width: 2, + ), + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas.createDate, + ), + ), + style: TextStyle( + color: Colors.red, + ), + ), + Divider(), + Text( + 'ID: ${datas.id}', + style: TextStyle( + color: Colors.red, + fontWeight: FontWeight.w700, + ), + ), + SizedBox( + height: 30, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Sterilizer ID', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.sterileId.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Cycle Number', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.cycleNumber.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Lot Number', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.lotNumber.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Sterile Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('y-M-d').format( + DateTime.parse( + datas.sterileDate, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Expire Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('y-M-d').format( + DateTime.parse( + datas.expireDate, + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, color: Colors.red), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Package', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.package.toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital Name', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas.hospitalName, + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + ], + ), + ), + SizedBox( + height: 20, + ), + InkWell( + onTap: () => launch( + 'https://cssd-doc.com/Show/Label/${datas.id.toString()}', + // forceSafariVC: true, + // forceWebView: true, + // headers: {'my_header_key': 'my_header_value'}, + // child: Text('Show Full Details'), + ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), + ), + ), + ), + ) + ], + ), ); } } diff --git a/lib/widgets/LabelScreens/Result/data_box.dart b/lib/widgets/LabelScreens/Result/data_box.dart index 943e2cf..d2673cd 100644 --- a/lib/widgets/LabelScreens/Result/data_box.dart +++ b/lib/widgets/LabelScreens/Result/data_box.dart @@ -46,7 +46,7 @@ class LabelItemBox extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - width: 50 * _deviceBlockSize, + width: 30 * _deviceBlockSize, child: Text( 'Package:', style: TextStyle( @@ -56,14 +56,14 @@ class LabelItemBox extends StatelessWidget { ), ), Container( - width: 50 * _deviceBlockSize, + width: 40 * _deviceBlockSize, child: Text( item.package, overflow: TextOverflow.ellipsis, ), ), Container( - width: 50 * _deviceBlockSize, + width: 30 * _deviceBlockSize, child: Row( children: [ Text( @@ -91,6 +91,29 @@ class LabelItemBox extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.end, children: [ + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushReplacementNamed( + Routes.labelUpdateScreen, + arguments: item.id, + ); + }, + child: Container( + padding: EdgeInsets.all(7), + width: 10 * _deviceBlockSize, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + Icons.edit, + size: 6 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + SizedBox(width: _deviceBlockSize,), InkWell( customBorder: CircleBorder(), onTap: () { diff --git a/lib/widgets/LabelScreens/Scan/save_button.dart b/lib/widgets/LabelScreens/Scan/save_button.dart index b1ac456..a1843c4 100644 --- a/lib/widgets/LabelScreens/Scan/save_button.dart +++ b/lib/widgets/LabelScreens/Scan/save_button.dart @@ -1,5 +1,5 @@ -import 'package:cssd/config/routes.dart'; import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; class FilterScanSaveButton extends StatelessWidget { const FilterScanSaveButton({ @@ -7,7 +7,9 @@ class FilterScanSaveButton extends StatelessWidget { @required GlobalKey form, @required this.idCTRL, @required double deviceBlockSize, - }) : _form = form, _deviceBlockSize = deviceBlockSize, super(key: key); + }) : _form = form, + _deviceBlockSize = deviceBlockSize, + super(key: key); final GlobalKey _form; final TextEditingController idCTRL; @@ -17,20 +19,23 @@ class FilterScanSaveButton extends StatelessWidget { Widget build(BuildContext context) { return InkWell( onTap: () { - if (! _form.currentState.validate()) { + if (!_form.currentState.validate()) { return; } - Navigator.of(context).pushNamed( - Routes.labelDetailScreen, - arguments: idCTRL.text, + launch( + 'https://cssd-doc.com/Show/Label/${idCTRL.text}', ); + // Navigator.of(context).pushNamed( + // Routes.labelDetailScreen, + // arguments: idCTRL.text, + // ); }, child: Container( padding: EdgeInsets.symmetric( horizontal: 5 * _deviceBlockSize, vertical: 10, ), - margin: EdgeInsets.symmetric(horizontal: 20), + margin: EdgeInsets.only(bottom: 50,left: 20,right: 20), decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.blue, Colors.green], diff --git a/lib/widgets/LabelScreens/Scan/scan_box.dart b/lib/widgets/LabelScreens/Scan/scan_box.dart index f760692..c5c50f5 100644 --- a/lib/widgets/LabelScreens/Scan/scan_box.dart +++ b/lib/widgets/LabelScreens/Scan/scan_box.dart @@ -1,7 +1,7 @@ import 'package:barcode_scan/barcode_scan.dart'; -import 'package:cssd/config/routes.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:url_launcher/url_launcher.dart'; class LabelScanBox extends StatelessWidget { const LabelScanBox({ @@ -24,9 +24,8 @@ class LabelScanBox extends StatelessWidget { return 'null'; } } on PlatformException catch (_) { - return 'access'; - } - catch (_){ + return 'access'; + } catch (_) { return 'error'; } @@ -70,15 +69,16 @@ class LabelScanBox extends StatelessWidget { print('cancel'); } else if (result == 'error') { print('error'); - } - else if(result == 'access'){ + } else if (result == 'access') { print('access'); - } - else { - Navigator.of(context).pushNamed( - Routes.labelDetailScreen, - arguments: result, + } else { + launch( + 'https://cssd-doc.com/Show/Label/$result', ); + // Navigator.of(context).pushNamed( + // Routes.labelDetailScreen, + // arguments: result, + // ); } }, ); diff --git a/lib/widgets/MyInfo/input_box.dart b/lib/widgets/MyInfo/input_box.dart index e6b386b..643ade7 100644 --- a/lib/widgets/MyInfo/input_box.dart +++ b/lib/widgets/MyInfo/input_box.dart @@ -7,15 +7,18 @@ class InfoInputBox extends StatelessWidget { @required double deviceBlockSize, @required String label, @required IconData icon, + @required TextInputType inputType, }) : _deviceBlockSize = deviceBlockSize, _label = label, _icon = icon, + _inputType = inputType, super(key: key); final TextEditingController controller; final double _deviceBlockSize; final String _label; final IconData _icon; + final TextInputType _inputType; @override Widget build(BuildContext context) { @@ -38,7 +41,7 @@ class InfoInputBox extends StatelessWidget { fontWeight: FontWeight.w700, fontSize: 5 * _deviceBlockSize, ), - keyboardType: TextInputType.number, + keyboardType: _inputType, textInputAction: TextInputAction.next, ); } diff --git a/lib/widgets/TestResultScreens/Add/capture_image.dart b/lib/widgets/TestResultScreens/Add/capture_image.dart new file mode 100644 index 0000000..8c12365 --- /dev/null +++ b/lib/widgets/TestResultScreens/Add/capture_image.dart @@ -0,0 +1,313 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:camera/camera.dart'; +import 'package:cssd/providers/test_results.dart'; +import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:provider/provider.dart'; + +class CaptureImage extends StatefulWidget { + @override + _CaptureImageState createState() { + return _CaptureImageState(); + } +} + +/// Returns a suitable camera icon for [direction]. +IconData getCameraLensIcon(CameraLensDirection direction) { + switch (direction) { + case CameraLensDirection.back: + return Icons.camera_rear; + case CameraLensDirection.front: + return Icons.camera_front; + case CameraLensDirection.external: + return Icons.camera; + } + throw ArgumentError('Unknown lens direction'); +} + +void logError(String code, String message) => + print('Error: $code\nError Message: $message'); + +class _CaptureImageState extends State + with WidgetsBindingObserver { + CameraController controller; + String imagePath; + // String videoPath; + VoidCallback videoPlayerListener; + bool isInit = true; + int curCamera = 0; + var cameras; + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addObserver(this); + } + + @override + void didChangeDependencies() async { + if (isInit) { + cameras = await availableCameras(); + onNewCameraSelected(cameras[curCamera]); + setState(() { + isInit = false; + }); + } + super.didChangeDependencies(); + } + + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + // App state changed before we got the chance to initialize. + if (controller == null || !controller.value.isInitialized) { + return; + } + if (state == AppLifecycleState.inactive) { + controller?.dispose(); + } else if (state == AppLifecycleState.resumed) { + if (controller != null) { + onNewCameraSelected(controller.description); + } + } + } + + final GlobalKey _scaffoldKey = GlobalKey(); + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Scaffold( + key: _scaffoldKey, + // appBar: AppBar( + // title: const Text('Take Picture'), + // ), + body: isInit + ? Center( + child: CircularProgressIndicator(), + ) + : Stack(children: [ + _cameraPreviewWidget(), + Positioned( + bottom: 100, left: 100, child: _captureControlRowWidget()), + Positioned( + bottom: 100, + right: 100, + child: InkWell( + onTap: () { + if (curCamera == 0) { + try { + onNewCameraSelected(cameras[1]); + setState(() { + curCamera = 1; + }); + } catch (e) {} + } else { + onNewCameraSelected(cameras[0]); + setState(() { + curCamera = 0; + }); + } + }, + child: Icon( + curCamera == 0 ? Icons.camera_rear : Icons.camera_front, + size: 40, + color: Colors.white, + ), + ), + ), + // _cameraTogglesRowWidget(cameras), + ]), + ), + ); + } + + /// Display the preview from the camera (or a message if the preview is not available). + Widget _cameraPreviewWidget() { + if (controller == null || !controller.value.isInitialized) { + return const Text( + 'Tap a camera', + style: TextStyle( + color: Colors.white, + fontSize: 24.0, + fontWeight: FontWeight.w900, + ), + ); + } else { + return Container( + width: double.infinity, + child: CameraPreview(controller), + ); + } + } + + /// Toggle recording audio + + /// Display the control bar with buttons to take pictures and record videos. + Widget _captureControlRowWidget() { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + children: [ + IconButton( + icon: const Icon( + Icons.camera_alt, + size: 40, + color: Colors.white, + ), + // color: Colors.blue, + onPressed: controller != null && + controller.value.isInitialized && + !controller.value.isRecordingVideo + ? onTakePictureButtonPressed + : null, + ), + ], + ); + } + + getCameras() async { + return await availableCameras(); + } + + /// Display a row of toggle to select the camera (or a message if no camera is available). + // Widget _cameraTogglesRowWidget(var cameras) { + // final List toggles = []; + + // if (cameras.isEmpty) { + // return const Text('No camera found'); + // } else { + // for (CameraDescription cameraDescription in cameras) { + // print("${cameraDescription.name}"); + // toggles.add( + // SizedBox( + // width: 90.0, + // child: RadioListTile( + // title: Icon(getCameraLensIcon(cameraDescription.lensDirection)), + // groupValue: controller?.description, + // value: cameraDescription, + // onChanged: controller != null && controller.value.isRecordingVideo + // ? null + // : onNewCameraSelected, + // ), + // ), + // ); + // } + // } + + // return Row(children: toggles); + // } + + String timestamp() => DateTime.now().millisecondsSinceEpoch.toString(); + + void showInSnackBar(String message) { + _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message))); + } + + void onNewCameraSelected(CameraDescription cameraDescription) async { + print(cameraDescription.lensDirection.toString()); + if (controller != null) { + await controller.dispose(); + } + controller = CameraController( + cameraDescription, + ResolutionPreset.medium, + // enableAudio: enableAudio, + ); + + // If the controller is updated then update the UI. + controller.addListener(() { + if (mounted) setState(() {}); + if (controller.value.hasError) { + showInSnackBar('Camera error ${controller.value.errorDescription}'); + } + }); + + try { + await controller.initialize(); + } on CameraException catch (e) { + _showCameraException(e); + } + + if (mounted) { + setState(() {}); + } + } + + void onTakePictureButtonPressed() { + takePicture().then((String filePath) { + if (mounted) { + setState(() { + imagePath = filePath; + var profileProviderObject = + Provider.of(context, listen: false); + List files = profileProviderObject.catchImages; + files.add(File(imagePath)); + profileProviderObject.setCatchImages(files); + profileProviderObject.setImages(); + print(imagePath); + }); + if (filePath != null) { + Navigator.of(context).pop(); + // showInSnackBar('Picture saved to $filePath'); + } + } + }); + } + + Future takePicture() async { + if (!controller.value.isInitialized) { + showInSnackBar('Error: select a camera first.'); + return null; + } + final Directory extDir = await getApplicationDocumentsDirectory(); + final String dirPath = '${extDir.path}/Pictures/flutter_test'; + await Directory(dirPath).create(recursive: true); + final String filePath = '$dirPath/${timestamp()}.jpg'; + + if (controller.value.isTakingPicture) { + // A capture is already pending, do nothing. + return null; + } + + try { + await controller.takePicture(filePath); + } on CameraException catch (e) { + _showCameraException(e); + return null; + } + return filePath; + } + + void _showCameraException(CameraException e) { + logError(e.code, e.description); + showInSnackBar('Error: ${e.code}\n${e.description}'); + } +} + +// class CameraApp extends StatelessWidget { +// @override +// Widget build(BuildContext context) { +// return MaterialApp( +// home: CaptureImage(), +// ); +// } +// } + +// List cameras = []; + +// Future main() async { +// // Fetch the available cameras before initializing the app. +// try { +// WidgetsFlutterBinding.ensureInitialized(); +// } on CameraException catch (e) { +// logError(e.code, e.description); +// } +// runApp(CameraApp()); +// } diff --git a/lib/widgets/TestResultScreens/Add/form_creator.dart b/lib/widgets/TestResultScreens/Add/form_creator.dart index 336f8c3..66fa5be 100644 --- a/lib/widgets/TestResultScreens/Add/form_creator.dart +++ b/lib/widgets/TestResultScreens/Add/form_creator.dart @@ -1,8 +1,16 @@ +import 'dart:io'; + +import 'package:cssd/config/routes.dart'; +import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; +import 'package:image_picker_gallery_camera/image_picker_gallery_camera.dart'; import 'package:meta/meta.dart'; import 'package:multiselect_formfield/multiselect_formfield.dart'; +import 'package:provider/provider.dart'; + +import '../../../providers/test_results.dart'; class FormCreator extends StatefulWidget { const FormCreator({ @@ -60,7 +68,82 @@ class _FormCreatorState extends State { ), ); } - + if (item['type'] == 'Image') { + final testProviderObject = Provider.of(context); + final mediaData = MediaQuery.of(context); + final deviceWidth = mediaData.size.width; + final _deviceBlockSize = deviceWidth / 100; + listWidgets.insert( + 3, + Container( + // height: 70, + child: Directionality( + textDirection: TextDirection.rtl, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + margin: EdgeInsets.only(top: 20), + height: testProviderObject.catchImages.length != 0 ? 60 : 0, + child: ImageBox( + deviceBlockSize: _deviceBlockSize, + testProvider: testProviderObject, + ), + ), + SizedBox( + height: testProviderObject.catchImages.length != 0 ? 10 : 0, + ), + InkWell( + onTap: () async { + await loadAssets(context); + }, + child: Container( + width: MediaQuery.of(context).size.width - 40, + padding: + EdgeInsets.symmetric(vertical: 10, horizontal: 30), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Colors.black, + ), + child: Text( + '+ Add an image or file from device', + textDirection: TextDirection.ltr, + style: TextStyle(color: Colors.white), + textAlign: TextAlign.center, + ), + ), + ), + SizedBox( + height: 10, + ), + InkWell( + onTap: () async { + await Navigator.of(context).pushNamed(Routes.captureImageScreen); + // await captureImage(context); + }, + child: Container( + width: MediaQuery.of(context).size.width - 40, + padding: + EdgeInsets.symmetric(vertical: 10, horizontal: 30), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Colors.black, + ), + child: Text( + '+ Add an image from camera', + textDirection: TextDirection.ltr, + style: TextStyle(color: Colors.white), + textAlign: TextAlign.center, + ), + ), + ), + ], + ), + ), + ), + ); + } if (item['type'] == "Label") { listWidgets.add( Container( @@ -113,26 +196,39 @@ class _FormCreatorState extends State { } formItems[count]['value'] = formItems[count]['value'] ?? startValue; - int divisions = (endValue - startValue).round(); + // int divisions = (endValue - startValue).round(); listWidgets.add( Padding( - padding: EdgeInsets.only(top: 35), - child: Slider( - min: startValue, - max: endValue, - value: formItems[count]['value'], - label: '${formItems[count]['value'].round()}', - divisions: divisions, - onChanged: (double value) { - setState(() { - formItems[count]['value'] = value; - }); - }, - semanticFormatterCallback: (double newValue) { - return '${newValue.round()}'; - }, - ), - ), + padding: EdgeInsets.only(top: 35, left: 10, right: 10), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(item['type']), + Text(formItems[count]['value'].toString()), + ], + ), + Slider( + min: startValue, + max: endValue, + value: formItems[count]['value'], + // label: '${formItems[count]['value'].round()}', + // divisions: divisions, + onChanged: (double value) { + setState(() { + formItems[count]['value'] = + double.parse(value.toStringAsFixed(2)); + }); + // print(formItems[count]['value']); + }, + // semanticFormatterCallback: (double newValue) { + // return '${newValue.round()}'; + // }, + ), + ], + )), ); } @@ -353,9 +449,51 @@ class _FormCreatorState extends State { // ), // ); } + return listWidgets; } + Future captureImage(BuildContext context) async { + var profileProviderObject = + Provider.of(context, listen: false); + List files = profileProviderObject.catchImages; + try { + files.add( + await ImagePickerGC.pickImage( + context: context, + source: ImgSource.Camera, + cameraIcon: Icon( + Icons.camera_alt, + color: Colors.red, + ), //cameraIcon and galleryIcon can change. If no icon provided default icon will be present + cameraText: Text( + "From Camera", + style: TextStyle(color: Colors.red), + ), + ), + ); + } catch (e) {} + profileProviderObject.setCatchImages(files); + profileProviderObject.setImages(); + } + + Future loadAssets(BuildContext context) async { + var profileProviderObject = + Provider.of(context, listen: false); + List files = profileProviderObject.catchImages; + try { + files += await FilePicker.getMultiFile( + type: FileType.custom, + allowedExtensions: ['jpg', 'png', 'bmp', 'jpeg', 'pdf', 'docx', 'doc'], + ); + // print(files); + } catch (_) {} + + profileProviderObject.setCatchImages(files); + profileProviderObject.setImages(); + // profileProviderObject.addImage(); + } + _FormCreatorState(this.formItems); void _handleChanged() { @@ -377,3 +515,110 @@ class _FormCreatorState extends State { ); } } + +class ImageBox extends StatelessWidget { + const ImageBox({ + Key key, + @required double deviceBlockSize, + @required TestResultsProvider testProvider, + }) : _deviceBlockSize = deviceBlockSize, + _testProvider = testProvider, + super(key: key); + + final double _deviceBlockSize; + final TestResultsProvider _testProvider; + + @override + Widget build(BuildContext context) { + return ListView.separated( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemBuilder: (ctx, index) { + bool isPdf = _testProvider.catchImages[index].path.endsWith('pdf'); + bool isWord = _testProvider.catchImages[index].path.endsWith('docx') || + _testProvider.catchImages[index].path.endsWith('doc'); + + // print(_testProvider.catchImages[index].path.endsWith('jpg')); + // .substring(_testProvider.catchImages[index].path.length - 4)); + return ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Container( + width: 60, + height: 60, + child: Stack( + children: [ + Positioned( + top: 10, + left: 0, + child: GestureDetector( + onTap: () => isPdf + ? print('pdf') + : isWord + ? print('word') + : Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => Container( + color: Colors.white, + child: Center( + child: Image.file( + _testProvider.catchImages[index], + ), + ), + ), + ), + ), + child: isPdf + ? Image.asset( + 'assets/Images/pdf.png', + width: 60, + height: 60, + fit: BoxFit.fill, + ) + : isWord + ? Image.asset( + 'assets/Images/word.png', + width: 60, + height: 60, + fit: BoxFit.fill, + ) + : Image.file( + _testProvider.catchImages[index], + // asset: _images[index], + width: 60, + height: 60, + fit: BoxFit.fill, + ), + ), + ), + Positioned( + top: 0, + right: 0, + child: GestureDetector( + onTap: () { + // setState(() { + _testProvider.removeImage(index); + // }); + }, + child: CircleAvatar( + backgroundColor: Colors.red, + radius: 10, + child: Icon( + Icons.close, + size: 12, + color: Colors.white, + ), + ), + ), + ) + ], + ), + ), + ); + }, + itemCount: _testProvider.catchImages.length, + separatorBuilder: (BuildContext context, int index) => SizedBox( + width: 3 * _deviceBlockSize, + ), + ); + } +} diff --git a/lib/widgets/TestResultScreens/Add/selector_box.dart b/lib/widgets/TestResultScreens/Add/selector_box.dart index 5c3c878..477ad5a 100644 --- a/lib/widgets/TestResultScreens/Add/selector_box.dart +++ b/lib/widgets/TestResultScreens/Add/selector_box.dart @@ -82,7 +82,7 @@ class _TestResultAddSelectorBoxState extends State { style: TextStyle( fontWeight: FontWeight.w700, color: Colors.black, - fontSize: 4 * widget._deviceBlockSize, + fontSize: 3 * widget._deviceBlockSize, ), ), // TextFormField( @@ -106,9 +106,11 @@ class _TestResultAddSelectorBoxState extends State { child: Container( child: Text( val, + overflow: TextOverflow.ellipsis, style: TextStyle( - // color: _mainFontColor, - fontSize: 4 * widget._deviceBlockSize, + fontWeight: FontWeight.w700, + color: Colors.black, + fontSize: 3 * widget._deviceBlockSize, ), ), ), diff --git a/lib/widgets/TestResultScreens/Details/datas_box.dart b/lib/widgets/TestResultScreens/Details/datas_box.dart index 3bb229f..5335d87 100644 --- a/lib/widgets/TestResultScreens/Details/datas_box.dart +++ b/lib/widgets/TestResultScreens/Details/datas_box.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; class DatasBox extends StatelessWidget { const DatasBox({ @@ -16,212 +17,240 @@ class DatasBox extends StatelessWidget { Widget build(BuildContext context) { return Padding( padding: EdgeInsets.all(20), - child: Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: Color.fromRGBO(230, 230, 230, 1), - border: Border( - left: BorderSide( - color: Colors.pink, - width: 2, - ), - ), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - DateFormat.yMMMd().format( - DateTime.parse( - datas['date'], + child: ListView( + children: [ + Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + border: Border( + left: BorderSide( + color: Colors.pink, + width: 2, ), ), - style: TextStyle( - color: Colors.red, - ), ), - Divider(), - Text( - datas['test_type_name'], - style: TextStyle( - color: Colors.red, - fontWeight: FontWeight.w700, - ), - ), - SizedBox( - height: 30, - ), - Row( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'CSSD ID', - style: TextStyle( - color: Colors.grey, + Text( + DateFormat.yMMMd().format( + DateTime.parse( + datas['date'], ), ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['id'].toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, + style: TextStyle( + color: Colors.red, ), ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Autocleave ID', - style: TextStyle( - color: Colors.grey, - ), + Divider(), + Text( + datas['test_type_name'], + style: TextStyle( + color: Colors.red, + fontWeight: FontWeight.w700, ), ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['auto_cleave_id'].toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), + SizedBox( + height: 30, ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Test Code', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['test_code'].toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Date', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - DateFormat('d-M-y').format( - DateTime.parse( - datas['date'], + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Test Register ID', + style: TextStyle( + color: Colors.grey, + ), ), ), - style: TextStyle( - fontWeight: FontWeight.w700, + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['id'].toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), ), - overflow: TextOverflow.clip, - ), + ], ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Autoclave ID', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['auto_cleave_id'].toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Hospital', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['hospital'].toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Date', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + DateFormat('d-M-y').format( + DateTime.parse( + datas['date'], + ), + ), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Status', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['accepted'] == 'Accepted' + ? 'Accepted' + : 'Rejected', + style: TextStyle( + fontWeight: FontWeight.w700, + color: datas['accepted'] == 'Accepted' + ? Colors.green + : Colors.red, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + width: 35 * _deviceBlockSize, + child: Text( + 'Description', + style: TextStyle( + color: Colors.grey, + ), + ), + ), + Container( + width: 45 * _deviceBlockSize, + child: Text( + datas['description'].toString(), + style: TextStyle( + fontWeight: FontWeight.w700, + ), + overflow: TextOverflow.clip, + ), + ), + ], + ), + Divider(), ], ), - Divider(), - SizedBox( - height: 5, + ), + SizedBox(height: 20,), + InkWell( + onTap: () async=> await launch( + 'https://cssd-doc.com/Show/TestResult/${datas['id'].toString()}', + // forceSafariVC: true, + // forceWebView: true, + // headers: {'my_header_key': 'my_header_value'}, + // child: Text('Show Full Details'), ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Status', - style: TextStyle( - color: Colors.grey, - ), - ), + child: Container( + padding: EdgeInsets.symmetric(vertical: 20), + width: double.infinity, + decoration: BoxDecoration( + color: Color.fromRGBO(230, 230, 230, 1), + borderRadius: BorderRadius.circular(25), + ), + child: Center( + child: Text( + 'Show More Details', + style: TextStyle(fontWeight: FontWeight.w700), ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['verified'] == 'NotVerified' - ? 'Rejected' - : 'Verified', - style: TextStyle( - fontWeight: FontWeight.w700, - color: datas['verified'] == 'NotVerified' - ? Colors.red - : Colors.blueAccent, - ), - overflow: TextOverflow.clip, - ), - ), - ], + ), ), - Divider(), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - width: 35 * _deviceBlockSize, - child: Text( - 'Description', - style: TextStyle( - color: Colors.grey, - ), - ), - ), - Container( - width: 45 * _deviceBlockSize, - child: Text( - datas['description'].toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - ), - overflow: TextOverflow.clip, - ), - ), - ], - ), - Divider(), - ], - ), + ) + ], ), ); } diff --git a/lib/widgets/TestResultScreens/Main/floating_button.dart b/lib/widgets/TestResultScreens/Main/floating_button.dart index 2f24bc8..e82b41f 100644 --- a/lib/widgets/TestResultScreens/Main/floating_button.dart +++ b/lib/widgets/TestResultScreens/Main/floating_button.dart @@ -1,5 +1,37 @@ import 'package:cssd/config/routes.dart'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +// class TestResultFloatingButton extends StatelessWidget { +// const TestResultFloatingButton({ +// Key key, +// @required double deviceBlockSize, +// }) : _deviceBlockSize = deviceBlockSize, +// super(key: key); + +// final double _deviceBlockSize; + +// @override +// Widget build(BuildContext context) { +// return InkWell( +// onTap: () { +// Navigator.of(context).popAndPushNamed(Routes.testResultAddScreen); +// }, +// child: Container( +// padding: EdgeInsets.all(5), +// decoration: BoxDecoration( +// shape: BoxShape.circle, +// color: Color.fromRGBO(0, 190, 190, 1), +// ), +// child: Icon( +// Icons.add, +// size: 10 * _deviceBlockSize, +// color: Colors.white, +// ), +// ), +// ); +// } +// } class TestResultFloatingButton extends StatelessWidget { const TestResultFloatingButton({ @@ -12,22 +44,49 @@ class TestResultFloatingButton extends StatelessWidget { @override Widget build(BuildContext context) { - return InkWell( - onTap: () { - Navigator.of(context).popAndPushNamed(Routes.testResultAddScreen); - }, - child: Container( - padding: EdgeInsets.all(5), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Color.fromRGBO(0, 190, 190, 1), + return Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushNamed(Routes.testScanScreen); + }, + child: Container( + padding: EdgeInsets.all(2.5 * _deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.black, + ), + child: Icon( + FontAwesomeIcons.barcode, + size: 7.1 * _deviceBlockSize, + color: Colors.white, + ), + ), ), - child: Icon( - Icons.add, - size: 10 * _deviceBlockSize, - color: Colors.white, + SizedBox( + width: 2 * _deviceBlockSize, ), - ), + InkWell( + customBorder: CircleBorder(), + onTap: () { + Navigator.of(context).pushReplacementNamed(Routes.testResultAddScreen); + }, + child: Container( + padding: EdgeInsets.all(_deviceBlockSize), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Color.fromRGBO(0, 190, 190, 1), + ), + child: Icon( + Icons.add, + size: 10 * _deviceBlockSize, + color: Colors.white, + ), + ), + ), + ], ); } -} \ No newline at end of file +} diff --git a/pubspec.lock b/pubspec.lock index 83d5451..ee84ae7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,21 +7,21 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" + version: "2.0.13" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" + version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.4.1" barcode_scan: dependency: "direct main" description: @@ -35,21 +35,28 @@ packages: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.0.0" + camera: + dependency: "direct main" + description: + name: camera + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.8+2" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.3" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.14.12" connectivity: dependency: "direct main" description: @@ -84,7 +91,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "2.1.4" cupertino_icons: dependency: "direct main" description: @@ -92,6 +99,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + dio: + dependency: "direct main" + description: + name: dio + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.9" double_back_to_close_app: dependency: "direct main" description: @@ -99,13 +113,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" - dropdown_formfield: - dependency: "direct main" + file: + dependency: transitive description: - name: dropdown_formfield + name: file url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "5.2.1" + file_picker: + dependency: "direct main" + description: + name: file_picker + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.0+1" fixnum: dependency: transitive description: @@ -125,6 +146,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.8" flutter_test: dependency: "direct dev" description: flutter @@ -142,20 +170,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "8.8.1" - hive: - dependency: "direct main" - description: - name: hive - url: "https://pub.dartlang.org" - source: hosted - version: "1.4.1+1" http: dependency: "direct main" description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.0+4" + version: "0.12.1" http_parser: dependency: transitive description: @@ -169,14 +190,28 @@ packages: name: image url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" - incrementally_loading_listview: - dependency: "direct main" + version: "2.1.12" + image_picker: + dependency: transitive description: - name: incrementally_loading_listview + name: image_picker url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.6.7+4" + image_picker_gallery_camera: + dependency: "direct main" + description: + name: image_picker_gallery_camera + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.6" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" intl: dependency: "direct main" description: @@ -212,6 +247,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.6.4" + path_provider: + dependency: "direct main" + description: + name: path_provider + url: "https://pub.dartlang.org" + source: hosted + version: "1.6.11" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+2" + path_provider_macos: + dependency: transitive + description: + name: path_provider_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.4+3" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" pedantic: dependency: transitive description: @@ -226,6 +289,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.4.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" + platform_detect: + dependency: transitive + description: + name: platform_detect + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.0" plugin_platform_interface: dependency: transitive description: @@ -233,6 +310,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.13" protobuf: dependency: transitive description: @@ -247,20 +331,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.2.0" + pub_semver: + dependency: transitive + description: + name: pub_semver + url: "https://pub.dartlang.org" + source: hosted + version: "1.4.4" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" - rxdart: - dependency: transitive + version: "2.1.3" + random_string: + dependency: "direct main" description: - name: rxdart + name: random_string url: "https://pub.dartlang.org" source: hosted - version: "0.23.1" + version: "2.1.0" shared_preferences: dependency: "direct main" description: @@ -300,7 +391,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.7.0" stack_trace: dependency: transitive description: @@ -335,7 +426,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.15" typed_data: dependency: transitive description: @@ -343,6 +434,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.6" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "5.4.10" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+7" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.7" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.1+6" vector_math: dependency: transitive description: @@ -350,13 +469,41 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" + video_player: + dependency: "direct main" + description: + name: video_player + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.11+2" + video_player_platform_interface: + dependency: transitive + description: + name: video_player_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + video_player_web: + dependency: transitive + description: + name: video_player_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3+2" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0" xml: dependency: transitive description: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "3.6.1" sdks: dart: ">=2.6.0 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index b119830..ab60650 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: A new Flutter project. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.1.0+1 +version: 1.4.0+1 environment: sdk: ">=2.2.2 <3.0.0" @@ -31,11 +31,23 @@ dependencies: font_awesome_flutter: ^8.8.1 intl: ^0.16.1 double_back_to_close_app: ^1.2.0 - hive: ^1.4.1+1 - + # hive: ^1.4.1+1 + url_launcher: ^5.4.10 + # multi_image_picker: ^4.6.7 + # image_picker: ^0.6.7 + file_picker: ^1.9.0+1 + dio: ^3.0.9 + # camera : any # loadmore: ^1.0.4 - incrementally_loading_listview: ^0.3.0 - dropdown_formfield: ^0.1.2 + # incrementally_loading_listview: ^0.3.0 + # dropdown_formfield: ^0.1.2 + path_provider: ^1.6.11 + # video_player: ^0.10.11+2 + image_picker_gallery_camera: ^0.1.6 + random_string: ^2.0.1 + camera: ^0.5.8+2 + video_player: ^0.10.11+2 + diff --git a/test/widget_test.dart b/test/widget_test.dart index eb2c626..f0d60ac 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -1,30 +1,30 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. +// // This is a basic Flutter widget test. +// // +// // To perform an interaction with a widget in your test, use the WidgetTester +// // utility that Flutter provides. For example, you can send tap and scroll +// // gestures. You can also use WidgetTester to find child widgets in the widget +// // tree, read text, and verify that the values of widget properties are correct. -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; +// import 'package:flutter/material.dart'; +// import 'package:flutter_test/flutter_test.dart'; -import 'package:cssd/main.dart'; +// import 'package:cssd/main.dart'; -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); +// void main() { +// testWidgets('Counter increments smoke test', (WidgetTester tester) async { +// // Build our app and trigger a frame. +// await tester.pumpWidget(MyApp()); - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); +// // Verify that our counter starts at 0. +// expect(find.text('0'), findsOneWidget); +// expect(find.text('1'), findsNothing); - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); +// // Tap the '+' icon and trigger a frame. +// await tester.tap(find.byIcon(Icons.add)); +// await tester.pump(); - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} +// // Verify that our counter has incremented. +// expect(find.text('0'), findsNothing); +// expect(find.text('1'), findsOneWidget); +// }); +// }