89 lines
3.0 KiB
Dart
89 lines
3.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../colors/app_colors.dart';
|
|
import '../colors/app_gradients.dart';
|
|
import '../strings/common_strings.dart';
|
|
|
|
import 'tap_bounce.dart';
|
|
|
|
const Color _teal = AppColors.teal;
|
|
const Color _accentPink = AppColors.pink;
|
|
|
|
/// Diálogo de confirmação com a identidade visual do app (título rosa
|
|
/// centrado, botão principal em pílula com gradiente), usado para todas as
|
|
/// confirmações destrutivas/decisórias.
|
|
Future<bool?> showConfirmDialog(
|
|
BuildContext context, {
|
|
required String title,
|
|
String? message,
|
|
String cancelLabel = CommonStrings.cancel,
|
|
required String confirmLabel,
|
|
Color confirmColor = _teal,
|
|
}) {
|
|
// Só o teal (o valor por omissão, usado nas confirmações não-destrutivas
|
|
// como "Adicionar outra criança?") ganha o gradiente verde da app; ações
|
|
// destrutivas continuam com a cor sólida passada (normalmente rosa), para
|
|
// manter esse alerta visual.
|
|
final isDefaultColor = confirmColor == _teal;
|
|
|
|
return showDialog<bool>(
|
|
context: context,
|
|
builder: (ctx) {
|
|
return AlertDialog(
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
|
titlePadding: const EdgeInsets.fromLTRB(24, 24, 24, 8),
|
|
contentPadding: const EdgeInsets.fromLTRB(24, 8, 24, 12),
|
|
actionsPadding: const EdgeInsets.fromLTRB(20, 0, 20, 20),
|
|
title: Text(
|
|
title,
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.w900,
|
|
color: _accentPink,
|
|
),
|
|
),
|
|
content: message == null
|
|
? null
|
|
: Text(
|
|
message,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Colors.black.withValues(alpha: 0.72),
|
|
height: 1.4,
|
|
),
|
|
),
|
|
actionsAlignment: MainAxisAlignment.center,
|
|
actions: [
|
|
TapBounce(
|
|
child: TextButton(
|
|
style: TextButton.styleFrom(foregroundColor: _teal),
|
|
onPressed: () => Navigator.of(ctx).pop(false),
|
|
child: Text(cancelLabel),
|
|
),
|
|
),
|
|
TapBounce(
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(999),
|
|
child: DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
gradient: isDefaultColor ? kGreenButtonGradient : null,
|
|
color: isDefaultColor ? null : confirmColor,
|
|
),
|
|
child: FilledButton(
|
|
style: FilledButton.styleFrom(
|
|
backgroundColor: Colors.transparent,
|
|
foregroundColor: Colors.white,
|
|
shape: const StadiumBorder(),
|
|
textStyle: const TextStyle(fontWeight: FontWeight.w800),
|
|
),
|
|
onPressed: () => Navigator.of(ctx).pop(true),
|
|
child: Text(confirmLabel),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|