mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 17:08:54 +03:30
commit
This commit is contained in:
@@ -0,0 +1,379 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:multiselect_formfield/multiselect_formfield.dart';
|
||||
|
||||
class FormCreator extends StatefulWidget {
|
||||
const FormCreator({
|
||||
@required this.form,
|
||||
@required this.onChanged,
|
||||
this.padding,
|
||||
});
|
||||
|
||||
final dynamic form;
|
||||
final double padding;
|
||||
final ValueChanged<dynamic> onChanged;
|
||||
|
||||
@override
|
||||
_FormCreatorState createState() => _FormCreatorState(form);
|
||||
}
|
||||
|
||||
class _FormCreatorState extends State<FormCreator> {
|
||||
final dynamic formItems;
|
||||
DateTime selectedDate = DateTime.now();
|
||||
|
||||
int rangeValue;
|
||||
String selectValue;
|
||||
|
||||
Future<Null> _selectDate() async {
|
||||
final DateTime picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: selectedDate,
|
||||
firstDate: DateTime(2015, 8),
|
||||
lastDate: DateTime(2101));
|
||||
if (picked != null && picked != selectedDate)
|
||||
setState(() {
|
||||
selectedDate = picked;
|
||||
});
|
||||
}
|
||||
|
||||
List<Widget> jsonToForm() {
|
||||
List<Widget> listWidgets = List<Widget>();
|
||||
|
||||
for (var count = 0; count < formItems.length; count++) {
|
||||
Map item = formItems[count];
|
||||
|
||||
if (item['type'] == "Date") {
|
||||
selectedDate = formItems[count]['value'];
|
||||
listWidgets.add(
|
||||
OutlineButton(
|
||||
onPressed: () {
|
||||
_selectDate().then((_) {
|
||||
formItems[count]['value'] = selectedDate;
|
||||
_handleChanged();
|
||||
});
|
||||
},
|
||||
child: Text(
|
||||
'Date: ${selectedDate.year}/${selectedDate.month}/${selectedDate.day}'),
|
||||
padding: EdgeInsets.symmetric(vertical: 20),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (item['type'] == "Label") {
|
||||
listWidgets.add(
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(),
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: Colors.black,
|
||||
),
|
||||
padding: EdgeInsets.only(top: 20, bottom: 20),
|
||||
margin: EdgeInsets.only(bottom: 20),
|
||||
child: Text(
|
||||
item['name'],
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.white, fontSize: 20),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (item['type'] == "Text") {
|
||||
listWidgets.add(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
labelText: item['name'] ?? "",
|
||||
border: UnderlineInputBorder(),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
initialValue: item['value'] ?? '',
|
||||
onChanged: (String value) {
|
||||
formItems[count]['value'] = value;
|
||||
_handleChanged();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (item['type'] == "Range" ||
|
||||
item['type'] == "Temperature" ||
|
||||
item['type'] == "Pressure") {
|
||||
double startValue, endValue;
|
||||
if (item['type'] == "Range") {
|
||||
startValue = double.parse(item['options'][0]['title']);
|
||||
endValue = double.parse(item['options'][1]['title']);
|
||||
} else {
|
||||
startValue = item['type'] == "Temperature" ? 0.0 : -1.0;
|
||||
endValue = item['type'] == "Temperature" ? 200.0 : 3.0;
|
||||
}
|
||||
|
||||
formItems[count]['value'] = formItems[count]['value'] ?? startValue;
|
||||
int divisions = (endValue - startValue).round();
|
||||
listWidgets.add(
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 35),
|
||||
child: Slider(
|
||||
min: startValue,
|
||||
max: endValue,
|
||||
value: formItems[count]['value'],
|
||||
label: '${formItems[count]['value'].round()}',
|
||||
divisions: divisions,
|
||||
onChanged: (double value) {
|
||||
setState(() {
|
||||
formItems[count]['value'] = value;
|
||||
});
|
||||
},
|
||||
semanticFormatterCallback: (double newValue) {
|
||||
return '${newValue.round()}';
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (item['type'] == "Time") {
|
||||
listWidgets.add(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextFormField(
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
LengthLimitingTextInputFormatter(5),
|
||||
WhitelistingTextInputFormatter.digitsOnly,
|
||||
// BlacklistingTextInputFormatter.singleLineFormatter,
|
||||
TextInputFormatter.withFunction(
|
||||
(TextEditingValue oldValue, TextEditingValue newValue) {
|
||||
final int newTextLength = newValue.text.length;
|
||||
int selectionIndex = newValue.selection.end;
|
||||
int usedSubstringIndex = 0;
|
||||
final StringBuffer newText = StringBuffer();
|
||||
if (newTextLength >= 2) {
|
||||
newText.write(
|
||||
newValue.text.substring(0, usedSubstringIndex = 2) +
|
||||
':');
|
||||
if (newValue.selection.end >= 2) selectionIndex++;
|
||||
}
|
||||
// Dump the rest.
|
||||
if (newTextLength >= usedSubstringIndex)
|
||||
newText.write(newValue.text.substring(usedSubstringIndex));
|
||||
return TextEditingValue(
|
||||
text: newText.toString(),
|
||||
selection: TextSelection.collapsed(offset: selectionIndex),
|
||||
);
|
||||
})
|
||||
],
|
||||
keyboardType: TextInputType.datetime,
|
||||
decoration: InputDecoration(
|
||||
labelText: item['name'] ?? "",
|
||||
border: UnderlineInputBorder(),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
initialValue: item['value'] ?? '',
|
||||
onChanged: (String value) {
|
||||
formItems[count]['value'] = value;
|
||||
_handleChanged();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (item['type'] == "Select") {
|
||||
var listItems = item['options'] as List<dynamic>;
|
||||
listWidgets.add(MultiSelectFormField(
|
||||
autovalidate: false,
|
||||
titleText: item['name'],
|
||||
dataSource: listItems,
|
||||
textField: 'title',
|
||||
valueField: 'id',
|
||||
okButtonLabel: 'OK',
|
||||
cancelButtonLabel: 'CANCEL',
|
||||
hintText: 'Please choose one or more',
|
||||
value: item['value'],
|
||||
onSaved: (value) {
|
||||
if (value == null) return;
|
||||
setState(() {
|
||||
item['value'] = value;
|
||||
});
|
||||
_handleChanged();
|
||||
},
|
||||
));
|
||||
|
||||
// listWidgets.add(
|
||||
// DropdownButtonFormField<String>(
|
||||
// items: listItems.map((dynamic value) {
|
||||
// String stringValue = value['id'].toString();
|
||||
// String textValue = value['title'].toString();
|
||||
// return DropdownMenuItem<String>(
|
||||
// value: stringValue,
|
||||
// child: Text(textValue),
|
||||
// );
|
||||
// }).toList(),
|
||||
// isDense: true,
|
||||
// value: item['value'],
|
||||
// hint: Text(item['name']),
|
||||
|
||||
// onChanged: (String value) {
|
||||
// this.setState(
|
||||
// () {
|
||||
// _setInput(item['name'], value);
|
||||
// formItems[count]['value'] = value;
|
||||
// _handleChanged();
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
if (item['type'] == "Radiobutton") {
|
||||
listWidgets.add(
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 14.0, bottom: 0),
|
||||
child: Text(
|
||||
item['name'],
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
|
||||
),
|
||||
),
|
||||
);
|
||||
var valueOrFirst =
|
||||
formItems[count]['value'] ?? formItems[count]['options'][0]['id'];
|
||||
for (var i = 0; i < item['options'].length; i++) {
|
||||
var isSelected = formItems[count]['options'][i]['id'] == valueOrFirst;
|
||||
formItems[count]['value'] = valueOrFirst;
|
||||
listWidgets.add(
|
||||
RadioListTile<int>(
|
||||
dense: true,
|
||||
controlAffinity: ListTileControlAffinity.trailing,
|
||||
title: Text(formItems[count]['options'][i]['title']),
|
||||
value: formItems[count]['options'][i]['id'],
|
||||
selected: isSelected,
|
||||
groupValue: formItems[count]['value'],
|
||||
onChanged: (int value) {
|
||||
this.setState(
|
||||
() {
|
||||
_setInput(item['name'], value.toString());
|
||||
formItems[count]['value'] = value;
|
||||
_handleChanged();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (item['type'] == "Switch") {
|
||||
listWidgets.add(SwitchListTile(
|
||||
activeColor: Colors.green,
|
||||
inactiveTrackColor: Colors.red.withAlpha(150),
|
||||
inactiveThumbColor: Colors.red,
|
||||
title: Text(item['name']),
|
||||
value: item['value'] ?? false,
|
||||
onChanged: (bool value) {
|
||||
this.setState(() {
|
||||
formItems[count]['value'] = value;
|
||||
_handleChanged();
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
if (item['type'] == "Form") {
|
||||
listWidgets.add(
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(border: Border.all()),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 10),
|
||||
child: Text(
|
||||
item['name'],
|
||||
style:
|
||||
TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
|
||||
),
|
||||
),
|
||||
FormCreator(
|
||||
form: item['children'],
|
||||
padding: 4,
|
||||
onChanged: (value) {
|
||||
// _handleChanged();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (item['type'] == "Checkbox") {
|
||||
formItems[count]['value'] = formItems[count]['value'] ?? [];
|
||||
listWidgets.add(
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 14.0, bottom: 0),
|
||||
child: Text(
|
||||
item['name'],
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
|
||||
),
|
||||
),
|
||||
);
|
||||
for (var i = 0; i < item['options'].length; i++) {
|
||||
listWidgets.add(
|
||||
CheckboxListTile(
|
||||
title: Text(formItems[count]['options'][i]['title']),
|
||||
value: (formItems[count]['value'] ?? [])
|
||||
.contains(formItems[count]['options'][i]['id']),
|
||||
onChanged: (bool value) {
|
||||
this.setState(
|
||||
() {
|
||||
setState(() {
|
||||
if (value) {
|
||||
(formItems[count]['value'] as List)
|
||||
.add(formItems[count]['options'][i]['id']);
|
||||
} else {
|
||||
(formItems[count]['value'] as List)
|
||||
.remove(formItems[count]['options'][i]['id']);
|
||||
}
|
||||
});
|
||||
_handleChanged();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
// listWidgets.add(
|
||||
// TestResultAddSaveButton(
|
||||
// deviceBlockSize: null,
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
return listWidgets;
|
||||
}
|
||||
|
||||
_FormCreatorState(this.formItems);
|
||||
|
||||
void _handleChanged() {
|
||||
widget.onChanged(formItems);
|
||||
}
|
||||
|
||||
void _setInput(String key, String value) {}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.builder(
|
||||
padding: EdgeInsets.all(widget.padding ?? 16.0),
|
||||
itemCount: jsonToForm().length,
|
||||
itemBuilder: (context, index) {
|
||||
return jsonToForm()[index];
|
||||
},
|
||||
shrinkWrap: true,
|
||||
controller: ScrollController(keepScrollOffset: false),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TestResultAddSaveButton extends StatelessWidget {
|
||||
const TestResultAddSaveButton({
|
||||
Key key,
|
||||
// @required GlobalKey<FormState> form,
|
||||
// @required this.idCTRL,
|
||||
@required double deviceBlockSize,
|
||||
}) :
|
||||
// _form = form,
|
||||
_deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
// final GlobalKey<FormState> _form;
|
||||
// final TextEditingController idCTRL;
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
// if (! _form.currentState.validate()) {
|
||||
// return;
|
||||
// }
|
||||
Navigator.of(context).pushNamed(
|
||||
Routes.labelDetailScreen,
|
||||
// arguments: idCTRL.text,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
margin: EdgeInsets.symmetric(horizontal: 20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.blue, Colors.green],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'GO!',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class TestResultAddSelectorBox extends StatefulWidget {
|
||||
const TestResultAddSelectorBox({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
@required this.dataCTRL,
|
||||
@required this.dataVals,
|
||||
@required String label,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
_label = label,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
final TextEditingController dataCTRL;
|
||||
final List<String> dataVals;
|
||||
final String _label;
|
||||
|
||||
@override
|
||||
_TestResultAddSelectorBoxState createState() =>
|
||||
_TestResultAddSelectorBoxState();
|
||||
}
|
||||
|
||||
class _TestResultAddSelectorBoxState extends State<TestResultAddSelectorBox> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
// height: 65,
|
||||
child: Row(
|
||||
// width: double.infinity,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
color: Colors.grey,
|
||||
size: 6 * widget._deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 4 * widget._deviceBlockSize,
|
||||
),
|
||||
Expanded(
|
||||
// width: MediaQuery.of(context).size.width - 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
widget._label,
|
||||
style: TextStyle(
|
||||
fontSize: 3 * widget._deviceBlockSize,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w100,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
height: 40,
|
||||
child: DropdownButtonFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 0),
|
||||
// border: InputBorder.none,
|
||||
),
|
||||
iconSize: 7 * widget._deviceBlockSize,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.angleDown,
|
||||
color: Colors.black,
|
||||
),
|
||||
isExpanded: true,
|
||||
hint: Container(
|
||||
// width: 100,
|
||||
height: 70,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Text(
|
||||
widget.dataCTRL.text,
|
||||
// textDirection: TextDirection.rtl,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
fontSize: 4 * widget._deviceBlockSize,
|
||||
),
|
||||
),
|
||||
// TextFormField(
|
||||
// controller: widget.dataCTRL,
|
||||
// decoration: InputDecoration(
|
||||
// contentPadding: EdgeInsets.only(bottom: 15),
|
||||
// isDense: true,
|
||||
// ),
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w700,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// // minLines: 1,
|
||||
// // maxLines: 3,
|
||||
// ),
|
||||
),
|
||||
isDense: true,
|
||||
items: widget.dataVals.map((val) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: val,
|
||||
child: Container(
|
||||
child: Text(
|
||||
val,
|
||||
style: TextStyle(
|
||||
// color: _mainFontColor,
|
||||
fontSize: 4 * widget._deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
widget.dataCTRL.text = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class DatasBox extends StatelessWidget {
|
||||
const DatasBox({
|
||||
Key key,
|
||||
@required this.datas,
|
||||
@required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final Map<String, Object> datas;
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromRGBO(230, 230, 230, 1),
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: Colors.pink,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
DateFormat.yMMMd().format(
|
||||
DateTime.parse(
|
||||
datas['date'],
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
Divider(),
|
||||
Text(
|
||||
datas['test_type_name'],
|
||||
style: TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 35 * _deviceBlockSize,
|
||||
child: Text(
|
||||
'CSSD ID',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 45 * _deviceBlockSize,
|
||||
child: Text(
|
||||
datas['id'].toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 35 * _deviceBlockSize,
|
||||
child: Text(
|
||||
'Autocleave ID',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 45 * _deviceBlockSize,
|
||||
child: Text(
|
||||
datas['auto_cleave_id'].toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 35 * _deviceBlockSize,
|
||||
child: Text(
|
||||
'Test Code',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 45 * _deviceBlockSize,
|
||||
child: Text(
|
||||
datas['test_code'].toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 35 * _deviceBlockSize,
|
||||
child: Text(
|
||||
'Date',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 45 * _deviceBlockSize,
|
||||
child: Text(
|
||||
DateFormat('d-M-y').format(
|
||||
DateTime.parse(
|
||||
datas['date'],
|
||||
),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 35 * _deviceBlockSize,
|
||||
child: Text(
|
||||
'Status',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 45 * _deviceBlockSize,
|
||||
child: Text(
|
||||
datas['verified'] == 'NotVerified'
|
||||
? 'Rejected'
|
||||
: 'Verified',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: datas['verified'] == 'NotVerified'
|
||||
? Colors.red
|
||||
: Colors.blueAccent,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 35 * _deviceBlockSize,
|
||||
child: Text(
|
||||
'Description',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 45 * _deviceBlockSize,
|
||||
child: Text(
|
||||
datas['description'].toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
overflow: TextOverflow.clip,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart' as DateEditor;
|
||||
|
||||
class TestResultFilterDatePicker extends StatefulWidget {
|
||||
TestResultFilterDatePicker({
|
||||
Key key,
|
||||
@required this.dateCTRL,
|
||||
@required double deviceBlockSize,
|
||||
@required String label,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
_label = label,
|
||||
super(key: key);
|
||||
|
||||
final TextEditingController dateCTRL;
|
||||
final double _deviceBlockSize;
|
||||
final String _label;
|
||||
|
||||
@override
|
||||
_TestResultFilterDatePickerState createState() => _TestResultFilterDatePickerState();
|
||||
}
|
||||
|
||||
class _TestResultFilterDatePickerState extends State<TestResultFilterDatePicker> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
var res = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2010, 1),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
if (res != null) {
|
||||
setState(
|
||||
() {
|
||||
widget.dateCTRL.text = DateEditor.DateFormat('y-M-d').format(res);
|
||||
// sDateValue =
|
||||
// DateEditor.DateFormat('y-M-d').format(
|
||||
// dateTimeS,
|
||||
// ); // baraye tavize makane gharar giri baraye api
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
enabled: false,
|
||||
controller: widget.dateCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.calendarAlt,
|
||||
size: 7 * widget._deviceBlockSize,
|
||||
),
|
||||
labelText: widget._label,
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.only(bottom: 12, right: 3, left: 3),
|
||||
// border: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * widget._deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(FontAwesomeIcons.angleDown)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class DropDownBox extends StatefulWidget {
|
||||
|
||||
DropDownBox({
|
||||
Key key,
|
||||
@required this.values,
|
||||
}) : super(key: key);
|
||||
|
||||
final List<String> values;
|
||||
|
||||
@override
|
||||
_DropDownBoxState createState() => _DropDownBoxState();
|
||||
}
|
||||
|
||||
class _DropDownBoxState extends State<DropDownBox> {
|
||||
String _curValue;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_curValue = widget.values[0];
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// _curValue = widget.values[0];
|
||||
// final ThemeData _theme = Theme.of(context);
|
||||
// final Color _mainFontColor = _theme.textSelectionColor;
|
||||
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 Row(
|
||||
// width: double.infinity,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
FontAwesomeIcons.sortNumericDown,
|
||||
color: Colors.grey,
|
||||
size: 4 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: _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(
|
||||
_curValue,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
// color: _mainFontColor,
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
isDense: true,
|
||||
items: widget.values.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(() {
|
||||
_curValue = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class TestResultFilterSelectorBox extends StatefulWidget {
|
||||
const TestResultFilterSelectorBox({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
@required this.dataCTRL,
|
||||
@required this.dataVals,
|
||||
@required String label,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
_label = label,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
final TextEditingController dataCTRL;
|
||||
final List<String> dataVals;
|
||||
final String _label;
|
||||
|
||||
@override
|
||||
_TestResultFilterSelectorBoxState createState() =>
|
||||
_TestResultFilterSelectorBoxState();
|
||||
}
|
||||
|
||||
class _TestResultFilterSelectorBoxState
|
||||
extends State<TestResultFilterSelectorBox> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
// height: 65,
|
||||
child: Row(
|
||||
// width: double.infinity,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
color: Colors.grey,
|
||||
size: 7 * widget._deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 4 * widget._deviceBlockSize,
|
||||
),
|
||||
Expanded(
|
||||
// width: MediaQuery.of(context).size.width - 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
widget._label,
|
||||
style: TextStyle(
|
||||
fontSize: 3.5 * widget._deviceBlockSize,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w100,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
// height: 30,
|
||||
child: DropdownButtonFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(left: 0),
|
||||
// border: InputBorder.none,
|
||||
),
|
||||
iconSize: 7 * widget._deviceBlockSize,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.angleDown,
|
||||
color: Colors.black,
|
||||
),
|
||||
isExpanded: true,
|
||||
hint: Container(
|
||||
// width: 100,
|
||||
height: 70,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Text(
|
||||
widget.dataCTRL.text,
|
||||
// textDirection: TextDirection.rtl,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
fontSize: 5 * widget._deviceBlockSize),
|
||||
),
|
||||
// TextFormField(
|
||||
// controller: widget.dataCTRL,
|
||||
// decoration: InputDecoration(
|
||||
// contentPadding: EdgeInsets.only(bottom: 15),
|
||||
// isDense: true,
|
||||
// ),
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w700,
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
// // minLines: 1,
|
||||
// // maxLines: 3,
|
||||
// ),
|
||||
),
|
||||
isDense: true,
|
||||
items: widget.dataVals.map((val) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: val,
|
||||
child: Container(
|
||||
child: Text(
|
||||
val,
|
||||
style: TextStyle(
|
||||
// color: _mainFontColor,
|
||||
fontSize: 4 * widget._deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
widget.dataCTRL.text = val;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TestResultAddButton extends StatelessWidget {
|
||||
const TestResultAddButton({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Routes.testResultAddScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.redAccent,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 10 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../providers/test_results.dart';
|
||||
|
||||
class TestResultChip extends StatelessWidget {
|
||||
const TestResultChip({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
@required String label,
|
||||
@required String id,
|
||||
@required String labelID,
|
||||
@required String testType,
|
||||
@required String hospital,
|
||||
@required String username,
|
||||
@required String fDate,
|
||||
@required String uDate,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
_id = id,
|
||||
_labelID = labelID,
|
||||
_testType = testType,
|
||||
_hispotal = hospital,
|
||||
_label = label,
|
||||
_username = username,
|
||||
_fDate = fDate,
|
||||
_uDate = uDate,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
final String _id;
|
||||
final String _labelID;
|
||||
final String _testType;
|
||||
final String _hispotal;
|
||||
final String _label;
|
||||
final String _username;
|
||||
final String _fDate;
|
||||
final String _uDate;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(children: <Widget>[
|
||||
SizedBox(
|
||||
width: _deviceBlockSize,
|
||||
),
|
||||
Chip(
|
||||
backgroundColor: Colors.black,
|
||||
label: Text(
|
||||
_label,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
deleteIcon: Icon(
|
||||
Icons.close,
|
||||
color: Colors.white,
|
||||
),
|
||||
onDeleted: () {
|
||||
var labelProviderObject = Provider.of<TestResultsProvider>(context);
|
||||
labelProviderObject.setFilters(
|
||||
_id,
|
||||
_labelID,
|
||||
_username,
|
||||
_testType,
|
||||
_hispotal,
|
||||
_fDate,
|
||||
_uDate,
|
||||
);
|
||||
labelProviderObject.setLoading();
|
||||
labelProviderObject.getTestResults().then((_) {
|
||||
labelProviderObject.resetLoading();
|
||||
});
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TestResultFloatingButton extends StatelessWidget {
|
||||
const TestResultFloatingButton({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).popAndPushNamed(Routes.testResultAddScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Color.fromRGBO(0, 190, 190, 1),
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 10 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../providers/test_results.dart';
|
||||
|
||||
class TestResultSearchBox extends StatelessWidget {
|
||||
const TestResultSearchBox({
|
||||
Key key,
|
||||
@required this.searchCTRL,
|
||||
@required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final TextEditingController searchCTRL;
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
onEditingComplete: () {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
onChanged: (value) {
|
||||
Provider.of<TestResultsProvider>(context, listen: false).search(value);
|
||||
},
|
||||
controller: searchCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.search,
|
||||
size: 6 * _deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
labelText: 'Search by test name',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 2, horizontal: 3),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user