xEntryDialog method
Implementation
Future<dynamic> xEntryDialog(String title, dynamic value, XCol xCol) async {
FocusScope.of(context).unfocus();
setState(() {
enteredInEditOnCell = true;
});
TextEditingController textController = TextEditingController(text: value.toString());
var res = await showDialog<dynamic>(
context: context,
barrierDismissible: false,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return Container(
alignment: Alignment.center,
child: SingleChildScrollView(
child: XAlertDialog(
content_insetPadding: EdgeInsets.all(5),
height: null,
title_Text: title,
title_Style: XStyles.xStyTextForLabel(Colors.blue),
btnYES_label: "OK",
btnNO_label: "Annulla",
btnNO_OnPressed: () {
Navigator.pop(context, null);
},
btnYES_OnPressed: () {
if (xCol.dataType == String && xCol.colKey.startsWith("li").not()) {
value = textController.text;
} else if (xCol.dataType == DateTime) {
var t = textController.text.split("-");
value = DateTime.parse(t[2] + "-" + t[1] + "-" + t[0]);
} else if (xCol.dataType == double) {
value = double.parse(textController.text);
} else if (xCol.dataType == int) {
value = int.parse(textController.text);
}
setState(() {
editedPage = true;
});
xOnXCell_Edit_SubmitValue(xCol, value, setState);
Navigator.pop(context, value);
},
child: Row(mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.start, children: [
(xCol.dataType == String && xCol.colKey.startsWith("li").not())
? Expanded(
child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
XBtnbase(
width: 40,
height: 40,
label: "C",
label_Color: Colors.red,
backGroundColor: Colors.grey[800],
onPressed: () {
textController.text = "";
},
),
]),
]))
: Container(),
Expanded(
flex: 4,
child: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 5),
Row(children: [Expanded(child: xDialog_CellBuilder(xCol, context, setState, textController))]),
SizedBox(height: 20),
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
xCol.dataType == String && xCol.colKey.startsWith("li").not()
? Container()
: XBtnbase(
width: 40,
height: 40,
label: "C",
label_Color: Colors.red,
backGroundColor: Colors.grey[800],
onPressed: () {
textController.text = "";
},
),
SizedBox(width: 10),
xCol.dataType == String && xCol.colKey.startsWith("li").not()
? Container(height: 0, width: 0)
: XBtnbase(
width: 40,
height: 40,
icon: Icons.remove,
icon_Color: Colors.red,
backGroundColor: Colors.grey[800],
onPressed: () {
calcCell_Negative(xCol, textController, 1);
},
),
SizedBox(width: 10),
xCol.dataType == String && xCol.colKey.startsWith("li").not()
? Container()
: XBtnbase(
width: 40,
height: 40,
icon: Icons.add,
icon_Color: Colors.green,
backGroundColor: Colors.grey[800],
onPressed: () {
calcCell_Positive(xCol, textController, 1);
},
)
]),
])),
SizedBox(width: 10),
Expanded(
child: xCol.dataType == String && xCol.colKey.startsWith("li").not()
? Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
XBtnbase(
width: 100,
height: 40,
label: "Copia \nTesto",
label_TextAlign: TextAlign.center,
label_Color: Colors.white,
padding: EdgeInsets.all(0),
backGroundColor: Colors.grey[800],
onPressed: () {
Clipboard.setData(ClipboardData(text: textController.text));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Testo copiato negli appunti')),
);
},
),
SizedBox(height: 10),
(xCol.dataType == String && xCol.colKey.startsWith("li").not() && (xCol.colKey.contains("sconti") || xCol.colKey.contains("sconto")))
? XBtnbase(
width: 100,
height: 40,
icon: Icons.add,
icon_Color: Colors.green,
backGroundColor: Colors.grey[800],
onPressed: () {
textController.text += "+";
textController.selection = TextSelection(baseOffset: textController.text.length, extentOffset: textController.text.length);
},
)
: Container()
])
: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [
XBtnbase(
width: 40,
height: 30,
label: "-10",
label_Color: Colors.red,
backGroundColor: Colors.grey[800],
onPressed: () {
calcCell_Negative(xCol, textController, 10);
},
),
SizedBox(height: 8),
XBtnbase(
width: 40,
height: 30,
label: "-5",
label_Color: Colors.red,
backGroundColor: Colors.grey[800],
onPressed: () {
calcCell_Negative(xCol, textController, 5);
},
),
SizedBox(height: 8),
XBtnbase(
width: 40,
height: 30,
label: "-1",
label_Color: Colors.red,
backGroundColor: Colors.grey[800],
onPressed: () {
calcCell_Negative(xCol, textController, 1);
},
),
SizedBox(height: 8),
XBtnbase(
width: 40,
height: 30,
label: "+1",
label_Color: Colors.green,
backGroundColor: Colors.grey[800],
onPressed: () {
calcCell_Positive(xCol, textController, 1);
},
),
SizedBox(height: 8),
XBtnbase(
width: 40,
height: 30,
label: "+5",
label_Color: Colors.green,
backGroundColor: Colors.grey[800],
onPressed: () {
calcCell_Positive(xCol, textController, 5);
},
),
SizedBox(height: 8),
XBtnbase(
width: 40,
height: 30,
label: "+10",
backGroundColor: Colors.grey[800],
label_Color: Colors.green,
onPressed: () {
calcCell_Positive(xCol, textController, 10);
},
),
])),
]),
)));
},
);
});
setState(() {
enteredInEditOnCell = false;
});
return res;
}