Implementation
Future<dynamic> xEntryDialog(String title, dynamic value, XCol xCol, {List<ScontiBTN>? liSconti}) async {
FocusScope.of(context).unfocus();
TextEditingController textController = TextEditingController(text: value.runtimeType != DateTime ? value.toString() : XUtils.dateToString(value, format: "dd/MM/yyyy", noDateLabel: ""));
if (enteredInEditOnCell) {
} else {
setState(() {
enteredInEditOnCell = true;
});
}
var res = await showDialog<dynamic>(
context: context,
barrierDismissible: false,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return Container(
width: MediaQuery.of(context).size.width - 20,
alignment: Alignment.center,
child: SingleChildScrollView(
child: XAlertDialog(
actionsBTNarea_Padding: EdgeInsets.symmetric(horizontal: 10),
content_insetPadding: EdgeInsets.all(2),
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(textController.text);
} else if (xCol.dataType == double) {
value = double.parse(textController.text);
} else if (xCol.dataType == int) {
value = int.parse(textController.text);
}
// lo fa giĆ xOnXCell_Edit_SubmitValue
xOnXCell_Edit_SubmitValue(xCol, value, setState);
Navigator.pop(context, value);
},
child: xLayout_Override_EntryDialog(xCol.colCaption, value, xCol, textController, setState) != null
? xLayout_Override_EntryDialog(xCol.colCaption, value, xCol, textController, setState)
: (xCol.dataType == String && xCol.colKey.startsWith("li").not() && xCol.dataType != DateTime && (xCol.colKey.contains("sconti") || xCol.colKey.contains("sconto")))
? xLayout_Sconto_EntryDialog(xCol, textController, setState, liSconti: liSconti)
: Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [
((xCol.dataType == String).not() && xCol.dataType != DateTime)
? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Expanded(
child: Wrap(alignment: WrapAlignment.end, spacing: 8, runSpacing: 8, children: [
builderEntryDialog_BTNs(textController, "-20", false, setState, xCol: xCol),
builderEntryDialog_BTNs(textController, "-10", false, setState, xCol: xCol),
builderEntryDialog_BTNs(textController, "-5", false, setState, xCol: xCol),
builderEntryDialog_BTNs(textController, "-3", false, setState, xCol: xCol),
xCol.dataType == String && xCol.colKey.startsWith("li").not() ? Container(height: 0, width: 0) : builderEntryDialog_BTNs(textController, "-1", false, setState, xCol: xCol),
]))
])
: Container(),
SizedBox(height: 10),
(xCol.dataType == String && xCol.colKey.startsWith("li").not() && (xCol.colKey.contains("sconti") || xCol.colKey.contains("sconto")))
? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Expanded(child: xDialog_CellBuilder(xCol, context, setState, textController)),
SizedBox(width: 10),
builderEntryDialog_BTNs(textController, "C", false, setState),
])
: xCol.dataType == String && xCol.colKey.startsWith("li").not()
? Column(mainAxisAlignment: MainAxisAlignment.center, children: [
Row(children: [Expanded(child: xDialog_CellBuilder(xCol, context, setState, textController))]),
SizedBox(height: 10),
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
XBtnbase(
width: 60,
height: 40,
label: "Copia \nTutto",
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(width: 20),
builderEntryDialog_BTNs(textController, "C", false, setState),
])
])
: xCol.dataType == DateTime
? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Expanded(child: xDialog_CellBuilder(xCol, context, setState, textController)),
])
: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Expanded(child: xDialog_CellBuilder(xCol, context, setState, textController)),
SizedBox(width: 10),
builderEntryDialog_BTNs(textController, "C", false, setState),
]),
SizedBox(height: 10),
((xCol.dataType == String).not() && xCol.dataType != DateTime)
? Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Expanded(
child: Wrap(alignment: WrapAlignment.end, spacing: 8, runSpacing: 8, children: [
builderEntryDialog_BTNs(textController, "+20", false, setState, xCol: xCol),
builderEntryDialog_BTNs(textController, "+10", false, setState, xCol: xCol),
builderEntryDialog_BTNs(textController, "+5", false, setState, xCol: xCol),
builderEntryDialog_BTNs(textController, "+3", false, setState, xCol: xCol),
xCol.dataType == String && xCol.colKey.startsWith("li").not() ? Container() : builderEntryDialog_BTNs(textController, "+1", false, setState, xCol: xCol),
]))
])
: Container(),
]))));
},
);
});
return res;
}