mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:08:56 +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/item_save_button.dart';
|
||||||
import 'package:cssd/widgets/ItemScreens/Add/upload_image.dart';
|
import 'package:cssd/widgets/ItemScreens/Add/upload_image.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:random_string/random_string.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,
|
void _saveForm(String name, String size, String specific, String udi,
|
||||||
String description) {
|
String description, ItemProvider itemProvider) async {
|
||||||
|
itemProvider.setLoadingButton();
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
if (!_form.currentState!.validate()) {
|
if (!_form.currentState!.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Provider.of<ItemProvider>(context, listen: false)
|
await Provider.of<ItemProvider>(context, listen: false)
|
||||||
.createItemResult(
|
.createItemResult(
|
||||||
name,
|
name,
|
||||||
size,
|
size,
|
||||||
@@ -67,37 +69,20 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
|
|||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
if (result == 'done') {
|
if (result == 'done') {
|
||||||
showDialog(
|
Navigator.of(context).popAndPushNamed(Routes.itemResultScreen);
|
||||||
context: context,
|
Fluttertoast.showToast(
|
||||||
builder: (ctx) => AlertDialog(
|
msg: "Item added.",
|
||||||
content: Text('Item added.'),
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
actions: <Widget>[
|
gravity: ToastGravity.BOTTOM,
|
||||||
TextButton(
|
);
|
||||||
onPressed: () {
|
} else {
|
||||||
Navigator.of(ctx).pop();
|
Fluttertoast.showToast(
|
||||||
},
|
msg: result,
|
||||||
child: Text('Ok'),
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
)
|
gravity: ToastGravity.BOTTOM,
|
||||||
],
|
|
||||||
),
|
|
||||||
).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'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
itemProvider.resetLoadingButton();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -384,12 +369,12 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
|
|||||||
ItemAddSaveButton(
|
ItemAddSaveButton(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
_saveForm(
|
_saveForm(
|
||||||
nameCTRL.text,
|
nameCTRL.text,
|
||||||
sizeCTRL.text,
|
sizeCTRL.text,
|
||||||
specificCTRL.text,
|
specificCTRL.text,
|
||||||
udiCTRL.text,
|
udiCTRL.text,
|
||||||
descriptionCTRL.text,
|
descriptionCTRL.text,
|
||||||
);
|
itemProviderObject);
|
||||||
},
|
},
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:random_string/random_string.dart';
|
import 'package:random_string/random_string.dart';
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ class FormPage extends StatefulWidget {
|
|||||||
class _FormPageState extends State<FormPage> {
|
class _FormPageState extends State<FormPage> {
|
||||||
bool _isInit = true;
|
bool _isInit = true;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
|
bool _isLoadingButton = false;
|
||||||
bool isAdding = false;
|
bool isAdding = false;
|
||||||
final _form = GlobalKey<FormState>();
|
final _form = GlobalKey<FormState>();
|
||||||
Map<String, dynamic> values = {};
|
Map<String, dynamic> values = {};
|
||||||
@@ -39,29 +41,26 @@ class _FormPageState extends State<FormPage> {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoadingButton = true;
|
||||||
});
|
});
|
||||||
prvObject.createTestResult(values, batchId).then(
|
prvObject.createTestResult(values, batchId).then(
|
||||||
(result) {
|
(result) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoadingButton = false;
|
||||||
});
|
});
|
||||||
if (result == 'done') {
|
if (result == 'done') {
|
||||||
showDialog(
|
Navigator.of(context).popAndPushNamed(Routes.testResultScreen);
|
||||||
context: context,
|
Fluttertoast.showToast(
|
||||||
builder: (ctx) => AlertDialog(
|
msg: "Test added.",
|
||||||
content: Text('Test added.'),
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
actions: <Widget>[
|
gravity: ToastGravity.BOTTOM,
|
||||||
TextButton(
|
);
|
||||||
onPressed: () {
|
} else {
|
||||||
Navigator.of(ctx).pop();
|
Fluttertoast.showToast(
|
||||||
},
|
msg: result,
|
||||||
child: Text('Ok'),
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
)
|
gravity: ToastGravity.BOTTOM,
|
||||||
],
|
);
|
||||||
),
|
|
||||||
).then((value) =>
|
|
||||||
Navigator.of(context).popAndPushNamed(Routes.testResultScreen));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -109,15 +108,29 @@ class _FormPageState extends State<FormPage> {
|
|||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
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,
|
backgroundColor: Colors.black,
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
IconButton(
|
_isLoadingButton
|
||||||
icon: Icon(Icons.save, color: Colors.white,),
|
? Center(
|
||||||
onPressed: () {
|
child: CircularProgressIndicator(
|
||||||
_saveForm();
|
color: Colors.white,
|
||||||
},
|
),
|
||||||
)
|
)
|
||||||
|
: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.save,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
_saveForm();
|
||||||
|
},
|
||||||
|
)
|
||||||
],
|
],
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(
|
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/LabelScreens/Detail/header.dart';
|
||||||
import 'package:cssd/widgets/MyInfo/input_box.dart';
|
import 'package:cssd/widgets/MyInfo/input_box.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import '../providers/auth.dart';
|
import '../providers/auth.dart';
|
||||||
@@ -23,6 +24,7 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
TextEditingController emailCTRL = new TextEditingController();
|
TextEditingController emailCTRL = new TextEditingController();
|
||||||
|
|
||||||
bool isInit = true;
|
bool isInit = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() async {
|
void didChangeDependencies() async {
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
@@ -48,7 +50,12 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
titleSpacing: -10,
|
titleSpacing: -10,
|
||||||
title: Text('Dashboard', style: TextStyle(color: Colors.white,),),
|
title: Text(
|
||||||
|
'Dashboard',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
@@ -126,55 +133,54 @@ class _MyInfoScreenState extends State<MyInfoScreen> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
),
|
),
|
||||||
InkWell(
|
Consumer<Auth>(builder: (context, auth, _) {
|
||||||
child: Container(
|
return InkWell(
|
||||||
padding: EdgeInsets.symmetric(
|
child: Container(
|
||||||
horizontal: 60, vertical: 10),
|
padding: EdgeInsets.symmetric(
|
||||||
margin:
|
horizontal: 60, vertical: 10),
|
||||||
EdgeInsets.only(top: 50, bottom: 20),
|
margin: EdgeInsets.only(
|
||||||
width: double.infinity,
|
top: 50, bottom: 20),
|
||||||
decoration: BoxDecoration(
|
width: double.infinity,
|
||||||
color: Colors.black,
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(5),
|
color: Colors.black,
|
||||||
),
|
borderRadius:
|
||||||
child: Text(
|
BorderRadius.circular(5),
|
||||||
'Save',
|
),
|
||||||
style: TextStyle(
|
child: auth.isloading
|
||||||
color: Colors.white,
|
? Center(
|
||||||
fontSize: 5 * _deviceBlockSize,
|
child:
|
||||||
),
|
CircularProgressIndicator(
|
||||||
textAlign: TextAlign.center,
|
color: Colors.white,
|
||||||
),
|
|
||||||
),
|
|
||||||
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();
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
)
|
||||||
),
|
: Text(
|
||||||
),
|
'Save',
|
||||||
);
|
style: TextStyle(
|
||||||
Navigator.of(context).pop();
|
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;
|
return token != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isloading = false;
|
||||||
|
|
||||||
|
void resetLoading() {
|
||||||
|
isloading = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLoading() {
|
||||||
|
isloading = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
String? get token {
|
String? get token {
|
||||||
if (_expiaryDate != null &&
|
if (_expiaryDate != null &&
|
||||||
_expiaryDate!.isAfter(DateTime.now()) &&
|
_expiaryDate!.isAfter(DateTime.now()) &&
|
||||||
|
|||||||
@@ -67,6 +67,17 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
// notifyListeners();
|
// notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isloadingButton = false;
|
||||||
|
void resetLoadingButton() {
|
||||||
|
isloadingButton = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLoadingButton() {
|
||||||
|
isloadingButton = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
Uri.parse(Url.filterItems),
|
Uri.parse(Url.filterItems),
|
||||||
|
|||||||
@@ -52,6 +52,17 @@ class ItemProvider extends ChangeNotifier {
|
|||||||
// notifyListeners();
|
// notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isloadingButton = false;
|
||||||
|
void resetLoadingButton() {
|
||||||
|
isloadingButton = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLoadingButton() {
|
||||||
|
isloadingButton = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
Uri.parse(Url.filterItems),
|
Uri.parse(Url.filterItems),
|
||||||
@@ -154,7 +165,7 @@ class ItemProvider extends ChangeNotifier {
|
|||||||
catchImages = [];
|
catchImages = [];
|
||||||
return 'done';
|
return 'done';
|
||||||
} else {
|
} else {
|
||||||
return 'error';
|
return 'error ${response.statusCode}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,17 @@ class LabelsProvider extends ChangeNotifier {
|
|||||||
// notifyListeners();
|
// notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isloadingButton = false;
|
||||||
|
void resetLoadingButton() {
|
||||||
|
isloadingButton = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLoadingButton() {
|
||||||
|
isloadingButton = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
Uri.parse(Url.filterItems),
|
Uri.parse(Url.filterItems),
|
||||||
|
|||||||
@@ -85,6 +85,17 @@ class PackageProvider extends ChangeNotifier {
|
|||||||
// notifyListeners();
|
// notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isloadingButton = false;
|
||||||
|
void resetLoadingButton() {
|
||||||
|
isloadingButton = false;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLoadingButton() {
|
||||||
|
isloadingButton = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
Future<List<Map<String, String>>> getHospitalsFilters() async {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
Uri.parse(Url.filterItems),
|
Uri.parse(Url.filterItems),
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ class TestResultsProvider with ChangeNotifier {
|
|||||||
catchImages = [];
|
catchImages = [];
|
||||||
return 'done';
|
return 'done';
|
||||||
} else {
|
} else {
|
||||||
return 'error';
|
return 'error ${response.statusCode}';
|
||||||
}
|
}
|
||||||
// var response = await http
|
// var response = await http
|
||||||
// .post(Url.createTestResult, body: json.encode(values), headers: {
|
// .post(Url.createTestResult, body: json.encode(values), headers: {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:cssd/config/colors.dart';
|
import 'package:cssd/config/colors.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../../config/routes.dart';
|
import '../../../config/routes.dart';
|
||||||
@@ -29,63 +30,81 @@ class CycleAddSaveButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return Consumer<CyclesProvider>(builder: (context, cyclesProvider, _) {
|
||||||
onTap: () {
|
return InkWell(
|
||||||
if (!_form.currentState!.validate()) {
|
onTap: () async {
|
||||||
return;
|
cyclesProvider.setLoadingButton();
|
||||||
}
|
if (!_form.currentState!.validate()) {
|
||||||
List<String> labels = [];
|
return;
|
||||||
for (TextEditingController label in labelValues) {
|
}
|
||||||
labels.add(label.text);
|
List<String> labels = [];
|
||||||
}
|
for (TextEditingController label in labelValues) {
|
||||||
Provider.of<CyclesProvider>(context, listen: false).createCycleResult(
|
labels.add(label.text);
|
||||||
cycleNumberCTRL.text,
|
}
|
||||||
dateValue,
|
await Provider.of<CyclesProvider>(context, listen: false)
|
||||||
labels,
|
.createCycleResult(
|
||||||
descriptionCTRL.text,
|
cycleNumberCTRL.text,
|
||||||
striizerIdCTRL.text,
|
dateValue,
|
||||||
);
|
labels,
|
||||||
showDialog(
|
descriptionCTRL.text,
|
||||||
context: context,
|
striizerIdCTRL.text,
|
||||||
builder: (ctx) => AlertDialog(
|
);
|
||||||
content: Text('Cycle added.'),
|
showDialog(
|
||||||
actions: <Widget>[
|
context: context,
|
||||||
TextButton(
|
builder: (ctx) => AlertDialog(
|
||||||
onPressed: () {
|
content: Text('Cycle added.'),
|
||||||
Navigator.of(ctx).pop();
|
actions: <Widget>[
|
||||||
},
|
TextButton(
|
||||||
child: Text('Ok'),
|
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,
|
|
||||||
),
|
),
|
||||||
|
).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/config/colors.dart';
|
||||||
|
import 'package:cssd/providers/items.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ItemAddSaveButton extends StatelessWidget {
|
class ItemAddSaveButton extends StatelessWidget {
|
||||||
const ItemAddSaveButton({
|
const ItemAddSaveButton({
|
||||||
@@ -11,32 +13,41 @@ class ItemAddSaveButton extends StatelessWidget {
|
|||||||
|
|
||||||
final double _deviceBlockSize;
|
final double _deviceBlockSize;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return Consumer<ItemProvider>(builder: (context, itemProvider, _) {
|
||||||
onTap: onTap,
|
return InkWell(
|
||||||
child: Container(
|
onTap: onTap,
|
||||||
padding: EdgeInsets.symmetric(
|
child: Container(
|
||||||
horizontal: 5 * _deviceBlockSize,
|
padding: EdgeInsets.symmetric(
|
||||||
vertical: 10,
|
horizontal: 5 * _deviceBlockSize,
|
||||||
),
|
vertical: 10,
|
||||||
decoration: BoxDecoration(
|
|
||||||
gradient: LinearGradient(
|
|
||||||
colors: [kBlue, kBlueSub],
|
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(7),
|
decoration: BoxDecoration(
|
||||||
),
|
gradient: LinearGradient(
|
||||||
child: Align(
|
colors: [kBlue, kBlueSub],
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text(
|
|
||||||
'Save',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 5 * _deviceBlockSize,
|
|
||||||
),
|
),
|
||||||
|
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:cssd/config/colors.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../../config/routes.dart';
|
import '../../../config/routes.dart';
|
||||||
@@ -31,67 +32,68 @@ class LabelAddSaveButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return Consumer<LabelsProvider>(builder: (context, labelsProvider, _) {
|
||||||
onTap: () {
|
return InkWell(
|
||||||
if (!_form.currentState!.validate()) {
|
onTap: () async {
|
||||||
return;
|
labelsProvider.setLoadingButton();
|
||||||
}
|
if (!_form.currentState!.validate()) {
|
||||||
List<String> packages = [];
|
return;
|
||||||
for (TextEditingController package in packageValue) {
|
}
|
||||||
packages.add(package.text);
|
List<String> packages = [];
|
||||||
}
|
for (TextEditingController package in packageValue) {
|
||||||
Provider.of<LabelsProvider>(context, listen: false).createLabelResult(
|
packages.add(package.text);
|
||||||
lotNumberCTRL.text,
|
}
|
||||||
cycleNumberCTRL.text,
|
await Provider.of<LabelsProvider>(context, listen: false)
|
||||||
sDateCTRL.text,
|
.createLabelResult(
|
||||||
// sDateValue,
|
lotNumberCTRL.text,
|
||||||
// {'id': packageValue[0], 'name': packageValue[1]},
|
cycleNumberCTRL.text,
|
||||||
packages[0],
|
sDateCTRL.text,
|
||||||
eDateCTRL.text,
|
// sDateValue,
|
||||||
// eDateValue,
|
// {'id': packageValue[0], 'name': packageValue[1]},
|
||||||
striizerIdCTRL.text,
|
packages[0],
|
||||||
);
|
eDateCTRL.text,
|
||||||
showDialog(
|
// eDateValue,
|
||||||
context: context,
|
striizerIdCTRL.text,
|
||||||
builder: (ctx) => AlertDialog(
|
);
|
||||||
content: Text('Label added.'),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(ctx).pop();
|
|
||||||
},
|
|
||||||
child: Text('Ok'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
).then((_) {
|
|
||||||
Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen);
|
Navigator.of(context).pushReplacementNamed(Routes.labelResultScreen);
|
||||||
});
|
Fluttertoast.showToast(
|
||||||
},
|
msg: "Label added.",
|
||||||
child: Container(
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
padding: EdgeInsets.symmetric(
|
gravity: ToastGravity.BOTTOM,
|
||||||
horizontal: 5 * _deviceBlockSize,
|
);
|
||||||
vertical: 10,
|
labelsProvider.resetLoadingButton();
|
||||||
),
|
},
|
||||||
// margin:
|
child: Container(
|
||||||
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
padding: EdgeInsets.symmetric(
|
||||||
decoration: BoxDecoration(
|
horizontal: 5 * _deviceBlockSize,
|
||||||
gradient: LinearGradient(
|
vertical: 10,
|
||||||
colors: [kLightBlue, kLightBlueSub],
|
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(7),
|
// margin:
|
||||||
),
|
// EdgeInsets.symmetric(horizontal: 35, vertical: 15),
|
||||||
child: Align(
|
decoration: BoxDecoration(
|
||||||
alignment: Alignment.center,
|
gradient: LinearGradient(
|
||||||
child: Text(
|
colors: [kLightBlue, kLightBlueSub],
|
||||||
'Save',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 5 * _deviceBlockSize,
|
|
||||||
),
|
),
|
||||||
|
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/config/colors.dart';
|
||||||
import 'package:cssd/providers/packages.dart';
|
import 'package:cssd/providers/packages.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../../config/routes.dart';
|
import '../../../config/routes.dart';
|
||||||
@@ -23,70 +24,73 @@ class PackageAddSaveButton extends StatelessWidget {
|
|||||||
final List<TextEditingController> itemValues;
|
final List<TextEditingController> itemValues;
|
||||||
final TextEditingController nameCTRL;
|
final TextEditingController nameCTRL;
|
||||||
final TextEditingController descriptionCTRL;
|
final TextEditingController descriptionCTRL;
|
||||||
|
|
||||||
// final TextEditingController udiCTRL;
|
// final TextEditingController udiCTRL;
|
||||||
final String dateValue;
|
final String dateValue;
|
||||||
final double _deviceBlockSize;
|
final double _deviceBlockSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return Consumer<PackageProvider>(
|
||||||
onTap: () {
|
builder: (context, packageProvider, _) {
|
||||||
if (!_form.currentState!.validate()) {
|
return InkWell(
|
||||||
return;
|
onTap: () async {
|
||||||
}
|
packageProvider.setLoadingButton();
|
||||||
List<String> items = [];
|
if (!_form.currentState!.validate()) {
|
||||||
for (TextEditingController item in itemValues) {
|
return;
|
||||||
items.add(item.text);
|
}
|
||||||
}
|
List<String> items = [];
|
||||||
Provider.of<PackageProvider>(context, listen: false)
|
for (TextEditingController item in itemValues) {
|
||||||
.createPackageResult(
|
items.add(item.text);
|
||||||
nameCTRL.text,
|
}
|
||||||
// udiCTRL.text,
|
await Provider.of<PackageProvider>(context, listen: false)
|
||||||
items,
|
.createPackageResult(
|
||||||
descriptionCTRL.text,
|
nameCTRL.text,
|
||||||
);
|
// udiCTRL.text,
|
||||||
showDialog(
|
items,
|
||||||
context: context,
|
descriptionCTRL.text,
|
||||||
builder: (ctx) => AlertDialog(
|
);
|
||||||
content: Text('Package added.'),
|
Navigator.of(context)
|
||||||
actions: <Widget>[
|
.pushReplacementNamed(Routes.packageResultScreen);
|
||||||
TextButton(
|
Fluttertoast.showToast(
|
||||||
onPressed: () {
|
msg: "Package added.",
|
||||||
Navigator.of(ctx).pop();
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
},
|
gravity: ToastGravity.BOTTOM,
|
||||||
child: Text('Ok'),
|
);
|
||||||
)
|
packageProvider.resetLoadingButton();
|
||||||
],
|
},
|
||||||
),
|
child: Container(
|
||||||
).then((_) {
|
padding: EdgeInsets.symmetric(
|
||||||
Navigator.of(context)
|
horizontal: 5 * _deviceBlockSize,
|
||||||
.pushReplacementNamed(Routes.packageResultScreen);
|
vertical: 10,
|
||||||
});
|
|
||||||
},
|
|
||||||
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,
|
|
||||||
),
|
),
|
||||||
|
// 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
|
permission_handler: ^11.1.0
|
||||||
carousel_slider: ^4.2.1
|
carousel_slider: ^4.2.1
|
||||||
pinch_zoom: ^2.0.0
|
pinch_zoom: ^2.0.0
|
||||||
|
fluttertoast: ^8.2.4
|
||||||
# video_player: ^0.10.11+2
|
# video_player: ^0.10.11+2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user