Files
social-app/apps/lib/shared/widgets/confirm_sheet.dart
T

98 lines
3.2 KiB
Dart

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: Colors.transparent,
builder: (sheetContext) {
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: AppColors.white,
borderRadius: BorderRadius.circular(AppRadius.xl),
border: Border.all(color: AppColors.borderSecondary),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
title,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: AppColors.slate900,
),
),
const SizedBox(height: AppSpacing.xs),
Text(
message,
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 14, color: AppColors.slate500),
),
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
? AppColors.feedbackErrorIcon
: AppColors.blue600,
borderRadius: BorderRadius.circular(AppRadius.full),
),
child: Text(
resolvedConfirmText,
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
color: AppColors.white,
),
),
),
),
),
const SizedBox(height: AppSpacing.sm),
SizedBox(
height: 52,
child: AppButton(
text: resolvedCancelText,
isOutlined: true,
onPressed: () => Navigator.of(sheetContext).pop(false),
),
),
],
),
),
);
},
);
return result == true;
}