xCMD_Back method

Future<bool> xCMD_Back()

Comando per il Back dalla Scheda

Implementation

Future<bool> xCMD_Back() async {
  if (editedPage.value) {
    var res = await showDialog(
        context: context,
        builder: (context) {
          return XAlertDialog(
            title_Text: "Vuoi salvare le tue modifiche?",
            title_Style: XStyles.xStyTextForSubLabel(textColor: Colors.yellow),
            actionsBTNarea_Child: Row(children: [
              Expanded(child: XBtnbase(label: "Annulla", label_Style: XStyles.xStyTextForDescr(textColor: Colors.yellow), onPressed: () => Navigator.pop(context, null))),
              Expanded(child: XBtnbase(label: "No", label_Style: XStyles.xStyTextForDescr(textColor: Colors.red), onPressed: () => Navigator.pop(context, false))),
              Expanded(child: XBtnbase(label: "Si", label_Style: XStyles.xStyTextForDescr(textColor: Colors.green), onPressed: () => Navigator.pop(context, true))),
            ]),
          );
        });
    if (res == null) {
      return false;
    } else if (res) {
      xCMD_Save();
      Navigator.pop(context, widget.itemInEdit);
      return true;
    } else {
      Navigator.pop(context);
      return false;
    }
  } else {
    editedPage.value = false;
    if (widget.itemInEdit.isModified)
      Navigator.pop(context, widget.itemInEdit);
    else
      Navigator.pop(context);
    return true;
  }
}