mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-12 16:58:55 +03:30
beta commit
This commit is contained in:
@@ -0,0 +1,343 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/utils/scan.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 '../../config/routes.dart';
|
||||
import '../../models/cycles_models.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../providers/cycles.dart';
|
||||
import '../../widgets/CycleScreens/Add/add_label_box.dart';
|
||||
import '../../widgets/CycleScreens/Add/date_picker.dart';
|
||||
import '../../widgets/CycleScreens/Add/save_button.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class CycleAddScreen extends StatefulWidget {
|
||||
// static const route = '/CycleAddScreen';
|
||||
|
||||
@override
|
||||
_CycleAddScreenState createState() => _CycleAddScreenState();
|
||||
}
|
||||
|
||||
class _CycleAddScreenState extends State<CycleAddScreen> {
|
||||
final _cycleNumberFocusNode = FocusNode();
|
||||
final _descriptionFocosNode = FocusNode();
|
||||
TextEditingController descriptionCTRL = new TextEditingController();
|
||||
TextEditingController cycleNumberCTRL = new TextEditingController();
|
||||
TextEditingController striizerIdCTRL = new TextEditingController();
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
DateTime? dateTimeFrom;
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
bool isInit = true;
|
||||
CycleFilterObject? filters;
|
||||
|
||||
List<TextEditingController> labelsCTRL = [TextEditingController()];
|
||||
int curLabelVal = 1;
|
||||
@override
|
||||
void initState() {
|
||||
descriptionCTRL.text = '';
|
||||
cycleNumberCTRL.text = '';
|
||||
dateCTRL.text = DateFormat('y-M-d').format(DateTime.now());
|
||||
striizerIdCTRL.text = '';
|
||||
// dateValue = DateFormat('y-M-d').format(DateTime.now());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
// var _id = ModalRoute.of(context).settings.arguments;
|
||||
var cycleProviderObject = Provider.of<CyclesProvider>(context);
|
||||
cycleProviderObject.resetLabelVals();
|
||||
cycleProviderObject.getLabelFilters().then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
// labelValues =
|
||||
// filters.hospital == '' ? labelVals[0] : filters.hospital;
|
||||
isInit = false;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.cycleResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Cycles'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.cycleResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Add a Cycle',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Strilizer ID required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: striizerIdCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Strilizer ID',
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType:
|
||||
TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).requestFocus(
|
||||
_cycleNumberFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
striizerIdCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Cycle number required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: cycleNumberCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Cycle Number',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _cycleNumberFocusNode,
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_descriptionFocosNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
CycleAddDatePicker(
|
||||
dateCTRL: dateCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
child: Text(
|
||||
'Labels included',
|
||||
style: TextStyle(
|
||||
color: kPink,
|
||||
letterSpacing: 2,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Consumer<CyclesProvider>(
|
||||
builder: (ctx, cycleProvider, _) =>
|
||||
ListView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (ctx, index) => AddLabelBox(
|
||||
text: 'Select Labels included',
|
||||
iconColor: kPinkSub,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
values:
|
||||
cycleProvider.labelValues[index],
|
||||
vals: cycleProvider.labelVals,
|
||||
initialLabelValue:
|
||||
cycleProvider.initialLabelValue,
|
||||
index: index,
|
||||
),
|
||||
itemCount:
|
||||
cycleProvider.labelValues.length,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: descriptionCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Description',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.multiline,
|
||||
focusNode: _descriptionFocosNode,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
CycleAddSaveButton(
|
||||
form: _form,
|
||||
labelValues: Provider.of<CyclesProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).labelValues,
|
||||
cycleNumberCTRL: cycleNumberCTRL,
|
||||
dateValue: dateCTRL.text,
|
||||
descriptionCTRL: descriptionCTRL,
|
||||
striizerIdCTRL: striizerIdCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+88
-85
@@ -1,85 +1,88 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../models/cycles_models.dart';
|
||||
import '../providers/connectivity.dart';
|
||||
import '../providers/cycles.dart';
|
||||
import '../widgets/CycleScreens/Details/datas_box.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
|
||||
class CycleDetailScreen extends StatefulWidget {
|
||||
// static const route = '/CycleDetailScreen';
|
||||
final String testResultId;
|
||||
|
||||
CycleDetailScreen({this.testResultId});
|
||||
|
||||
@override
|
||||
_CycleDetailScreenState createState() => _CycleDetailScreenState();
|
||||
}
|
||||
|
||||
class _CycleDetailScreenState extends State<CycleDetailScreen> {
|
||||
bool isInit = true;
|
||||
bool isEmpty = false;
|
||||
CycleDetailObject datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context).settings.arguments;
|
||||
await Provider.of<CyclesProvider>(context, listen: false)
|
||||
.showCycleResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
if (result.id == 'null') {
|
||||
isEmpty = true;
|
||||
}
|
||||
datas = result;
|
||||
isInit = false;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Cycles'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: isEmpty
|
||||
? Center(
|
||||
child: Text('This Cycle doesnt exists!'),
|
||||
)
|
||||
: CycleDetailsDataBox(
|
||||
datas: datas,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../models/cycles_models.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../providers/cycles.dart';
|
||||
import '../../widgets/CycleScreens/Details/datas_box.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class CycleDetailScreen extends StatefulWidget {
|
||||
// static const route = '/CycleDetailScreen';
|
||||
final String? testResultId;
|
||||
|
||||
CycleDetailScreen({this.testResultId});
|
||||
|
||||
@override
|
||||
_CycleDetailScreenState createState() => _CycleDetailScreenState();
|
||||
}
|
||||
|
||||
class _CycleDetailScreenState extends State<CycleDetailScreen> {
|
||||
bool isInit = true;
|
||||
bool isEmpty = false;
|
||||
CycleDetailObject? datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<CyclesProvider>(context, listen: false)
|
||||
.showCycleResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
if (result.id == 'null') {
|
||||
isEmpty = true;
|
||||
}
|
||||
datas = result;
|
||||
isInit = false;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Cycles'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: isEmpty
|
||||
? Center(
|
||||
child: Text('This Cycle doesnt exists!'),
|
||||
)
|
||||
: CycleDetailsDataBox(
|
||||
datas: datas!,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
import 'package:cssd/utils/scan.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/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';
|
||||
|
||||
@override
|
||||
_CycleFilterScreenState createState() => _CycleFilterScreenState();
|
||||
}
|
||||
|
||||
class _CycleFilterScreenState extends State<CycleFilterScreen> {
|
||||
final _cycleNumberFocusNode = FocusNode();
|
||||
final _strilizerIdFocusNode = FocusNode();
|
||||
TextEditingController cycleIdCTRL = new TextEditingController();
|
||||
TextEditingController cycleNumberCTRL = new TextEditingController();
|
||||
TextEditingController striizerIdCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
DateTime? dateTimeFrom;
|
||||
// String dateValue;
|
||||
|
||||
List<Map<String, String>> hospitalVals = [];
|
||||
// String curhospitalVal;
|
||||
bool isInit = true;
|
||||
CycleFilterObject? filters;
|
||||
@override
|
||||
void initState() {
|
||||
filters = Provider.of<CyclesProvider>(context, listen: false).filters;
|
||||
cycleIdCTRL.text = filters!.id;
|
||||
cycleNumberCTRL.text = filters!.cycleNumber;
|
||||
// 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();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
// var _id = ModalRoute.of(context).settings.arguments;
|
||||
await Provider.of<CyclesProvider>(context, listen: false)
|
||||
.getHospitalsFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
hospitalVals = [
|
||||
{'id': '', 'name': ''}
|
||||
];
|
||||
for (var hospital in result) {
|
||||
hospitalVals.add(hospital);
|
||||
}
|
||||
filters!.hospital == ''
|
||||
? hospitalCTRL.text = hospitalVals[0]['name']!
|
||||
: hospitalVals.forEach(
|
||||
//id convert to name
|
||||
(hospital) {
|
||||
if (hospital['id'] == filters!.hospital) {
|
||||
hospitalCTRL.text = hospital['name']!;
|
||||
}
|
||||
},
|
||||
);
|
||||
isInit = false;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.cycleResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Cycles'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.cycleResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Filter Cycles',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: cycleIdCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Cycle ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).requestFocus(
|
||||
_cycleNumberFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
// Spacer(),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
cycleIdCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: cycleNumberCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Cycle Number',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _cycleNumberFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_strilizerIdFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextField(
|
||||
controller: striizerIdCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Strilizer ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _strilizerIdFocusNode,
|
||||
keyboardType:
|
||||
TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.done,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
striizerIdCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
FilterHospitalBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
hospitalCTRL: hospitalCTRL,
|
||||
hospitalVals: hospitalVals,
|
||||
label: 'Hospital',
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
CycleFilterDatePicker(
|
||||
dateCTRL: dateCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
CycleFilterSaveButton(
|
||||
hospitalVals: hospitalVals,
|
||||
hospitalCTRL: hospitalCTRL,
|
||||
cycleIdCTRL: cycleIdCTRL,
|
||||
cycleNumberCTRL: cycleNumberCTRL,
|
||||
striizerIdCTRL: striizerIdCTRL,
|
||||
dateCTRL: dateCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Result/banner.dart';
|
||||
import '../../widgets/CycleScreens/Result/data_box.dart';
|
||||
import '../../widgets/CycleScreens/Result/filter_objects.dart';
|
||||
import '../../widgets/CycleScreens/Result/search_box.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
import '../../providers/cycles.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CycleResultScreen extends StatefulWidget {
|
||||
// static const route = '/CycleResultScreen';
|
||||
final bool? isAdmin;
|
||||
|
||||
CycleResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_CycleResultScreenState createState() => _CycleResultScreenState();
|
||||
}
|
||||
|
||||
class _CycleResultScreenState extends State<CycleResultScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var testResults = Provider.of<CyclesProvider>(context);
|
||||
testResults.setLoading();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getCycleResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var testResults = Provider.of<CyclesProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
testResults.getCycleResults();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
floatingActionButton: CycleResultFloatingButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20, right: 20, bottom: 60, left: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Cycles',
|
||||
push: Routes.cycleFilterScreen,
|
||||
),
|
||||
Consumer<CyclesProvider>(builder: (ctx, cycle, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
cycle.filters!.id != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'ID',
|
||||
id: '',
|
||||
cycleNumber:
|
||||
cycle.filters!.cycleNumber,
|
||||
sterilizerId:
|
||||
cycle.filters!.sterilizerId,
|
||||
hospital: cycle.filters!.hospital,
|
||||
date: cycle.filters!.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters!.cycleNumber != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Cycle Number',
|
||||
id: cycle.filters!.id,
|
||||
cycleNumber: '',
|
||||
sterilizerId:
|
||||
cycle.filters!.sterilizerId,
|
||||
hospital: cycle.filters!.hospital,
|
||||
date: cycle.filters!.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters!.sterilizerId != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Sterilizer ID',
|
||||
id: cycle.filters!.id,
|
||||
cycleNumber:
|
||||
cycle.filters!.cycleNumber,
|
||||
sterilizerId: '',
|
||||
hospital: cycle.filters!.hospital,
|
||||
date: cycle.filters!.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters!.hospital != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Hospital',
|
||||
id: cycle.filters!.id,
|
||||
cycleNumber:
|
||||
cycle.filters!.cycleNumber,
|
||||
sterilizerId:
|
||||
cycle.filters!.sterilizerId,
|
||||
hospital: '',
|
||||
date: cycle.filters!.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters!.date != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Date',
|
||||
id: cycle.filters!.id,
|
||||
cycleNumber:
|
||||
cycle.filters!.cycleNumber,
|
||||
sterilizerId:
|
||||
cycle.filters!.sterilizerId,
|
||||
hospital: cycle.filters!.hospital,
|
||||
date: '',
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'cycle',
|
||||
onChanged: (value) {
|
||||
Provider.of<CyclesProvider>(context,
|
||||
listen: false)
|
||||
.search(value);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<CyclesProvider>(
|
||||
builder: (context, cycleResults, _) {
|
||||
return cycleResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
String labels = '';
|
||||
for (var label in cycleResults
|
||||
.items![index].label) {
|
||||
labels += label;
|
||||
labels += ' , ';
|
||||
}
|
||||
if (labels.length >= 3) {
|
||||
labels = labels.substring(
|
||||
0,
|
||||
labels.length -
|
||||
3); // remove extra ,
|
||||
}
|
||||
return CycleItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: cycleResults.items?[index],
|
||||
labels: labels,
|
||||
);
|
||||
},
|
||||
itemCount: cycleResults.items?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CycleResultFloatingButton extends StatelessWidget {
|
||||
const CycleResultFloatingButton({
|
||||
Key? key,
|
||||
required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Routes.cycleScanScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(2.5 * _deviceBlockSize),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 7.1 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.cycleAddScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(_deviceBlockSize),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: kPink,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 10 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class CycleScanScreen extends StatefulWidget {
|
||||
// static const route = '/cycleScanScreen';
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _CycleScanScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _CycleScanScreenState extends State<CycleScanScreen> {
|
||||
String testCode = "";
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
@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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Cycles'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 30),
|
||||
child: Text(
|
||||
'Looking for a Cycle?',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5.5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Please Scan The Cycle Barcode',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/Cycle/$result',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Form(
|
||||
key: _form,
|
||||
child: TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Id required!!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Or enter a cycle ID',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
// borderRadius: BorderRadius.only(Radius.circular(4)),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/Cycle/${idCTRL.text}',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: idCTRL.text,
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kPink, kPinkSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Search',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
import 'package:cssd/models/cycles_models.dart';
|
||||
import 'package:cssd/providers/cycles.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Add/cycle_update_button.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 '../../widgets/Global/internet_error.dart';
|
||||
import '../../widgets/LabelScreens/Add/date_picker.dart';
|
||||
|
||||
class CycleUpdateScreen extends StatefulWidget {
|
||||
@override
|
||||
_CycleUpdateScreenState createState() => _CycleUpdateScreenState();
|
||||
}
|
||||
|
||||
class _CycleUpdateScreenState extends State<CycleUpdateScreen> {
|
||||
final _cycleNumberFocusNode = FocusNode();
|
||||
final _descriptionFocusNode = FocusNode();
|
||||
TextEditingController cycleNumberCTRL = new TextEditingController();
|
||||
TextEditingController sterilizerIdCTRL = new TextEditingController();
|
||||
TextEditingController descriptionCTRL = new TextEditingController();
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
TextEditingController labelCTRL = new TextEditingController();
|
||||
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
// List<Map<String, String>> labelVals = [];
|
||||
// List<String> labelValue = [];
|
||||
bool isEmpty = false;
|
||||
bool isInit = true;
|
||||
CycleDetailObject? datas;
|
||||
@override
|
||||
void initState() {
|
||||
dateCTRL.text = 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<CyclesProvider>(context, listen: false)
|
||||
.showCycleResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
datas = result;
|
||||
cycleNumberCTRL.text = datas!.cycleNumber;
|
||||
sterilizerIdCTRL.text = datas!.sterileId;
|
||||
descriptionCTRL.text = datas!.description;
|
||||
dateCTRL.text = datas!.date;
|
||||
// for (var label in datas!.labels) {
|
||||
// labelCTRL.text = label;
|
||||
// }
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
await Provider.of<CyclesProvider>(context, listen: false)
|
||||
.getLabelFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
// labelVals = 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.cycleResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
backgroundColor: Colors.black,
|
||||
title: Text('Cycles'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.cycleResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(color: Colors.black),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Update 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: sterilizerIdCTRL,
|
||||
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(
|
||||
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,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_descriptionFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
LabelAddDatePicker(
|
||||
dateCTRL: dateCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Date',
|
||||
),
|
||||
// SizedBox(
|
||||
// height: 20.0,
|
||||
// ),
|
||||
// Consumer<CyclesProvider>(
|
||||
// builder: (ctx, cycleProvider, _) =>
|
||||
// ListView.builder(
|
||||
// physics: NeverScrollableScrollPhysics(),
|
||||
// shrinkWrap: true,
|
||||
// itemBuilder: (ctx, index) => AddLabelBox(
|
||||
// text: 'Select Labels included',
|
||||
// iconColor: kPinkSub,
|
||||
// deviceBlockSize: _deviceBlockSize,
|
||||
// values: cycleProvider.labelValues[index],
|
||||
// vals: cycleProvider.labelVals,
|
||||
// initialLabelValue: labelCTRL.text,
|
||||
// index: index,
|
||||
// ),
|
||||
// itemCount: cycleProvider.labelValues.length,
|
||||
// ),
|
||||
// ),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
controller: descriptionCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Description',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.multiline,
|
||||
focusNode: _descriptionFocusNode,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
CycleUpdateButton(
|
||||
form: _form,
|
||||
id: datas!.id,
|
||||
cycleNumberCTRL: cycleNumberCTRL,
|
||||
dateCTRL: dateCTRL,
|
||||
// labelValue: labelCTRL,
|
||||
striizerIdCTRL: sterilizerIdCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
descriptionCTRL: descriptionCTRL,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
import 'package:cssd/models/item_model.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Add/item_save_button.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Add/upload_image.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:random_string/random_string.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class ItemAddScreen extends StatefulWidget {
|
||||
@override
|
||||
_ItemAddScreenState createState() => _ItemAddScreenState();
|
||||
}
|
||||
|
||||
class _ItemAddScreenState extends State<ItemAddScreen> {
|
||||
final _itemSizeFocusNode = FocusNode();
|
||||
final _itemSpecificFocusNode = FocusNode();
|
||||
final _itemUdiFocusNode = FocusNode();
|
||||
final _descriptionFocusNode = FocusNode();
|
||||
TextEditingController descriptionCTRL = new TextEditingController();
|
||||
TextEditingController udiCTRL = new TextEditingController();
|
||||
TextEditingController nameCTRL = new TextEditingController();
|
||||
TextEditingController specificCTRL = new TextEditingController();
|
||||
TextEditingController sizeCTRL = new TextEditingController();
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
bool isInit = true;
|
||||
ItemFilterObject? filters;
|
||||
final batchId = randomString(10);
|
||||
|
||||
int curLabelVal = 1;
|
||||
@override
|
||||
void initState() {
|
||||
descriptionCTRL.text = '';
|
||||
udiCTRL.text = '';
|
||||
nameCTRL.text = '';
|
||||
sizeCTRL.text = '';
|
||||
specificCTRL.text = '';
|
||||
dateCTRL.text = DateFormat('y-M-d').format(DateTime.now());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var itemProviderObject = Provider.of<ItemProvider>(context);
|
||||
itemProviderObject.getItemResults().then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
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;
|
||||
final itemProviderObject = Provider.of<ItemProvider>(context);
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.itemResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Items'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.itemResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Add an Item',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Name required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: nameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Item Name',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemSizeFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Size required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: sizeCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Size',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemSizeFocusNode,
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemSpecificFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Specific required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: specificCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Specific',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemSpecificFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemUdiFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'UDI required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: udiCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'UDI',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemUdiFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_descriptionFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: descriptionCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Description',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.multiline,
|
||||
focusNode: _descriptionFocusNode,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
),
|
||||
SizedBox(
|
||||
height: 30.0,
|
||||
),
|
||||
UploaderImage(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
providerObject: itemProviderObject,
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
ItemAddSaveButton(
|
||||
form: _form,
|
||||
nameCTRL: nameCTRL,
|
||||
udiCTRL: udiCTRL,
|
||||
descriptionCTRL: descriptionCTRL,
|
||||
sizeCTRL: sizeCTRL,
|
||||
specificCTRL: specificCTRL,
|
||||
batchId: batchId,
|
||||
dateValue: dateCTRL.text,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import 'package:cssd/models/item_model.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Details/item_detail_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class ItemDetailScreen extends StatefulWidget {
|
||||
final String? testResultId;
|
||||
|
||||
ItemDetailScreen({
|
||||
this.testResultId,
|
||||
});
|
||||
|
||||
@override
|
||||
_ItemDetailScreenState createState() => _ItemDetailScreenState();
|
||||
}
|
||||
|
||||
class _ItemDetailScreenState extends State<ItemDetailScreen> {
|
||||
bool isInit = true;
|
||||
bool isEmpty = false;
|
||||
ItemDetailObject? datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<ItemProvider>(context, listen: false)
|
||||
.showItemResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
if (result.id == 'null') {
|
||||
isEmpty = true;
|
||||
}
|
||||
datas = 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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Items'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: isEmpty
|
||||
? Center(
|
||||
child: Text('This Item does\'nt exists!'),
|
||||
)
|
||||
: ItemDetailsDataBox(
|
||||
datas: datas!,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/models/item_model.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Filter/item_filter_button.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 '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Filter/selector_box.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class ItemFilterScreen extends StatefulWidget {
|
||||
@override
|
||||
_ItemFilterScreenState createState() => _ItemFilterScreenState();
|
||||
}
|
||||
|
||||
class _ItemFilterScreenState extends State<ItemFilterScreen> {
|
||||
final _itemSizeFocusNode = FocusNode();
|
||||
final _itemNameFocusNode = FocusNode();
|
||||
final _itemUdiFocusNode = FocusNode();
|
||||
final _itemSpecificFocusNode = FocusNode();
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
TextEditingController nameCTRL = new TextEditingController();
|
||||
TextEditingController udiCTRL = new TextEditingController();
|
||||
TextEditingController sizeCTRL = new TextEditingController();
|
||||
TextEditingController specificCTRL = new TextEditingController();
|
||||
|
||||
List<Map<String, String>> hospitalVals = [];
|
||||
bool isInit = true;
|
||||
ItemFilterObject? filters;
|
||||
@override
|
||||
void initState() {
|
||||
filters = Provider.of<ItemProvider>(context, listen: false).filters;
|
||||
idCTRL.text = filters!.id;
|
||||
hospitalCTRL.text = filters!.hospital;
|
||||
nameCTRL.text = filters!.name;
|
||||
sizeCTRL.text = filters!.size;
|
||||
specificCTRL.text = filters!.specific;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
// var _id = ModalRoute.of(context).settings.arguments;
|
||||
await Provider.of<ItemProvider>(context, listen: false)
|
||||
.getHospitalsFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
hospitalVals = [
|
||||
{'id': '', 'name': ''}
|
||||
];
|
||||
for (var hospital in result) {
|
||||
hospitalVals.add(hospital);
|
||||
}
|
||||
filters!.hospital == ''
|
||||
? hospitalCTRL.text = hospitalVals[0]['name']!
|
||||
: hospitalVals.forEach(
|
||||
//id convert to name
|
||||
(hospital) {
|
||||
if (hospital['id'] == filters!.hospital) {
|
||||
hospitalCTRL.text = hospital['name']!;
|
||||
}
|
||||
},
|
||||
);
|
||||
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.itemResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Items'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.itemResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Filter Items',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Item ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemNameFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
// Spacer(),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
idCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: nameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Item Name',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemNameFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemUdiFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: udiCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'UDI',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemUdiFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemSizeFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
idCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30.0,
|
||||
),
|
||||
TextFormField(
|
||||
controller: sizeCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Size',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemSizeFocusNode,
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemSpecificFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: specificCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Specific',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemSpecificFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
FilterHospitalBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
hospitalCTRL: hospitalCTRL,
|
||||
hospitalVals: hospitalVals,
|
||||
label: 'Hospital',
|
||||
),
|
||||
SizedBox(
|
||||
height: 90,
|
||||
),
|
||||
ItemFilterSaveButton(
|
||||
hospitalVals: hospitalVals,
|
||||
hospitalCTRL: hospitalCTRL,
|
||||
idCTRL: idCTRL,
|
||||
nameCTRL: nameCTRL,
|
||||
udiCTRL: udiCTRL,
|
||||
sizeCTRL: sizeCTRL,
|
||||
specificCTRL: specificCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kBlue,
|
||||
secondColor: kBlueSub,
|
||||
push: Routes.itemResultScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Filter/item_filter_object.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Result/item_data_box.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Result/banner.dart';
|
||||
import '../../widgets/CycleScreens/Result/search_box.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ItemResultScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
|
||||
ItemResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_ItemResultScreenState createState() => _ItemResultScreenState();
|
||||
}
|
||||
|
||||
class _ItemResultScreenState extends State<ItemResultScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var testResults = Provider.of<ItemProvider>(context);
|
||||
testResults.setLoading();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getItemResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var testResults = Provider.of<ItemProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
testResults.getItemResults();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
floatingActionButton: ItemResultFloatingButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Items',
|
||||
push: Routes.itemFilterScreen,
|
||||
),
|
||||
Consumer<ItemProvider>(
|
||||
builder: (ctx, item, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
item.filters!.id != ''
|
||||
? ItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'ID',
|
||||
id: '',
|
||||
name: item.filters!.name,
|
||||
udi: item.filters!.udi,
|
||||
hospital: item.filters!.hospital,
|
||||
size: item.filters!.size,
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.name != ''
|
||||
? ItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Item Name',
|
||||
id: item.filters!.id,
|
||||
name: '',
|
||||
udi: item.filters!.udi,
|
||||
hospital: item.filters!.hospital,
|
||||
size: item.filters!.size,
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.udi != ''
|
||||
? ItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'UDI',
|
||||
id: item.filters!.id,
|
||||
name: item.filters!.name,
|
||||
udi: '',
|
||||
hospital: item.filters!.hospital,
|
||||
size: item.filters!.size,
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.hospital != ''
|
||||
? ItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Hospital',
|
||||
id: item.filters!.id,
|
||||
name: item.filters!.name,
|
||||
hospital: '',
|
||||
udi: item.filters!.udi,
|
||||
size: item.filters!.size,
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.size != ''
|
||||
? ItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Size',
|
||||
id: item.filters!.id,
|
||||
name: item.filters!.name,
|
||||
udi: item.filters!.udi,
|
||||
hospital: item.filters!.hospital,
|
||||
size: '',
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.specific != ''
|
||||
? ItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Specific',
|
||||
id: item.filters!.id,
|
||||
name: item.filters!.name,
|
||||
udi: item.filters!.udi,
|
||||
hospital: item.filters!.hospital,
|
||||
size: item.filters!.size,
|
||||
specific: '',
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
text: 'item',
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
onChanged: (value) {
|
||||
Provider.of<ItemProvider>(context, listen: false)
|
||||
.search(value);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<ItemProvider>(
|
||||
builder: (context, itemResults, _) {
|
||||
return itemResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
// remove extra ,
|
||||
return ItemItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: itemResults.items?[index],
|
||||
);
|
||||
},
|
||||
itemCount: itemResults.items?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemResultFloatingButton extends StatelessWidget {
|
||||
const ItemResultFloatingButton({
|
||||
Key? key,
|
||||
required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Routes.itemScanScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(2.5 * _deviceBlockSize),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 7.1 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.itemAddScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(_deviceBlockSize),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: kBlue,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 10 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class ItemScanScreen extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _ItemScanScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _ItemScanScreenState extends State<ItemScanScreen> {
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
@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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Items'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 30),
|
||||
child: Text(
|
||||
'Looking for a Item?',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5.5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Please Scan The Item Barcode',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/Item/$result',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Form(
|
||||
key: _form,
|
||||
child: TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Id required!!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Or enter a Item ID',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
// borderRadius: BorderRadius.only(Radius.circular(4)),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/Item/${idCTRL.text}',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: idCTRL.text,
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kBlue, kBlueSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Search',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
import 'package:cssd/models/item_model.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Add/item_update_button.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 '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class ItemUpdateScreen extends StatefulWidget {
|
||||
@override
|
||||
_ItemUpdateScreenState createState() => _ItemUpdateScreenState();
|
||||
}
|
||||
|
||||
class _ItemUpdateScreenState extends State<ItemUpdateScreen> {
|
||||
final _itemSizeFocusNode = FocusNode();
|
||||
final _itemSpecificFocusNode = FocusNode();
|
||||
final _itemUdiFocusNode = FocusNode();
|
||||
final _descriptionFocusNode = FocusNode();
|
||||
TextEditingController descriptionCTRL = new TextEditingController();
|
||||
TextEditingController udiCTRL = new TextEditingController();
|
||||
TextEditingController nameCTRL = new TextEditingController();
|
||||
TextEditingController specificCTRL = new TextEditingController();
|
||||
TextEditingController sizeCTRL = new TextEditingController();
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
bool isEmpty = false;
|
||||
bool isInit = true;
|
||||
ItemDetailObject? datas;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<ItemProvider>(context, listen: false)
|
||||
.showItemResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
datas = result;
|
||||
nameCTRL.text = datas!.name;
|
||||
udiCTRL.text = datas!.udi;
|
||||
descriptionCTRL.text = datas!.description;
|
||||
sizeCTRL.text = datas!.size;
|
||||
specificCTRL.text = datas!.specific;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
await Provider.of<ItemProvider>(context, listen: false)
|
||||
.getItemResults()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
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.itemResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
backgroundColor: Colors.black,
|
||||
title: Text('Items'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.itemResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(color: Colors.black),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Update a Item',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Name required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: nameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize),
|
||||
isDense: true,
|
||||
labelText: 'Item Name',
|
||||
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.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemSizeFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Size required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: sizeCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Size',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemSizeFocusNode,
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemSpecificFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
controller: specificCTRL,
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Specific required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Specific',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
focusNode: _itemSpecificFocusNode,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemUdiFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
controller: udiCTRL,
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'UDI required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'UDI',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
focusNode: _itemUdiFocusNode,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_descriptionFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
controller: descriptionCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Description',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.multiline,
|
||||
focusNode: _descriptionFocusNode,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
ItemUpdateButton(
|
||||
form: _form,
|
||||
id: datas!.id,
|
||||
nameCTRL: nameCTRL,
|
||||
udiCTRL: udiCTRL,
|
||||
sizeCTRL: sizeCTRL,
|
||||
specificCTRL: specificCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
descriptionCTRL: descriptionCTRL,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:cssd/widgets/LabelScreens/Add/add_package_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';
|
||||
|
||||
class LabelAddScreen extends StatefulWidget {
|
||||
@override
|
||||
_LabelAddScreenState createState() => _LabelAddScreenState();
|
||||
}
|
||||
|
||||
class _LabelAddScreenState extends State<LabelAddScreen> {
|
||||
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;
|
||||
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
List<Map<String, String>> packageVals = [];
|
||||
List<String> packageValue = [];
|
||||
bool isInit = true;
|
||||
|
||||
List<TextEditingController> labelsCTRL = [TextEditingController()];
|
||||
int curLabelVal = 1;
|
||||
@override
|
||||
void initState() {
|
||||
sDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now());
|
||||
eDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var labelProviderObject = Provider.of<LabelsProvider>(context);
|
||||
labelProviderObject.resetPackageVals();
|
||||
labelProviderObject.getPackageFilters().then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
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: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Labels'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.labelResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Add a Label',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
lotNumberCTRL.text = val +
|
||||
' - ' +
|
||||
cycleNumberCTRL.text;
|
||||
});
|
||||
},
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Strilizer ID required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: striizerIdCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons
|
||||
.sortNumericDown,
|
||||
size: 7 * _deviceBlockSize),
|
||||
isDense: true,
|
||||
labelText: 'Strilizer ID',
|
||||
contentPadding:
|
||||
EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType:
|
||||
TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).requestFocus(
|
||||
_cycleNumberFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
striizerIdCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
onChanged: (val) {
|
||||
setState(
|
||||
() {
|
||||
lotNumberCTRL.text =
|
||||
striizerIdCTRL.text + ' - ' + val;
|
||||
},
|
||||
);
|
||||
},
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Cycle number required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: cycleNumberCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Cycle Number',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _cycleNumberFocusNode,
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.done,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
readOnly: true,
|
||||
controller: lotNumberCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Lot Number',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
child: Text(
|
||||
'Packages included',
|
||||
style: TextStyle(
|
||||
color: kLightBlue,
|
||||
letterSpacing: 2,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Consumer<LabelsProvider>(
|
||||
builder: (ctx, labelProvider, _) =>
|
||||
ListView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (ctx, index) =>
|
||||
AddPackageBox(
|
||||
text: 'Package ID',
|
||||
iconColor: kLightBlueSub,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
values:
|
||||
labelProvider.packageValues[index],
|
||||
vals: labelProvider.packageVals,
|
||||
initialLabelValue:
|
||||
labelProvider.initialPackageValue,
|
||||
index: index,
|
||||
),
|
||||
itemCount:
|
||||
labelProvider.packageValues.length,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
LabelAddDatePicker(
|
||||
dateCTRL: sDateCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Sterile Date',
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
LabelAddDatePicker(
|
||||
dateCTRL: eDateCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Expire Date',
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
LabelAddSaveButton(
|
||||
form: _form,
|
||||
lotNumberCTRL: lotNumberCTRL,
|
||||
cycleNumberCTRL: cycleNumberCTRL,
|
||||
sDateCTRL: sDateCTRL,
|
||||
packageValue: packageValue,
|
||||
eDateCTRL: eDateCTRL,
|
||||
striizerIdCTRL: striizerIdCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+88
-85
@@ -1,85 +1,88 @@
|
||||
import '../models/label_models.dart';
|
||||
import '../providers/connectivity.dart';
|
||||
import '../providers/labels.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
import '../widgets/LabelScreens/Detail/datas_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class LabelDetailScreen extends StatefulWidget {
|
||||
// static const route = '/LabelDetailScreen';
|
||||
// final String testResultId;
|
||||
|
||||
// LabelDetailScreen({this.testResultId});
|
||||
|
||||
@override
|
||||
_LabelDetailScreenState createState() => _LabelDetailScreenState();
|
||||
}
|
||||
|
||||
class _LabelDetailScreenState extends State<LabelDetailScreen> {
|
||||
bool isEmpty = false;
|
||||
bool isInit = true;
|
||||
LabelDetailsObject datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context).settings.arguments;
|
||||
await Provider.of<LabelsProvider>(context, listen: false)
|
||||
.showLabelResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
if (result.id == 'null') {
|
||||
isEmpty = true;
|
||||
}
|
||||
datas = result;
|
||||
isInit = false;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
// print(datas);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Labels'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: isEmpty
|
||||
? Center(
|
||||
child: Text('This Lable doesnt exists!'),
|
||||
)
|
||||
: LabelDetailsDataBox(
|
||||
datas: datas,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import '../../models/label_models.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../providers/labels.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
import '../../widgets/LabelScreens/Detail/datas_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class LabelDetailScreen extends StatefulWidget {
|
||||
// static const route = '/LabelDetailScreen';
|
||||
// final String testResultId;
|
||||
|
||||
// LabelDetailScreen({this.testResultId});
|
||||
|
||||
@override
|
||||
_LabelDetailScreenState createState() => _LabelDetailScreenState();
|
||||
}
|
||||
|
||||
class _LabelDetailScreenState extends State<LabelDetailScreen> {
|
||||
bool isEmpty = false;
|
||||
bool isInit = true;
|
||||
LabelDetailsObject? datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<LabelsProvider>(context, listen: false)
|
||||
.showLabelResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
if (result.id == 'null') {
|
||||
isEmpty = true;
|
||||
}
|
||||
datas = result;
|
||||
isInit = false;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
// print(datas);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Labels'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: isEmpty
|
||||
? Center(
|
||||
child: Text('This Label dos\'nt exists!'),
|
||||
)
|
||||
: LabelDetailsDataBox(
|
||||
datas: datas!,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
import 'package:cssd/utils/scan.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/label_models.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../providers/labels.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
import '../../widgets/LabelScreens/Filter/save_button.dart';
|
||||
import '../../widgets/LabelScreens/Filter/selector_box.dart';
|
||||
|
||||
class LabelFilterScreen extends StatefulWidget {
|
||||
@override
|
||||
_LabelFilterScreenState createState() => _LabelFilterScreenState();
|
||||
}
|
||||
|
||||
class _LabelFilterScreenState extends State<LabelFilterScreen> {
|
||||
final _cycleNumberFocusNode = FocusNode();
|
||||
final _strilizerIdFocusNode = FocusNode();
|
||||
|
||||
TextEditingController labelIdCTRl = new TextEditingController();
|
||||
TextEditingController cycleNumberCTRL = new TextEditingController();
|
||||
TextEditingController striizerIdCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
DateTime? dateTimeFrom;
|
||||
|
||||
List<Map<String, String>> hospitalVals = [];
|
||||
bool isInit = true;
|
||||
LabelFilterObject? filters;
|
||||
@override
|
||||
void initState() {
|
||||
filters = Provider.of<LabelsProvider>(context, listen: false).filters;
|
||||
labelIdCTRl.text = filters!.id;
|
||||
cycleNumberCTRL.text = filters!.cycleNumber;
|
||||
striizerIdCTRL.text = filters!.sterilizerId;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
await Provider.of<LabelsProvider>(context, listen: false)
|
||||
.getHospitalsFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
hospitalVals = [
|
||||
{'id': '', 'name': ''}
|
||||
];
|
||||
for (var hospital in result) {
|
||||
hospitalVals.add(hospital);
|
||||
}
|
||||
// hospitalVals = result;
|
||||
filters!.hospital == ''
|
||||
? hospitalCTRL.text = hospitalVals[0]['name']!
|
||||
: hospitalVals.forEach(
|
||||
//id convert to name
|
||||
(hospital) {
|
||||
if (hospital['id'] == filters!.hospital)
|
||||
hospitalCTRL.text = hospital['name']!;
|
||||
},
|
||||
);
|
||||
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: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Labels'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.labelResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Filter Labels',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: labelIdCTRl,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Label ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).requestFocus(
|
||||
_cycleNumberFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
labelIdCTRl.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: cycleNumberCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Cycle Number',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _cycleNumberFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_strilizerIdFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: striizerIdCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Strilizer ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
textInputAction: TextInputAction.done,
|
||||
keyboardType:
|
||||
TextInputType.visiblePassword,
|
||||
focusNode: _strilizerIdFocusNode,
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
striizerIdCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
LabelFilterSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
hospitalCTRL: hospitalCTRL,
|
||||
hospitalVals: hospitalVals,
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
LabelFilterSaveButton(
|
||||
hospitalVals: hospitalVals,
|
||||
hospitalCTRL: hospitalCTRL,
|
||||
labelIdCTRl: labelIdCTRl,
|
||||
cycleNumberCTRL: cycleNumberCTRL,
|
||||
striizerIdCTRL: striizerIdCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 50,
|
||||
),
|
||||
// DropDownBox(values: ['Washer ID']),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
import 'package:flutter/material.dart';
|
||||
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/Global/page_header.dart';
|
||||
import '../../widgets/LabelScreens/Result/data_box.dart';
|
||||
import '../../widgets/LabelScreens/Result/filter_chip_box.dart';
|
||||
import '../../widgets/LabelScreens/Result/floating_buttons.dart';
|
||||
import '../../widgets/LabelScreens/Result/search_box.dart';
|
||||
|
||||
class LabelResultScreen extends StatefulWidget {
|
||||
// static const route = '/LabelResultScreen';
|
||||
final bool? isAdmin;
|
||||
|
||||
LabelResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_LabelResultScreenState createState() => _LabelResultScreenState();
|
||||
}
|
||||
|
||||
class _LabelResultScreenState extends State<LabelResultScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var labelProviderObject =
|
||||
Provider.of<LabelsProvider>(context, listen: false);
|
||||
labelProviderObject.setLoading();
|
||||
labelProviderObject.resetPageNumber();
|
||||
labelProviderObject.getLabelResults().then((_) {
|
||||
labelProviderObject.resetLoading();
|
||||
sc!.addListener(() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var labelProviderObject =
|
||||
Provider.of<LabelsProvider>(context, listen: false);
|
||||
labelProviderObject.getLabelResults();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
floatingActionButton:
|
||||
LabelFloatingButtons(deviceBlockSize: _deviceBlockSize),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20, right: 20, bottom: 60, left: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
PageHeader(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Labels',
|
||||
route: Routes.labelFilterScreen,
|
||||
),
|
||||
Consumer<LabelsProvider>(
|
||||
builder: (context, label, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
label.filters.id != ''
|
||||
? LabelFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
id: '',
|
||||
cycleNumber:
|
||||
label.filters.cycleNumber,
|
||||
sterilizerId:
|
||||
label.filters.sterilizerId,
|
||||
hospital: label.filters.hospital,
|
||||
label: 'ID',
|
||||
)
|
||||
: Container(),
|
||||
label.filters.cycleNumber != ''
|
||||
? LabelFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
id: label.filters.id,
|
||||
cycleNumber: '',
|
||||
sterilizerId:
|
||||
label.filters.sterilizerId,
|
||||
hospital: label.filters.hospital,
|
||||
label: 'Cycle Number',
|
||||
)
|
||||
: Container(),
|
||||
label.filters.sterilizerId != ''
|
||||
? LabelFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
id: label.filters.id,
|
||||
cycleNumber:
|
||||
label.filters.cycleNumber,
|
||||
sterilizerId: '',
|
||||
hospital: label.filters.hospital,
|
||||
label: 'Sterilizer ID',
|
||||
)
|
||||
: Container(),
|
||||
label.filters.hospital != ''
|
||||
? LabelFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
id: label.filters.id,
|
||||
cycleNumber:
|
||||
label.filters.cycleNumber,
|
||||
sterilizerId:
|
||||
label.filters.sterilizerId,
|
||||
hospital: '',
|
||||
label: 'Hospital',
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
LabelSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
deviceBlockSize: _deviceBlockSize),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<LabelsProvider>(
|
||||
builder: (context, labelResults, _) {
|
||||
return labelResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) =>
|
||||
LabelItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: labelResults.items?[index],
|
||||
),
|
||||
itemCount: labelResults.items?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
import '../../widgets/LabelScreens/Scan/input_box.dart';
|
||||
import '../../widgets/LabelScreens/Scan/save_button.dart';
|
||||
import '../../widgets/LabelScreens/Scan/scan_box.dart';
|
||||
// import 'package:flutter/services.dart';
|
||||
// import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
|
||||
class LabelScanScreen extends StatefulWidget {
|
||||
// static const route = '/LabelScanScreen';
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _LabelScanScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _LabelScanScreenState extends State<LabelScanScreen> {
|
||||
String testCode = "";
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
@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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Labels'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 30),
|
||||
child: Text(
|
||||
'Looking for a Label?',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5.5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
LabelScanBox(),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Form(
|
||||
key: _form,
|
||||
child: LabelScanInputBox(
|
||||
idCTRL: idCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
FilterScanSaveButton(
|
||||
form: _form,
|
||||
idCTRL: idCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
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 '../../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/update_button.dart';
|
||||
|
||||
class LabelUpdateScreen extends StatefulWidget {
|
||||
// static const route = '/LabelUpdateScreen';
|
||||
|
||||
@override
|
||||
_LabelUpdateScreenState createState() => _LabelUpdateScreenState();
|
||||
}
|
||||
|
||||
class _LabelUpdateScreenState extends State<LabelUpdateScreen> {
|
||||
final _cycleNumberFocusNode = FocusNode();
|
||||
final _lotNumberFocusNode = 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<FormState>();
|
||||
|
||||
List<Map<String, String>> packageVals = [];
|
||||
List<String> packageValue = [];
|
||||
bool isEmpty = false;
|
||||
bool isInit = true;
|
||||
LabelDetailsObject? datas;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sDateCTRL.text = DateEditor.DateFormat('y-M-d').format(DateTime.now());
|
||||
eDateCTRL.text = 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<LabelsProvider>(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;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
await Provider.of<LabelsProvider>(context, listen: false)
|
||||
.getPackageFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
// packageVals = result.map((value) => {"name": value}).toList();
|
||||
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: SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
backgroundColor: Colors.black,
|
||||
title: Text('Labels'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.labelResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(color: Colors.black),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
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,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_lotNumberFocusNode);
|
||||
},
|
||||
),
|
||||
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,
|
||||
focusNode: _lotNumberFocusNode,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
LabelAddSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
packageCTRL: packageCTRL,
|
||||
packageVals: packageVals,
|
||||
packageValue: packageValue,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
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();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+196
-198
@@ -1,198 +1,196 @@
|
||||
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<StatefulWidget> createState() {
|
||||
return _ForgetPassScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _ForgetPassScreenState extends State<ForgetPassScreen> {
|
||||
final _form = GlobalKey<FormState>();
|
||||
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: <Widget>[
|
||||
TextButton(
|
||||
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<Auth>(context, listen: false)
|
||||
.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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
),
|
||||
body: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) => value != 'offline'
|
||||
? _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
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: <Widget>[
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
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<StatefulWidget> createState() {
|
||||
return _ForgetPassScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _ForgetPassScreenState extends State<ForgetPassScreen> {
|
||||
final _form = GlobalKey<FormState>();
|
||||
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: <Widget>[
|
||||
TextButton(
|
||||
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<Auth>(context, listen: false)
|
||||
.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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
body: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) => value != 'offline'
|
||||
? _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
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: <Widget>[
|
||||
InkWell(
|
||||
onTap: () => _requestCode(),
|
||||
child: Container(
|
||||
width: 88 * _deviceBlockSize,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Request Code',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox(),
|
||||
selector: (_, connectivity) => connectivity.conStatus,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.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 LoginScreen extends StatefulWidget {
|
||||
// static const route = '/HomeScreen';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _LoginScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
final _passwordFocusNode = FocusNode();
|
||||
final _form = GlobalKey<FormState>();
|
||||
bool _isLoading = false;
|
||||
final cellNumberController = TextEditingController();
|
||||
final passwordController = TextEditingController();
|
||||
|
||||
bool _hidePass = true;
|
||||
Map<String, dynamic> map = Map<String, dynamic>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (map['cellNumber'] != null) {
|
||||
cellNumberController.text = map['cellNumber'];
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_passwordFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _showDialog(String message) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('Error'),
|
||||
content: Text(message),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _login() async {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
_form.currentState!.save();
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
await Provider.of<Auth>(context, listen: false)
|
||||
.login(
|
||||
map['cellNumber'],
|
||||
map['password'],
|
||||
)
|
||||
.then(
|
||||
(result) {
|
||||
if (result == 'error') {
|
||||
_showDialog('Something went wrong!');
|
||||
setState(
|
||||
() {
|
||||
_isLoading = false;
|
||||
},
|
||||
);
|
||||
} else if (result == 'badinput') {
|
||||
_showDialog('User or password incorrect!');
|
||||
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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
body: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) => value != 'offline'
|
||||
? _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 20),
|
||||
child: Text(
|
||||
'Login',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return 'Call 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: 'Call Number',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.phone,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_passwordFocusNode);
|
||||
},
|
||||
onSaved: (value) {
|
||||
map['cellNumber'] = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
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: (_) {
|
||||
_login();
|
||||
},
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
focusNode: _passwordFocusNode,
|
||||
onSaved: (value) {
|
||||
map['password'] = value;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
InkWell(
|
||||
onTap: () => _login(),
|
||||
child: Container(
|
||||
width: _devicewidth,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.exit_to_app,
|
||||
color: Colors.white,
|
||||
),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Text(
|
||||
'Login',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
TextButton(
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Forgot Password ?',
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushNamed(Routes.forgetPassScreen),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox(),
|
||||
selector: (_, connectivity) => connectivity.conStatus,
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,243 +1,239 @@
|
||||
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<StatefulWidget> createState() {
|
||||
return _RePassScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _RePassScreenState extends State<RePassScreen> {
|
||||
final _form = GlobalKey<FormState>();
|
||||
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<void> _showDialog(String message) async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text(message),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
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<Auth>(context, listen: false)
|
||||
.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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
),
|
||||
body: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) => value != 'offline'
|
||||
? _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
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: <Widget>[
|
||||
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,
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
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<StatefulWidget> createState() {
|
||||
return _RePassScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _RePassScreenState extends State<RePassScreen> {
|
||||
final _form = GlobalKey<FormState>();
|
||||
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.toString();
|
||||
isInit = false;
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
Future<void> _showDialog(String message) async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text(message),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
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<Auth>(context, listen: false)
|
||||
.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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
body: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) => value != 'offline'
|
||||
? _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
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: <Widget>[
|
||||
InkWell(
|
||||
onTap: () => _sendRePass(),
|
||||
child: Container(
|
||||
width: 88 * _deviceBlockSize,
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Text(
|
||||
'Change',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox(),
|
||||
selector: (_, connectivity) => connectivity.conStatus,
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,379 +1,381 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class Register extends StatefulWidget {
|
||||
// static const route = '/RegisterScreen';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _RegisterState();
|
||||
}
|
||||
}
|
||||
|
||||
class _RegisterState extends State<Register> {
|
||||
final _passwordFocusNode = FocusNode();
|
||||
final _form = GlobalKey<FormState>();
|
||||
bool _isLoading = false;
|
||||
final cellNumberController = TextEditingController();
|
||||
bool _hidePass = true;
|
||||
Map<String, dynamic> map = Map<String, dynamic>();
|
||||
final List<String> hospitalVals = ['Shahid Beheshti', 'None'];
|
||||
String curhospitalVal;
|
||||
@override
|
||||
void initState() {
|
||||
cellNumberController.text = map['cellNumber'];
|
||||
curhospitalVal = hospitalVals[0];
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_passwordFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// void _showDialog(String message) {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (ctx) => AlertDialog(
|
||||
// title: Text('error occured'),
|
||||
// content: Text(message),
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// child: Text('Ok'),
|
||||
// onPressed: () {
|
||||
// Navigator.of(ctx).pop();
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
void _register() async {
|
||||
if (!_form.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_form.currentState.save();
|
||||
// setState(() {
|
||||
// _isLoading = true;
|
||||
// });
|
||||
// try {
|
||||
// // await Provider.of<Auth>(context).register(
|
||||
// // map['cellNumber'],
|
||||
// // map['password'],
|
||||
// // );
|
||||
// } catch (error) {
|
||||
// _showDialog('something went wrong!');
|
||||
// setState(() {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
// }
|
||||
|
||||
// Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) {
|
||||
// return HomePage();
|
||||
// }),
|
||||
// );
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Login'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 20),
|
||||
child: Text(
|
||||
'register',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 7 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
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;
|
||||
},
|
||||
style: TextStyle(fontWeight: FontWeight.w700),
|
||||
keyboardType: TextInputType.phone,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).requestFocus(_passwordFocusNode);
|
||||
},
|
||||
controller: cellNumberController,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
Icons.call,
|
||||
color: Colors.grey,
|
||||
),
|
||||
border: UnderlineInputBorder(),
|
||||
fillColor: Colors.red,
|
||||
labelText: 'Cell Number',
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 5),
|
||||
),
|
||||
onSaved: (value) {
|
||||
map['cellNumber'] = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
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,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) {
|
||||
_register();
|
||||
},
|
||||
style: TextStyle(fontWeight: FontWeight.w700),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.starOfLife,
|
||||
color: Colors.grey,
|
||||
),
|
||||
border: UnderlineInputBorder(),
|
||||
fillColor: Colors.red,
|
||||
labelText: 'Password',
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 5),
|
||||
suffixIcon: InkWell(
|
||||
child: Icon(FontAwesomeIcons.eye),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_hidePass = !_hidePass;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
focusNode: _passwordFocusNode,
|
||||
onSaved: (value) {
|
||||
map['password'] = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (value) {
|
||||
if (value.isEmpty) {
|
||||
return 'Full Name 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;
|
||||
},
|
||||
// keyboardType: TextInputType.phone,
|
||||
// textInputAction: TextInputAction.next,
|
||||
// onFieldSubmitted: (_) {
|
||||
// FocusScope.of(context).requestFocus(_passwordFocusNode);
|
||||
// },
|
||||
// controller: cellNumberController,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
color: Colors.grey,
|
||||
),
|
||||
border: UnderlineInputBorder(),
|
||||
fillColor: Colors.red,
|
||||
labelText: 'Full Name',
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 5),
|
||||
),
|
||||
style: TextStyle(fontWeight: FontWeight.w700),
|
||||
// onSaved: (value) {
|
||||
// map['cellNumber'] = value;
|
||||
// },
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
// width: double.infinity,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
color: Colors.grey,
|
||||
size: 5 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 3 * _deviceBlockSize,
|
||||
),
|
||||
Expanded(
|
||||
// width: MediaQuery.of(context).size.width - 70,
|
||||
child: DropdownButton(
|
||||
focusColor: Colors.red,
|
||||
icon: Icon(FontAwesomeIcons.angleDown),
|
||||
isExpanded: true,
|
||||
hint: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text(
|
||||
curhospitalVal,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
// color: _mainFontColor,
|
||||
// fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
isDense: true,
|
||||
items: hospitalVals.map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Container(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
// color: _mainFontColor,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
curhospitalVal = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: () => _register(),
|
||||
child: Container(
|
||||
width: 40 * _deviceBlockSize,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 5,
|
||||
),
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.blue, Colors.green],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
Text(
|
||||
'register',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
Spacer()
|
||||
],
|
||||
)
|
||||
// TextButton.icon(
|
||||
// padding: EdgeInsets.all(0),
|
||||
// onPressed: () {
|
||||
// _register();
|
||||
// },
|
||||
// icon: Icon(Icons.exit_to_app,
|
||||
// color: Colors.white, size: 17),
|
||||
// label: Text('register',
|
||||
// style: TextStyle(color: Colors.white)),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Container(
|
||||
width: 40 * _deviceBlockSize,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.exit_to_app,
|
||||
// size: 6 * _pixelRatio,
|
||||
),
|
||||
Text(
|
||||
'Login',
|
||||
style: TextStyle(
|
||||
// fontSize: 5.5,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class Register extends StatefulWidget {
|
||||
// static const route = '/RegisterScreen';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _RegisterState();
|
||||
}
|
||||
}
|
||||
|
||||
class _RegisterState extends State<Register> {
|
||||
final _passwordFocusNode = FocusNode();
|
||||
final _form = GlobalKey<FormState>();
|
||||
bool _isLoading = false;
|
||||
final cellNumberController = TextEditingController();
|
||||
bool _hidePass = true;
|
||||
Map<String, dynamic> map = Map<String, dynamic>();
|
||||
final List<String> hospitalVals = ['Shahid Beheshti', 'None'];
|
||||
String? curhospitalVal;
|
||||
@override
|
||||
void initState() {
|
||||
cellNumberController.text = map['cellNumber'];
|
||||
curhospitalVal = hospitalVals[0];
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_passwordFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// void _showDialog(String message) {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (ctx) => AlertDialog(
|
||||
// title: Text('error occured'),
|
||||
// content: Text(message),
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// child: Text('Ok'),
|
||||
// onPressed: () {
|
||||
// Navigator.of(ctx).pop();
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
void _register() async {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
_form.currentState!.save();
|
||||
// setState(() {
|
||||
// _isLoading = true;
|
||||
// });
|
||||
// try {
|
||||
// // await Provider.of<Auth>(context).register(
|
||||
// // map['cellNumber'],
|
||||
// // map['password'],
|
||||
// // );
|
||||
// } catch (error) {
|
||||
// _showDialog('something went wrong!');
|
||||
// setState(() {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
// }
|
||||
|
||||
// Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) {
|
||||
// return HomePage();
|
||||
// }),
|
||||
// );
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Login'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 20),
|
||||
child: Text(
|
||||
'register',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 7 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
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;
|
||||
},
|
||||
style: TextStyle(fontWeight: FontWeight.w700),
|
||||
keyboardType: TextInputType.phone,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).requestFocus(_passwordFocusNode);
|
||||
},
|
||||
controller: cellNumberController,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
Icons.call,
|
||||
color: Colors.grey,
|
||||
),
|
||||
border: UnderlineInputBorder(),
|
||||
fillColor: Colors.red,
|
||||
labelText: 'Cell Number',
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 5),
|
||||
),
|
||||
onSaved: (value) {
|
||||
map['cellNumber'] = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
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,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) {
|
||||
_register();
|
||||
},
|
||||
style: TextStyle(fontWeight: FontWeight.w700),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.starOfLife,
|
||||
color: Colors.grey,
|
||||
),
|
||||
border: UnderlineInputBorder(),
|
||||
fillColor: Colors.red,
|
||||
labelText: 'Password',
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 5),
|
||||
suffixIcon: InkWell(
|
||||
child: Icon(FontAwesomeIcons.eye),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_hidePass = !_hidePass;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
focusNode: _passwordFocusNode,
|
||||
onSaved: (value) {
|
||||
map['password'] = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (value) {
|
||||
if (value!.isEmpty) {
|
||||
return 'Full Name 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;
|
||||
},
|
||||
// keyboardType: TextInputType.phone,
|
||||
// textInputAction: TextInputAction.next,
|
||||
// onFieldSubmitted: (_) {
|
||||
// FocusScope.of(context).requestFocus(_passwordFocusNode);
|
||||
// },
|
||||
// controller: cellNumberController,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
color: Colors.grey,
|
||||
),
|
||||
border: UnderlineInputBorder(),
|
||||
fillColor: Colors.red,
|
||||
labelText: 'Full Name',
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 5),
|
||||
),
|
||||
style: TextStyle(fontWeight: FontWeight.w700),
|
||||
// onSaved: (value) {
|
||||
// map['cellNumber'] = value;
|
||||
// },
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
// width: double.infinity,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
color: Colors.grey,
|
||||
size: 5 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 3 * _deviceBlockSize,
|
||||
),
|
||||
Expanded(
|
||||
// width: MediaQuery.of(context).size.width - 70,
|
||||
child: DropdownButton(
|
||||
focusColor: Colors.red,
|
||||
icon: Icon(FontAwesomeIcons.angleDown),
|
||||
isExpanded: true,
|
||||
hint: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Text(
|
||||
curhospitalVal!,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
// color: _mainFontColor,
|
||||
// fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
isDense: true,
|
||||
items: hospitalVals.map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Container(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
// color: _mainFontColor,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
curhospitalVal = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: () => _register(),
|
||||
child: Container(
|
||||
width: 40 * _deviceBlockSize,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 5,
|
||||
),
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.blue, Colors.green],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
Text(
|
||||
'register',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
Spacer()
|
||||
],
|
||||
)
|
||||
// TextButton.icon(
|
||||
// padding: EdgeInsets.all(0),
|
||||
// onPressed: () {
|
||||
// _register();
|
||||
// },
|
||||
// icon: Icon(Icons.exit_to_app,
|
||||
// color: Colors.white, size: 17),
|
||||
// label: Text('register',
|
||||
// style: TextStyle(color: Colors.white)),
|
||||
// ),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Container(
|
||||
width: 40 * _deviceBlockSize,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.exit_to_app,
|
||||
// size: 6 * _pixelRatio,
|
||||
),
|
||||
Text(
|
||||
'Login',
|
||||
style: TextStyle(
|
||||
// fontSize: 5.5,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+194
-196
@@ -1,196 +1,194 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.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 VerifyPassScreen extends StatefulWidget {
|
||||
// static const route = '/HomeScreen';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _VerifyPassScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _VerifyPassScreenState extends State<VerifyPassScreen> {
|
||||
final _form = GlobalKey<FormState>();
|
||||
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: <Widget>[
|
||||
TextButton(
|
||||
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<Auth>(context, listen: false)
|
||||
.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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
),
|
||||
body: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) => value != 'offline'
|
||||
? _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
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: <Widget>[
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.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 VerifyPassScreen extends StatefulWidget {
|
||||
// static const route = '/HomeScreen';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _VerifyPassScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _VerifyPassScreenState extends State<VerifyPassScreen> {
|
||||
final _form = GlobalKey<FormState>();
|
||||
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: <Widget>[
|
||||
TextButton(
|
||||
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<Auth>(context, listen: false)
|
||||
.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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
body: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) => value != 'offline'
|
||||
? _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
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: <Widget>[
|
||||
InkWell(
|
||||
onTap: () => _sendCode(),
|
||||
child: Container(
|
||||
width: 88 * _deviceBlockSize,
|
||||
padding: EdgeInsets.all(10),
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:cssd/pages/MyItemsPages/my_items_history_screen.dart';
|
||||
import 'package:cssd/providers/auth.dart';
|
||||
import 'package:cssd/providers/connectivity.dart';
|
||||
import 'package:cssd/providers/my_items.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/banner.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/search_box.dart';
|
||||
import 'package:cssd/widgets/Global/internet_error.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Filter/my_items_chip_widget.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Result/my_items_data_box_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyItemsMineScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
const MyItemsMineScreen({
|
||||
Key? key,
|
||||
this.isAdmin,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyItemsMineScreen> createState() => _MyItemsMineScreenState();
|
||||
}
|
||||
|
||||
class _MyItemsMineScreenState extends State<MyItemsMineScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var myItemResults = Provider.of<MyItemProvider>(context);
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
myItemResults.setLoading();
|
||||
myItemResults.resetPageNumber();
|
||||
if (userData['roles']?.contains('User')) {
|
||||
myItemResults.getMyItems().then(
|
||||
(_) {
|
||||
myItemResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var myItemResults = Provider.of<MyItemProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
myItemResults.getMyItems();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
myItemResults.getHospitalItems().then((_) {
|
||||
myItemResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var myItemResults = Provider.of<MyItemProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
myItemResults.getHospitalItems();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
_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;
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'My Items',
|
||||
push: Routes.myItemsFilterScreen,
|
||||
),
|
||||
Consumer<MyItemProvider>(builder: (ctx, item, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
item.filters!.id != ''
|
||||
? MyItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'ID',
|
||||
id: '',
|
||||
name: item.filters!.name,
|
||||
udi: item.filters!.udi,
|
||||
size: item.filters!.size,
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.name != ''
|
||||
? MyItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Item Name',
|
||||
id: item.filters!.id,
|
||||
name: '',
|
||||
udi: item.filters!.udi,
|
||||
size: item.filters!.size,
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.udi != ''
|
||||
? MyItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'UDI',
|
||||
id: item.filters!.id,
|
||||
name: item.filters!.name,
|
||||
udi: '',
|
||||
size: item.filters!.size,
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.size != ''
|
||||
? MyItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Size',
|
||||
id: item.filters!.id,
|
||||
name: item.filters!.name,
|
||||
udi: item.filters!.udi,
|
||||
size: '',
|
||||
specific: item.filters!.specific,
|
||||
)
|
||||
: Container(),
|
||||
item.filters!.specific != ''
|
||||
? MyItemFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Specific',
|
||||
id: item.filters!.id,
|
||||
name: item.filters!.name,
|
||||
udi: item.filters!.udi,
|
||||
size: item.filters!.size,
|
||||
specific: '',
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
text: 'item',
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
onChanged: (value) {
|
||||
if (userData['roles']?.contains('User')) {
|
||||
Provider.of<MyItemProvider>(context, listen: false)
|
||||
.searchMyItems(value);
|
||||
} else {
|
||||
Provider.of<MyItemProvider>(context, listen: false)
|
||||
.searchHospitalItems(value);
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<MyItemProvider>(
|
||||
builder: (context, itemResults, _) {
|
||||
return itemResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
if (userData['roles']?.contains('User')) {
|
||||
return MyItemsItemDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
isAdmin: false,
|
||||
items: itemResults.myItems?[index],
|
||||
push: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: ((context) =>
|
||||
MyItemsHistoryScreen(
|
||||
items: itemResults
|
||||
.myItems?[index],
|
||||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return MyItemsItemDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
isAdmin: true,
|
||||
items:
|
||||
itemResults.hospitalItems?[index],
|
||||
push: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: ((context) =>
|
||||
MyItemsHistoryScreen(
|
||||
items: itemResults
|
||||
.myItems?[index],
|
||||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
itemCount: userData['roles']?.contains('User')
|
||||
? itemResults.myItems?.length
|
||||
: itemResults.hospitalItems?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:cssd/providers/auth.dart';
|
||||
import 'package:cssd/providers/connectivity.dart';
|
||||
import 'package:cssd/providers/my_items.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/banner.dart';
|
||||
import 'package:cssd/widgets/Global/internet_error.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Result/item_requests_data_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyItemsRequestsScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
const MyItemsRequestsScreen({
|
||||
Key? key,
|
||||
this.isAdmin,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyItemsRequestsScreen> createState() => _MyItemsRequestsScreenState();
|
||||
}
|
||||
|
||||
class _MyItemsRequestsScreenState extends State<MyItemsRequestsScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var itemResults = Provider.of<MyItemProvider>(context);
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
itemResults.setLoading();
|
||||
itemResults.resetPageNumber();
|
||||
if (userData['roles']?.contains('User')) {
|
||||
itemResults.getMyItemRequests().then(
|
||||
(_) {
|
||||
itemResults.resetLoading();
|
||||
sc?.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent) {
|
||||
var itemResults = Provider.of<MyItemProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
itemResults.getMyItemRequests();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
itemResults.getHospitalItemRequests().then(
|
||||
(_) {
|
||||
itemResults.resetLoading();
|
||||
sc?.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent) {
|
||||
var itemResults = Provider.of<MyItemProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
itemResults.getHospitalItemRequests();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
_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;
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'My Requests',
|
||||
hasFilterObject: false,
|
||||
push: Routes.myItemsFilterScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<MyItemProvider>(
|
||||
builder: (context, itemResults, _) {
|
||||
return itemResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
if (userData['roles']?.contains('User')) {
|
||||
return RequestsDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
isAdmin: false,
|
||||
item: itemResults
|
||||
.originalMyItemsRequests?[index],
|
||||
);
|
||||
} else {
|
||||
return RequestsDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
isAdmin: true,
|
||||
item: itemResults
|
||||
.originalHospitalItemsRequests?[
|
||||
index],
|
||||
);
|
||||
}
|
||||
},
|
||||
itemCount: userData['roles']?.contains('User')
|
||||
? itemResults
|
||||
.originalMyItemsRequests?.length
|
||||
: itemResults
|
||||
.originalHospitalItemsRequests
|
||||
?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/pages/MyItemsPages/Result/my_items_mine_screen.dart';
|
||||
import 'package:cssd/pages/MyItemsPages/Result/my_items_requests_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MyItemsResultScreen extends StatefulWidget {
|
||||
const MyItemsResultScreen({super.key});
|
||||
|
||||
@override
|
||||
State<MyItemsResultScreen> createState() => _MyItemsResultScreenState();
|
||||
}
|
||||
|
||||
class _MyItemsResultScreenState extends State<MyItemsResultScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final TabController _tabController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: DefaultTabController(
|
||||
length: 2,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
indicatorColor: kBlue,
|
||||
tabs: [
|
||||
Tab(
|
||||
text: 'Mine',
|
||||
),
|
||||
Tab(
|
||||
text: 'Requests',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
MyItemsMineScreen(),
|
||||
MyItemsRequestsScreen(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import 'package:cssd/models/item_model.dart';
|
||||
import 'package:cssd/pages/MyItemsPages/my_items_transfer_screen.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/my_items_detail_box_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class MyItemsDetailScreen extends StatefulWidget {
|
||||
final String? testResultId;
|
||||
|
||||
MyItemsDetailScreen({
|
||||
this.testResultId,
|
||||
});
|
||||
|
||||
@override
|
||||
_MyItemsDetailScreenState createState() => _MyItemsDetailScreenState();
|
||||
}
|
||||
|
||||
class _MyItemsDetailScreenState extends State<MyItemsDetailScreen> {
|
||||
bool isInit = true;
|
||||
bool isEmpty = false;
|
||||
ItemDetailObject? datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<ItemProvider>(context, listen: false)
|
||||
.showItemResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
if (result.id == 'null') {
|
||||
isEmpty = true;
|
||||
}
|
||||
datas = 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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('My Items'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: isEmpty
|
||||
? Center(
|
||||
child: Text('This Item does\'nt exists!'),
|
||||
)
|
||||
: MyItemsDetailsDataBox(
|
||||
datas: datas!,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
push: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ItemsTransferScreen(
|
||||
items: datas,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/models/item_model.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Filter/my_items_filter_button.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 '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class MyItemsFilterScreen extends StatefulWidget {
|
||||
@override
|
||||
_MyItemsFilterScreenState createState() => _MyItemsFilterScreenState();
|
||||
}
|
||||
|
||||
class _MyItemsFilterScreenState extends State<MyItemsFilterScreen> {
|
||||
final _itemSizeFocusNode = FocusNode();
|
||||
final _itemNameFocusNode = FocusNode();
|
||||
final _itemUdiFocusNode = FocusNode();
|
||||
final _itemSpecificFocusNode = FocusNode();
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
TextEditingController nameCTRL = new TextEditingController();
|
||||
TextEditingController udiCTRL = new TextEditingController();
|
||||
TextEditingController sizeCTRL = new TextEditingController();
|
||||
TextEditingController specificCTRL = new TextEditingController();
|
||||
|
||||
bool isInit = true;
|
||||
ItemFilterObject? filters;
|
||||
@override
|
||||
void initState() {
|
||||
filters = Provider.of<ItemProvider>(context, listen: false).filters;
|
||||
idCTRL.text = filters!.id;
|
||||
nameCTRL.text = filters!.name;
|
||||
sizeCTRL.text = filters!.size;
|
||||
specificCTRL.text = filters!.specific;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@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.myItemsResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('My Items'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.myItemsResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Filter My Items',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Item ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemNameFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
// Spacer(),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
idCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: nameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Item Name',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemNameFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemUdiFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: udiCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'UDI',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemUdiFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemSizeFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
idCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30.0,
|
||||
),
|
||||
TextFormField(
|
||||
controller: sizeCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Size',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemSizeFocusNode,
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_itemSpecificFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: specificCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Specific',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _itemSpecificFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
SizedBox(
|
||||
height: 90,
|
||||
),
|
||||
MyItemFilterSaveButton(
|
||||
idCTRL: idCTRL,
|
||||
nameCTRL: nameCTRL,
|
||||
udiCTRL: udiCTRL,
|
||||
sizeCTRL: sizeCTRL,
|
||||
specificCTRL: specificCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kDarkBlue,
|
||||
secondColor: kDarkBlueSub,
|
||||
push: Routes.myItemsResultScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
import 'package:cssd/models/my_item_model.dart';
|
||||
import 'package:cssd/providers/auth.dart';
|
||||
import 'package:cssd/providers/users.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/History/my_items_history_date_widget.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Result/my_items_data_box_widget.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Result/banner.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyItemsHistoryScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
final MyItemResultObject? items;
|
||||
|
||||
MyItemsHistoryScreen({this.isAdmin, this.items});
|
||||
|
||||
@override
|
||||
_MyItemsHistoryScreenState createState() => _MyItemsHistoryScreenState();
|
||||
}
|
||||
|
||||
class _MyItemsHistoryScreenState extends State<MyItemsHistoryScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var userResults = Provider.of<UsersProvider>(context);
|
||||
userResults.setLoading();
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String)
|
||||
.then((_) {
|
||||
userResults.resetLoading();
|
||||
sc?.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent) {
|
||||
var userResults = Provider.of<UsersProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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;
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('My Items'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Item History',
|
||||
push: Routes.itemFilterScreen,
|
||||
hasFilterObject: false,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
MyItemsItemDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
hasHistoryBtn: false,
|
||||
items: MyItemsHistoryScreen().items!,
|
||||
isAdmin: userData['roles']?.contains('User')
|
||||
? false
|
||||
: true,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
height: 2.0,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<UsersProvider>(
|
||||
builder: (context, userResults, child) {
|
||||
return userResults.isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
children: [
|
||||
ItemHistoryDate(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
items:
|
||||
MyItemsHistoryScreen().items!,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
TransferDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
user:
|
||||
userResults.usersBox?[index],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
itemCount: userResults.usersBox?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,341 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:cssd/models/item_model.dart';
|
||||
import 'package:cssd/providers/connectivity.dart';
|
||||
import 'package:cssd/providers/my_items.dart';
|
||||
import 'package:cssd/providers/users.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/banner.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/search_box.dart';
|
||||
import 'package:cssd/widgets/Global/internet_error.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ItemsTransferScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
final ItemDetailObject? items;
|
||||
const ItemsTransferScreen({
|
||||
super.key,
|
||||
this.isAdmin,
|
||||
this.items,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ItemsTransferScreen> createState() => _ItemsTransferScreenState();
|
||||
}
|
||||
|
||||
class _ItemsTransferScreenState extends State<ItemsTransferScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var userResults = Provider.of<UsersProvider>(context);
|
||||
userResults.setLoading();
|
||||
userResults.getUsers(userResults.getUserMedicalCenter() as String).then(
|
||||
(_) {
|
||||
userResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var userResults = Provider.of<UsersProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Item Details'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 40,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Transfer to',
|
||||
hasFilterObject: false,
|
||||
push: Routes.myItemsFilterScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
text: 'user',
|
||||
text2: 'name',
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
onChanged: (value) {
|
||||
Provider.of<UsersProvider>(context, listen: false)
|
||||
.searchUsers(value);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<UsersProvider>(
|
||||
builder: (context, userResults, _) {
|
||||
return userResults.isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
return TransferDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
user: userResults.usersBox?[index],
|
||||
isClicked:
|
||||
userResults.selectedUserIndex ==
|
||||
index,
|
||||
onTap: (userId) {
|
||||
Provider.of<UsersProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).selectUser(index);
|
||||
print(userId);
|
||||
Provider.of<UsersProvider>(
|
||||
context)
|
||||
.saveUserId = userId;
|
||||
},
|
||||
);
|
||||
},
|
||||
itemCount: userResults.usersBox?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kDarkBlue,
|
||||
secondColor: kDarkBlueSub,
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Are you sure to transfer this Item?',
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
content: SizedBox(
|
||||
width: _deviceBlockSize,
|
||||
height: 280,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'By approving, your item will be transferred the specified user. It can be undone unless the user reject the transfer.',
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
ItemCard(_deviceBlockSize),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
Text('To'),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
ItemCard(_deviceBlockSize),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kDarkBlue,
|
||||
secondColor: kDarkBlueSub,
|
||||
onTap: () {
|
||||
Provider.of<MyItemProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).transferItems(
|
||||
ItemsTransferScreen().items!.id,
|
||||
Provider.of<UsersProvider>(
|
||||
context,
|
||||
).saveUserId!,
|
||||
);
|
||||
},
|
||||
text: 'Transfer',
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
CancelTransferButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
color: kPink,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Transfer',
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container ItemCard(double _deviceBlockSize) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Text(
|
||||
ItemsTransferScreen().items!.id,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 3 * _deviceBlockSize,
|
||||
),
|
||||
// Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 40 * _deviceBlockSize,
|
||||
child: Text(
|
||||
ItemsTransferScreen().items!.name,
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 30 * _deviceBlockSize,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
'Size: ',
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
ItemsTransferScreen().items!.size,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 30 * _deviceBlockSize,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'User: ',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
ItemsTransferScreen().items!.userName,
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:cssd/pages/MyPackagesPages/my_packages_history_screen.dart';
|
||||
import 'package:cssd/providers/auth.dart';
|
||||
import 'package:cssd/providers/connectivity.dart';
|
||||
import 'package:cssd/providers/my_packages.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/banner.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/search_box.dart';
|
||||
import 'package:cssd/widgets/Global/internet_error.dart';
|
||||
import 'package:cssd/widgets/MyPackagesScreens/Filter/my_packages_chip_widget.dart';
|
||||
import 'package:cssd/widgets/MyPackagesScreens/Result/my_packages_data_box_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyPackagesMineScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
const MyPackagesMineScreen({
|
||||
Key? key,
|
||||
this.isAdmin,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyPackagesMineScreen> createState() => _MyPackagesMineScreenState();
|
||||
}
|
||||
|
||||
class _MyPackagesMineScreenState extends State<MyPackagesMineScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var myPackageResults = Provider.of<MyPackageProvider>(context);
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
myPackageResults.setLoading();
|
||||
myPackageResults.resetPageNumber();
|
||||
if (userData['roles']?.contains('User')) {
|
||||
myPackageResults.getMyPackages().then(
|
||||
(_) {
|
||||
myPackageResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var myItemResults = Provider.of<MyPackageProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
myItemResults.getMyPackages();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
myPackageResults.getHospitalPackages().then((_) {
|
||||
myPackageResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var myPackageResults = Provider.of<MyPackageProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
myPackageResults.getHospitalPackages();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
_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;
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'My Packages',
|
||||
push: Routes.myPackagesFilterScreen,
|
||||
),
|
||||
Consumer<MyPackageProvider>(
|
||||
builder: (ctx, package, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
package.filters!.id != ''
|
||||
? MyPackageFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'ID',
|
||||
id: '',
|
||||
name: package.filters!.name,
|
||||
udi: package.filters!.udi,
|
||||
)
|
||||
: Container(),
|
||||
package.filters!.name != ''
|
||||
? MyPackageFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Package Name',
|
||||
id: package.filters!.id,
|
||||
name: '',
|
||||
udi: package.filters!.udi,
|
||||
)
|
||||
: Container(),
|
||||
package.filters!.udi != ''
|
||||
? MyPackageFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'UDI',
|
||||
id: package.filters!.id,
|
||||
name: package.filters!.name,
|
||||
udi: '',
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
text: 'package',
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
onChanged: (value) {
|
||||
if (userData['roles']?.contains('User')) {
|
||||
Provider.of<MyPackageProvider>(context, listen: false)
|
||||
.searchMyPackages(value);
|
||||
} else {
|
||||
Provider.of<MyPackageProvider>(context, listen: false)
|
||||
.searchHospitalPackages(value);
|
||||
}
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<MyPackageProvider>(
|
||||
builder: (context, packageResults, _) {
|
||||
return packageResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
if (userData['roles']?.contains('User')) {
|
||||
return MyPackagesItemDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
isAdmin: false,
|
||||
packages:
|
||||
packageResults.myPackages?[index],
|
||||
push: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: ((context) =>
|
||||
MyPackagesHistoryScreen(
|
||||
packages: packageResults
|
||||
.myPackages?[index],
|
||||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return MyPackagesItemDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
isAdmin: true,
|
||||
packages: packageResults
|
||||
.hospitalPackages?[index],
|
||||
push: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: ((context) =>
|
||||
MyPackagesHistoryScreen(
|
||||
packages: packageResults
|
||||
.myPackages?[index],
|
||||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
itemCount: userData['roles']?.contains('User')
|
||||
? packageResults.myPackages?.length
|
||||
: packageResults.hospitalPackages?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:cssd/providers/auth.dart';
|
||||
import 'package:cssd/providers/connectivity.dart';
|
||||
import 'package:cssd/providers/my_packages.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/banner.dart';
|
||||
import 'package:cssd/widgets/Global/internet_error.dart';
|
||||
import 'package:cssd/widgets/MyPackagesScreens/Result/package_requests_data_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyPackagesRequestsScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
const MyPackagesRequestsScreen({
|
||||
Key? key,
|
||||
this.isAdmin,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<MyPackagesRequestsScreen> createState() =>
|
||||
_MyPackagesRequestsScreenState();
|
||||
}
|
||||
|
||||
class _MyPackagesRequestsScreenState extends State<MyPackagesRequestsScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var packageResults = Provider.of<MyPackageProvider>(context);
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
packageResults.setLoading();
|
||||
packageResults.resetPageNumber();
|
||||
if (userData['roles']?.contains('User')) {
|
||||
packageResults.getMyPackageRequests().then(
|
||||
(_) {
|
||||
packageResults.resetLoading();
|
||||
sc?.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent) {
|
||||
var packageResults = Provider.of<MyPackageProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
packageResults.getMyPackageRequests();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
packageResults.getHospitalPackageRequests().then(
|
||||
(_) {
|
||||
packageResults.resetLoading();
|
||||
sc?.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent) {
|
||||
var packageResults = Provider.of<MyPackageProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
packageResults.getHospitalPackageRequests();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
_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;
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'My Requests',
|
||||
hasFilterObject: false,
|
||||
push: Routes.myPackagesFilterScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<MyPackageProvider>(
|
||||
builder: (context, packageResults, _) {
|
||||
return packageResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
if (userData['roles']?.contains('User')) {
|
||||
return PackageRequestsDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
isAdmin: false,
|
||||
package: packageResults
|
||||
.originalMyPackagesRequests?[index],
|
||||
);
|
||||
} else {
|
||||
return PackageRequestsDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
isAdmin: true,
|
||||
package: packageResults
|
||||
.originalHospitalPackagesRequests?[
|
||||
index],
|
||||
);
|
||||
}
|
||||
},
|
||||
itemCount: userData['roles']?.contains('User')
|
||||
? packageResults
|
||||
.originalMyPackagesRequests?.length
|
||||
: packageResults
|
||||
.originalHospitalPackagesRequests
|
||||
?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/pages/MyPackagesPages/Result/my_packages_mine_screen.dart';
|
||||
import 'package:cssd/pages/MyPackagesPages/Result/my_packages_requests_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MyPackagesResultScreen extends StatefulWidget {
|
||||
const MyPackagesResultScreen({super.key});
|
||||
|
||||
@override
|
||||
State<MyPackagesResultScreen> createState() => _MyPackagesResultScreenState();
|
||||
}
|
||||
|
||||
class _MyPackagesResultScreenState extends State<MyPackagesResultScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final TabController _tabController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: DefaultTabController(
|
||||
length: 2,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
indicatorColor: kPurple,
|
||||
tabs: [
|
||||
Tab(
|
||||
text: 'Mine',
|
||||
),
|
||||
Tab(
|
||||
text: 'Requests',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
MyPackagesMineScreen(),
|
||||
MyPackagesRequestsScreen(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import 'package:cssd/models/package_model.dart';
|
||||
import 'package:cssd/pages/MyPackagesPages/my_packages_transfer_screen.dart';
|
||||
import 'package:cssd/providers/packages.dart';
|
||||
import 'package:cssd/widgets/MyPackagesScreens/Detail/my_packages_detail_box_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class MyPackagesDetailScreen extends StatefulWidget {
|
||||
final String? testResultId;
|
||||
|
||||
MyPackagesDetailScreen({
|
||||
this.testResultId,
|
||||
});
|
||||
|
||||
@override
|
||||
_MyPackagesDetailScreenState createState() => _MyPackagesDetailScreenState();
|
||||
}
|
||||
|
||||
class _MyPackagesDetailScreenState extends State<MyPackagesDetailScreen> {
|
||||
bool isInit = true;
|
||||
bool isEmpty = false;
|
||||
PackageDetailObject? datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<PackageProvider>(context, listen: false)
|
||||
.showPackageResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
if (result.id == 'null') {
|
||||
isEmpty = true;
|
||||
}
|
||||
datas = 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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('My Packages'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: isEmpty
|
||||
? Center(
|
||||
child: Text('This Package does\'nt exists!'),
|
||||
)
|
||||
: MyPackageDetailsDataBox(
|
||||
datas: datas!,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
push: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PackageTransferScreen(
|
||||
packages: datas,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/models/package_model.dart';
|
||||
import 'package:cssd/providers/packages.dart';
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:cssd/widgets/MyPackagesScreens/Filter/my_packages_filter_button.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 '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class MyPackageFilterScreen extends StatefulWidget {
|
||||
@override
|
||||
_MyPackageFilterScreenState createState() => _MyPackageFilterScreenState();
|
||||
}
|
||||
|
||||
class _MyPackageFilterScreenState extends State<MyPackageFilterScreen> {
|
||||
final _nameFocusNode = FocusNode();
|
||||
final _udiFocusNode = FocusNode();
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
TextEditingController nameCTRL = new TextEditingController();
|
||||
TextEditingController udiCTRL = new TextEditingController();
|
||||
|
||||
bool isInit = true;
|
||||
PackageFilterObject? filters;
|
||||
@override
|
||||
void initState() {
|
||||
filters = Provider.of<PackageProvider>(context, listen: false).filters;
|
||||
idCTRL.text = filters!.id;
|
||||
hospitalCTRL.text = filters!.hospital;
|
||||
nameCTRL.text = filters!.name;
|
||||
udiCTRL.text = filters!.udi;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@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.myPackagesResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('My Packages'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.myPackagesResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Filter My Packages',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Package ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_nameFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
// Spacer(),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
idCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: nameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Package Name',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _nameFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_udiFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: udiCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'UDI',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _udiFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
SizedBox(
|
||||
height: 90,
|
||||
),
|
||||
MyPackagesFilterSaveButton(
|
||||
idCTRL: idCTRL,
|
||||
nameCTRL: nameCTRL,
|
||||
udiCTRL: udiCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kDarkPurple,
|
||||
secondColor: kDarkPurpleSub,
|
||||
push: Routes.myPackagesResultScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
import 'package:cssd/models/my_package_model.dart';
|
||||
import 'package:cssd/providers/auth.dart';
|
||||
import 'package:cssd/providers/users.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart';
|
||||
import 'package:cssd/widgets/MyPackagesScreens/History/my_packages_history_date_widget.dart';
|
||||
import 'package:cssd/widgets/MyPackagesScreens/Result/my_packages_data_box_widget.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Result/banner.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyPackagesHistoryScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
final MyPackageResultObject? packages;
|
||||
|
||||
MyPackagesHistoryScreen({this.isAdmin, this.packages});
|
||||
|
||||
@override
|
||||
_MyPackagesHistoryScreenState createState() =>
|
||||
_MyPackagesHistoryScreenState();
|
||||
}
|
||||
|
||||
class _MyPackagesHistoryScreenState extends State<MyPackagesHistoryScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var userResults = Provider.of<UsersProvider>(context);
|
||||
userResults.setLoading();
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String)
|
||||
.then((_) {
|
||||
userResults.resetLoading();
|
||||
sc?.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent) {
|
||||
var userResults = Provider.of<UsersProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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;
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('My Packages'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Package History',
|
||||
push: Routes.itemFilterScreen,
|
||||
hasFilterObject: false,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
MyPackagesItemDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
hasHistoryBtn: false,
|
||||
packages: MyPackagesHistoryScreen().packages!,
|
||||
isAdmin: userData['roles']?.contains('User')
|
||||
? false
|
||||
: true,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
height: 2.0,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<UsersProvider>(
|
||||
builder: (context, userResults, child) {
|
||||
return userResults.isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
children: [
|
||||
PackageHistoryDate(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
packages:
|
||||
MyPackagesHistoryScreen()
|
||||
.packages!,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
TransferDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
user:
|
||||
userResults.usersBox?[index],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
itemCount: userResults.usersBox?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:cssd/models/package_model.dart';
|
||||
import 'package:cssd/providers/connectivity.dart';
|
||||
import 'package:cssd/providers/my_packages.dart';
|
||||
import 'package:cssd/providers/users.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/banner.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/search_box.dart';
|
||||
import 'package:cssd/widgets/Global/internet_error.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PackageTransferScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
final PackageDetailObject? packages;
|
||||
const PackageTransferScreen({
|
||||
super.key,
|
||||
this.isAdmin,
|
||||
this.packages,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PackageTransferScreen> createState() => _PackageTransferScreenState();
|
||||
}
|
||||
|
||||
class _PackageTransferScreenState extends State<PackageTransferScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var userResults = Provider.of<UsersProvider>(context);
|
||||
userResults.setLoading();
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String)
|
||||
.then((_) {
|
||||
userResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var userResults = Provider.of<UsersProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Package Details'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 40,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Transfer to',
|
||||
hasFilterObject: false,
|
||||
push: Routes.myItemsFilterScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
text: 'user',
|
||||
text2: 'name',
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
onChanged: (value) {
|
||||
Provider.of<UsersProvider>(context, listen: false)
|
||||
.searchUsers(value);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<UsersProvider>(
|
||||
builder: (context, userResults, _) {
|
||||
return userResults.isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
return TransferDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
user: userResults.usersBox?[index],
|
||||
isClicked:
|
||||
userResults.selectedUserIndex ==
|
||||
index,
|
||||
onTap: (userId) {
|
||||
Provider.of<UsersProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).selectUser(index);
|
||||
print(userId);
|
||||
Provider.of<UsersProvider>(
|
||||
context)
|
||||
.saveUserId = userId;
|
||||
},
|
||||
);
|
||||
},
|
||||
itemCount: userResults.usersBox?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kDarkPurple,
|
||||
secondColor: kDarkPurpleSub,
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Are you sure to transfer this Package?',
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
content: SizedBox(
|
||||
width: _deviceBlockSize,
|
||||
height: 280,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'By approving, all items in your package will be transferred the specified user. it can be undone unless the user reject the transfer.',
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
PackageCard(_deviceBlockSize),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
Text('To'),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
PackageCard(_deviceBlockSize),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kDarkBlue,
|
||||
secondColor: kDarkBlueSub,
|
||||
onTap: () {
|
||||
Provider.of<MyPackageProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).transferPackage(
|
||||
PackageTransferScreen()
|
||||
.packages!
|
||||
.id,
|
||||
Provider.of<UsersProvider>(
|
||||
context,
|
||||
).saveUserId!,
|
||||
);
|
||||
},
|
||||
text: 'Transfer',
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
CancelTransferButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
color: kPink,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Transfer',
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container PackageCard(double _deviceBlockSize) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Text(
|
||||
PackageTransferScreen().packages!.id,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 3 * _deviceBlockSize,
|
||||
),
|
||||
// Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 40 * _deviceBlockSize,
|
||||
child: Text(
|
||||
PackageTransferScreen().packages!.name,
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
// Container(
|
||||
// width: 30 * _deviceBlockSize,
|
||||
// child: Row(
|
||||
// children: [
|
||||
// Text(
|
||||
// 'Size: ',
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// style: TextStyle(
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// PackageTransferScreen().packages!.size,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w700,
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 30 * _deviceBlockSize,
|
||||
// child: Row(
|
||||
// children: <Widget>[
|
||||
// Text(
|
||||
// 'User: ',
|
||||
// style: TextStyle(
|
||||
// color: Colors.grey,
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// PackageTransferScreen().packages!.userName,
|
||||
// style: TextStyle(
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// fontWeight: FontWeight.w700,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/models/package_model.dart';
|
||||
import 'package:cssd/providers/packages.dart';
|
||||
import 'package:cssd/widgets/PackageScreens/Add/package_save_button.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 '../../config/routes.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Add/add_label_box.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class PackageAddScreen extends StatefulWidget {
|
||||
@override
|
||||
_PackageAddScreenState createState() => _PackageAddScreenState();
|
||||
}
|
||||
|
||||
class _PackageAddScreenState extends State<PackageAddScreen> {
|
||||
final _packageUdiFocusNode = FocusNode();
|
||||
final _descriptionFocusNode = FocusNode();
|
||||
TextEditingController descriptionCTRL = new TextEditingController();
|
||||
TextEditingController udiCTRL = new TextEditingController();
|
||||
TextEditingController nameCTRL = new TextEditingController();
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
bool isInit = true;
|
||||
PackageFilterObject? filters;
|
||||
|
||||
int curLabelVal = 1;
|
||||
@override
|
||||
void initState() {
|
||||
descriptionCTRL.text = '';
|
||||
udiCTRL.text = '';
|
||||
nameCTRL.text = '';
|
||||
dateCTRL.text = DateFormat('y-M-d').format(DateTime.now());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var packageProviderObject = Provider.of<PackageProvider>(context);
|
||||
packageProviderObject.resetItemVals();
|
||||
packageProviderObject.getItemFilters().then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
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.packageResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Packages'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.packageResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Add a Package',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Name required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: nameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Package Name',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_packageUdiFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'UDI required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: udiCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'UDI',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _packageUdiFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_descriptionFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 5),
|
||||
child: Text(
|
||||
'Items included',
|
||||
style: TextStyle(
|
||||
color: kPurple,
|
||||
letterSpacing: 2,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Consumer<PackageProvider>(
|
||||
builder: (ctx, packageProvider, _) =>
|
||||
ListView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (ctx, index) => AddLabelBox(
|
||||
text: 'Select Items Included',
|
||||
iconColor: kPurpleSub,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
values:
|
||||
packageProvider.itemValues[index],
|
||||
vals: packageProvider.itemVals,
|
||||
initialLabelValue:
|
||||
packageProvider.initialItemValue,
|
||||
index: index,
|
||||
),
|
||||
itemCount:
|
||||
packageProvider.itemValues.length,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: descriptionCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Description',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.multiline,
|
||||
focusNode: _descriptionFocusNode,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
PackageAddSaveButton(
|
||||
form: _form,
|
||||
itemValues: Provider.of<PackageProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).itemValues,
|
||||
nameCTRL: nameCTRL,
|
||||
udiCTRL: udiCTRL,
|
||||
dateValue: dateCTRL.text,
|
||||
descriptionCTRL: descriptionCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import 'package:cssd/models/package_model.dart';
|
||||
import 'package:cssd/providers/packages.dart';
|
||||
import 'package:cssd/widgets/PackageScreens/Details/package_detail_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class PackageDetailScreen extends StatefulWidget {
|
||||
final String? testResultId;
|
||||
|
||||
PackageDetailScreen({
|
||||
this.testResultId,
|
||||
});
|
||||
|
||||
@override
|
||||
_PackageDetailScreenState createState() => _PackageDetailScreenState();
|
||||
}
|
||||
|
||||
class _PackageDetailScreenState extends State<PackageDetailScreen> {
|
||||
bool isInit = true;
|
||||
bool isEmpty = false;
|
||||
PackageDetailObject? datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<PackageProvider>(context, listen: false)
|
||||
.showPackageResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
if (result.id == 'null') {
|
||||
isEmpty = true;
|
||||
}
|
||||
datas = 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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Packages'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: isEmpty
|
||||
? Center(
|
||||
child: Text('This Package does\'nt exists!'),
|
||||
)
|
||||
: PackageDetailsDataBox(
|
||||
datas: datas!,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
import 'package:cssd/models/package_model.dart';
|
||||
import 'package:cssd/providers/packages.dart';
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:cssd/widgets/PackageScreens/Filter/filter_button.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 '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Filter/selector_box.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class PackageFilterScreen extends StatefulWidget {
|
||||
@override
|
||||
_PackageFilterScreenState createState() => _PackageFilterScreenState();
|
||||
}
|
||||
|
||||
class _PackageFilterScreenState extends State<PackageFilterScreen> {
|
||||
final _nameFocusNode = FocusNode();
|
||||
final _udiFocusNode = FocusNode();
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
TextEditingController nameCTRL = new TextEditingController();
|
||||
TextEditingController udiCTRL = new TextEditingController();
|
||||
|
||||
List<Map<String, String>> hospitalVals = [];
|
||||
bool isInit = true;
|
||||
PackageFilterObject? filters;
|
||||
@override
|
||||
void initState() {
|
||||
filters = Provider.of<PackageProvider>(context, listen: false).filters;
|
||||
idCTRL.text = filters!.id;
|
||||
hospitalCTRL.text = filters!.hospital;
|
||||
nameCTRL.text = filters!.name;
|
||||
udiCTRL.text = filters!.udi;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
await Provider.of<PackageProvider>(context, listen: false)
|
||||
.getHospitalsFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
hospitalVals = [
|
||||
{'id': '', 'name': ''}
|
||||
];
|
||||
for (var hospital in result) {
|
||||
hospitalVals.add(hospital);
|
||||
}
|
||||
filters!.hospital == ''
|
||||
? hospitalCTRL.text = hospitalVals[0]['name']!
|
||||
: hospitalVals.forEach(
|
||||
//id convert to name
|
||||
(hospital) {
|
||||
if (hospital['id'] == filters!.hospital) {
|
||||
hospitalCTRL.text = hospital['name']!;
|
||||
}
|
||||
},
|
||||
);
|
||||
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.packageResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Packages'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.packageResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Filter Packages',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Package ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_nameFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
// Spacer(),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
idCTRL.text = result;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: nameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Package Name',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _nameFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_udiFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: udiCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'UDI',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _udiFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
SizedBox(
|
||||
height: 30.0,
|
||||
),
|
||||
FilterHospitalBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
hospitalCTRL: hospitalCTRL,
|
||||
hospitalVals: hospitalVals,
|
||||
label: 'Hospital',
|
||||
),
|
||||
SizedBox(
|
||||
height: 90,
|
||||
),
|
||||
PackageFilterSaveButton(
|
||||
hospitalVals: hospitalVals,
|
||||
hospitalCTRL: hospitalCTRL,
|
||||
idCTRL: idCTRL,
|
||||
nameCTRL: nameCTRL,
|
||||
udiCTRL: udiCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/providers/packages.dart';
|
||||
import 'package:cssd/widgets/PackageScreens/Filter/package_filter_object.dart';
|
||||
import 'package:cssd/widgets/PackageScreens/Result/package_data_box.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Result/banner.dart';
|
||||
import '../../widgets/CycleScreens/Result/search_box.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PackageResultScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
|
||||
PackageResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_PackageResultScreenState createState() => _PackageResultScreenState();
|
||||
}
|
||||
|
||||
class _PackageResultScreenState extends State<PackageResultScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var testResults = Provider.of<PackageProvider>(context);
|
||||
testResults.setLoading();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getPackageResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var testResults = Provider.of<PackageProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
testResults.getPackageResults();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
floatingActionButton: PackageResultFloatingButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Packages',
|
||||
push: Routes.packageFilterScreen,
|
||||
),
|
||||
Consumer<PackageProvider>(
|
||||
builder: (ctx, package, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
package.filters!.id != ''
|
||||
? PackageFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'ID',
|
||||
id: '',
|
||||
name: package.filters!.name,
|
||||
hospital: package.filters!.hospital,
|
||||
udi: package.filters!.udi,
|
||||
)
|
||||
: Container(),
|
||||
package.filters!.name != ''
|
||||
? PackageFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Package Name',
|
||||
id: package.filters!.id,
|
||||
name: '',
|
||||
udi: package.filters!.udi,
|
||||
hospital: package.filters!.hospital,
|
||||
)
|
||||
: Container(),
|
||||
package.filters!.hospital != ''
|
||||
? PackageFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Hospital',
|
||||
id: package.filters!.id,
|
||||
name: package.filters!.name,
|
||||
udi: package.filters!.udi,
|
||||
hospital: '',
|
||||
)
|
||||
: Container(),
|
||||
package.filters!.udi != ''
|
||||
? PackageFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'UDI',
|
||||
id: package.filters!.id,
|
||||
name: package.filters!.name,
|
||||
udi: '',
|
||||
hospital: package.filters!.hospital,
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
text: 'package',
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
onChanged: (value) {
|
||||
Provider.of<PackageProvider>(context, listen: false)
|
||||
.search(value);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<PackageProvider>(
|
||||
builder: (context, packageResults, _) {
|
||||
return packageResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
// String items = '';
|
||||
// for (var item in packageResults
|
||||
// .items![index].items) {
|
||||
// items += item;
|
||||
// items += ' , ';
|
||||
// }
|
||||
// items = items.substring(
|
||||
// 0,
|
||||
// items.length - 3,
|
||||
// ); // remove extra ,
|
||||
return PackageItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: packageResults.items?[index],
|
||||
);
|
||||
},
|
||||
itemCount: packageResults.items?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class PackageResultFloatingButton extends StatelessWidget {
|
||||
const PackageResultFloatingButton({
|
||||
Key? key,
|
||||
required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Routes.packageScanScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(2.5 * _deviceBlockSize),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 7.1 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.packageAddScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(_deviceBlockSize),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: kPurple,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 10 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class PackageScanScreen extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _PackageScanScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _PackageScanScreenState extends State<PackageScanScreen> {
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
@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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Packages'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 30),
|
||||
child: Text(
|
||||
'Looking for a Package?',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5.5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Please Scan The Package Barcode',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/Package/$result',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Form(
|
||||
key: _form,
|
||||
child: TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Id required!!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Or enter a Package ID',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
// borderRadius: BorderRadius.only(Radius.circular(4)),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/Package/${idCTRL.text}',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: idCTRL.text,
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kPurple, kPurpleSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Search',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
import 'package:cssd/models/package_model.dart';
|
||||
import 'package:cssd/providers/packages.dart';
|
||||
import 'package:cssd/widgets/PackageScreens/Add/package_update_button.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 '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class PackageUpdateScreen extends StatefulWidget {
|
||||
@override
|
||||
_PackageUpdateScreenState createState() => _PackageUpdateScreenState();
|
||||
}
|
||||
|
||||
class _PackageUpdateScreenState extends State<PackageUpdateScreen> {
|
||||
final _udiFocusNode = FocusNode();
|
||||
final _descriptionFocusNode = FocusNode();
|
||||
TextEditingController nameCTRL = new TextEditingController();
|
||||
TextEditingController udiCTRL = new TextEditingController();
|
||||
TextEditingController descriptionCTRL = new TextEditingController();
|
||||
TextEditingController itemCTRL = new TextEditingController();
|
||||
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
bool isEmpty = false;
|
||||
bool isInit = true;
|
||||
PackageDetailObject? datas;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<PackageProvider>(context, listen: false)
|
||||
.showPackageResult(_id.toString())
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
datas = result;
|
||||
nameCTRL.text = datas!.name;
|
||||
udiCTRL.text = datas!.udi;
|
||||
descriptionCTRL.text = datas!.description;
|
||||
for (String item in datas!.items) {
|
||||
itemCTRL.text = item;
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
await Provider.of<PackageProvider>(context, listen: false)
|
||||
.getItemFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
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.packageResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
backgroundColor: Colors.black,
|
||||
title: Text('Packages'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.packageResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(color: Colors.black),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Update a Package',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Name required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: nameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize),
|
||||
isDense: true,
|
||||
labelText: 'Package Name',
|
||||
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.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_udiFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'UDI required!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: udiCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'UDI',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _udiFocusNode,
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_descriptionFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
controller: descriptionCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Description',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.multiline,
|
||||
focusNode: _descriptionFocusNode,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
PackageUpdateButton(
|
||||
form: _form,
|
||||
id: datas!.id,
|
||||
nameCTRL: nameCTRL,
|
||||
udiCTRL: udiCTRL,
|
||||
itemCTRL: itemCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
descriptionCTRL: descriptionCTRL,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../providers/test_results.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
import '../../widgets/TestResultScreens/Add/selector_box.dart';
|
||||
|
||||
class TestResultAddScreen extends StatefulWidget {
|
||||
// static const route = '/TestResultAddScreen';
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _TestResultAddScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _TestResultAddScreenState extends State<TestResultAddScreen> {
|
||||
TextEditingController testTypeCTRL = new TextEditingController();
|
||||
final List<String> testTypeVals = [];
|
||||
|
||||
TextEditingController testCodeCTRL = new TextEditingController();
|
||||
bool isInit = true;
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (isInit) {
|
||||
var testResultProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
testResultProviderObject.getFilterItems().then((result) {
|
||||
for (var testType in result[1].keys) {
|
||||
testTypeVals.add(testType);
|
||||
}
|
||||
testTypeCTRL.text = testTypeVals[0];
|
||||
setState(() {
|
||||
isInit = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.testResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Test Results'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
// padding: EdgeInsets.all(0),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.popAndPushNamed(Routes.testResultScreen),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 20, vertical: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: 10,
|
||||
),
|
||||
child: Text(
|
||||
'Add a Test Result',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 5, bottom: 30),
|
||||
padding: EdgeInsets.all(10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'PLease Scan The Test Barcode',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: result,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 70 * _deviceBlockSize,
|
||||
child: TestResultAddSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
dataCTRL: testTypeCTRL,
|
||||
dataVals: testTypeVals,
|
||||
label: 'Choose a Test Type',
|
||||
),
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'OR',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 7 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 8 * _deviceBlockSize,
|
||||
),
|
||||
Container(
|
||||
width: 50 * _deviceBlockSize,
|
||||
child: TextFormField(
|
||||
onChanged: (val) {
|
||||
if (val != '') {
|
||||
setState(() {
|
||||
testTypeCTRL.text = '';
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
testTypeCTRL.text =
|
||||
testTypeVals[0];
|
||||
});
|
||||
}
|
||||
},
|
||||
controller: testCodeCTRL,
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons
|
||||
.sortNumericDown,
|
||||
),
|
||||
labelText: 'Enter a Test Code',
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
contentPadding: EdgeInsets.only(
|
||||
bottom: 5,
|
||||
top: 5,
|
||||
),
|
||||
),
|
||||
keyboardType:
|
||||
TextInputType.visiblePassword,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 40.0,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
width: 50 * _deviceBlockSize,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: TextButton(
|
||||
child: Text(
|
||||
'Select',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
if (testCodeCTRL.text != '') {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).testCode = testCodeCTRL.text;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: testCodeCTRL.text,
|
||||
);
|
||||
} else if (testTypeCTRL.text !=
|
||||
'') {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).testType = testTypeCTRL.text;
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.formTestResultScreen,
|
||||
arguments: testTypeCTRL.text,
|
||||
);
|
||||
}
|
||||
// print(testCode);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 5 * _deviceBlockSize,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> scan() async {
|
||||
try {
|
||||
var barcode = await BarcodeScanner.scan();
|
||||
if (barcode.type.name == 'Cancelled') {
|
||||
return 'cancel';
|
||||
} else if (barcode.type.name == 'Failed') {
|
||||
return 'error';
|
||||
}
|
||||
return barcode.rawContent;
|
||||
} on PlatformException catch (_) {
|
||||
return 'access';
|
||||
} catch (_) {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +1,78 @@
|
||||
import '../providers/connectivity.dart';
|
||||
import '../providers/test_results.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
import '../widgets/TestResultScreens/Details/datas_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class TestDetailsScreen extends StatefulWidget {
|
||||
// static const route = '/TestDetailsScreen';
|
||||
final String testResultId;
|
||||
|
||||
TestDetailsScreen({this.testResultId});
|
||||
|
||||
@override
|
||||
_TestDetailsScreenState createState() => _TestDetailsScreenState();
|
||||
}
|
||||
|
||||
class _TestDetailsScreenState extends State<TestDetailsScreen> {
|
||||
bool isInit = true;
|
||||
Map<String, dynamic> datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context).settings.arguments;
|
||||
await Provider.of<TestResultsProvider>(context, listen: false)
|
||||
.showTestResult(_id.toString())
|
||||
.then((result) {
|
||||
setState(() {
|
||||
datas = result;
|
||||
isInit = false;
|
||||
});
|
||||
});
|
||||
// print(datas);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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;
|
||||
// print(datas);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Test Result Detail'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: DatasBox(
|
||||
datas: datas,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../providers/test_results.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
import '../../widgets/TestResultScreens/Details/datas_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class TestDetailsScreen extends StatefulWidget {
|
||||
// static const route = '/TestDetailsScreen';
|
||||
final String? testResultId;
|
||||
|
||||
TestDetailsScreen({this.testResultId});
|
||||
|
||||
@override
|
||||
_TestDetailsScreenState createState() => _TestDetailsScreenState();
|
||||
}
|
||||
|
||||
class _TestDetailsScreenState extends State<TestDetailsScreen> {
|
||||
bool isInit = true;
|
||||
Map<String, Object>? datas;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var _id = ModalRoute.of(context)!.settings.arguments;
|
||||
await Provider.of<TestResultsProvider>(context, listen: false)
|
||||
.showTestResult(_id.toString())
|
||||
.then((result) {
|
||||
setState(() {
|
||||
datas = result.cast<String, Object>();
|
||||
isInit = false;
|
||||
});
|
||||
});
|
||||
// print(datas);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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;
|
||||
// print(datas);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Test Results'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: DatasBox(
|
||||
datas: datas!,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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/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';
|
||||
|
||||
@override
|
||||
_TestFilterScreenState createState() => _TestFilterScreenState();
|
||||
}
|
||||
|
||||
class _TestFilterScreenState extends State<TestFilterScreen> {
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
TextEditingController labelIdCTRL = new TextEditingController();
|
||||
TextEditingController testTypeCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
TextEditingController fDateCTRL = new TextEditingController();
|
||||
TextEditingController uDateCTRL = new TextEditingController();
|
||||
|
||||
TextEditingController usernameCTRL = new TextEditingController();
|
||||
// TextEditingController dateFrom = new TextEditingController();
|
||||
// TextEditingController dateUntil = new TextEditingController();
|
||||
DateTime? dateTimeFrom;
|
||||
DateTime? dateTimeUntil;
|
||||
|
||||
final List<String> labelIDVals = [
|
||||
'',
|
||||
'Washer ID',
|
||||
'Autoclave ID',
|
||||
'Sterilizer ID',
|
||||
'Seal Machine ID',
|
||||
'Patiant ID',
|
||||
'Set/Pack ID',
|
||||
'Medical Device ID',
|
||||
'OR ID',
|
||||
'Insrtument ID',
|
||||
'Basket ID',
|
||||
'Implant ID',
|
||||
// 'None',
|
||||
];
|
||||
// String curLabelIDVal;
|
||||
|
||||
final List<String> testTypeVals = [];
|
||||
Map<String, String>? testTypes;
|
||||
|
||||
final List<String> hospitalVals = [];
|
||||
Map<String, String> hospitals = {};
|
||||
// String curhospitalVal;
|
||||
|
||||
bool isInit = true;
|
||||
// final List<String> labelIDVals = ['Washer ID'];
|
||||
// String curLabelIDVal;
|
||||
|
||||
// final List<String> labelIDVals = ['Washer ID'];
|
||||
// String curLabelIDVal;
|
||||
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// }
|
||||
|
||||
@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 = '';
|
||||
uDateCTRL.text = '';
|
||||
var testResultProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
TestResultFilterObject filters = testResultProviderObject.filters;
|
||||
idCTRL.text = filters.id;
|
||||
usernameCTRL.text = filters.userName;
|
||||
labelIdCTRL.text =
|
||||
filters.labelID == '' ? labelIDVals[0] : filters.labelID;
|
||||
idCTRL.text = filters.id;
|
||||
usernameCTRL.text = filters.userName;
|
||||
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);
|
||||
}
|
||||
var testTypeKey = testTypes!.keys.firstWhere(
|
||||
(k) => testTypes![k] == filters.testType,
|
||||
orElse: () => ''); // recent testtype name
|
||||
var hospitalKey = hospitals.keys.firstWhere(
|
||||
(k) => hospitals[k] == filters.hospital,
|
||||
orElse: () => ''); // recent testtype name
|
||||
testTypeCTRL.text =
|
||||
filters.testType == '' ? testTypeVals[0] : testTypeKey;
|
||||
hospitalCTRL.text =
|
||||
filters.hospital == '' ? hospitalVals[0] : hospitalKey;
|
||||
// print(result[0]);
|
||||
// print(result[1]);
|
||||
setState(() {
|
||||
isInit = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.testResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Test Results'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).popAndPushNamed(
|
||||
Routes.testResultScreen,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'Filter Test Results',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
// onFieldSubmitted: (_) {
|
||||
// FocusScope.of(context)
|
||||
// .requestFocus(_cycleNumberFocusNode);
|
||||
// },
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
idCTRL.text = result;
|
||||
// Navigator.of(context).pushNamed(
|
||||
// CycleDetailScreen.route,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
TestResultFilterSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
dataCTRL: labelIdCTRL,
|
||||
dataVals: labelIDVals,
|
||||
label: 'Label ID',
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
|
||||
TextFormField(
|
||||
controller: usernameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Username',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
// onFieldSubmitted: (_) {
|
||||
// FocusScope.of(context)
|
||||
// .requestFocus(_cycleNumberFocusNode);
|
||||
// },
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
TestResultFilterSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
dataCTRL: testTypeCTRL,
|
||||
dataVals: testTypeVals,
|
||||
label: 'Test Type',
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
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<TestResultsProvider>(context,
|
||||
listen: false)
|
||||
.setFilters(
|
||||
idCTRL.text,
|
||||
labelIdCTRL.text != ''
|
||||
? labelIdCTRL.text
|
||||
: '',
|
||||
usernameCTRL.text,
|
||||
testTypeCTRL.text != ''
|
||||
? testTypes![testTypeCTRL.text]
|
||||
: '',
|
||||
hospitalCTRL.text != ''
|
||||
? hospitals[hospitalCTRL.text]
|
||||
: '',
|
||||
fDateCTRL.text,
|
||||
uDateCTRL.text,
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Filters changed.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
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,
|
||||
),
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.black, Colors.black87],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Filter',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
// DropDownBox(values: ['Washer ID']),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> 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';
|
||||
}
|
||||
}
|
||||
@@ -1,195 +1,204 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:random_string/random_string.dart';
|
||||
|
||||
import '../config/routes.dart';
|
||||
import '../providers/input.dart';
|
||||
import '../providers/test_results.dart';
|
||||
import '../widgets/TestResultScreens/Add/form_creator.dart';
|
||||
|
||||
class FormPage extends StatefulWidget {
|
||||
final String name;
|
||||
final String uniqueCode;
|
||||
final String testResultId;
|
||||
final String testTypeId;
|
||||
|
||||
FormPage({this.name, this.uniqueCode, this.testResultId, this.testTypeId});
|
||||
|
||||
@override
|
||||
_FormPageState createState() => _FormPageState();
|
||||
}
|
||||
|
||||
class _FormPageState extends State<FormPage> {
|
||||
bool _isInit = true;
|
||||
bool _isLoading = false;
|
||||
bool isAdding = false;
|
||||
final _form = GlobalKey<FormState>();
|
||||
Map<String, dynamic> values = {};
|
||||
List<Map<String, dynamic>> formInputs;
|
||||
|
||||
void _saveForm() {
|
||||
final batchId = randomString(10);
|
||||
formatData(formInputs);
|
||||
var prvObject = Provider.of<TestResultsProvider>(context, listen: false);
|
||||
if (this.widget.testResultId != null && this.widget.testResultId != '') {
|
||||
values['_method'] = 'put';
|
||||
TestResultsProvider.updateTestResult(this.widget.testResultId, values)
|
||||
.then((_) {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
prvObject.createTestResult(values, batchId).then((result) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
if (result == 'done') {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Test added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((value) =>
|
||||
Navigator.of(context).popAndPushNamed(Routes.testResultScreen));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
Provider.of<Inputs>(context, listen: false)
|
||||
.getInputs(
|
||||
testResultId: this.widget.testResultId ?? "",
|
||||
name: this.widget.name ?? "",
|
||||
uniqueCode: this.widget.uniqueCode ?? "",
|
||||
testTypeId: this.widget.testTypeId ?? "")
|
||||
.then((_) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
_isInit = false;
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.testResultAddScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('Add Test Result'),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.save),
|
||||
onPressed: () {
|
||||
_saveForm();
|
||||
},
|
||||
)
|
||||
],
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.popAndPushNamed(Routes.testResultScreen);
|
||||
},
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: _isLoading
|
||||
? Center(child: CircularProgressIndicator())
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Consumer<Inputs>(
|
||||
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,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void formatData(inputs) {
|
||||
for (var input in inputs) {
|
||||
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') {
|
||||
var date = input["value"];
|
||||
|
||||
values[input["key"]] = "${date.year}-${date.month}-${date.day}";
|
||||
} else {
|
||||
values[input["key"]] = input["value"];
|
||||
// print('${input["key"]} : ${input["value"]}');
|
||||
}
|
||||
}
|
||||
if (input['children'] != null && input['children'].isNotEmpty) {
|
||||
formatData(input['children']);
|
||||
}
|
||||
}
|
||||
// print(values);
|
||||
}
|
||||
}
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:random_string/random_string.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../providers/input.dart';
|
||||
import '../../providers/test_results.dart';
|
||||
import '../../widgets/TestResultScreens/Add/form_creator.dart';
|
||||
|
||||
class FormPage extends StatefulWidget {
|
||||
final String? name;
|
||||
final String? uniqueCode;
|
||||
final String? testResultId;
|
||||
final String? testTypeId;
|
||||
|
||||
FormPage({this.name, this.uniqueCode, this.testResultId, this.testTypeId});
|
||||
|
||||
@override
|
||||
_FormPageState createState() => _FormPageState();
|
||||
}
|
||||
|
||||
class _FormPageState extends State<FormPage> {
|
||||
bool _isInit = true;
|
||||
bool _isLoading = false;
|
||||
bool isAdding = false;
|
||||
final _form = GlobalKey<FormState>();
|
||||
Map<String, dynamic> values = {};
|
||||
List<Map<String, dynamic>> formInputs = [];
|
||||
|
||||
void _saveForm() {
|
||||
final batchId = randomString(10);
|
||||
formatData(formInputs);
|
||||
var prvObject = Provider.of<TestResultsProvider>(context, listen: false);
|
||||
if (this.widget.testResultId != null && this.widget.testResultId != '') {
|
||||
values['_method'] = 'put';
|
||||
TestResultsProvider.updateTestResult(this.widget.testResultId!, values)
|
||||
.then((_) {
|
||||
Navigator.of(context).pop();
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
prvObject.createTestResult(values, batchId).then((result) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
if (result == 'done') {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Test added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((value) =>
|
||||
Navigator.of(context).popAndPushNamed(Routes.testResultScreen));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
String testTypeName = Provider.of<TestResultsProvider>(context).testType;
|
||||
String testCode = Provider.of<TestResultsProvider>(context).testCode;
|
||||
Provider.of<Inputs>(context, listen: false)
|
||||
.getInputs(
|
||||
testResultId: '',
|
||||
name: testTypeName,
|
||||
uniqueCode: testCode,
|
||||
testTypeId: '',
|
||||
)
|
||||
.then((_) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
_isInit = false;
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.testResultAddScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('Add Test Result'),
|
||||
backgroundColor: Colors.black,
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.save),
|
||||
onPressed: () {
|
||||
_saveForm();
|
||||
},
|
||||
)
|
||||
],
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).popAndPushNamed(Routes.testResultScreen);
|
||||
},
|
||||
),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
_isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Consumer<Inputs>(
|
||||
builder: (context, inputs, _) {
|
||||
formInputs = inputs.inputItems;
|
||||
print(formInputs);
|
||||
return formInputs.length != 0
|
||||
? FormCreator(
|
||||
form: formInputs,
|
||||
onChanged: (value) {
|
||||
formInputs = value;
|
||||
},
|
||||
)
|
||||
: Center(
|
||||
child: Text('Something went wrong!!!'),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
// https://www.cssd-doc.com/api/GetInfo
|
||||
// InkWell(
|
||||
// onTap: () {
|
||||
// _saveForm();
|
||||
// },
|
||||
// child: Container(
|
||||
// padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15),
|
||||
// margin: EdgeInsets.symmetric(vertical: 20, horizontal: 50),
|
||||
// decoration: BoxDecoration(
|
||||
// gradient: LinearGradient(colors: [Colors.blue, Colors.green]),
|
||||
// borderRadius: BorderRadius.circular(10),
|
||||
// ),
|
||||
// child: Text(
|
||||
// 'Save',
|
||||
// style: TextStyle(color: Colors.white, fontSize: 17),
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void formatData(inputs) {
|
||||
for (var input in inputs) {
|
||||
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') {
|
||||
var date = input["value"];
|
||||
|
||||
values[input["key"]] = "${date.year}-${date.month}-${date.day}";
|
||||
} else {
|
||||
values[input["key"]] = input["value"];
|
||||
// print('${input["key"]} : ${input["value"]}');
|
||||
}
|
||||
}
|
||||
if (input['children'] != null && input['children'].isNotEmpty) {
|
||||
formatData(input['children']);
|
||||
}
|
||||
}
|
||||
// print(values);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
// import 'package:cssd/providers/test_result.dart';
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/providers/auth.dart';
|
||||
import 'package:cssd/providers/test_results.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';
|
||||
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/connectivity.dart';
|
||||
|
||||
class TestResultScreen extends StatefulWidget {
|
||||
// static const route = '/TestResultScreen';
|
||||
final bool? isAdmin;
|
||||
|
||||
TestResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_TestResultScreenState createState() => _TestResultScreenState();
|
||||
}
|
||||
|
||||
class _TestResultScreenState extends State<TestResultScreen> {
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
ScrollController? sc;
|
||||
|
||||
bool _isInit = true;
|
||||
// List<TestResult> _data = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var testResults =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
// testResults.resetFilters();
|
||||
testResults.setLoading();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getTestResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc!.addListener(() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var labelProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
labelProviderObject.getTestResults();
|
||||
}
|
||||
});
|
||||
|
||||
// setState(() {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
});
|
||||
_isInit = false;
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
floatingActionButton:
|
||||
TestResultFloatingButton(deviceBlockSize: _deviceBlockSize),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20, left: 20, right: 20, bottom: 60),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
// padding: EdgeInsets.only(top: 20, bottom: 40),
|
||||
child: Text(
|
||||
'My Test Results',
|
||||
// textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context)
|
||||
.popAndPushNamed(Routes.testFilterScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
FontAwesomeIcons.filter,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Consumer<TestResultsProvider>(
|
||||
builder: (context, testResult, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
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,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<TestResultsProvider>(
|
||||
builder: (context, testResults, _) {
|
||||
return testResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) =>
|
||||
TestItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: testResults.items![index],
|
||||
),
|
||||
itemCount: testResults.items?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestItemBox extends StatelessWidget {
|
||||
final TestResultObject? item;
|
||||
const TestItemBox({
|
||||
Key? key,
|
||||
required double deviceBlockSize,
|
||||
required this.item,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// print(item.result);
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).pushNamed(
|
||||
Routes.testDetailsScreen,
|
||||
arguments: item!.id,
|
||||
),
|
||||
child: Card(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 57 * _deviceBlockSize,
|
||||
child: Text(
|
||||
item!.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
// style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 57 * _deviceBlockSize,
|
||||
child: Text(
|
||||
item!.hospital,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
item!.result == 'Accepted'
|
||||
? Text(
|
||||
'Accepted',
|
||||
style: TextStyle(
|
||||
color: kLightBlue,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'Rejected',
|
||||
style: TextStyle(
|
||||
color: kPink,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(item!.date),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
userData['roles']?.contains('User') ?? false
|
||||
? Container()
|
||||
: InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text('Delete'),
|
||||
content: Text(
|
||||
'Are you sure you want delete this Test?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Yes'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false)
|
||||
.removeTestResult(item!.id);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text('No'),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 7.5,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
Routes.testDetailsScreen,
|
||||
arguments: item!.id,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(7),
|
||||
width: 9 * _deviceBlockSize,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
FontAwesomeIcons.fileAlt,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
class TestScanScreen extends StatefulWidget {
|
||||
// static const route = '/TestScanScreen';
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _TestScanScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _TestScanScreenState extends State<TestScanScreen> {
|
||||
String testCode = "";
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Test Results'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 30),
|
||||
child: Text(
|
||||
'Looking for a Test Result?',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5.5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Please Scan The Test Result Barcode',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/TestResult/$result',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Form(
|
||||
key: _form,
|
||||
child: TextFormField(
|
||||
validator: (val) {
|
||||
if (val!.isEmpty) {
|
||||
return 'Id required!!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Or enter a Test Result ID',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
// borderRadius: BorderRadius.only(Radius.circular(4)),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/TestResult/${idCTRL.text}',
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.black, Colors.black87],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Search',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,515 +1,466 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../config/routes.dart';
|
||||
import '../models/test_result_models.dart';
|
||||
import '../providers/auth.dart';
|
||||
import '../providers/test_results.dart';
|
||||
import '../widgets/TestResultScreens/Main/search_box.dart';
|
||||
|
||||
class TestVerifyScreen extends StatefulWidget {
|
||||
// static const route = '/TestVerifyScreen';
|
||||
// final bool isAdmin;
|
||||
|
||||
// TestVerifyScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_TestVerifyScreenState createState() => _TestVerifyScreenState();
|
||||
}
|
||||
|
||||
class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
ScrollController sc;
|
||||
|
||||
bool _isInit = true;
|
||||
// List<TestResult> _data = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
// setState(() {
|
||||
// _isLoading = true;
|
||||
// });
|
||||
var testResults =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
testResults.setLoading();
|
||||
testResults.resetFilters();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getTestResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc.addListener(() {
|
||||
if (sc.position.pixels == sc.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var labelProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
labelProviderObject.getTestResults();
|
||||
}
|
||||
});
|
||||
|
||||
// setState(() {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
});
|
||||
_isInit = false;
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userData = Provider.of<Auth>(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;
|
||||
final double _deviceBlockSize = _devicewidth / 100;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 60),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
// padding: EdgeInsets.only(top: 20, bottom: 40),
|
||||
child: Text(
|
||||
'TESTS TO VERIFY',
|
||||
// textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
// 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<TestResultsProvider>(
|
||||
// builder: (context, testResult, _) {
|
||||
// return Container(
|
||||
// height: 50,
|
||||
// child: ListView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// shrinkWrap: true,
|
||||
// children: <Widget>[
|
||||
// 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,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<TestResultsProvider>(
|
||||
builder: (context, testResults, _) {
|
||||
return testResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
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: <Widget>[
|
||||
// Text(testResults.items[index].name),
|
||||
// Text(testResults.items[index].isVerified.toString()),
|
||||
// Text(testResults.items[index].hospital),
|
||||
// Text(testResults.items[index].date),
|
||||
|
||||
// ],
|
||||
// ),
|
||||
// ChangeNotifierProvider.value(
|
||||
// value: testResults.items[index],
|
||||
// child: ResultCard(
|
||||
// isAdmin: widget.isAdmin,
|
||||
// ),
|
||||
// ),
|
||||
itemCount: testResults.items.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestItemBox extends StatelessWidget {
|
||||
final TestResultObject item;
|
||||
const TestItemBox({
|
||||
Key key,
|
||||
@required String id,
|
||||
@required double deviceBlockSize,
|
||||
@required this.item,
|
||||
@required this.userData,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
// _id = id,
|
||||
super(key: key);
|
||||
final Map<String, dynamic> userData;
|
||||
final double _deviceBlockSize;
|
||||
// final String _id;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).pushNamed(
|
||||
Routes.testDetailsScreen,
|
||||
arguments: item.id,
|
||||
),
|
||||
child: Card(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 57 * _deviceBlockSize,
|
||||
child: Text(
|
||||
item.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
// style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 57 * _deviceBlockSize,
|
||||
child: Text(
|
||||
item.hospital,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
item.verified == 'None'
|
||||
? Text(
|
||||
'Awaiting Verification',
|
||||
style: TextStyle(color: Colors.orange),
|
||||
)
|
||||
: item.verified == 'Verified'
|
||||
? Text(
|
||||
'Verified',
|
||||
style: TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'Rejected',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(item.date),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('Verify'),
|
||||
content: Text(
|
||||
'Are you sure for verify this test?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context)
|
||||
.changeVerification(
|
||||
item.id, 'Verified')
|
||||
.then((result) {
|
||||
if (result) {
|
||||
print('true');
|
||||
}
|
||||
Navigator.of(ctx).pop();
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
Routes.testVerifyScreen);
|
||||
});
|
||||
},
|
||||
child: Text('Yes'),
|
||||
),
|
||||
TextButton(
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 3,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('Reject'),
|
||||
content: Text(
|
||||
'Are you sure for reject this test?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await Provider.of<TestResultsProvider>(
|
||||
context)
|
||||
.changeVerification(
|
||||
item.id, 'NotVerified')
|
||||
.then((result) {
|
||||
if (result) {
|
||||
print('true');
|
||||
}
|
||||
Navigator.of(ctx).pop();
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
Routes.testVerifyScreen);
|
||||
});
|
||||
},
|
||||
child: Text('Yes'),
|
||||
),
|
||||
TextButton(
|
||||
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,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/widgets/TestResultScreens/Main/filter_chip_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../models/test_result_models.dart';
|
||||
import '../../providers/auth.dart';
|
||||
import '../../providers/test_results.dart';
|
||||
import '../../widgets/TestResultScreens/Main/search_box.dart';
|
||||
|
||||
class TestVerifyScreen extends StatefulWidget {
|
||||
// static const route = '/TestVerifyScreen';
|
||||
// final bool isAdmin;
|
||||
|
||||
// TestVerifyScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_TestVerifyScreenState createState() => _TestVerifyScreenState();
|
||||
}
|
||||
|
||||
class _TestVerifyScreenState extends State<TestVerifyScreen> {
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
ScrollController? sc;
|
||||
|
||||
bool _isInit = true;
|
||||
// List<TestResult> _data = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
// setState(() {
|
||||
// _isLoading = true;
|
||||
// });
|
||||
var testResults =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
testResults.setLoading();
|
||||
testResults.resetFilters();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getTestResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc!.addListener(() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var labelProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
labelProviderObject.getTestResults();
|
||||
}
|
||||
});
|
||||
|
||||
// setState(() {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
});
|
||||
_isInit = false;
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userData = Provider.of<Auth>(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;
|
||||
final double _deviceBlockSize = _devicewidth / 100;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.only(top: 20, left: 20, right: 20, bottom: 60),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
// padding: EdgeInsets.only(top: 20, bottom: 40),
|
||||
child: Text(
|
||||
'Tests To Verify',
|
||||
// textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Consumer<TestResultsProvider>(
|
||||
builder: (context, testResult, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
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,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<TestResultsProvider>(
|
||||
builder: (context, testResults, _) {
|
||||
return testResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
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(),
|
||||
itemCount: testResults.items?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestItemBox extends StatelessWidget {
|
||||
final TestResultObject item;
|
||||
const TestItemBox({
|
||||
Key? key,
|
||||
required String id,
|
||||
required double deviceBlockSize,
|
||||
required this.item,
|
||||
required this.userData,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
// _id = id,
|
||||
super(key: key);
|
||||
final Map<String, dynamic> userData;
|
||||
final double _deviceBlockSize;
|
||||
// final String _id;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).pushNamed(
|
||||
Routes.testDetailsScreen,
|
||||
arguments: item.id,
|
||||
),
|
||||
child: Card(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 57 * _deviceBlockSize,
|
||||
child: Text(
|
||||
item.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
// style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 57 * _deviceBlockSize,
|
||||
child: Text(
|
||||
item.hospital,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
item.verified == 'None'
|
||||
? Text(
|
||||
'Awaiting Verification',
|
||||
style: TextStyle(color: Colors.orange),
|
||||
)
|
||||
: item.verified == 'Verified'
|
||||
? Text(
|
||||
'Verified',
|
||||
style: TextStyle(
|
||||
color: kBlue,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'Rejected',
|
||||
style: TextStyle(
|
||||
color: kPink,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(item.date),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('Verify'),
|
||||
content: Text(
|
||||
'Are you sure for verify this test?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false)
|
||||
.changeVerification(
|
||||
item.id, 'Verified')
|
||||
.then((result) {
|
||||
if (result) {
|
||||
print('true');
|
||||
}
|
||||
Navigator.of(ctx).pop();
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
Routes.testVerifyScreen);
|
||||
});
|
||||
},
|
||||
child: Text('Yes'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('No'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(7),
|
||||
width: 10 * _deviceBlockSize,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: kBlue,
|
||||
),
|
||||
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: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await Provider.of<TestResultsProvider>(
|
||||
context,
|
||||
listen: false)
|
||||
.changeVerification(
|
||||
item.id, 'NotVerified')
|
||||
.then((result) {
|
||||
if (result) {
|
||||
print('true');
|
||||
}
|
||||
Navigator.of(ctx).pop();
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
Routes.testVerifyScreen);
|
||||
});
|
||||
},
|
||||
child: Text('Yes'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('No'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(7),
|
||||
width: 10 * _deviceBlockSize,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: kPink,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.close,
|
||||
size: 6 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: _deviceBlockSize,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,291 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../config/routes.dart';
|
||||
import '../models/cycles_models.dart';
|
||||
import '../providers/connectivity.dart';
|
||||
import '../providers/cycles.dart';
|
||||
import '../widgets/CycleScreens/Add/add_label_box.dart';
|
||||
import '../widgets/CycleScreens/Add/date_picker.dart';
|
||||
import '../widgets/CycleScreens/Add/save_button.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
|
||||
class CycleAddScreen extends StatefulWidget {
|
||||
// static const route = '/CycleAddScreen';
|
||||
|
||||
@override
|
||||
_CycleAddScreenState createState() => _CycleAddScreenState();
|
||||
}
|
||||
|
||||
class _CycleAddScreenState extends State<CycleAddScreen> {
|
||||
final _cycleNumberFocusNode = FocusNode();
|
||||
final _descriptionFocosNode = FocusNode();
|
||||
TextEditingController descriptionCTRL = new TextEditingController();
|
||||
TextEditingController cycleNumberCTRL = new TextEditingController();
|
||||
TextEditingController striizerIdCTRL = new TextEditingController();
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
// String initialLabelValue = '';
|
||||
DateTime dateTimeFrom;
|
||||
// String dateValue;
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
// List<String> labelVals = [];
|
||||
// List<TextEditingController> labelValues = [];
|
||||
bool isInit = true;
|
||||
CycleFilterObject filters;
|
||||
|
||||
List<TextEditingController> labelsCTRL = [TextEditingController()];
|
||||
int curLabelVal = 1;
|
||||
@override
|
||||
void initState() {
|
||||
descriptionCTRL.text = '';
|
||||
cycleNumberCTRL.text = '';
|
||||
dateCTRL.text = DateFormat('y-M-d').format(DateTime.now());
|
||||
striizerIdCTRL.text = '';
|
||||
// dateValue = DateFormat('y-M-d').format(DateTime.now());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
// var _id = ModalRoute.of(context).settings.arguments;
|
||||
var cycleProviderObject = Provider.of<CyclesProvider>(context);
|
||||
cycleProviderObject.resetLabelVals();
|
||||
cycleProviderObject.getLabelFilters().then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
// labelValues =
|
||||
// filters.hospital == '' ? labelVals[0] : filters.hospital;
|
||||
isInit = false;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.cycleResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
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),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(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: <Widget>[
|
||||
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',
|
||||
style: TextStyle(
|
||||
color: Colors.deepOrange,
|
||||
letterSpacing: 2,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Consumer<CyclesProvider>(
|
||||
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,
|
||||
),
|
||||
),
|
||||
|
||||
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<CyclesProvider>(
|
||||
context,
|
||||
listen: false)
|
||||
.labelValues,
|
||||
cycleNumberCTRL: cycleNumberCTRL,
|
||||
dateValue: dateCTRL.text,
|
||||
descriptionCTRL: descriptionCTRL,
|
||||
striizerIdCTRL: striizerIdCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
|
||||
// DropDownBox(values: ['Washer ID']),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,330 +0,0 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.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';
|
||||
|
||||
@override
|
||||
_CycleFilterScreenState createState() => _CycleFilterScreenState();
|
||||
}
|
||||
|
||||
class _CycleFilterScreenState extends State<CycleFilterScreen> {
|
||||
final _cycleNumberFocusNode = FocusNode();
|
||||
final _strilizerIdFocusNode = FocusNode();
|
||||
TextEditingController cycleIdCTRL = new TextEditingController();
|
||||
TextEditingController cycleNumberCTRL = new TextEditingController();
|
||||
TextEditingController striizerIdCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
DateTime dateTimeFrom;
|
||||
// String dateValue;
|
||||
|
||||
List<Map<String, String>> hospitalVals = [];
|
||||
// String curhospitalVal;
|
||||
bool isInit = true;
|
||||
CycleFilterObject filters;
|
||||
@override
|
||||
void initState() {
|
||||
filters = Provider.of<CyclesProvider>(context, listen: false).filters;
|
||||
cycleIdCTRL.text = filters.id;
|
||||
cycleNumberCTRL.text = filters.cycleNumber;
|
||||
// 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();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
// var _id = ModalRoute.of(context).settings.arguments;
|
||||
await Provider.of<CyclesProvider>(context, listen: false)
|
||||
.getHospitalsFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
hospitalVals = [
|
||||
{'id': '', 'name': ''}
|
||||
];
|
||||
for (var hospital in result) {
|
||||
hospitalVals.add(hospital);
|
||||
}
|
||||
filters.hospital == ''
|
||||
? hospitalCTRL.text = hospitalVals[0]['name']
|
||||
: hospitalVals.forEach(
|
||||
//id convert to name
|
||||
(hospital) {
|
||||
if (hospital['id'] == filters.hospital) {
|
||||
hospitalCTRL.text = hospital['name'];
|
||||
}
|
||||
},
|
||||
);
|
||||
isInit = false;
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.cycleResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
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),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'FILTER RESULTS',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: cycleIdCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Cycle ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_cycleNumberFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
// Spacer(),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
cycleIdCTRL.text = result;
|
||||
// Navigator.of(context).pushNamed(
|
||||
// CycleDetailScreen.route,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
FontAwesomeIcons.barcode,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: cycleNumberCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Cycle Number',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _cycleNumberFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_strilizerIdFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
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();
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> 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';
|
||||
}
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
import '../config/routes.dart';
|
||||
|
||||
import '../providers/connectivity.dart';
|
||||
import '../widgets/CycleScreens/Result/banner.dart';
|
||||
import '../widgets/CycleScreens/Result/data_box.dart';
|
||||
import '../widgets/CycleScreens/Result/filter_objects.dart';
|
||||
import '../widgets/CycleScreens/Result/search_box.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
|
||||
import '../providers/cycles.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CycleResultScreen extends StatefulWidget {
|
||||
// static const route = '/CycleResultScreen';
|
||||
final bool isAdmin;
|
||||
|
||||
CycleResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_CycleResultScreenState createState() => _CycleResultScreenState();
|
||||
}
|
||||
|
||||
class _CycleResultScreenState extends State<CycleResultScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var testResults = Provider.of<CyclesProvider>(context);
|
||||
testResults.setLoading();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getCycleResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc.addListener(
|
||||
() {
|
||||
if (sc.position.pixels == sc.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var testResults = Provider.of<CyclesProvider>(context);
|
||||
testResults.getCycleResults();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: Scaffold(
|
||||
floatingActionButton: CycleResultFloatingButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding:
|
||||
EdgeInsets.only(top: 20, right: 20, bottom: 60, left: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
CycleResultBanner(deviceBlockSize: _deviceBlockSize),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Consumer<CyclesProvider>(builder: (ctx, cycle, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
CycleFilterBaner(
|
||||
deviceBlockSize: _deviceBlockSize),
|
||||
cycle.filters.id != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'ID',
|
||||
id: '',
|
||||
cycleNumber: cycle.filters.cycleNumber,
|
||||
sterilizerId: cycle.filters.sterilizerId,
|
||||
hospital: cycle.filters.hospital,
|
||||
date: cycle.filters.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters.cycleNumber != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Cycle Number',
|
||||
id: cycle.filters.id,
|
||||
cycleNumber: '',
|
||||
sterilizerId: cycle.filters.sterilizerId,
|
||||
hospital: cycle.filters.hospital,
|
||||
date: cycle.filters.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters.sterilizerId != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Sterilizer ID',
|
||||
id: cycle.filters.id,
|
||||
cycleNumber: cycle.filters.cycleNumber,
|
||||
sterilizerId: '',
|
||||
hospital: cycle.filters.hospital,
|
||||
date: cycle.filters.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters.hospital != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Hospital',
|
||||
id: cycle.filters.id,
|
||||
cycleNumber: cycle.filters.cycleNumber,
|
||||
sterilizerId: cycle.filters.sterilizerId,
|
||||
hospital: '',
|
||||
date: cycle.filters.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters.date != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Date',
|
||||
id: cycle.filters.id,
|
||||
cycleNumber: cycle.filters.cycleNumber,
|
||||
sterilizerId: cycle.filters.sterilizerId,
|
||||
hospital: cycle.filters.hospital,
|
||||
date: '',
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
CycleResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<CyclesProvider>(
|
||||
builder: (context, cycleResults, _) {
|
||||
return cycleResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
String labels = '';
|
||||
for (var label
|
||||
in cycleResults.items[index].label) {
|
||||
labels += label;
|
||||
labels += ' , ';
|
||||
}
|
||||
labels = labels.substring(0,
|
||||
labels.length - 3); // remove extra ,
|
||||
return CycleItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: cycleResults.items[index],
|
||||
labels: labels,
|
||||
);
|
||||
},
|
||||
itemCount: cycleResults.items.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CycleResultFloatingButton extends StatelessWidget {
|
||||
const CycleResultFloatingButton({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Routes.cycleScanScreen);
|
||||
},
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.cycleAddScreen);
|
||||
},
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../providers/connectivity.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
|
||||
class CycleScanScreen extends StatefulWidget {
|
||||
// static const route = '/cycleScanScreen';
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _CycleScanScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _CycleScanScreenState extends State<CycleScanScreen> {
|
||||
String testCode = "";
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
@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 SafeArea(
|
||||
child: 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<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 30),
|
||||
child: Text(
|
||||
'LOOKING FOR A CYCLE?',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5.5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Please Scan The Cycle Barcode',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/Cycle/$result',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
Form(
|
||||
key: _form,
|
||||
child: TextFormField(
|
||||
validator: (val) {
|
||||
if (val.isEmpty) {
|
||||
return 'Id required!!';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
isDense: true,
|
||||
labelText: 'Or enter a cycle ID',
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2,
|
||||
horizontal: 3,
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
// borderRadius: BorderRadius.only(Radius.circular(4)),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
Divider(
|
||||
color: Colors.black,
|
||||
thickness: 3,
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
launch(
|
||||
'https://cssd-doc.com/Show/Cycle/${idCTRL.text}',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// Routes.cycleDetailScreen,
|
||||
// arguments: idCTRL.text,
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
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<String> 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';
|
||||
}
|
||||
}
|
||||
}
|
||||
+484
-462
@@ -1,462 +1,484 @@
|
||||
import 'package:barcode_scan2/platform_wrapper.dart';
|
||||
import 'package:double_back_to_close_app/double_back_to_close_app.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_phoenix/flutter_phoenix.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.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 'my_info_screen.dart';
|
||||
import 'test_result_screen.dart';
|
||||
import 'test_verify_screen.dart';
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
// 09338736511
|
||||
|
||||
// static const route = '/HomeScreen';
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
|
||||
// print(userData['roles']);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
// resizeToAvoidBottomPadding: false,
|
||||
drawer: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) =>
|
||||
value != 'offline' ? AppDrawer() : Container(),
|
||||
selector: (_, connctivity) => connctivity.conStatus,
|
||||
)
|
||||
// Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
// return connection.conStatus != 'offline' ? AppDrawer() : Container();
|
||||
// })
|
||||
,
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
actions: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
Icons.power_settings_new,
|
||||
),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('LogOut'),
|
||||
content: Text('Are you sure for logout?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Yes'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
Provider.of<Auth>(context, listen: false).logout();
|
||||
Phoenix.rebirth(context);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text('No'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? DoubleBackToCloseApp(
|
||||
snackBar: SnackBar(
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: Colors.black,
|
||||
content: Text(
|
||||
'Double tap for exit . . .',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: 0, bottom: 10, left: 20, right: 20),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 20, bottom: 10),
|
||||
child: Text(
|
||||
'WELCOME HOME',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
letterSpacing: 3.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
startColor: Color(0xFFFCB8A2),
|
||||
endColor: Color(0xFFFFECD2),
|
||||
firstLine: 'My INFO',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return MyInfoScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
startColor: Color(0xFFD5F5FD),
|
||||
endColor: Color(0xFFE9FFF7),
|
||||
firstLine: 'TEST RESULTS',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return TestResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
// MyTestResult(
|
||||
// isAdmin: false,
|
||||
// ),
|
||||
),
|
||||
SelectionItem(
|
||||
startColor: Color(0xFFE2D2C4),
|
||||
endColor: Color(0xFFFAF7F5),
|
||||
firstLine: 'LABELS',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return LabelResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
startColor: Color(0xFFA7CCE1),
|
||||
endColor: Color(0xFFECF7ED),
|
||||
firstLine: 'CYCLES',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return CycleResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
// 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: 'Verify and reject Test Results',
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return TestVerifyScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
BarcodeSelectionItem(),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> 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;
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'null';
|
||||
}
|
||||
} on PlatformException catch (_) {
|
||||
return 'access';
|
||||
} catch (_) {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
class SelectionItem extends StatelessWidget {
|
||||
final Color startColor;
|
||||
final Color endColor;
|
||||
final String firstLine;
|
||||
final String secondLine;
|
||||
final Function onTap;
|
||||
|
||||
SelectionItem(
|
||||
{this.startColor,
|
||||
this.endColor,
|
||||
this.firstLine,
|
||||
this.secondLine,
|
||||
this.onTap});
|
||||
|
||||
@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 Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [startColor, endColor],
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(3),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
splashColor: Colors.red,
|
||||
onTap: onTap,
|
||||
child: ListTile(
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
firstLine,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3.5,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
secondLine,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
// Column(
|
||||
// children: <Widget>[
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// firstLine,
|
||||
// textAlign: TextAlign.start,
|
||||
// style: TextStyle(color: Colors.black),
|
||||
// ),
|
||||
// ),
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// secondLine,
|
||||
// style: TextStyle(color: Colors.black, fontSize: 20),
|
||||
// ),
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward_ios,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BarcodeSelectionItem extends StatelessWidget {
|
||||
@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 Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.black, Colors.black87],
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(3),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
splashColor: Colors.red,
|
||||
onTap: () => scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: Text(
|
||||
'نتیجه ی اسکن',
|
||||
textDirection: TextDirection.rtl,
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontSize: 2.75 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
result,
|
||||
textDirection: TextDirection.rtl,
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await launch(result);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(
|
||||
'بازکردن در مرورگر',
|
||||
style: TextStyle(
|
||||
fontFamily: 'montserrat',
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.qr_code_scanner,
|
||||
color: Colors.white,
|
||||
size: 8 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'SCANNER',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3.5,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Scan a Bar or QR code',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
// Column(
|
||||
// children: <Widget>[
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// firstLine,
|
||||
// textAlign: TextAlign.start,
|
||||
// style: TextStyle(color: Colors.black),
|
||||
// ),
|
||||
// ),
|
||||
// ListTile(
|
||||
// title: Text(
|
||||
// secondLine,
|
||||
// style: TextStyle(color: Colors.black, fontSize: 20),
|
||||
// ),
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward_ios,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:barcode_scan2/platform_wrapper.dart';
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/pages/ItemPages/item_result_screen.dart';
|
||||
import 'package:cssd/pages/MyItemsPages/Result/my_items_result_screen.dart';
|
||||
import 'package:cssd/pages/MyPackagesPages/Result/my_packages_result_screen.dart';
|
||||
import 'package:cssd/pages/PackagePages/package_result_screen.dart';
|
||||
import 'package:double_back_to_close_app/double_back_to_close_app.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_phoenix/flutter_phoenix.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../providers/auth.dart';
|
||||
import '../providers/connectivity.dart';
|
||||
import '../widgets/Global/drawer.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
import 'CyclePages/cycle_result_screen.dart';
|
||||
import 'LabelPages/label_result_screen.dart';
|
||||
import 'my_info_screen.dart';
|
||||
import 'TestPages/test_result_screen.dart';
|
||||
import 'TestPages/test_verify_screen.dart';
|
||||
|
||||
class HomePage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
drawer: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) =>
|
||||
value != 'offline' ? AppDrawer() : Container(),
|
||||
selector: (_, connectivity) => connectivity.conStatus,
|
||||
),
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
backgroundColor: Colors.black,
|
||||
actions: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
Icons.power_settings_new,
|
||||
),
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('LogOut'),
|
||||
content: Text('Are you sure for logout?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Yes'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
Provider.of<Auth>(context, listen: false).logout();
|
||||
Phoenix.rebirth(context);
|
||||
},
|
||||
),
|
||||
TextButton(
|
||||
child: Text('No'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? DoubleBackToCloseApp(
|
||||
snackBar: SnackBar(
|
||||
duration: Duration(seconds: 2),
|
||||
backgroundColor: Colors.black,
|
||||
content: Text(
|
||||
'Double tap for exit . . .',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: 0, bottom: 10, left: 20, right: 20),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 20, bottom: 10),
|
||||
child: Text(
|
||||
'WELCOME HOME',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 20,
|
||||
letterSpacing: 3.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'MY INFO',
|
||||
secondLine: 'Personal Details',
|
||||
firstLineColor: Colors.black,
|
||||
secondLineColor: Colors.grey,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return MyInfoScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'TEST RESULTS',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: Colors.black,
|
||||
secondLineColor: Colors.grey,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return TestResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 2,
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'LABELS',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: kLightBlue,
|
||||
secondLineColor: kLightBlueSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return LabelResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'CYCLES',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: kPink,
|
||||
secondLineColor: kPinkSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return CycleResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 2,
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'PACKAGES',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: kPurple,
|
||||
secondLineColor: kPurpleSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return PackageResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'MY PACKAGES',
|
||||
secondLine: 'The Package that i possess',
|
||||
firstLineColor: kDarkPurple,
|
||||
secondLineColor: kDarkPurpleSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return MyPackagesResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 2,
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'ITEMS',
|
||||
secondLine: 'List, Details & Add a one',
|
||||
firstLineColor: kBlue,
|
||||
secondLineColor: kBlueSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return ItemResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
SelectionItem(
|
||||
firstLine: 'MY ITEMS',
|
||||
secondLine: 'The Items that i possess',
|
||||
firstLineColor: kDarkBlue,
|
||||
secondLineColor: kDarkBlueSub,
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return MyItemsResultScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(height: 2),
|
||||
userData['roles']?.contains('User') ?? false
|
||||
? Container()
|
||||
: SelectionItem(
|
||||
firstLine: 'TEST TO VERIFY',
|
||||
secondLine: 'Verify and reject Test Results',
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
return Consumer<Auth>(
|
||||
builder: (ctx, auth, _) {
|
||||
return TestVerifyScreen();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
BarcodeSelectionItem(),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> 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;
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'null';
|
||||
}
|
||||
} on PlatformException catch (_) {
|
||||
return 'access';
|
||||
} catch (_) {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
class SelectionItem extends StatelessWidget {
|
||||
final String? firstLine;
|
||||
final String? secondLine;
|
||||
final Color? firstLineColor;
|
||||
final Color? secondLineColor;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
SelectionItem({
|
||||
this.firstLine,
|
||||
this.secondLine,
|
||||
this.onTap,
|
||||
this.firstLineColor,
|
||||
this.secondLineColor,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final _media = MediaQuery.of(context);
|
||||
final double _devicewidth = _media.size.width;
|
||||
final double _deviceBlockSize = _devicewidth / 100;
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(3),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
splashColor: Colors.grey[350],
|
||||
onTap: onTap,
|
||||
child: ListTile(
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
firstLine!,
|
||||
style: TextStyle(
|
||||
color: firstLineColor,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3.5,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
secondLine!,
|
||||
style: TextStyle(
|
||||
color: secondLineColor,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BarcodeSelectionItem extends StatelessWidget {
|
||||
@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 Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.black, Colors.black87],
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(3),
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
splashColor: Colors.red,
|
||||
onTap: () => scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: Text(
|
||||
'نتیجه ی اسکن',
|
||||
textDirection: TextDirection.rtl,
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontSize: 2.75 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
content: Text(
|
||||
result,
|
||||
textDirection: TextDirection.rtl,
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await launch(result);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(
|
||||
'بازکردن در مرورگر',
|
||||
style: TextStyle(
|
||||
fontFamily: 'montserrat',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.qr_code_scanner,
|
||||
color: Colors.white,
|
||||
size: 8 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'SCANNER',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3.5,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Scan a Bar or QR code',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,281 +0,0 @@
|
||||
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';
|
||||
|
||||
@override
|
||||
_LabelAddScreenState createState() => _LabelAddScreenState();
|
||||
}
|
||||
|
||||
class _LabelAddScreenState extends State<LabelAddScreen> {
|
||||
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<FormState>();
|
||||
|
||||
List<Map<String, String>> packageVals = [];
|
||||
List<String> packageValue = [];
|
||||
bool isInit = true;
|
||||
// CycleFilterObject filters;
|
||||
|
||||
List<TextEditingController> 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) {
|
||||
Provider.of<LabelsProvider>(context, listen: false)
|
||||
.getPackageFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
packageVals = result;
|
||||
packageValue.add(result[0]['id']);
|
||||
packageValue.add(result[0]['name']);
|
||||
packageCTRL.text = result[0]['name'];
|
||||
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: SafeArea(
|
||||
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<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
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,
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
LabelAddSaveButton(
|
||||
form: _form,
|
||||
lotNumberCTRL: lotNumberCTRL,
|
||||
cycleNumberCTRL: cycleNumberCTRL,
|
||||
sDateCTRL: sDateCTRL,
|
||||
packageValue: packageValue,
|
||||
eDateCTRL: eDateCTRL,
|
||||
striizerIdCTRL: striizerIdCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
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/Filter/save_button.dart';
|
||||
import '../widgets/LabelScreens/Filter/selector_box.dart';
|
||||
|
||||
class LabelFilterScreen extends StatefulWidget {
|
||||
// static const route = '/LabelFilterScreen';
|
||||
|
||||
@override
|
||||
_LabelFilterScreenState createState() => _LabelFilterScreenState();
|
||||
}
|
||||
|
||||
class _LabelFilterScreenState extends State<LabelFilterScreen> {
|
||||
final _cycleNumberFocusNode = FocusNode();
|
||||
final _strilizerIdFocusNode = FocusNode();
|
||||
|
||||
TextEditingController labelIdCTRl = new TextEditingController();
|
||||
TextEditingController cycleNumberCTRL = new TextEditingController();
|
||||
TextEditingController striizerIdCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
|
||||
TextEditingController dateCTRL = new TextEditingController();
|
||||
DateTime dateTimeFrom;
|
||||
|
||||
List<Map<String, String>> hospitalVals = [];
|
||||
bool isInit = true;
|
||||
LabelFilterObject filters;
|
||||
@override
|
||||
void initState() {
|
||||
filters = Provider.of<LabelsProvider>(context, listen: false).filters;
|
||||
labelIdCTRl.text = filters.id;
|
||||
cycleNumberCTRL.text = filters.cycleNumber;
|
||||
striizerIdCTRL.text = filters.sterilizerId;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
await Provider.of<LabelsProvider>(context, listen: false)
|
||||
.getHospitalsFilters()
|
||||
.then(
|
||||
(result) {
|
||||
setState(
|
||||
() {
|
||||
hospitalVals = [
|
||||
{'id': '', 'name': ''}
|
||||
];
|
||||
for (var hospital in result) {
|
||||
hospitalVals.add(hospital);
|
||||
}
|
||||
// hospitalVals = result;
|
||||
filters.hospital == ''
|
||||
? hospitalCTRL.text = hospitalVals[0]['name']
|
||||
: hospitalVals.forEach(
|
||||
//id convert to name
|
||||
(hospital) {
|
||||
if (hospital['id'] == filters.hospital)
|
||||
hospitalCTRL.text = hospital['name'];
|
||||
},
|
||||
);
|
||||
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: SafeArea(
|
||||
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<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'FILTER RESULTS',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: labelIdCTRl,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Label ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).requestFocus(
|
||||
_cycleNumberFocusNode);
|
||||
},
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
labelIdCTRl.text = result;
|
||||
// Navigator.of(context).pushNamed(
|
||||
// CycleDetailScreen.route,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
FontAwesomeIcons.barcode,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: cycleNumberCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Cycle Number',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
focusNode: _cycleNumberFocusNode,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_strilizerIdFocusNode);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
TextFormField(
|
||||
controller: striizerIdCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Strilizer ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
textInputAction: TextInputAction.done,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
focusNode: _strilizerIdFocusNode,
|
||||
),
|
||||
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();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> 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';
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
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/Global/page_header.dart';
|
||||
import '../widgets/LabelScreens/Result/data_box.dart';
|
||||
import '../widgets/LabelScreens/Result/filter_chip_box.dart';
|
||||
import '../widgets/LabelScreens/Result/floating_buttons.dart';
|
||||
import '../widgets/LabelScreens/Result/search_box.dart';
|
||||
|
||||
class LabelResultScreen extends StatefulWidget {
|
||||
// static const route = '/LabelResultScreen';
|
||||
final bool isAdmin;
|
||||
|
||||
LabelResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_LabelResultScreenState createState() => _LabelResultScreenState();
|
||||
}
|
||||
|
||||
class _LabelResultScreenState extends State<LabelResultScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var labelProviderObject =
|
||||
Provider.of<LabelsProvider>(context, listen: false);
|
||||
labelProviderObject.setLoading();
|
||||
labelProviderObject.resetPageNumber();
|
||||
labelProviderObject.getLabelResults().then((_) {
|
||||
labelProviderObject.resetLoading();
|
||||
sc.addListener(() {
|
||||
if (sc.position.pixels == sc.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var labelProviderObject =
|
||||
Provider.of<LabelsProvider>(context, listen: false);
|
||||
labelProviderObject.getLabelResults();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: Scaffold(
|
||||
floatingActionButton:
|
||||
LabelFloatingButtons(deviceBlockSize: _deviceBlockSize),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20, right: 20, bottom: 60, left: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
PageHeader(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'LABELS',
|
||||
route: Routes.labelFilterScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Consumer<LabelsProvider>(
|
||||
builder: (context, label, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
Routes.labelFilterScreen,
|
||||
);
|
||||
},
|
||||
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.labelFilterScreen,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
label.filters.id != ''
|
||||
? LabelFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
id: '',
|
||||
cycleNumber:
|
||||
label.filters.cycleNumber,
|
||||
sterilizerId:
|
||||
label.filters.sterilizerId,
|
||||
hospital: label.filters.hospital,
|
||||
label: 'ID',
|
||||
)
|
||||
: Container(),
|
||||
label.filters.cycleNumber != ''
|
||||
? LabelFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
id: label.filters.id,
|
||||
cycleNumber: '',
|
||||
sterilizerId:
|
||||
label.filters.sterilizerId,
|
||||
hospital: label.filters.hospital,
|
||||
label: 'Cycle Number',
|
||||
)
|
||||
: Container(),
|
||||
label.filters.sterilizerId != ''
|
||||
? LabelFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
id: label.filters.id,
|
||||
cycleNumber:
|
||||
label.filters.cycleNumber,
|
||||
sterilizerId: '',
|
||||
hospital: label.filters.hospital,
|
||||
label: 'Sterilizer ID',
|
||||
)
|
||||
: Container(),
|
||||
label.filters.hospital != ''
|
||||
? LabelFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
id: label.filters.id,
|
||||
cycleNumber:
|
||||
label.filters.cycleNumber,
|
||||
sterilizerId:
|
||||
label.filters.sterilizerId,
|
||||
hospital: '',
|
||||
label: 'Hospital',
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
LabelSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
deviceBlockSize: _deviceBlockSize),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<LabelsProvider>(
|
||||
builder: (context, labelResults, _) {
|
||||
return labelResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) =>
|
||||
LabelItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: labelResults.items[index],
|
||||
),
|
||||
itemCount: labelResults.items.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../providers/connectivity.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
import '../widgets/LabelScreens/Scan/input_box.dart';
|
||||
import '../widgets/LabelScreens/Scan/save_button.dart';
|
||||
import '../widgets/LabelScreens/Scan/scan_box.dart';
|
||||
// import 'package:flutter/services.dart';
|
||||
// import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
|
||||
class LabelScanScreen extends StatefulWidget {
|
||||
// static const route = '/LabelScanScreen';
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _LabelScanScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _LabelScanScreenState extends State<LabelScanScreen> {
|
||||
String testCode = "";
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
@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 SafeArea(
|
||||
child: 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<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 30),
|
||||
child: Text(
|
||||
'LOOKING FOR A Label?',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5.5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
LabelScanBox(),
|
||||
Form(
|
||||
key: _form,
|
||||
child: LabelScanInputBox(
|
||||
idCTRL: idCTRL, deviceBlockSize: _deviceBlockSize),
|
||||
),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
Divider(
|
||||
color: Colors.black,
|
||||
thickness: 3,
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
FilterScanSaveButton(
|
||||
form: _form,
|
||||
idCTRL: idCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,305 +0,0 @@
|
||||
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<LabelUpdateScreen> {
|
||||
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<FormState>();
|
||||
|
||||
List<Map<String, String>> packageVals = [];
|
||||
List<String> packageValue = [];
|
||||
bool isEmpty = false;
|
||||
bool isInit = true;
|
||||
LabelDetailsObject datas;
|
||||
// CycleFilterObject filters;
|
||||
|
||||
List<TextEditingController> 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<LabelsProvider>(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<LabelsProvider>(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: SafeArea(
|
||||
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<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
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();
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,297 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.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 LoginScreen extends StatefulWidget {
|
||||
// static const route = '/HomeScreen';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _LoginScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _LoginScreenState extends State<LoginScreen> {
|
||||
final _passwordFocusNode = FocusNode();
|
||||
final _form = GlobalKey<FormState>();
|
||||
bool _isLoading = false;
|
||||
final cellNumberController = TextEditingController();
|
||||
final passwordController = TextEditingController();
|
||||
|
||||
bool _hidePass = true;
|
||||
Map<String, dynamic> map = Map<String, dynamic>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
cellNumberController.text = map['cellNumber'];
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_passwordFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _showDialog(String message) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
title: Text('Error'),
|
||||
content: Text(message),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _login() async {
|
||||
if (!_form.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
_form.currentState.save();
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
// try {
|
||||
await Provider.of<Auth>(context, listen: false)
|
||||
.login(
|
||||
map['cellNumber'],
|
||||
map['password'],
|
||||
)
|
||||
.then(
|
||||
(result) {
|
||||
if (result == 'error') {
|
||||
_showDialog('Something went wrong!');
|
||||
setState(
|
||||
() {
|
||||
_isLoading = false;
|
||||
},
|
||||
);
|
||||
} else if (result == 'badinput') {
|
||||
_showDialog('User or password incorrect!');
|
||||
setState(
|
||||
() {
|
||||
_isLoading = false;
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
// }
|
||||
// } catch (error) {
|
||||
// _showDialog('something went wrong!');
|
||||
// setState(() {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
// }
|
||||
|
||||
// Navigator.pushReplacement(
|
||||
// context,
|
||||
// MaterialPageRoute(builder: (context) {
|
||||
// return HomePage();
|
||||
// }),
|
||||
// );
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('CSSD'),
|
||||
),
|
||||
body: Selector<ConnectivityProvider, String>(
|
||||
builder: (ctx, value, _) => value != 'offline'
|
||||
? _isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Form(
|
||||
key: _form,
|
||||
child: ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 20),
|
||||
child: Text(
|
||||
'LOGIN',
|
||||
textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 6 * _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,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_passwordFocusNode);
|
||||
},
|
||||
onSaved: (value) {
|
||||
map['cellNumber'] = value;
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
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: (_) {
|
||||
_login();
|
||||
},
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
focusNode: _passwordFocusNode,
|
||||
onSaved: (value) {
|
||||
map['password'] = value;
|
||||
},
|
||||
),
|
||||
SizedBox(height: 40),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: () => _login(),
|
||||
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: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.exit_to_app,
|
||||
color: Colors.white,
|
||||
),
|
||||
Text(
|
||||
'Login',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
Spacer()
|
||||
],
|
||||
)),
|
||||
),
|
||||
Spacer(),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 10),
|
||||
TextButton(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
'Forgot Password ?',
|
||||
style: TextStyle(
|
||||
color: Colors.black54,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushNamed(Routes.forgetPassScreen),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox(),
|
||||
selector: (_, connectivity) => connectivity.conStatus,
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
+189
-180
@@ -1,180 +1,189 @@
|
||||
// import 'package:cssd/widgets/LabelScreens/LabelDetails/header.dart';
|
||||
import 'package:cssd/providers/connectivity.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';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/auth.dart';
|
||||
|
||||
class MyInfoScreen extends StatefulWidget {
|
||||
// static const route = '/MyInfoScreenRoute';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _MyInfoScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||
Map<String, dynamic> user;
|
||||
TextEditingController usernameCTRL = new TextEditingController();
|
||||
TextEditingController emailCTRL = new TextEditingController();
|
||||
|
||||
bool isInit = true;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var authObj = Provider.of<Auth>(context, listen: false);
|
||||
user = await authObj.getUserData();
|
||||
usernameCTRL.text = user['name'] != null ? user['name'] : '';
|
||||
emailCTRL.text = user['email'] != null ? user['email'] : '';
|
||||
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 SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Dashboard'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView(
|
||||
children: <Widget>[
|
||||
InfoHeader(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'MY INFO',
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
InfoInputBox(
|
||||
controller: usernameCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Full Name',
|
||||
icon: FontAwesomeIcons.sortNumericDown,
|
||||
inputType: TextInputType.text,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
readOnly: true,
|
||||
initialValue: user['cell_number'],
|
||||
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,
|
||||
color: Colors.grey,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InfoInputBox(
|
||||
controller: emailCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Email Address',
|
||||
icon: FontAwesomeIcons.envelope,
|
||||
inputType: TextInputType.emailAddress,
|
||||
),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
InkWell(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 60, vertical: 10),
|
||||
margin: EdgeInsets.only(top: 50, bottom: 20),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.blue, Colors.green],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
await Provider.of<Auth>(context,
|
||||
listen: false)
|
||||
.setUserData(
|
||||
user['id'],
|
||||
usernameCTRL.text,
|
||||
emailCTRL.text,
|
||||
)
|
||||
.then(
|
||||
(value) async => await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text(
|
||||
'Info changed successfully.',
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// import 'package:cssd/widgets/LabelScreens/LabelDetails/header.dart';
|
||||
import 'package:cssd/providers/connectivity.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';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/auth.dart';
|
||||
|
||||
class MyInfoScreen extends StatefulWidget {
|
||||
// static const route = '/MyInfoScreenRoute';
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _MyInfoScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||
Map<String, dynamic>? user;
|
||||
TextEditingController usernameCTRL = new TextEditingController();
|
||||
TextEditingController emailCTRL = new TextEditingController();
|
||||
|
||||
bool isInit = true;
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
var authObj = Provider.of<Auth>(context, listen: false);
|
||||
user = await authObj.getUserData();
|
||||
usernameCTRL.text = user!['name'] != null ? user!['name'] : '';
|
||||
emailCTRL.text = user!['email'] != null ? user!['email'] : '';
|
||||
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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Dashboard'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView(
|
||||
children: <Widget>[
|
||||
InfoHeader(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'My Info',
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
InfoInputBox(
|
||||
controller: usernameCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Full Name',
|
||||
icon: FontAwesomeIcons.alignLeft,
|
||||
inputType: TextInputType.text,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
TextFormField(
|
||||
readOnly: true,
|
||||
initialValue: user!['cell_number'],
|
||||
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,
|
||||
color: Colors.grey,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
InfoInputBox(
|
||||
controller: emailCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Email Address',
|
||||
icon: FontAwesomeIcons.envelope,
|
||||
inputType: TextInputType.emailAddress,
|
||||
),
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
InkWell(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 60, vertical: 10),
|
||||
margin:
|
||||
EdgeInsets.only(top: 50, bottom: 20),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
await Provider.of<Auth>(context,
|
||||
listen: false)
|
||||
.setUserData(
|
||||
user!['id'],
|
||||
usernameCTRL.text,
|
||||
emailCTRL.text,
|
||||
)
|
||||
.then(
|
||||
(value) async => await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text(
|
||||
'Info changed successfully.',
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,283 +0,0 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
// import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
|
||||
|
||||
import 'package:cssd/pages/test_form_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../config/routes.dart';
|
||||
import '../providers/connectivity.dart';
|
||||
import '../providers/test_results.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
import '../widgets/TestResultScreens/Add/selector_box.dart';
|
||||
|
||||
class TestResultAddScreen extends StatefulWidget {
|
||||
// static const route = '/TestResultAddScreen';
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _TestResultAddScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _TestResultAddScreenState extends State<TestResultAddScreen> {
|
||||
String testCode = "";
|
||||
TextEditingController testTypeCTRL = new TextEditingController();
|
||||
final List<String> testTypeVals = [];
|
||||
|
||||
TextEditingController testIdCTRL = new TextEditingController();
|
||||
bool isInit = true;
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (isInit) {
|
||||
var testResultProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
testResultProviderObject.getFilterItems().then((result) {
|
||||
for (var testType in result[1].keys) {
|
||||
testTypeVals.add(testType);
|
||||
}
|
||||
testTypeCTRL.text = testTypeVals[0];
|
||||
setState(() {
|
||||
isInit = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.testResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
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),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView(
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 20, vertical: 20),
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
top: 10,
|
||||
),
|
||||
child: Text(
|
||||
'ADD A TEST RESULT',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
letterSpacing: 3,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 5, bottom: 30),
|
||||
padding: EdgeInsets.all(10),
|
||||
height: 200,
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'PLEASE SCAN THE TEST BARCODE',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w100,
|
||||
letterSpacing: 3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 70 * _deviceBlockSize,
|
||||
child: TestResultAddSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
dataCTRL: testTypeCTRL,
|
||||
dataVals: testTypeVals,
|
||||
label: 'Choose a Test Type'),
|
||||
),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'OR',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 7 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 8 * _deviceBlockSize,
|
||||
),
|
||||
Container(
|
||||
width: 50 * _deviceBlockSize,
|
||||
child: TextFormField(
|
||||
onChanged: (val) {
|
||||
if (val != '') {
|
||||
setState(() {
|
||||
testTypeCTRL.text = '';
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
testTypeCTRL.text =
|
||||
testTypeVals[0];
|
||||
});
|
||||
}
|
||||
},
|
||||
controller: 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,
|
||||
margin: EdgeInsets.only(bottom: 50),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFEB4A64),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: TextButton(
|
||||
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();
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> scan() async {
|
||||
try {
|
||||
var barcode = await BarcodeScanner.scan();
|
||||
if (barcode.type.name == 'Cancelled') {
|
||||
return 'cancel';
|
||||
} else if (barcode.type.name == 'Failed') {
|
||||
return 'error';
|
||||
}
|
||||
return barcode.rawContent;
|
||||
} on PlatformException catch (_) {
|
||||
return 'access';
|
||||
} catch (_) {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,423 +0,0 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.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/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';
|
||||
|
||||
@override
|
||||
_TestFilterScreenState createState() => _TestFilterScreenState();
|
||||
}
|
||||
|
||||
class _TestFilterScreenState extends State<TestFilterScreen> {
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
TextEditingController labelIdCTRL = new TextEditingController();
|
||||
TextEditingController testTypeCTRL = new TextEditingController();
|
||||
TextEditingController hospitalCTRL = new TextEditingController();
|
||||
TextEditingController fDateCTRL = new TextEditingController();
|
||||
TextEditingController uDateCTRL = new TextEditingController();
|
||||
|
||||
TextEditingController usernameCTRL = new TextEditingController();
|
||||
// TextEditingController dateFrom = new TextEditingController();
|
||||
// TextEditingController dateUntil = new TextEditingController();
|
||||
DateTime dateTimeFrom;
|
||||
DateTime dateTimeUntil;
|
||||
|
||||
final List<String> labelIDVals = [
|
||||
'',
|
||||
'Washer ID',
|
||||
'Autoclave ID',
|
||||
'Sterilizer ID',
|
||||
'Seal Machine ID',
|
||||
'Patiant ID',
|
||||
'Set/Pack ID',
|
||||
'Medical Device ID',
|
||||
'OR ID',
|
||||
'Insrtument ID',
|
||||
'Basket ID',
|
||||
'Implant ID',
|
||||
// 'None',
|
||||
];
|
||||
// String curLabelIDVal;
|
||||
|
||||
final List<String> testTypeVals = [];
|
||||
Map<String, String> testTypes;
|
||||
|
||||
final List<String> hospitalVals = [];
|
||||
Map<String, String> hospitals = {};
|
||||
// String curhospitalVal;
|
||||
|
||||
bool isInit = true;
|
||||
// final List<String> labelIDVals = ['Washer ID'];
|
||||
// String curLabelIDVal;
|
||||
|
||||
// final List<String> labelIDVals = ['Washer ID'];
|
||||
// String curLabelIDVal;
|
||||
|
||||
// @override
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// }
|
||||
|
||||
@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 = '';
|
||||
uDateCTRL.text = '';
|
||||
var testResultProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
TestResultFilterObject filters = testResultProviderObject.filters;
|
||||
idCTRL.text = filters.id;
|
||||
usernameCTRL.text = filters.userName;
|
||||
labelIdCTRL.text =
|
||||
filters.labelID == '' ? labelIDVals[0] : filters.labelID;
|
||||
idCTRL.text = filters.id;
|
||||
usernameCTRL.text = filters.userName;
|
||||
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);
|
||||
}
|
||||
var testTypeKey = testTypes.keys.firstWhere(
|
||||
(k) => testTypes[k] == filters.testType,
|
||||
orElse: () => ''); // recent testtype name
|
||||
var hospitalKey = hospitals.keys.firstWhere(
|
||||
(k) => hospitals[k] == filters.hospital,
|
||||
orElse: () => ''); // recent testtype name
|
||||
testTypeCTRL.text =
|
||||
filters.testType == '' ? testTypeVals[0] : testTypeKey;
|
||||
hospitalCTRL.text =
|
||||
filters.hospital == '' ? hospitalVals[0] : hospitalKey;
|
||||
// print(result[0]);
|
||||
// print(result[1]);
|
||||
setState(() {
|
||||
isInit = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 WillPopScope(
|
||||
onWillPop: () async {
|
||||
Navigator.pushReplacementNamed(
|
||||
context,
|
||||
Routes.testResultScreen,
|
||||
);
|
||||
return true;
|
||||
},
|
||||
child: SafeArea(
|
||||
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<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? isInit
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'FILTER RESULTS',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 8,
|
||||
child: TextFormField(
|
||||
controller: idCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'ID',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.text,
|
||||
textInputAction: TextInputAction.next,
|
||||
// onFieldSubmitted: (_) {
|
||||
// FocusScope.of(context)
|
||||
// .requestFocus(_cycleNumberFocusNode);
|
||||
// },
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
idCTRL.text = result;
|
||||
// Navigator.of(context).pushNamed(
|
||||
// CycleDetailScreen.route,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
FontAwesomeIcons.barcode,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
TestResultFilterSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
dataCTRL: labelIdCTRL,
|
||||
dataVals: labelIDVals,
|
||||
label: 'Label ID',
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
|
||||
TextFormField(
|
||||
controller: usernameCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Username',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textInputAction: TextInputAction.next,
|
||||
// onFieldSubmitted: (_) {
|
||||
// FocusScope.of(context)
|
||||
// .requestFocus(_cycleNumberFocusNode);
|
||||
// },
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
TestResultFilterSelectorBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
dataCTRL: testTypeCTRL,
|
||||
dataVals: testTypeVals,
|
||||
label: 'Test Type',
|
||||
),
|
||||
SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
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<TestResultsProvider>(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: <Widget>[
|
||||
TextButton(
|
||||
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,
|
||||
),
|
||||
// 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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 70,
|
||||
),
|
||||
// DropDownBox(values: ['Washer ID']),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> 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';
|
||||
}
|
||||
}
|
||||
@@ -1,454 +0,0 @@
|
||||
// import 'package:cssd/providers/test_result.dart';
|
||||
import 'package:cssd/providers/test_results.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';
|
||||
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/connectivity.dart';
|
||||
|
||||
class TestResultScreen extends StatefulWidget {
|
||||
// static const route = '/TestResultScreen';
|
||||
final bool isAdmin;
|
||||
|
||||
TestResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_TestResultScreenState createState() => _TestResultScreenState();
|
||||
}
|
||||
|
||||
class _TestResultScreenState extends State<TestResultScreen> {
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
ScrollController sc;
|
||||
|
||||
bool _isInit = true;
|
||||
// List<TestResult> _data = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var testResults =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
// testResults.resetFilters();
|
||||
testResults.setLoading();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getTestResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc.addListener(() {
|
||||
if (sc.position.pixels == sc.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var labelProviderObject =
|
||||
Provider.of<TestResultsProvider>(context, listen: false);
|
||||
labelProviderObject.getTestResults();
|
||||
}
|
||||
});
|
||||
|
||||
// setState(() {
|
||||
// _isLoading = false;
|
||||
// });
|
||||
});
|
||||
_isInit = false;
|
||||
}
|
||||
super.didChangeDependencies();
|
||||
}
|
||||
|
||||
@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 SafeArea(
|
||||
child: Scaffold(
|
||||
floatingActionButton:
|
||||
TestResultFloatingButton(deviceBlockSize: _deviceBlockSize),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20, left: 20, right: 20, bottom: 60),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
// padding: EdgeInsets.only(top: 20, bottom: 40),
|
||||
child: Text(
|
||||
'MY TEST RESULTS',
|
||||
// textAlign: TextAlign.left,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 6 * _deviceBlockSize,
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
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<TestResultsProvider>(
|
||||
builder: (context, testResult, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
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,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<TestResultsProvider>(
|
||||
builder: (context, testResults, _) {
|
||||
return testResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) =>
|
||||
TestItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: testResults.items[index],
|
||||
),
|
||||
itemCount: testResults.items.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestItemBox extends StatelessWidget {
|
||||
final TestResultObject item;
|
||||
const TestItemBox({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
this.item,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// print(item.result);
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).pushNamed(
|
||||
Routes.testDetailsScreen,
|
||||
arguments: item.id,
|
||||
),
|
||||
child: Card(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 57 * _deviceBlockSize,
|
||||
child: Text(
|
||||
item.name,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
// style: TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 57 * _deviceBlockSize,
|
||||
child: Text(
|
||||
item.hospital,
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
item.result == 'Accepted'
|
||||
? Text(
|
||||
'Accepted',
|
||||
style: TextStyle(color: Colors.green),
|
||||
)
|
||||
: Text(
|
||||
'Rejected',
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
Text(item.date),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
// item.result != 'Accepted'
|
||||
// ? InkWell(
|
||||
// onTap: () {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (ctx) => AlertDialog(
|
||||
// title: Text('Delete'),
|
||||
// content: Text(
|
||||
// 'Are you sure for delete this test?'),
|
||||
// actions: <Widget>[
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Provider.of<TestResultsProvider>(
|
||||
// context)
|
||||
// .removeTestResult(
|
||||
// item.id.toString())
|
||||
// .then((_) {
|
||||
// Navigator.of(ctx).pop();
|
||||
// });
|
||||
// },
|
||||
// child: Text('Yes'),
|
||||
// ),
|
||||
// TextButton(
|
||||
// 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(
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,216 +0,0 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../providers/connectivity.dart';
|
||||
import '../widgets/Global/internet_error.dart';
|
||||
|
||||
class TestScanScreen extends StatefulWidget {
|
||||
// static const route = '/TestScanScreen';
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _TestScanScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _TestScanScreenState extends State<TestScanScreen> {
|
||||
String testCode = "";
|
||||
TextEditingController idCTRL = new TextEditingController();
|
||||
final _form = GlobalKey<FormState>();
|
||||
|
||||
@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 SafeArea(
|
||||
child: 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<ConnectivityProvider>(builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? ListView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20),
|
||||
children: <Widget>[
|
||||
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<String> 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';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user