getView method

Widget getView(
  1. BuildContext context
)

Implementation

Widget getView(BuildContext context) {
  int getSelectedItemCount() {
    if (showIncludeInactiveButton && !includeInactive) {
      return mainList
          .where((element) => element.isSelect && (element.active ?? true))
          .length;
    }
    return mainList.where((element) => element.isSelect).length;
  }

  int mainListLength() {
    if (showIncludeInactiveButton && !includeInactive) {
      return mainList.where((element) => element.active ?? true).length;
    }
    return totalNetworkListCount ?? mainList.length;
  }

  Widget selectionList = UFUMultiSelectList(
    controller: scrollController,
    list: list,
    onItemTap: onItemTap,
    canShowMore: canShowMore,
    isLoading: isLoading,
    type: type,
    listLoader: listLoader,
    searchKeyWord: searchInputCtrl?.text ?? '',
    showInactiveUserLabel: showIncludeInactiveButton,
  );

  return AnimatedPadding(
    duration: const Duration(milliseconds: 100),
    padding: UFUResponsiveDesign.popOverBottomInsets,
    child: Container(
      margin: EdgeInsets.only(
        left: 10,
        right: 10,
        top: type == UFUMultiSelectType.network || UFUScreen.isTablet
            ? 0
            : MediaQuery.of(context).size.height * 0.05,
        bottom: isFilterSheet && !UFUScreen.hasBottomPadding ? 20 : 0,
      ),
      decoration: BoxDecoration(
        borderRadius: getBorderRadius(),
        color: AppTheme.themeColors.themeBlue,
      ),
      child: SafeArea(
        top: true,
        bottom: !isFilterSheet,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            UFUMultiSelectHeader(
              totalAmount: totalAmount,
              inputHintText: inputHintText,
              canShowSearchBar:
                  type == UFUMultiSelectType.network ||
                      (searchInputCtrl?.text.isNotEmpty ?? false)
                  ? true
                  : !isFilterSheet && mainList.length > 8,
              title: title!,
              searchInputCtrl: searchInputCtrl,
              onSearch: onSearch,
              headerPrefixChild: headerPrefixChild,
              canShowSubList: canShowSubList ?? false,
              helperText: helperText,
              showSubList: showSubList,
              isViewSubList: isViewSubList,
              isSelectedSubListItems: isSelectedSubListItems ?? false,
            ),
            UFUMultiSelectSubHeader(
              mainListLength: mainListLength(),
              listLength: list.length,
              canShowClearAll:
                  !(hideSelectAll || searchInputCtrl!.text.isNotEmpty),
              selectedItemCount: getSelectedItemCount(),
              selectAndClearAll: selectAndClearAll,
              canShowCount:
                  list.isNotEmpty ||
                  selectedItems
                      .where((element) => element.isSelect)
                      .isNotEmpty,
              tempSelectedItemsCount: tempSelectedItemsCount,
              filterListItemsCount: filterListItemsCount,
              isViewSubList: isViewSubList,
              subList: subList,
              showIncludeInactiveButton: showIncludeInactiveButton,
              includeInactive: includeInactive,
              onTapIncludeInactiveButton: onTapIncludeInactiveButton,
            ),

            if (type == UFUMultiSelectType.network) ...{
              Flexible(child: selectionList),
            } else ...{
              Flexible(
                child: SingleChildScrollView(
                  controller: type != UFUMultiSelectType.local
                      ? scrollController
                      : scrollList,
                  child: Column(
                    children: [
                      if (isViewSubList && subList.isNotEmpty)
                        Padding(
                          padding: const EdgeInsets.symmetric(vertical: 15),
                          child: TweenAnimationBuilder<double>(
                            duration: const Duration(milliseconds: 200),
                            tween: Tween<double>(
                              begin: 0,
                              end: getsubListHeight(),
                            ),
                            builder:
                                (
                                  BuildContext context,
                                  dynamic value,
                                  Widget? child,
                                ) {
                                  return Padding(
                                    padding: const EdgeInsets.symmetric(
                                      horizontal: 20,
                                    ),
                                    child: Container(
                                      decoration: BoxDecoration(
                                        color: AppTheme.themeColors.dimGray
                                            .withAlpha(50),
                                        borderRadius: BorderRadius.circular(
                                          8,
                                        ),
                                      ),
                                      constraints: BoxConstraints(
                                        maxHeight: value,
                                      ),
                                      child: UFUMultiSelectSubList(
                                        controller: scrollController,
                                        subList: subList,
                                        onSubItemTap: onSubItemTap,
                                        canShowMore: canShowMore,
                                        isLoading: isLoading,
                                        type: type,
                                        listLoader: listLoader,
                                        subTitleHeader:
                                            subTitleHeader ?? 'user groups',
                                      ),
                                    ),
                                  );
                                },
                          ),
                        ),
                      selectionList,
                    ],
                  ),
                ),
              ),
            },

            UFUMultiSelectFooter(
              disableButtons: disableButtons,
              canDisableDoneButton: canDisableDoneButton,
              doneIcon: doneIcon,
              selectedItemCount: getSelectedItemCount(),
              callBack: (String action) {
                if (action == 'done') {
                  onDone!();
                  return;
                }
                Navigator.of(context).pop();
              },
            ),
          ],
        ),
      ),
    ),
  );
}