mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 12:48:54 +03:30
bog fix
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -5,8 +7,8 @@ import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../config/routes.dart';
|
||||
|
||||
class ItemAddSaveButton extends StatelessWidget {
|
||||
const ItemAddSaveButton({
|
||||
class ItemAddSaveButton extends StatefulWidget {
|
||||
ItemAddSaveButton({
|
||||
Key? key,
|
||||
required GlobalKey<FormState> form,
|
||||
this.batchId,
|
||||
@@ -17,6 +19,7 @@ class ItemAddSaveButton extends StatelessWidget {
|
||||
required this.sizeCTRL,
|
||||
required this.specificCTRL,
|
||||
required this.dateValue,
|
||||
required this.isLoading,
|
||||
}) : _form = form,
|
||||
_deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
@@ -30,21 +33,55 @@ class ItemAddSaveButton extends StatelessWidget {
|
||||
final String dateValue;
|
||||
final String? batchId;
|
||||
final double _deviceBlockSize;
|
||||
bool isLoading;
|
||||
|
||||
@override
|
||||
State<ItemAddSaveButton> createState() => _ItemAddSaveButtonState();
|
||||
}
|
||||
|
||||
class _ItemAddSaveButtonState extends State<ItemAddSaveButton> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
if (!widget._form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
Provider.of<ItemProvider>(context, listen: false).createItemResult(
|
||||
nameCTRL.text,
|
||||
sizeCTRL.text,
|
||||
specificCTRL.text,
|
||||
udiCTRL.text,
|
||||
descriptionCTRL.text,
|
||||
batchId,
|
||||
setState(() {
|
||||
widget.isLoading = true;
|
||||
});
|
||||
Provider.of<ItemProvider>(context, listen: false)
|
||||
.createItemResult(
|
||||
widget.nameCTRL.text,
|
||||
widget.sizeCTRL.text,
|
||||
widget.specificCTRL.text,
|
||||
widget.udiCTRL.text,
|
||||
widget.descriptionCTRL.text,
|
||||
widget.batchId,
|
||||
)
|
||||
.then(
|
||||
(result) {
|
||||
setState(() {
|
||||
widget.isLoading = false;
|
||||
});
|
||||
if (result == 'done') {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Item added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((value) => Navigator.of(context)
|
||||
.popAndPushNamed(Routes.testResultScreen));
|
||||
}
|
||||
},
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -65,7 +102,7 @@ class ItemAddSaveButton extends StatelessWidget {
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
horizontal: 5 * widget._deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
@@ -80,7 +117,7 @@ class ItemAddSaveButton extends StatelessWidget {
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
fontSize: 5 * widget._deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user