| 1 | import 'package:cake_wallet/src/widgets/alert_background.dart'; |
| 2 | import 'package:cake_wallet/src/widgets/primary_button.dart'; |
| 3 | import 'package:flutter/material.dart'; |
| 4 | |
| 5 | class CakePayAlertModal extends StatelessWidget { |
| 6 | const CakePayAlertModal({ |
| 7 | super.key, |
| 8 | required this.title, |
| 9 | required this.content, |
| 10 | required this.actionTitle, |
| 11 | this.showCloseButton = true, |
| 12 | this.dismissible = false, |
| 13 | }); |
| 14 | |
| 15 | final String title; |
| 16 | final Widget content; |
| 17 | final String actionTitle; |
| 18 | final bool showCloseButton; |
| 19 | final bool dismissible; |
| 20 | |
| 21 | @override |
| 22 | Widget build(BuildContext context) { |
| 23 | final theme = Theme.of(context); |
| 24 | final maxHeight = MediaQuery.of(context).size.height * 0.8; |
| 25 | |
| 26 | return AlertBackground( |
| 27 | dismissible: dismissible, |
| 28 | child: ConstrainedBox( |
| 29 | constraints: BoxConstraints(maxHeight: maxHeight), |
| 30 | child: Material( |
| 31 | color: Colors.transparent, |
| 32 | child: Padding( |
| 33 | padding: const EdgeInsets.symmetric(horizontal: 16), |
| 34 | child: Container( |
| 35 | decoration: BoxDecoration( |
| 36 | color: theme.colorScheme.surface, borderRadius: BorderRadius.circular(30)), |
| 37 | padding: const EdgeInsets.all(24), |
| 38 | child: Column( |
| 39 | mainAxisSize: MainAxisSize.min, |
| 40 | children: [ |
| 41 | if (title.isNotEmpty) ...[ |
| 42 | Text(title, |
| 43 | style: theme.textTheme.titleLarge?.copyWith( |
| 44 | color: theme.colorScheme.onSurface, fontWeight: FontWeight.bold), |
| 45 | textAlign: TextAlign.center), |
| 46 | const SizedBox(height: 12), |
| 47 | ], |
| 48 | Flexible(child: SingleChildScrollView(child: content)), |
| 49 | const SizedBox(height: 24), |
| 50 | PrimaryButton( |
| 51 | onPressed: () => Navigator.pop(context), |
| 52 | text: actionTitle, |
| 53 | color: theme.colorScheme.surfaceContainer, |
| 54 | textColor: theme.colorScheme.primary), |
| 55 | if (showCloseButton) ...[ |
| 56 | const SizedBox(height: 16), |
| 57 | InkWell( |
| 58 | onTap: () => Navigator.pop(context), |
| 59 | child: CircleAvatar( |
| 60 | backgroundColor: theme.colorScheme.surfaceContainer, |
| 61 | child: Icon(Icons.close, color: theme.colorScheme.onSurface), |
| 62 | ), |
| 63 | ), |
| 64 | ], |
| 65 | ], |
| 66 | ), |
| 67 | ), |
| 68 | ), |
| 69 | ), |
| 70 | ), |
| 71 | ); |
| 72 | } |
| 73 | } |