mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 02:58:55 +03:30
beta commit
This commit is contained in:
@@ -1,251 +1,212 @@
|
||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../providers/cycles.dart';
|
||||
|
||||
class CycleAddLabelBox extends StatelessWidget {
|
||||
const CycleAddLabelBox({
|
||||
Key key,
|
||||
@required double deviceBlockSize,
|
||||
@required this.labelValues,
|
||||
@required this.labelVals,
|
||||
@required this.initialLabelValue,
|
||||
@required this.index,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
final TextEditingController labelValues;
|
||||
final List<String> labelVals;
|
||||
final String initialLabelValue;
|
||||
final int index;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
// color: Colors.blue,
|
||||
height: 150,
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
right: 10,
|
||||
bottom: 30,
|
||||
left: 10,
|
||||
top: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
left: BorderSide(color: Colors.black, width: 2),
|
||||
right: BorderSide(color: Colors.grey),
|
||||
bottom: BorderSide(color: Colors.grey),
|
||||
top: BorderSide(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
height: 120,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
// height: 65,
|
||||
child: Row(
|
||||
// width: double.infinity,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
color: Colors.grey,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 4 * _deviceBlockSize,
|
||||
),
|
||||
Expanded(
|
||||
// width: MediaQuery.of(context).size.width - 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: _deviceBlockSize,
|
||||
),
|
||||
Text(
|
||||
'Select Labels Included',
|
||||
style: TextStyle(
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w100,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width -
|
||||
(40 * _deviceBlockSize),
|
||||
// height: 30,
|
||||
child: DropdownButtonFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: _deviceBlockSize,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
),
|
||||
iconSize: 7 * _deviceBlockSize,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.angleDown,
|
||||
color: Colors.black,
|
||||
),
|
||||
isExpanded: true,
|
||||
hint: Container(
|
||||
// width: 100,
|
||||
height: 70,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 0),
|
||||
child: TextFormField(
|
||||
controller: labelValues,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(
|
||||
bottom: 12,
|
||||
),
|
||||
isDense: true,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
isDense: true,
|
||||
items: labelVals.map((val) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: val,
|
||||
child: Container(
|
||||
child: Text(
|
||||
val,
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
Provider.of<CyclesProvider>(context,
|
||||
listen: false)
|
||||
.changeLabelVal(val, index);
|
||||
// setState(() {
|
||||
// labelValues[index]
|
||||
// .text = val;
|
||||
// });
|
||||
},
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
Provider.of<CyclesProvider>(context,
|
||||
listen: false)
|
||||
.changeLabelVal(result, index);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// CycleDetailScreen.route,
|
||||
// arguments: result,
|
||||
// );
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
FontAwesomeIcons.barcode,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 15,
|
||||
right: 0,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Provider.of<CyclesProvider>(context).addLabelVal();
|
||||
// setState(
|
||||
// () {
|
||||
// curLabelVal += 1;
|
||||
// TextEditingController lbl =
|
||||
// new TextEditingController();
|
||||
// lbl.text = initialLabelValue;
|
||||
// labelValues.add(lbl);
|
||||
// },
|
||||
// );
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(3),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.deepOrange,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> scan() async {
|
||||
try {
|
||||
var barcode = await BarcodeScanner.scan();
|
||||
if (barcode.type.name == 'Cancelled') {
|
||||
return 'cancel';
|
||||
} else if (barcode.type.name == 'Failed') {
|
||||
return 'error';
|
||||
}
|
||||
try {
|
||||
var id = barcode.rawContent.contains('www.cssd-doc.com')
|
||||
? barcode.rawContent.split('/')[5]
|
||||
: barcode.rawContent;
|
||||
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'null';
|
||||
}
|
||||
} on PlatformException catch (_) {
|
||||
return 'access';
|
||||
} catch (_) {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
}
|
||||
import 'package:cssd/utils/scan.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../providers/cycles.dart';
|
||||
|
||||
class AddLabelBox extends StatelessWidget {
|
||||
const AddLabelBox({
|
||||
Key? key,
|
||||
required double deviceBlockSize,
|
||||
required this.values,
|
||||
required this.vals,
|
||||
required this.initialLabelValue,
|
||||
required this.index,
|
||||
required this.text,
|
||||
this.iconColor,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
final TextEditingController values;
|
||||
final List<String> vals;
|
||||
final String initialLabelValue;
|
||||
final int index;
|
||||
final String text;
|
||||
final Color? iconColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 150,
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(
|
||||
right: 10,
|
||||
bottom: 25,
|
||||
left: 10,
|
||||
top: 10,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
left: BorderSide(color: Colors.black, width: 2),
|
||||
right: BorderSide(color: Colors.grey),
|
||||
bottom: BorderSide(color: Colors.grey),
|
||||
top: BorderSide(color: Colors.grey),
|
||||
),
|
||||
),
|
||||
height: 120,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 5),
|
||||
// height: 65,
|
||||
child: Row(
|
||||
// width: double.infinity,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
color: Colors.grey,
|
||||
size: 7 * _deviceBlockSize,
|
||||
),
|
||||
SizedBox(
|
||||
width: 4 * _deviceBlockSize,
|
||||
),
|
||||
Expanded(
|
||||
// width: MediaQuery.of(context).size.width - 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
width: _deviceBlockSize,
|
||||
),
|
||||
Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 3.5 * _deviceBlockSize,
|
||||
color: Colors.grey,
|
||||
fontWeight: FontWeight.w100,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width -
|
||||
(40 * _deviceBlockSize),
|
||||
// height: 30,
|
||||
child: DropdownButtonFormField(
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(
|
||||
left: _deviceBlockSize,
|
||||
),
|
||||
border: InputBorder.none,
|
||||
),
|
||||
iconSize: 7 * _deviceBlockSize,
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.angleDown,
|
||||
color: Colors.black,
|
||||
),
|
||||
isExpanded: true,
|
||||
hint: Container(
|
||||
// width: 100,
|
||||
height: 70,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 0),
|
||||
child: TextFormField(
|
||||
controller: values,
|
||||
decoration: InputDecoration(
|
||||
contentPadding: EdgeInsets.only(
|
||||
bottom: 12,
|
||||
),
|
||||
isDense: true,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: Colors.black,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
isDense: true,
|
||||
items: vals.map((val) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: val,
|
||||
child: Container(
|
||||
child: Text(
|
||||
val,
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
Provider.of<CyclesProvider>(context,
|
||||
listen: false)
|
||||
.changeLabelVal(val!, index);
|
||||
},
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
scan().then(
|
||||
(String result) {
|
||||
if (result == 'cancel') {
|
||||
print('cancel');
|
||||
} else if (result == 'error') {
|
||||
print('error');
|
||||
} else if (result == 'access') {
|
||||
print('access');
|
||||
} else {
|
||||
print(result);
|
||||
Provider.of<CyclesProvider>(context,
|
||||
listen: false)
|
||||
.changeLabelVal(result, index);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 5 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
]),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 15,
|
||||
right: 0,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Provider.of<CyclesProvider>(context).addLabelVal();
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(3),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: iconColor,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,77 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
class CycleAddDatePicker extends StatefulWidget {
|
||||
const CycleAddDatePicker({
|
||||
Key key,
|
||||
@required this.dateCTRL,
|
||||
@required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize, super(key: key);
|
||||
|
||||
final TextEditingController dateCTRL;
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
_CycleAddDatePickerState createState() => _CycleAddDatePickerState();
|
||||
}
|
||||
|
||||
class _CycleAddDatePickerState extends State<CycleAddDatePicker> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
var res = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2010, 1),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
if (res != null) {
|
||||
// dateTimeFrom = res;
|
||||
setState(
|
||||
() {
|
||||
widget.dateCTRL.text = DateFormat('y-M-d').format(res);
|
||||
// dateValue = DateFormat('y-M-d').format(
|
||||
// dateTimeFrom,
|
||||
// ); // baraye tavize makane gharar giri baraye api
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
enabled: false,
|
||||
controller: widget.dateCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * widget._deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * widget._deviceBlockSize,
|
||||
),
|
||||
labelText: 'Date',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.only(
|
||||
bottom: 7,
|
||||
right: 3,
|
||||
left: 3,
|
||||
),
|
||||
// border: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * widget._deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(FontAwesomeIcons.angleDown)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class CycleAddDatePicker extends StatefulWidget {
|
||||
const CycleAddDatePicker({
|
||||
Key? key,
|
||||
required this.dateCTRL,
|
||||
required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final TextEditingController dateCTRL;
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
_CycleAddDatePickerState createState() => _CycleAddDatePickerState();
|
||||
}
|
||||
|
||||
class _CycleAddDatePickerState extends State<CycleAddDatePicker> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
var res = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2010, 1),
|
||||
lastDate: DateTime(2101),
|
||||
);
|
||||
if (res != null) {
|
||||
// dateTimeFrom = res;
|
||||
setState(
|
||||
() {
|
||||
widget.dateCTRL.text = DateFormat('y-M-d').format(res);
|
||||
// dateValue = DateFormat('y-M-d').format(
|
||||
// dateTimeFrom,
|
||||
// ); // baraye tavize makane gharar giri baraye api
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TextField(
|
||||
enabled: false,
|
||||
controller: widget.dateCTRL,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(
|
||||
FontAwesomeIcons.alignLeft,
|
||||
size: 7 * widget._deviceBlockSize,
|
||||
),
|
||||
labelStyle: TextStyle(
|
||||
fontWeight: FontWeight.w100,
|
||||
fontSize: 4 * widget._deviceBlockSize,
|
||||
),
|
||||
labelText: 'Date',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.only(
|
||||
bottom: 7,
|
||||
right: 3,
|
||||
left: 3,
|
||||
),
|
||||
// border: InputBorder.none,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
fontSize: 5 * widget._deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Icon(FontAwesomeIcons.angleDown)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,91 +1,92 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../config/routes.dart';
|
||||
import '../../../providers/cycles.dart';
|
||||
|
||||
class CycleAddSaveButton extends StatelessWidget {
|
||||
const CycleAddSaveButton({
|
||||
Key key,
|
||||
@required GlobalKey<FormState> form,
|
||||
@required this.labelValues,
|
||||
@required this.cycleNumberCTRL,
|
||||
@required this.dateValue,
|
||||
@required this.descriptionCTRL,
|
||||
@required this.striizerIdCTRL,
|
||||
@required double deviceBlockSize,
|
||||
}) : _form = form,
|
||||
_deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final GlobalKey<FormState> _form;
|
||||
final List<TextEditingController> labelValues;
|
||||
final TextEditingController cycleNumberCTRL;
|
||||
final String dateValue;
|
||||
final TextEditingController descriptionCTRL;
|
||||
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 labelValues) {
|
||||
labels.add(label.text);
|
||||
}
|
||||
Provider.of<CyclesProvider>(context).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: [Colors.red, Colors.orange],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
'SAVE',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 5 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../config/routes.dart';
|
||||
import '../../../providers/cycles.dart';
|
||||
|
||||
class CycleAddSaveButton extends StatelessWidget {
|
||||
const CycleAddSaveButton({
|
||||
Key? key,
|
||||
required GlobalKey<FormState> form,
|
||||
required this.labelValues,
|
||||
required this.cycleNumberCTRL,
|
||||
required this.dateValue,
|
||||
required this.descriptionCTRL,
|
||||
required this.striizerIdCTRL,
|
||||
required double deviceBlockSize,
|
||||
}) : _form = form,
|
||||
_deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final GlobalKey<FormState> _form;
|
||||
final List<TextEditingController> labelValues;
|
||||
final TextEditingController cycleNumberCTRL;
|
||||
final String dateValue;
|
||||
final TextEditingController descriptionCTRL;
|
||||
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 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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user