show static method
void
show(
- List<
ActionSheetModel> list, - dynamic clickBlock(), {
- String? title,
- Color backgroundColor = LiveColors.designStandardG2,
Implementation
static void show(
List<ActionSheetModel> list, Function(ActionSheetModel) clickBlock,
{String? title, Color backgroundColor = LiveColors.designStandardG2}) {
final bool hasTitle = title != null && title.isNotEmpty;
double titleHeight = hasTitle ? 50 : 0;
double bottomHeight = MediaQuery.of(Global.appContext()).padding.bottom;
double actionSheetHeight =
list.fold(0.0, (sum, item) => sum + item.cellHeight);
debugPrint("showActionSheet:$actionSheetHeight");
showModalBottomSheet(
context: Global.appContext(),
builder: (context) => Container(
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
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, color: LiveColors.designStandardWhite7)),
Expanded(
child: ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
return _buildCell(list[index], clickBlock);
},
),
),
],
),
),
);
}