Files

105 lines
3.4 KiB
Dart
Raw Permalink Normal View History

import 'package:flutter/material.dart';
import '../../core/l10n/l10n.dart';
import '../../core/theme/design_tokens.dart';
import 'app_button.dart';
Future<bool> showConfirmSheet(
BuildContext context, {
required String title,
required String message,
String? confirmText,
String? cancelText,
bool isDestructive = false,
}) async {
final l10n = context.l10n;
final resolvedConfirmText = confirmText ?? l10n.commonConfirm;
final resolvedCancelText = cancelText ?? l10n.commonCancel;
final result = await showModalBottomSheet<bool>(
context: context,
isScrollControlled: true,
backgroundColor: Theme.of(context).colorScheme.surface.withValues(alpha: 0),
builder: (sheetContext) {
final colorScheme = Theme.of(sheetContext).colorScheme;
return SafeArea(
top: false,
child: Container(
margin: const EdgeInsets.fromLTRB(
AppSpacing.md,
AppSpacing.none,
AppSpacing.md,
AppSpacing.md,
),
padding: const EdgeInsets.all(AppSpacing.lg),
decoration: BoxDecoration(
color: colorScheme.surface,
borderRadius: BorderRadius.circular(AppRadius.xl),
border: Border.all(color: colorScheme.outlineVariant),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
title,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: colorScheme.onSurface,
),
),
const SizedBox(height: AppSpacing.xs),
Text(
message,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: colorScheme.onSurfaceVariant,
),
),
const SizedBox(height: AppSpacing.lg),
SizedBox(
height: 52,
child: GestureDetector(
onTap: () => Navigator.of(sheetContext).pop(true),
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: isDestructive
? colorScheme.error
: colorScheme.primary,
borderRadius: BorderRadius.circular(AppRadius.full),
),
child: Text(
resolvedConfirmText,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
color: isDestructive
? colorScheme.onError
: colorScheme.onPrimary,
),
),
),
),
),
const SizedBox(height: AppSpacing.sm),
SizedBox(
height: 52,
child: AppButton(
text: resolvedCancelText,
isOutlined: true,
onPressed: () => Navigator.of(sheetContext).pop(false),
),
),
],
),
),
);
},
);
return result == true;
}