showNiceActionSheet function
- BuildContext context, {
- String? title,
- required List<
NiceActionSheetItem> actions, - String? cancelLabel,
Shows a bottom action sheet.
Implementation
Future<void> showNiceActionSheet(
BuildContext context, {
String? title,
required List<NiceActionSheetItem> actions,
String? cancelLabel,
}) {
final theme = NiceTheme.of(context);
return showModalBottomSheet<void>(
context: context,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(theme.borderRadius * 2)),
),
builder: (ctx) {
return SafeArea(
child: Padding(
padding: EdgeInsets.all(theme.spacing),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Handle
Container(
width: 36,
height: 4,
margin: EdgeInsets.only(bottom: theme.spacing),
decoration: BoxDecoration(
color: theme.colors.disabled,
borderRadius: BorderRadius.circular(2),
),
),
if (title != null)
Padding(
padding: EdgeInsets.only(bottom: theme.spacing),
child: Text(title, style: theme.typography.label),
),
...actions.map((a) => ListTile(
leading:
a.icon != null ? Icon(a.icon, size: 20) : null,
title: Text(
a.label,
style: theme.typography.body.copyWith(
color: a.destructive
? theme.colors.error
: null,
),
),
onTap: () {
Navigator.of(ctx).pop();
a.onTap?.call();
},
)),
if (cancelLabel != null) ...[
const Divider(),
ListTile(
title: Text(cancelLabel,
textAlign: TextAlign.center,
style: theme.typography.body
.copyWith(fontWeight: FontWeight.w600)),
onTap: () => Navigator.of(ctx).pop(),
),
],
],
),
),
);
},
);
}