mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-11 23:48:54 +03:30
282 lines
13 KiB
Dart
282 lines
13 KiB
Dart
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();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|