| 1 | import 'package:cake_wallet/src/widgets/alert_close_button.dart'; |
| 2 | import 'package:cake_wallet/src/widgets/primary_button.dart'; |
| 3 | import 'package:flutter/material.dart'; |
| 4 | import 'package:cake_wallet/src/widgets/alert_background.dart'; |
| 5 | |
| 6 | class PopUpCancellableAlertDialog extends StatelessWidget { |
| 7 | final String contentText; |
| 8 | final String actionButtonText; |
| 9 | final VoidCallback? buttonAction; |
| 10 | final bool sameActionForButtonAndClose; |
| 11 | |
| 12 | const PopUpCancellableAlertDialog({ |
| 13 | super.key, |
| 14 | this.contentText = '', |
| 15 | this.actionButtonText = '', |
| 16 | this.buttonAction, |
| 17 | this.sameActionForButtonAndClose = true, |
| 18 | }); |
| 19 | bool get barrierDismissible => false; |
| 20 | Color? get actionButtonTextColor => null; |
| 21 | Color? get actionButtonColor => null; |
| 22 | |
| 23 | Widget content(BuildContext context) { |
| 24 | return Text( |
| 25 | contentText, |
| 26 | textAlign: TextAlign.center, |
| 27 | style: Theme.of(context).textTheme.bodyMedium!.copyWith( |
| 28 | fontSize: 16, |
| 29 | fontWeight: FontWeight.normal, |
| 30 | color: Theme.of(context).colorScheme.onSurface, |
| 31 | decoration: TextDecoration.none, |
| 32 | ), |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | @override |
| 37 | Widget build(BuildContext context) { |
| 38 | return GestureDetector( |
| 39 | onTap: () => barrierDismissible ? Navigator.of(context).pop() : null, |
| 40 | child: AlertBackground( |
| 41 | child: Stack( |
| 42 | alignment: AlignmentDirectional.center, |
| 43 | children: [ |
| 44 | Positioned( |
| 45 | top: 280, |
| 46 | child: Column( |
| 47 | children: [ |
| 48 | Padding( |
| 49 | padding: EdgeInsets.only(left: 24, right: 24, top: 24), |
| 50 | child: ClipRRect( |
| 51 | borderRadius: BorderRadius.all(Radius.circular(30)), |
| 52 | child: Container( |
| 53 | width: 340, |
| 54 | padding: EdgeInsets.all(10), |
| 55 | color: Theme.of(context).colorScheme.surface, |
| 56 | child: Column( |
| 57 | mainAxisSize: MainAxisSize.min, |
| 58 | children: <Widget>[ |
| 59 | Column( |
| 60 | children: [ |
| 61 | Padding( |
| 62 | padding: EdgeInsets.fromLTRB(24, 8, 24, 32), |
| 63 | child: content(context), |
| 64 | ), |
| 65 | PrimaryButton( |
| 66 | onPressed: buttonAction, |
| 67 | text: actionButtonText, |
| 68 | color: Theme.of(context).colorScheme.primaryContainer, |
| 69 | textColor: Theme.of(context).colorScheme.onPrimaryContainer, |
| 70 | ), |
| 71 | ], |
| 72 | ), |
| 73 | ], |
| 74 | ), |
| 75 | ), |
| 76 | ), |
| 77 | ), |
| 78 | ], |
| 79 | ), |
| 80 | ), |
| 81 | AlertCloseButton( |
| 82 | onTap: sameActionForButtonAndClose ? buttonAction : null, |
| 83 | ), |
| 84 | ], |
| 85 | ), |
| 86 | ), |
| 87 | ); |
| 88 | } |
| 89 | } |