show static method

BottomSheetHandler show(
  1. List<ActionSheetModel> list,
  2. dynamic clickBlock(
    1. ActionSheetModel
    ), {
  3. String? title,
  4. Color backgroundColor = LiveColors.designStandardG2,
  5. BuildContext? parentContext,
})

Implementation

static BottomSheetHandler show(List<ActionSheetModel> list, Function(ActionSheetModel) clickBlock,
    {String? title, Color backgroundColor = LiveColors.designStandardG2, BuildContext? parentContext}) {
  final context = parentContext ?? Global.appContext();
  final bool hasTitle = title != null && title.isNotEmpty;
  double titleHeight = hasTitle ? 50.height : 0;
  double bottomHeight = MediaQuery.paddingOf(context).bottom;
  double actionSheetHeight = list.fold(0.0, (sum, item) => sum + item.cellHeight);
  debugPrint("showActionSheet:$actionSheetHeight");
  return BaseBottomSheet.showModalSheet(
    context: context,
    builder: (context) => Container(
      decoration: BoxDecoration(
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(20.radius),
          topRight: Radius.circular(20.radius),
        ),
        color: backgroundColor,
      ),
      height: titleHeight + actionSheetHeight + bottomHeight,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Visibility(
            visible: hasTitle,
            child: SizedBox(
              height: titleHeight,
              child: Center(
                child: Text(hasTitle ? title : '',
                    style: const TextStyle(color: LiveColors.designStandardG4, fontSize: 12),
                    textAlign: TextAlign.center),
              ),
            ),
          ),
          Visibility(visible: hasTitle, child: Container(height: 1.height, color: LiveColors.designStandardWhite7)),
          Expanded(
            child: ListView.builder(
              itemCount: list.length,
              itemBuilder: (context, index) {
                return _buildCell(list[index], clickBlock, context);
              },
            ),
          ),
        ],
      ),
    ),
  );
}