xLayout_AreaElenco method

Widget xLayout_AreaElenco()

Override per cambiare widget dell'intero Elenco anche la XSearchBar

Implementation

Widget xLayout_AreaElenco() {
  return Container(
      color: widget.backgroundColor,
      margin: EdgeInsets.symmetric(horizontal: widget.margin_Horizontal ?? 0),
      child: Column(children: [
        widget.appBar_Custom_Visible ? xLayout_AppBarCustom() : Container(),
        widget.appBar_Custom_Visible ? SizedBox(height: 10) : Container(),
        Container(
            decoration: (widget.searchBar_Active && xFilter_SearchBarXCols.isNotEmpty && list.length > 10 || (widget.liDetts != null && widget.liDetts!.length > 10)) || (widget.view!.cols.where((xcol) => xcol.colKey.startsWith("li").not()).length > 3 && (widget.schedaMode?.not()))
                ? BoxDecoration(
                    border: Border(
                    left: BorderSide(color: XSchedaState.color_AppBar_Background, width: 3),
                    right: BorderSide(color: XSchedaState.color_AppBar_Background, width: 3),
                    bottom: BorderSide(color: XSchedaState.color_AppBar_Background, width: 3),
                  ))
                : null,
            padding: EdgeInsets.only(bottom: 1),
            child: Row(children: [
              Expanded(
                  child: (widget.searchBar_Active && xFilter_SearchBarXCols.isNotEmpty && list.length > 10 || (widget.liDetts != null && widget.liDetts!.length > 10))
                      ? XSearchBar(
                          marginOfSearchBox: EdgeInsets.symmetric(vertical: 2),
                          paddingOfContent: EdgeInsets.only(left: 5),
                          height: 40,
                          hintStyle: searchBar_HintStyleText ?? searchBar_StyleText ?? XStyles.xStyTextForSubLabel(textColor: widget.searchBar_ColorHint ?? XColors.foregroundLight),
                          textStyle: searchBar_StyleText ?? XStyles.xStyTextForSubLabel(textColor: widget.searchBar_ColorText ?? XColors.foregroundLight),
                          colorIconForClear: widget.searchBar_ColorIconClear ?? XColors.foregroundLight,
                          colorIconForSearch: widget.searchBar_ColorIconSearch ?? XColors.foregroundLight,
                          autoFocus: false,
                          onTextChanged: (value) => setState(() {
                                if (value == "") {
                                  searchController.text = "";
                                  xFilterCurrent = xFilterAll;
                                } else
                                  xFilterCurrent = value;
                              }),
                          onPressedClear: () => setState(() {
                                xFilterCurrent = xFilterAll;
                                searchController.text = "";
                              }),
                          border: UnderlineInputBorder(borderSide: BorderSide(color: widget.searchBar_ColorBorder ?? widget.searchBar_ColorHint ?? widget.searchBar_ColorText ?? XColors.foregroundLight)),
                          disabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: widget.searchBar_ColorBorder ?? widget.searchBar_ColorHint ?? widget.searchBar_ColorText ?? XColors.foregroundLight)),
                          enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: widget.searchBar_ColorBorder ?? widget.searchBar_ColorHint ?? widget.searchBar_ColorText ?? XColors.foregroundLight)),
                          controller: searchController,
                          colorOfSearchBox: widget.searchBar_Color,
                          hintText: widget.searchBar_hintText ?? "cerca..",
                          iconForSearch: null)
                      : Container()),
              widget.view!.cols.where((xcol) => xcol.colKey.startsWith("li").not()).length > 3 && (widget.schedaMode?.not())
                  ? XBtnbase(
                      icon: widget.headers_Visible ? Icons.expand_less_outlined : Icons.expand_more_outlined,
                      backGroundColor: Colors.grey[900],
                      width: 40,
                      height: 40,
                      icon_Color: widget.headers_Visible ? Colors.amber : Colors.white,
                      onPressed: () {
                        setState(() {
                          widget.headers_Visible = widget.headers_Visible.not();
                        });
                      })
                  : Container(),
              (widget.schedaMode ?? false)
                  ? Container()
                  : widget.allowAdd
                      ? xLayout_AddBTN_Widget()
                      : Container()
            ])),

        //RENDERIZZA L'HEADER DEL L ELENCO
        (widget.headers_Visible && widget.view!.cols.where((xcol) => xcol.colKey.startsWith("li").not()).length > 3)
            ? MediaQuery.of(context).size.height < 40
                ? Container()
                : Container(
                    margin: xMedia_Active ? EdgeInsets.only(left: 30) : null,
                    padding: EdgeInsets.only(top: 4),
                    decoration: BoxDecoration(
                        border: Border(
                      bottom: BorderSide(color: XSchedaState.color_AppBar_Background, width: 3),
                      left: BorderSide(color: XSchedaState.color_AppBar_Background, width: 3),
                      right: BorderSide(color: XSchedaState.color_AppBar_Background, width: 3),
                    )),
                    child: Row(children: [Expanded(child: SingleChildScrollView(child: Column(children: xLayout_Render_HeadView(widget.view!, border_Visible: widget.borderAree_Header ?? false))))]))
            : Container(),
        //RENDERIZZA L'HEADER DEL L ELENCO
        xLayout_AreaUnderHeader(),
        ((widget.schedaMode ?? false))
            ? Container()
            : widget.title_OnTop_Visible
                ? Row(children: [
                    Expanded(
                        child: XContainerWithLabel(
                      widget.title_Text,
                      height: widget.title_OnTop_AddBTN_Height,
                      color: widget.title_OnTop_BackgroundColor ?? widget.searchBar_Color ?? XColors.backGroundTitleContainerForElenco,
                      textStyle: widget.title_Style ?? XStyles.xStyTextForTextBase(textColor: XColors.foregroundDark),
                    )),
                    widget.title_OnTop_AddBTN_Visible == true
                        ? Container(
                            margin: widget.title_OnTop_AddBTN_Margin ?? EdgeInsets.only(left: 5),
                            height: widget.title_OnTop_AddBTN_Height ?? 25,
                            width: widget.title_OnTop_AddBTN_Width ?? 70,
                            child: XBtnbase(
                              label: widget.title_OnTop_AddBTN_Label ?? "Add New",
                              onPressed: widget.title_OnTop_AddBTN_OnPressed,
                              decoration: BoxDecoration(color: widget.title_OnTop_AddBTN_Color),
                            ))
                        : Container()
                  ])
                : Container(),

        ///Da overridare per aggiungere un tuo widget nell'elenco solo se la lista รจ vuota
        SizedBox(height: 10),
        Expanded(
            flex: widget.xLayout_HeightElArea_Factor ?? 18,
            child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
              widget.xWidget_Left ?? Container(),
              Expanded(
                  child: Stack(alignment: widget.xLayout_Stack_Alignment ?? Alignment.topCenter, children: [
                DragTarget<XFDataItem>(
                  builder: (context, candidateData, rejectedData) {
                    return xLayout_ElencoWidget() != null
                        ? xLayout_ElencoWidget() ?? Container()
                        : widget.isCompexUI_WrapItems
                            ? Scrollbar(
                                thumbVisibility: true,
                                controller: scroll_controller,
                                child: Container(
                                    alignment: Alignment.topCenter,
                                    child: SingleChildScrollView(
                                        controller: scroll_controller,
                                        child: Wrap(
                                            spacing: 10,
                                            runSpacing: 10,
                                            children: (list.isEmpty && (widget.liDetts != null && widget.liDetts!.isEmpty))
                                                ? [xLayout_Widget_IfEmptyList()]
                                                : widget.liDetts != null
                                                    ? widget.liDetts!.where((element) => xFilter_FilterItem(element)).map((e) {
                                                        return DragTarget<T>(
                                                            onWillAccept: (data) => xOnDrop_BeforeAccept(data! as XFDataItem, e),
                                                            onAccept: (data) async => await xOnDrop_Accept(data as XFDataItem, e),
                                                            builder: (context, candidateData, rejectedData) {
                                                              return widget.item_Widget != null
                                                                  ? widget.item_Widget!(e) ?? Container() //
                                                                  : xLayout_ItemWidget(e) ?? Container();
                                                            });
                                                      }).toList()
                                                    : list.where((element) => xFilter_FilterItem(element)).map((e) {
                                                        return DragTarget<T>(
                                                            onWillAccept: (data) => xOnDrop_BeforeAccept(data! as XFDataItem, e),
                                                            onAccept: (data) async => await xOnDrop_Accept(data as XFDataItem, e),
                                                            builder: (context, candidateData, rejectedData) {
                                                              return widget.item_Widget != null
                                                                  ? widget.item_Widget!(e) ?? Container() //
                                                                  : xLayout_ItemWidget(e) ?? Container();
                                                            });
                                                      }).toList()))))
                            :
                            //  isWeb
                            //     ? XElGrid(widget.title_Text, widget.view!,
                            //         allowEdit: true,
                            //         xgds_Origin: () => gds_El((widget.liDetts as List<K>?) ?? list, widget.view!, rootItemEdited: (p0) {
                            //               var x = ((widget.liDetts as List<K>?) ?? list).firstWhereOrNull((element) => element.id == p0.id);
                            //               if (x != null) {
                            //                 widget.view!.cols.forEach((e) {
                            //                   xOnXCell_Edit_SubmitValue_ToItem(x, e, p0[e.colKey], p0[e.colKey] != x[e.colKey]);
                            //                 });
                            //                 widget.rootItemEdited!(x);
                            //               }
                            //             }))
                            //     :
                            ((widget.schedaMode ?? false) && widget.onRefresh_ScrollDownList != null)
                                ? RefreshIndicator(
                                    triggerMode: RefreshIndicatorTriggerMode.anywhere,
                                    onRefresh: () => widget.onRefresh_ScrollDownList!(context),
                                    child: Scrollbar(
                                        thumbVisibility: true,
                                        controller: scroll_controller,
                                        child: ListView(
                                            children: (list.isEmpty && (widget.liDetts != null && widget.liDetts!.isEmpty))
                                                ? [xLayout_Widget_IfEmptyList()]
                                                : widget.liDetts != null
                                                    ? widget.liDetts!.where((element) => xFilter_FilterItem(element)).map((e) {
                                                        return DragTarget<T>(
                                                            onWillAccept: (data) => xOnDrop_BeforeAccept(data! as XFDataItem, e),
                                                            onAccept: (data) async => await xOnDrop_Accept(data as XFDataItem, e),
                                                            builder: (context, candidateData, rejectedData) {
                                                              return widget.item_Widget != null
                                                                  ? widget.item_Widget!(e) ?? Container() //
                                                                  : xLayout_ItemWidget(e) ?? Container();
                                                            });
                                                      }).toList()
                                                    : list.where((element) => xFilter_FilterItem(element)).map((e) {
                                                        return DragTarget<T>(
                                                            onWillAccept: (data) => xOnDrop_BeforeAccept(data! as XFDataItem, e),
                                                            onAccept: (data) async => await xOnDrop_Accept(data as XFDataItem, e),
                                                            builder: (context, candidateData, rejectedData) {
                                                              return widget.item_Widget != null
                                                                  ? widget.item_Widget!(e) ?? Container() //
                                                                  : xLayout_ItemWidget(e) ?? Container();
                                                            });
                                                      }).toList(),
                                            controller: scroll_controller)))
                                : Scrollbar(
                                    thumbVisibility: true,
                                    controller: scroll_controller,
                                    child: ListView(
                                        children: (list.isEmpty && (widget.liDetts != null && widget.liDetts!.isEmpty))
                                            ? [xLayout_Widget_IfEmptyList()]
                                            : widget.liDetts != null
                                                ? widget.liDetts!.where((element) {
                                                    // for (var xProp in xFilter_OrderBy_XProps) {
                                                    //   widget.liDetts!.orderBy([xProp.col_Name], desc: (widget.view!.cols.firstWhere((element) => element.colKey == xProp.col_Name).sorted ?? false).not());
                                                    // }
                                                    return xFilter_FilterItem(element);
                                                  }).map((e) {
                                                    return DragTarget<T>(
                                                        onWillAccept: (data) => xOnDrop_BeforeAccept(data! as XFDataItem, e),
                                                        onAccept: (data) async => await xOnDrop_Accept(data as XFDataItem, e),
                                                        builder: (context, candidateData, rejectedData) {
                                                          return widget.item_Widget != null
                                                              ? widget.item_Widget!(e) ?? Container() //
                                                              : xLayout_ItemWidget(e) ?? Container();
                                                        });
                                                  }).toList()
                                                : list.where((element) {
                                                    // for (var xProp in xFilter_OrderBy_XProps) {
                                                    //   list.orderBy([xProp.col_Name], desc: (widget.view!.cols.firstWhere((element) => element.colKey == xProp.col_Name).sorted ?? false).not());
                                                    // }
                                                    return xFilter_FilterItem(element);
                                                  }).map((e) {
                                                    return DragTarget<T>(
                                                        onWillAccept: (data) => xOnDrop_BeforeAccept(data! as XFDataItem, e),
                                                        onAccept: (data) async => await xOnDrop_Accept(data as XFDataItem, e),
                                                        builder: (context, candidateData, rejectedData) {
                                                          return widget.item_Widget != null
                                                              ? widget.item_Widget!(e) ?? Container() //
                                                              : xLayout_ItemWidget(e) ?? Container();
                                                        });
                                                  }).toList(),
                                        controller: scroll_controller));
                  },
                  onWillAccept: (data) => xOnDrop_BeforeAccept(data!, widget.xObjParent),
                  onAccept: (data) async => await xOnDrop_Accept(data, widget.xObjParent),
                ),
                isActive_addDropInElenco
                    ? DragTarget<XFDataItem>(
                        builder: (context, candidateData, rejectedData) {
                          return Container(
                              height: 50,
                              width: MediaQuery.of(context).size.width,
                              color: (widget.title_Color ?? Colors.white).withAlpha(150),
                              child: Row(children: [
                                Expanded(child: Text("...trascina qui per aggiungere...", textAlign: TextAlign.center, style: XStyles.xStyTextForLabel(textColor: XColors.foregroundDark))),
                              ]));
                        },
                        onWillAccept: (data) => xOnDrop_BeforeAccept(data!, widget.xObjParent),
                        onAccept: (data) async {
                          await xOnDrop_Accept(data, widget.xObjParent);
                        },
                      )
                    : Container(),
              ])),
              widget.xWidget_Right ?? Container(),
            ]))
      ]));
}