Files
cssd/lib/widgets/LabelScreens/Add/save_button.dart
T
2020-05-10 14:09:07 +04:30

91 lines
2.6 KiB
Dart

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,
),
),
),
),
);
}
}