mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:58:56 +03:30
282 lines
12 KiB
Dart
282 lines
12 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:intl/intl.dart' as DateEditor;
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../config/routes.dart';
|
|
import '../providers/connectivity.dart';
|
|
import '../providers/labels.dart';
|
|
import '../widgets/Global/internet_error.dart';
|
|
import '../widgets/LabelScreens/Add/date_picker.dart';
|
|
import '../widgets/LabelScreens/Add/save_button.dart';
|
|
import '../widgets/LabelScreens/Add/selector_box.dart';
|
|
|
|
class LabelAddScreen extends StatefulWidget {
|
|
// static const route = '/LabelAddScreen';
|
|
|
|
@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();
|
|
}),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|