getDefaultHeader function

Widget getDefaultHeader(
  1. BuildContext context,
  2. String title, {
  3. Function? function,
  4. ValueChanged<String>? funChange,
  5. bool withFilter = false,
  6. Function? filterFun,
  7. bool isShowBack = false,
  8. bool isBackQuestion = false,
  9. TextEditingController? searchController,
  10. FocusNode? searchFocusNode,
  11. dynamic backResult,
  12. void addOnTap()?,
  13. Function? searchOnBlur,
})

Implementation

Widget getDefaultHeader(
  BuildContext context,
  String title, {
  Function? function,
  ValueChanged<String>? funChange,
  bool withFilter = false,
  Function? filterFun,
  bool isShowBack = false,
  bool isBackQuestion = false,
  TextEditingController? searchController,
  FocusNode? searchFocusNode,
  dynamic backResult,
  void Function()? addOnTap,
  Function? searchOnBlur,
}) {
  double appbarPadding = MahasDimensions.getAppBarPadding();
  double toolbarHeight = MahasDimensions.getToolbarHeight(context);
  return Container(
    color: MahasColors.primaryColor,
    child: Column(
      children: [
        Container(
          width: double.infinity,
          padding: EdgeInsets.only(
              top: MahasDimensions.getToolbarTopHeight(context),
              left: appbarPadding,
              right: appbarPadding),
          height: toolbarHeight,
          child: Stack(
            children: [
              Visibility(
                visible: isShowBack,
                child: Align(
                  alignment: Alignment.centerLeft,
                  child: SizedBox(
                    height: double.infinity,
                    child: InkWell(
                      onTap: () {
                        if (isBackQuestion) {
                          MahasDialog.getBackDialog(backResult: backResult);
                        } else {
                          Get.back(result: backResult);
                        }
                      },
                      child: getIcon(
                        'arrow_left',
                        color: MahasColors.whiteColor,
                        size: MahasDimensions.getHeightPercentSize(
                            MahasDimensions.fontSizeExtraLarge),
                      ),
                    ),
                  ),
                ),
              ),
              Center(
                child: getCustomText(
                  title,
                  align: TextAlign.center,
                  weight: FontWeight.bold,
                  color: MahasColors.whiteColor,
                  size: MahasDimensions.getHeightPercentSize(
                      MahasDimensions.fontSizeLarge),
                ),
              ),
              Visibility(
                visible: addOnTap != null,
                child: Align(
                  alignment: Alignment.centerRight,
                  child: SizedBox(
                    height: double.infinity,
                    child: InkWell(
                      onTap: addOnTap,
                      child: getIcon(
                        'add_circle',
                        color: MahasColors.whiteColor,
                        size: MahasDimensions.getHeightPercentSize(
                            MahasDimensions.fontSizeExtraLarge),
                      ),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
        if (searchController != null && searchFocusNode != null)
          Container(
            margin: EdgeInsets.only(
                right: appbarPadding,
                left: appbarPadding,
                bottom: appbarPadding / 2),
            child: getTextField(
              searchController,
              focusNode: searchFocusNode,
              hint: "Search",
              icon: "search",
              colorSet: MahasColors.whiteColor,
              rightIcon: filterFun != null ? "filter" : null,
              rightIconFieldFunction: filterFun,
              onBlur: searchOnBlur,
            ),
          )
        else
          getSpaceWidth(0),
      ],
    ),
  );
}