mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-11 01:38:56 +03:30
95 lines
2.7 KiB
Dart
Executable File
95 lines
2.7 KiB
Dart
Executable File
import 'package:cssd/config/colors.dart';
|
|
import 'package:cssd/providers/cycles.dart';
|
|
|
|
import '../../../config/routes.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class CycleUpdateButton extends StatelessWidget {
|
|
const CycleUpdateButton({
|
|
Key? key,
|
|
required GlobalKey<FormState> form,
|
|
required this.id,
|
|
required this.descriptionCTRL,
|
|
required this.cycleNumberCTRL,
|
|
required this.dateCTRL,
|
|
// required this.labelValue,
|
|
required this.striizerIdCTRL,
|
|
required double deviceBlockSize,
|
|
}) : _form = form,
|
|
_deviceBlockSize = deviceBlockSize,
|
|
super(key: key);
|
|
|
|
final GlobalKey<FormState> _form;
|
|
final String id;
|
|
final TextEditingController descriptionCTRL;
|
|
final TextEditingController cycleNumberCTRL;
|
|
final TextEditingController dateCTRL;
|
|
// final TextEditingController labelValue;
|
|
final TextEditingController striizerIdCTRL;
|
|
final double _deviceBlockSize;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: () {
|
|
if (!_form.currentState!.validate()) {
|
|
return;
|
|
}
|
|
// List<String> labels = [];
|
|
// for (TextEditingController label in labelValue) {
|
|
// labels.add(label.text);
|
|
// }
|
|
Provider.of<CyclesProvider>(context, listen: false).updateCycleResult(
|
|
id,
|
|
striizerIdCTRL.text,
|
|
cycleNumberCTRL.text,
|
|
// labelValue.text,
|
|
dateCTRL.text,
|
|
descriptionCTRL.text,
|
|
);
|
|
showDialog(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
content: Text('Cycle updated.'),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(ctx).pop();
|
|
},
|
|
child: Text('Ok'),
|
|
)
|
|
],
|
|
),
|
|
).then((_) {
|
|
Navigator.of(context).pushReplacementNamed(Routes.cycleResultScreen);
|
|
});
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 5 * _deviceBlockSize,
|
|
vertical: 10,
|
|
),
|
|
// margin:
|
|
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [kPink, kPinkSub],
|
|
),
|
|
borderRadius: BorderRadius.circular(7),
|
|
),
|
|
child: Align(
|
|
alignment: Alignment.center,
|
|
child: Text(
|
|
'Update',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 5 * _deviceBlockSize,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|