mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:19:17 +03:30
Set some save button progress bar and toast message
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:cssd/providers/items.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Add/item_save_button.dart';
|
||||
import 'package:cssd/widgets/ItemScreens/Add/upload_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:random_string/random_string.dart';
|
||||
@@ -45,14 +46,15 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
|
||||
}
|
||||
|
||||
void _saveForm(String name, String size, String specific, String udi,
|
||||
String description) {
|
||||
String description, ItemProvider itemProvider) async {
|
||||
itemProvider.setLoadingButton();
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
if (!_form.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
Provider.of<ItemProvider>(context, listen: false)
|
||||
await Provider.of<ItemProvider>(context, listen: false)
|
||||
.createItemResult(
|
||||
name,
|
||||
size,
|
||||
@@ -67,37 +69,20 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
|
||||
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.itemResultScreen));
|
||||
} else if (result == 'error') {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('error.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
Navigator.of(context).popAndPushNamed(Routes.itemResultScreen);
|
||||
Fluttertoast.showToast(
|
||||
msg: "Item added.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: result,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
itemProvider.resetLoadingButton();
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -384,12 +369,12 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
|
||||
ItemAddSaveButton(
|
||||
onTap: () {
|
||||
_saveForm(
|
||||
nameCTRL.text,
|
||||
sizeCTRL.text,
|
||||
specificCTRL.text,
|
||||
udiCTRL.text,
|
||||
descriptionCTRL.text,
|
||||
);
|
||||
nameCTRL.text,
|
||||
sizeCTRL.text,
|
||||
specificCTRL.text,
|
||||
udiCTRL.text,
|
||||
descriptionCTRL.text,
|
||||
itemProviderObject);
|
||||
},
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:random_string/random_string.dart';
|
||||
|
||||
@@ -22,6 +23,7 @@ class FormPage extends StatefulWidget {
|
||||
class _FormPageState extends State<FormPage> {
|
||||
bool _isInit = true;
|
||||
bool _isLoading = false;
|
||||
bool _isLoadingButton = false;
|
||||
bool isAdding = false;
|
||||
final _form = GlobalKey<FormState>();
|
||||
Map<String, dynamic> values = {};
|
||||
@@ -39,29 +41,26 @@ class _FormPageState extends State<FormPage> {
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_isLoadingButton = true;
|
||||
});
|
||||
prvObject.createTestResult(values, batchId).then(
|
||||
(result) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_isLoadingButton = false;
|
||||
});
|
||||
if (result == 'done') {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text('Test added.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
child: Text('Ok'),
|
||||
)
|
||||
],
|
||||
),
|
||||
).then((value) =>
|
||||
Navigator.of(context).popAndPushNamed(Routes.testResultScreen));
|
||||
Navigator.of(context).popAndPushNamed(Routes.testResultScreen);
|
||||
Fluttertoast.showToast(
|
||||
msg: "Test added.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
} else {
|
||||
Fluttertoast.showToast(
|
||||
msg: result,
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -109,15 +108,29 @@ class _FormPageState extends State<FormPage> {
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text('Add Test Result', style: TextStyle(color: Colors.white,),),
|
||||
title: Text(
|
||||
'Add Test Result',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.black,
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.save, color: Colors.white,),
|
||||
onPressed: () {
|
||||
_saveForm();
|
||||
},
|
||||
)
|
||||
_isLoadingButton
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
icon: Icon(
|
||||
Icons.save,
|
||||
color: Colors.white,
|
||||
),
|
||||
onPressed: () {
|
||||
_saveForm();
|
||||
},
|
||||
)
|
||||
],
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:cssd/widgets/Global/internet_error.dart';
|
||||
import 'package:cssd/widgets/LabelScreens/Detail/header.dart';
|
||||
import 'package:cssd/widgets/MyInfo/input_box.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/auth.dart';
|
||||
@@ -23,6 +24,7 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||
TextEditingController emailCTRL = new TextEditingController();
|
||||
|
||||
bool isInit = true;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() async {
|
||||
if (isInit) {
|
||||
@@ -48,7 +50,12 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Dashboard', style: TextStyle(color: Colors.white,),),
|
||||
title: Text(
|
||||
'Dashboard',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
@@ -126,55 +133,54 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
InkWell(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 60, vertical: 10),
|
||||
margin:
|
||||
EdgeInsets.only(top: 50, bottom: 20),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
await Provider.of<Auth>(context,
|
||||
listen: false)
|
||||
.setUserData(
|
||||
user!['id'],
|
||||
usernameCTRL.text,
|
||||
emailCTRL.text,
|
||||
)
|
||||
.then(
|
||||
(value) async => await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => AlertDialog(
|
||||
content: Text(
|
||||
'Info changed successfully.',
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('Ok'),
|
||||
onPressed: () {
|
||||
Navigator.of(ctx).pop();
|
||||
},
|
||||
Consumer<Auth>(builder: (context, auth, _) {
|
||||
return InkWell(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 60, vertical: 10),
|
||||
margin: EdgeInsets.only(
|
||||
top: 50, bottom: 20),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
borderRadius:
|
||||
BorderRadius.circular(5),
|
||||
),
|
||||
child: auth.isloading
|
||||
? Center(
|
||||
child:
|
||||
CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
'Save',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize:
|
||||
5 * _deviceBlockSize,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
)),
|
||||
onTap: () async {
|
||||
auth.setLoading();
|
||||
await Provider.of<Auth>(context,
|
||||
listen: false)
|
||||
.setUserData(
|
||||
user!['id'],
|
||||
usernameCTRL.text,
|
||||
emailCTRL.text,
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
auth.resetLoading();
|
||||
Fluttertoast.showToast(
|
||||
msg: "Info changed successfully.",
|
||||
toastLength: Toast.LENGTH_SHORT,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -18,6 +18,18 @@ class Auth with ChangeNotifier {
|
||||
return token != null;
|
||||
}
|
||||
|
||||
bool isloading = false;
|
||||
|
||||
void resetLoading() {
|
||||
isloading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setLoading() {
|
||||
isloading = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
String? get token {
|
||||
if (_expiaryDate != null &&
|
||||
_expiaryDate!.isAfter(DateTime.now()) &&
|
||||
|
||||
@@ -67,6 +67,17 @@ class CyclesProvider extends ChangeNotifier {
|
||||
// notifyListeners();
|
||||
}
|
||||
|
||||
bool isloadingButton = false;
|
||||
void resetLoadingButton() {
|
||||
isloadingButton = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setLoadingButton() {
|
||||
isloadingButton = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
||||
var response = await http.get(
|
||||
Uri.parse(Url.filterItems),
|
||||
|
||||
@@ -52,6 +52,17 @@ class ItemProvider extends ChangeNotifier {
|
||||
// notifyListeners();
|
||||
}
|
||||
|
||||
bool isloadingButton = false;
|
||||
void resetLoadingButton() {
|
||||
isloadingButton = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setLoadingButton() {
|
||||
isloadingButton = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
||||
var response = await http.get(
|
||||
Uri.parse(Url.filterItems),
|
||||
@@ -154,7 +165,7 @@ class ItemProvider extends ChangeNotifier {
|
||||
catchImages = [];
|
||||
return 'done';
|
||||
} else {
|
||||
return 'error';
|
||||
return 'error ${response.statusCode}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,17 @@ class LabelsProvider extends ChangeNotifier {
|
||||
// notifyListeners();
|
||||
}
|
||||
|
||||
bool isloadingButton = false;
|
||||
void resetLoadingButton() {
|
||||
isloadingButton = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setLoadingButton() {
|
||||
isloadingButton = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
||||
var response = await http.get(
|
||||
Uri.parse(Url.filterItems),
|
||||
|
||||
@@ -85,6 +85,17 @@ class PackageProvider extends ChangeNotifier {
|
||||
// notifyListeners();
|
||||
}
|
||||
|
||||
bool isloadingButton = false;
|
||||
void resetLoadingButton() {
|
||||
isloadingButton = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setLoadingButton() {
|
||||
isloadingButton = true;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
||||
var response = await http.get(
|
||||
Uri.parse(Url.filterItems),
|
||||
|
||||
@@ -312,7 +312,7 @@ class TestResultsProvider with ChangeNotifier {
|
||||
catchImages = [];
|
||||
return 'done';
|
||||
} else {
|
||||
return 'error';
|
||||
return 'error ${response.statusCode}';
|
||||
}
|
||||
// var response = await http
|
||||
// .post(Url.createTestResult, body: json.encode(values), headers: {
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+212
-204
File diff suppressed because it is too large
Load Diff
@@ -46,6 +46,7 @@ dependencies:
|
||||
permission_handler: ^11.1.0
|
||||
carousel_slider: ^4.2.1
|
||||
pinch_zoom: ^2.0.0
|
||||
fluttertoast: ^8.2.4
|
||||
# video_player: ^0.10.11+2
|
||||
|
||||
dev_dependencies:
|
||||
|
||||
Reference in New Issue
Block a user