mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-11 14:08:55 +03:30
Set some save button progress bar and toast message
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../config/routes.dart';
|
||||
@@ -29,63 +30,81 @@ class CycleAddSaveButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
List<String> labels = [];
|
||||
for (TextEditingController label in labelValues) {
|
||||
labels.add(label.text);
|
||||
}
|
||||
Provider.of<CyclesProvider>(context, listen: false).createCycleResult(
|
||||
cycleNumberCTRL.text,
|
||||
dateValue,
|
||||
labels,
|
||||
descriptionCTRL.text,
|
||||
striizerIdCTRL.text,
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Cycle added.'),
|
||||
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(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
return Consumer<CyclesProvider>(builder: (context, cyclesProvider, _) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
cyclesProvider.setLoadingButton();
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
List<String> labels = [];
|
||||
for (TextEditingController label in labelValues) {
|
||||
labels.add(label.text);
|
||||
}
|
||||
await Provider.of<CyclesProvider>(context, listen: false)
|
||||
.createCycleResult(
|
||||
cycleNumberCTRL.text,
|
||||
dateValue,
|
||||
labels,
|
||||
descriptionCTRL.text,
|
||||
striizerIdCTRL.text,
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Cycle added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((_) {
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.cycleResultScreen);
|
||||
});
|
||||
Navigator.of(context).pushReplacementNamed(Routes.cycleResultScreen);
|
||||
Fluttertoast.showToast(
|
||||
msg: "Cycle added.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
cyclesProvider.resetLoadingButton();
|
||||
},
|
||||
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: cyclesProvider.isloadingButton
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/providers/items.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ItemAddSaveButton extends StatelessWidget {
|
||||
const ItemAddSaveButton({
|
||||
@@ -11,32 +13,41 @@ class ItemAddSaveButton extends StatelessWidget {
|
||||
|
||||
final double _deviceBlockSize;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kBlue, kBlueSub],
|
||||
return Consumer<ItemProvider>(builder: (context, itemProvider, _) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kBlue, kBlueSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: itemProvider.isloadingButton
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../config/routes.dart';
|
||||
@@ -31,67 +32,68 @@ class LabelAddSaveButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
List<String> packages = [];
|
||||
for (TextEditingController package in packageValue) {
|
||||
packages.add(package.text);
|
||||
}
|
||||
Provider.of<LabelsProvider>(context, listen: false).createLabelResult(
|
||||
lotNumberCTRL.text,
|
||||
cycleNumberCTRL.text,
|
||||
sDateCTRL.text,
|
||||
// sDateValue,
|
||||
// {'id': packageValue[0], 'name': packageValue[1]},
|
||||
packages[0],
|
||||
eDateCTRL.text,
|
||||
// eDateValue,
|
||||
striizerIdCTRL.text,
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Label added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((_) {
|
||||
return Consumer<LabelsProvider>(builder: (context, labelsProvider, _) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
labelsProvider.setLoadingButton();
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
List<String> packages = [];
|
||||
for (TextEditingController package in packageValue) {
|
||||
packages.add(package.text);
|
||||
}
|
||||
await Provider.of<LabelsProvider>(context, listen: false)
|
||||
.createLabelResult(
|
||||
lotNumberCTRL.text,
|
||||
cycleNumberCTRL.text,
|
||||
sDateCTRL.text,
|
||||
// sDateValue,
|
||||
// {'id': packageValue[0], 'name': packageValue[1]},
|
||||
packages[0],
|
||||
eDateCTRL.text,
|
||||
// eDateValue,
|
||||
striizerIdCTRL.text,
|
||||
);
|
||||
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: [kLightBlue, kLightBlueSub],
|
||||
Fluttertoast.showToast(
|
||||
msg: "Label added.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
labelsProvider.resetLoadingButton();
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kLightBlue, kLightBlueSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: labelsProvider.isloadingButton
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/providers/packages.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../config/routes.dart';
|
||||
@@ -23,70 +24,73 @@ class PackageAddSaveButton extends StatelessWidget {
|
||||
final List<TextEditingController> itemValues;
|
||||
final TextEditingController nameCTRL;
|
||||
final TextEditingController descriptionCTRL;
|
||||
|
||||
// final TextEditingController udiCTRL;
|
||||
final String dateValue;
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
List<String> items = [];
|
||||
for (TextEditingController item in itemValues) {
|
||||
items.add(item.text);
|
||||
}
|
||||
Provider.of<PackageProvider>(context, listen: false)
|
||||
.createPackageResult(
|
||||
nameCTRL.text,
|
||||
// udiCTRL.text,
|
||||
items,
|
||||
descriptionCTRL.text,
|
||||
);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Package added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((_) {
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.packageResultScreen);
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kPurple, kPurpleSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
return Consumer<PackageProvider>(
|
||||
builder: (context, packageProvider, _) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
packageProvider.setLoadingButton();
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
List<String> items = [];
|
||||
for (TextEditingController item in itemValues) {
|
||||
items.add(item.text);
|
||||
}
|
||||
await Provider.of<PackageProvider>(context, listen: false)
|
||||
.createPackageResult(
|
||||
nameCTRL.text,
|
||||
// udiCTRL.text,
|
||||
items,
|
||||
descriptionCTRL.text,
|
||||
);
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.packageResultScreen);
|
||||
Fluttertoast.showToast(
|
||||
msg: "Package added.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
packageProvider.resetLoadingButton();
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 5 * _deviceBlockSize,
|
||||
vertical: 10,
|
||||
),
|
||||
// margin:
|
||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [kPurple, kPurpleSub],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: packageProvider.isloadingButton
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user