xLayout_ItemWidget method

Widget? xLayout_ItemWidget(
  1. K item
)

Override per cambiare il Widget di ogni Items dell'Elenco, chiamato per ogni Items.

Implementation

Widget? xLayout_ItemWidget(K item) {
  List<XAction>? _xActionsLi_LEFT = List<XAction>.empty(growable: true);
  List<XAction>? _xActionsLi_RIGHT = List<XAction>.empty(growable: true);
  List<XAction>? _xActionsLi_FAST = List<XAction>.empty(growable: true);
  _xActionsLi_RIGHT.clear();
  late List<XFDataItem> liDettsUI;
  if (widget.xDetts_xColname != null) liDettsUI = item[widget.xDetts_xColname!];
  //Aggiungo alla lista delle XActionsRight quelle fisse a livello di xelenco
  if (xActionLi_RIGHT != null) _xActionsLi_RIGHT.addAll(xActionLi_RIGHT!.toList());
  if (xActions_RIGHT_ForItem(item) != null) {
    xActions_RIGHT_ForItem(item)!.forEach((xActionRight) {
      if (xActionRight != null) _xActionsLi_RIGHT.add(xActionRight);
    });
  }
  //Aggiungo alla lista delle XActionsLeft quelle fisse a livello di xelenco
  if (xActionLi_LEFT != null) _xActionsLi_LEFT.addAll(xActionLi_LEFT!.toList());
  //Aggiungo le altre XAction Left a livello di Item dell'elenco
  if (xActions_LEFT_ForItem(item) != null) {
    xActions_LEFT_ForItem(item)!.forEach((xActionLeft) {
      if (xActionLeft != null) {
        _xActionsLi_LEFT.add(xActionLeft);
      }
    });
  }

  var x = xActions_FAST_ForItem(item)!;
  x.forEach((xActionFast) {
    if (xActionFast != null) _xActionsLi_FAST.add(xActionFast);
  });
  return widget.schedaMode == true
      ? DragTarget<XFDataItem>(onWillAccept: (data) {
          var res = xOnDrop_BeforeAccept(data!, item);
          setState(() {
            if (res)
              item.isSel = true;
            else
              item.isSel = false;
          });
          return res;
        }, onAccept: (data) async {
          await xOnDrop_Accept(data, item);
          setState(() => item.isSel = false);
        }, onLeave: (data) {
          xOnDrop_Leave(data!);
          setState(() => item.isSel = false);
        }, builder: (context, candidateData, rejectedData) {
          return XElencoItem(setState, item, context, widget.view!,
              funct: widget.rootItemEdited != null ? () => widget.rootItemEdited!(item) : null,
              showingDetails: item.isShowDetails,
              margin: EdgeInsets.symmetric(vertical: 2),
              liXActions_LEFT: _xActionsLi_LEFT,
              xActions_RIGHT_HorizontalAxis: xActions_RIGHT_HorizontalAxis,
              xActions_LEFT_HorizontalAxis: xActions_LEFT_HorizontalAxis,
              visible_EmptyCells: widget.isEditable,
              widgetOnStackOfItems: xLayout_WidgetOverItems(item),
              liXActions_RIGHT: _xActionsLi_RIGHT,
              liXActions_FAST: _xActionsLi_FAST,
              xActions_LEFT_widthArea: xActions_LEFT_widthArea,
              xActions_RIGHT_widthArea: xActions_RIGHT_widthArea,
              cellIsFlexible: xItem_cellIsFlexible,
              styleForItemCell: widget.xCells_Item_TextStyle,
              xLayout_Row_CellWidth: widget.xCells_Item_Width,
              xLayout_Row_Cell: widget.xCells_Item_Widget ?? (xCol, item) => widget.isEditable ? xLayout_CellWidget_Editable(xCol, item, context, item) : xLayout_Item_RowWidgets(xCol, item),
              paddingOfItem: xItems_Padding,
              decorationBackGroundContainer: widget.xApp!.state.xBox_Decoration(
                item,
                backGround_Color: xLayout_XItem_BackgoundColor(item) != null ? xLayout_XItem_BackgoundColor(item) : widget.backgroundColor,
                border: (xLayout_XItem_BackgoundColor(item) != null ? xLayout_XItem_BackgoundColor(item) : widget.backgroundColor) == xItems_BackgroundColor ? Border(bottom: BorderSide(color: xItems_BorderColor, width: 2)) : null,
              ),
              backGroundColor_ChildMain: itemSelectedInEdit != null && itemSelectedInEdit!.id == item.id
                  ? widget.itemSelected_BackGroundColor
                  : xLayout_XItem_BackgoundColor(item) != null
                      ? xLayout_XItem_BackgoundColor(item)
                      : (item.isShowDetails && widget.elDettsMode_SchItem == true ? xItems_BackgroundColor : widget.itemSelected_BackGroundColor ?? (widget.appBar_Color == null ? widget.itemSelected_BackGroundColor ?? xItems_BackgroundColor : widget.appBar_Color!.withAlpha(30))),
              backGroundColor_ChildDetails: xLayout_XItem_BackgoundColor(item) != null
                  ? xLayout_XItem_BackgoundColor(item)
                  : (item.isShowDetails ? xItems_BackgroundColor : widget.itemSelected_BackGroundColor ?? (widget.appBar_Color == null ? widget.itemSelected_BackGroundColor ?? xItems_BackgroundColor : widget.appBar_Color!.withAlpha(30))),
              onDoubleTapItem: widget.onDoubleTapItem,
              showTrailingArrow: false,
              widgets_RightArea: xLayout_WidgetsRightArea_Item(item, setState),
              childMain: widget.item_Widget != null ? widget.item_Widget!(item) : null,
              widgets_LeftArea: xLayout_WidgetsLeftArea_Item(item, setState),
              onTapItem: () async {
                if ((changed_Data || widget.edited!.value) && (widget.schedaMode ?? false).not() && widget.isEditable) {
                  await showDialog(
                      context: context,
                      builder: (context) {
                        return XAlertDialog(
                          title_Text: "Hai modificato i dati vuoi salvare?",
                          btnYES_OnPressed: () async {
                            await xOnSave(list);
                            Navigator.pop(context);
                            await xOnTapItem_INTERNAL(item);
                            widget.onTapItem != null ? widget.onTapItem!(item) : null;
                          },
                          btnNO_OnPressed: () => Navigator.pop(context),
                        );
                      });
                  return;
                } else {
                  await xOnTapItem_INTERNAL(item);
                  widget.onTapItem != null ? widget.onTapItem!(item) : null;
                }
              },
              onLongTapItem: () => xOnLongTapItem(item),
              // xLayout_Row_Cell: (xCol, item) => xLayout_Item_RowWidgets(xCol, item),
              edited: widget.edited ?? ValueNotifier(false),
              //Widget che raffigura i dettagli che sono dentro la riga espansa
              childDetails: Column(mainAxisSize: MainAxisSize.min, children: [(widget.xDettItem_Widget != null ? widget.xDettItem_Widget!(item) ?? Container() : Container())]));
        })
      : (widget.elDettsMode_SchItem != null && widget.elDettsMode_SchItem!)
          ? xLayout_DettItemWidget(item) ??
              DragTarget<XFDataItem>(onWillAccept: (data) {
                var res = xOnDrop_BeforeAccept(data!, item);
                setState(() {
                  if (res) {
                    item.isSel = true;
                  } else {
                    item.isSel = false;
                  }
                });
                return res;
              }, onAccept: (data) async {
                await xOnDrop_Accept(data, item);
                setState(() {
                  item.isSel = false;
                });
              }, onLeave: (data) {
                xOnDrop_Leave(data!);
                setState(() {
                  item.isSel = false;
                });
              }, builder: (context, candidateData, rejectedData) {
                return XElencoItem(setState, item, context, widget.view!,
                    funct: widget.rootItemEdited != null ? () => widget.rootItemEdited!(item) : null,
                    showingDetails: item.isShowDetails,
                    liXActions_LEFT: _xActionsLi_LEFT,
                    liXActions_RIGHT: _xActionsLi_RIGHT,
                    liXActions_FAST: _xActionsLi_FAST,
                    visible_EmptyCells: widget.isEditable,
                    xActions_RIGHT_HorizontalAxis: xActions_RIGHT_HorizontalAxis,
                    xActions_LEFT_HorizontalAxis: xActions_LEFT_HorizontalAxis,
                    xActions_LEFT_widthArea: xActions_LEFT_widthArea,
                    xActions_RIGHT_widthArea: xActions_RIGHT_widthArea,
                    widgetOnStackOfItems: xLayout_WidgetOverItems(item),
                    cellIsFlexible: xItem_cellIsFlexible,
                    styleForItemCell: widget.xCells_Item_TextStyle,
                    xLayout_Row_CellWidth: widget.xCells_Item_Width,
                    xLayout_Row_Cell: widget.xCells_Item_Widget ?? (xCol, item) => widget.isEditable ? xLayout_CellWidget_Editable(xCol, item, context, item) : xLayout_Item_RowWidgets(xCol, item),
                    paddingOfItem: xItems_Padding,
                    margin: EdgeInsets.symmetric(vertical: 2),
                    decorationBackGroundContainer: widget.xApp!.state.xBox_Decoration(
                      item,
                      backGround_Color: xLayout_XItem_BackgoundColor(item) != null ? xLayout_XItem_BackgoundColor(item) : widget.backgroundColor,
                      border: (xLayout_XItem_BackgoundColor(item) != null ? xLayout_XItem_BackgoundColor(item) : widget.backgroundColor) == xItems_BackgroundColor ? Border(bottom: BorderSide(color: xItems_BorderColor, width: 2)) : null,
                    ),
                    backGroundColor_ChildMain: itemSelectedInEdit != null && itemSelectedInEdit!.id == item.id
                        ? widget.itemSelected_BackGroundColor
                        : xLayout_XItem_BackgoundColor(item) != null
                            ? xLayout_XItem_BackgoundColor(item)
                            : widget.itemSelected_BackGroundColor ?? (widget.appBar_Color == null ? widget.itemSelected_BackGroundColor ?? xItems_BackgroundColor : widget.appBar_Color!.withAlpha(30)),
                    backGroundColor_ChildDetails: xLayout_XItem_BackgoundColor(item) != null ? xLayout_XItem_BackgoundColor(item) : widget.xDettItem_BackGroundColor ?? (widget.appBar_Color == null ? widget.xDettItem_BackGroundColor ?? xItems_BackgroundColor : widget.appBar_Color!.withAlpha(30)),
                    onDoubleTapItem: widget.onDoubleTapItem,
                    childMain: widget.item_Widget != null ? widget.item_Widget!(item) : null,
                    widgets_RightArea: xLayout_WidgetsRightArea_Item(item, setState),
                    widgets_LeftArea: xLayout_WidgetsLeftArea_Item(item, setState),
                    showTrailingArrow: true,
                    //DD 19/09/23 questo ha risolto su ELattACQ che NON espandeva i datt, magari ha portato altri casini
                    onTapItem: () async {
                      if ((changed_Data || widget.edited!.value) && (widget.schedaMode ?? false).not() && widget.isEditable) {
                        showDialog(
                            context: context,
                            builder: (context) {
                              return XAlertDialog(
                                title_Text: "I dati sono da Salvare:",
                              );
                            });
                        return;
                      } else {
                        setState(() {
                          item.isSel = item.isShowDetails = item.isShowDetails.not();
                        });
                        await xOnTapItem_INTERNAL(item);
                        widget.onTapItem != null ? widget.onTapItem!(item) : null;
                      }
                    },
                    onLongTapItem: () => xOnLongTapItem(item),
                    edited: widget.edited ?? ValueNotifier(false),
                    childDetails: Container(
                        width: MediaQuery.of(context).size.width,
                        child: widget.showHead_DettsRowInItem && widget.xDetts_xColname != null
                            ? XScheda(item, widget.viewDetts!, xHead_Show: widget.showHead_DettsRowInItem, modePage_Active: false)
                            : Container(
                                child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: liDettsUI
                                    .map((element) => Container(
                                        child: Column(
                                            crossAxisAlignment: CrossAxisAlignment.start,
                                            children: widget.viewDetts!.cols.groupListsBy((element) => element.originY).entries.map((e) {
                                              return Wrap(
                                                  spacing: 3,
                                                  runSpacing: 5,
                                                  children: e.value.map((e) {
                                                    return xLayout_Item_RowWidgets(e, element);
                                                  }).toList());
                                            }).toList())))
                                    .toList(),
                              ))));
              })
          : xLayout_DettItemWidget(item) ??
              DragTarget<XFDataItem>(onWillAccept: (data) {
                var res = xOnDrop_BeforeAccept(data!, item);
                setState(() {
                  if (res) {
                    item.isSel = true;
                  } else {
                    item.isSel = false;
                  }
                });
                return res;
              }, onAccept: (data) async {
                await xOnDrop_Accept(data, item);
                setState(() {
                  item.isSel = false;
                });
              }, onLeave: (data) {
                xOnDrop_Leave(data!);
                setState(() {
                  item.isSel = false;
                });
              }, builder: (context, candidateData, rejectedData) {
                return XElencoItem(setState, item, context, widget.view!,
                    funct: widget.rootItemEdited != null ? () => widget.rootItemEdited!(item) : null,
                    showingDetails: item.isShowDetails,
                    liXActions_LEFT: _xActionsLi_LEFT,
                    liXActions_RIGHT: _xActionsLi_RIGHT,
                    liXActions_FAST: _xActionsLi_FAST,
                    xActions_RIGHT_HorizontalAxis: xActions_RIGHT_HorizontalAxis,
                    xActions_LEFT_HorizontalAxis: xActions_LEFT_HorizontalAxis,
                    visible_EmptyCells: widget.isEditable,
                    xActions_LEFT_widthArea: xActions_LEFT_widthArea,
                    xActions_RIGHT_widthArea: xActions_RIGHT_widthArea,
                    widgetOnStackOfItems: xLayout_WidgetOverItems(item),
                    cellIsFlexible: xItem_cellIsFlexible,
                    styleForItemCell: widget.xCells_Item_TextStyle,
                    xLayout_Row_CellWidth: widget.xCells_Item_Width,
                    xLayout_Row_Cell: widget.xCells_Item_Widget ?? (xCol, item) => widget.isEditable ? xLayout_CellWidget_Editable(xCol, item, context, item) : xLayout_Item_RowWidgets(xCol, item), //rick
                    paddingOfItem: xItems_Padding,
                    margin: EdgeInsets.symmetric(vertical: 2),
                    decorationBackGroundContainer: widget.xApp!.state.xBox_Decoration(
                      item,
                      backGround_Color: xLayout_XItem_BackgoundColor(item) != null ? xLayout_XItem_BackgoundColor(item) : widget.backgroundColor,
                      border: (xLayout_XItem_BackgoundColor(item) != null ? xLayout_XItem_BackgoundColor(item) : widget.backgroundColor) == xItems_BackgroundColor ? Border(bottom: BorderSide(color: xItems_BorderColor, width: 2)) : null,
                    ),
                    backGroundColor_ChildMain: itemSelectedInEdit != null && itemSelectedInEdit!.id == item.id
                        ? widget.itemSelected_BackGroundColor
                        : xLayout_XItem_BackgoundColor(item) != null
                            ? xLayout_XItem_BackgoundColor(item)
                            : (item.isShowDetails && widget.elDettsMode_SchItem == true ? xItems_BackgroundColor : widget.itemSelected_BackGroundColor ?? (widget.appBar_Color == null ? widget.itemSelected_BackGroundColor ?? xItems_BackgroundColor : widget.appBar_Color!.withAlpha(30))),
                    backGroundColor_ChildDetails: xLayout_XItem_BackgoundColor(item) != null
                        ? xLayout_XItem_BackgoundColor(item)
                        : (item.isShowDetails ? xItems_BackgroundColor : widget.itemSelected_BackGroundColor ?? (widget.appBar_Color == null ? widget.itemSelected_BackGroundColor ?? xItems_BackgroundColor : widget.appBar_Color!.withAlpha(30))),
                    onDoubleTapItem: widget.onDoubleTapItem,
                    edited: widget.edited ?? ValueNotifier(false),
                    showTrailingArrow: false,
                    childMain: widget.item_Widget != null ? widget.item_Widget!(item) : null,
                    widgets_RightArea: xLayout_WidgetsRightArea_Item(item, setState),
                    widgets_LeftArea: xLayout_WidgetsLeftArea_Item(item, setState),
                    onLongTapItem: () => xOnLongTapItem(item),
                    onTapItem: () async {
                      if ((changed_Data || widget.edited!.value) && (widget.schedaMode ?? false).not() && widget.isEditable) {
                        showDialog(
                            context: context,
                            builder: (context) {
                              return XAlertDialog(
                                title_Text: "I dati sono da Salvare:",
                              );
                            });
                        return;
                      } else {
                        await xOnTapItem_INTERNAL(item);
                        if (widget.onTapItem != null) {
                          widget.onTapItem!(item);
                        }
                        (widget.schNameToOpen != null && widget.schedaMode == false
                            ? Navigator.pushNamed(context, widget.schNameToOpen!, arguments: item).then((value) {
                                setState(() {
                                  isBusy.value = true;
                                  widget.xOnReturnBack != null ? widget.xOnReturnBack!(setState) : null;
                                  if (widget.edited != null) {
                                    widget.edited!.value;
                                  }
                                });

                                rebuildAllChildren(context);
                              }) //
                            : setState(() => item.isShowDetails = item.isShowDetails.not()));
                      }
                    },
                    //Widget che raffigura i dettagli che sono dentro la riga espansa
                    childDetails: Column(mainAxisSize: MainAxisSize.min, children: [(widget.xDettItem_Widget != null ? widget.xDettItem_Widget!(item) ?? Container() : Container())]));
              });
}