mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 04:38:55 +03:30
commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart' as DateEditor;
|
||||
|
||||
class LabelAddDatePicker extends StatefulWidget {
|
||||
LabelAddDatePicker({
|
||||
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
|
||||
_LabelAddDatePickerState createState() => _LabelAddDatePickerState();
|
||||
}
|
||||
|
||||
class _LabelAddDatePickerState extends State<LabelAddDatePicker> {
|
||||
@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: 7, right: 3, left: 3),
|
||||
// border: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(FontAwesomeIcons.angleDown)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cssd/providers/labels.dart';
|
||||
|
||||
class LabelAddSaveButton extends StatelessWidget {
|
||||
const LabelAddSaveButton({
|
||||
Key key,
|
||||
@required GlobalKey<FormState> form,
|
||||
@required this.lotNumberCTRL,
|
||||
@required this.cycleNumberCTRL,
|
||||
@required this.sDateCTRL,
|
||||
@required this.packageValue,
|
||||
@required this.eDateCTRL,
|
||||
@required this.striizerIdCTRL,
|
||||
@required double deviceBlockSize,
|
||||
}) : _form = form,
|
||||
_deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final GlobalKey<FormState> _form;
|
||||
final TextEditingController lotNumberCTRL;
|
||||
final TextEditingController cycleNumberCTRL;
|
||||
final TextEditingController sDateCTRL;
|
||||
final List<String> packageValue;
|
||||
final TextEditingController eDateCTRL;
|
||||
final TextEditingController striizerIdCTRL;
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState.validate()) {
|
||||
return;
|
||||
}
|
||||
Provider.of<LabelsProvider>(context).createLabelResult(
|
||||
lotNumberCTRL.text,
|
||||
cycleNumberCTRL.text,
|
||||
sDateCTRL.text,
|
||||
// sDateValue,
|
||||
{'id': packageValue[0], 'name': packageValue[1]},
|
||||
eDateCTRL.text,
|
||||
// eDateValue,
|
||||
striizerIdCTRL.text,
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Label added.'),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((_) {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [Colors.blue, Colors.green],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'SAVE',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class LabelAddSelectorBox extends StatefulWidget {
|
||||
const LabelAddSelectorBox({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
@required this.packageCTRL,
|
||||
@required this.packageVals,
|
||||
@required this.packageValue,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
final TextEditingController packageCTRL;
|
||||
final List<Map<String, String>> packageVals;
|
||||
final List<String> packageValue;
|
||||
|
||||
@override
|
||||
_LabelAddSelectorBoxState createState() => _LabelAddSelectorBoxState();
|
||||
}
|
||||
|
||||
class _LabelAddSelectorBoxState extends State<LabelAddSelectorBox> {
|
||||
@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>[
|
||||
SizedBox(
|
||||
width: widget._deviceBlockSize,
|
||||
),
|
||||
Text(
|
||||
'Package',
|
||||
style: TextStyle(
|
||||
fontSize: 3.5 * widget._deviceBlockSize,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w700),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
// height: 30,
|
||||
child: DropdownButtonFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding:
|
||||
EdgeInsets.only(left: widget._deviceBlockSize),
|
||||
// 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.packageCTRL.text,
|
||||
textDirection: TextDirection.rtl,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
fontSize: 5 * widget._deviceBlockSize
|
||||
),
|
||||
),),
|
||||
// Container(
|
||||
// // width: 100,
|
||||
// height: 70,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 0),
|
||||
// child: TextFormField(
|
||||
// controller: widget.packageCTRL,
|
||||
// decoration: InputDecoration(
|
||||
// contentPadding: EdgeInsets.only(bottom: 15),
|
||||
// isDense: true,
|
||||
// ),
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w700,
|
||||
// color: Colors.black,
|
||||
// fontSize: 5 * widget._deviceBlockSize,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
isDense: true,
|
||||
items: widget.packageVals.map((val) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: val['name'],
|
||||
child: Container(
|
||||
child: Text(
|
||||
val['name'],
|
||||
style: TextStyle(
|
||||
// color: _mainFontColor,
|
||||
fontSize: 4 * widget._deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
setState(() {
|
||||
widget.packageValue[1] = val;
|
||||
widget.packageCTRL.text = val;
|
||||
widget.packageVals.forEach((package) {
|
||||
if (package['name'] == val) {
|
||||
widget.packageValue[0] = package['id'];
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user