From cca397526406954b2decfcc0df9d7cac14da39ed Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 08:21:01 +0200 Subject: [PATCH 01/46] docs: minor changes --- README.md | 65 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 905ce20..a650769 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,24 @@ A Flutter package to display animated alert dialogs ## Usage -To use this package, add cool_alert as a dependency in your pubspec.yaml file. -And add this import to your file. +To use this package, add the package as dependency in your `pubspec.yaml` file. +```dart +cool_alert: ^2.0.1 +``` + +And add this import to your dart file. + +```dart import 'package:cool_alert/cool_alert.dart'; +``` ## Image ![Screenshot Gif](screenshots/gif.gif) ### Example -``` +```dart CoolAlert.show( context: context, type: CoolAlertType.success, @@ -22,35 +29,33 @@ CoolAlert.show( ); ``` - ### CoolAlert Class - -| Attribute | Data type | Description | Default Value | -|:----------------------|:-------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------:| -| context| BuildContext | @required | Null | -| type | CoolAlertType | @required - Type of alert dialog, ex: CoolAlertType.success for success dialogs | Null -title| String | Set a custom title for dialog | Based on the CoolAlertType selected| | -| text| String | Set the description text of the dialog. | Null | -| widget| Widget | Set any you expect widget of the dialog. | Null | -| confirmBtnText | String | Text of confirm button | 'Ok' | | -| confirmBtnTap| Function | Function that handle click of confirm button | () => Navigator.pop(context)| -| confirmBtnColor| Color | Color of confirm Button | Theme.of(context).primaryColor | | -| cancelBtnText| String | Text of cancel button | 'Cancel' | -| cancelBtnTap| Function | Function that handle click of cancel button | () => Navigator.pop(context) -| barrierDismissible| bool | Dismiss dialog on touch overlay | true -| animType | CoolAlertAnimType| Type of dialogue enter animation | CoolAlertAnimType.scale| -| backgroundColor | Color| Background color of the animation | Color(0xFF515C6F)| -| confirmBtnTextStyle | TextStyle | Confirm button text theme | TextStyle(color: Colors.white, fontWeight:FontWeight.w600,fontSize: 18.0)| -| cancelBtnTextStyle | TextStyle | Cancel button text theme | TextStyle(color: Colors.grey, fontWeight:FontWeight.w600,fontSize: 18.0)| -| flareAsset | String | Custom flare asset | "animation.flr" | -| flareAnimationName | String | The name of the flare animation to play | "play" | -| lottieAsset | String | Custom lottie asset | "animation.json" | -|autoCloseDuration|Duration|Determines how long the dialog stays open for before closing|Null| -|width|double|Dialog width|MediaQuery.of(context).size.width| -|loopAnimation|boolean|Determines if the animation should loop or not|false| -|closeOnConfirmBtnTap|boolean|Detemines if dialog closes when the confirm button is tapped|true| -|reverseBtnOrder|boolean|Reverse the order of the buttons|false| +| Attribute | Data type | Description | Default Value | +|:---------------------|:------------------|:--------------------------------------------------------------------------------|:-------------------------------------------------------------------------:| +| context | BuildContext | @required | Null | +| type | CoolAlertType | @required - Type of alert dialog, ex: CoolAlertType.success for success dialogs | Null | +| title | String | Set a custom title for dialog | Based on the CoolAlertType selected | +| text | String | Set the description text of the dialog. | Null | +| widget | Widget | Set any you expect widget of the dialog. | Null | +| confirmBtnText | String | Text of confirm button | 'Ok' | +| confirmBtnTap | Function | Function that handle click of confirm button | () => Navigator.pop(context) | +| confirmBtnColor | Color | Color of confirm Button | Theme.of(context).primaryColor | +| cancelBtnText | String | Text of cancel button | 'Cancel' | +| cancelBtnTap | Function | Function that handle click of cancel button | () => Navigator.pop(context) | +| barrierDismissible | bool | Dismiss dialog on touch overlay | true | +| animType | CoolAlertAnimType | Type of dialogue enter animation | CoolAlertAnimType.scale | +| backgroundColor | Color | Background color of the animation | Color(0xFF515C6F) | +| confirmBtnTextStyle | TextStyle | Confirm button text theme | TextStyle(color: Colors.white, fontWeight:FontWeight.w600,fontSize: 18.0) | +| cancelBtnTextStyle | TextStyle | Cancel button text theme | TextStyle(color: Colors.grey, fontWeight:FontWeight.w600,fontSize: 18.0) | +| flareAsset | String | Custom flare asset | "animation.flr" | +| flareAnimationName | String | The name of the flare animation to play | "play" | +| lottieAsset | String | Custom lottie asset | "animation.json" | +| autoCloseDuration | Duration | Determines how long the dialog stays open for before closing | Null | +| width | double | Dialog width | MediaQuery.of(context).size.width | +| loopAnimation | boolean | Determines if the animation should loop or not | false | +| closeOnConfirmBtnTap | boolean | Detemines if dialog closes when the confirm button is tapped | true | +| reverseBtnOrder | boolean | Reverse the order of the buttons | false | From fd81f3c78cb73e13f2f23b02ce162229b5413b37 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 14:50:21 +0200 Subject: [PATCH 02/46] feat: added PopScope around AlertDialog child --- lib/cool_alert.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/cool_alert.dart b/lib/cool_alert.dart index a4c6589..160fb0c 100644 --- a/lib/cool_alert.dart +++ b/lib/cool_alert.dart @@ -105,6 +105,14 @@ class CoolAlert { /// When it is false, you will have to close it manually by using Navigator.of(context).pop(); bool closeOnConfirmBtnTap = true, + /// Determines if the dialog can be popped, a wrapper for [PopScope.canPop]. + /// If false, the dialog will not be popped. + bool canPop = true, + + /// Triggered when the dialog is popped, a wrapper for [PopScope.onPopInvoked]. + /// [bool] parameter indicates if the dialog has been popped. + void Function(bool)? onPopInvoked, + /// Reverse the order of the buttons bool reverseBtnOrder = false, }) { @@ -143,7 +151,7 @@ class CoolAlert { reverseBtnOrder: reverseBtnOrder, ); - final child = AlertDialog( + final dialog = AlertDialog( contentPadding: EdgeInsets.zero, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(borderRadius), @@ -153,6 +161,12 @@ class CoolAlert { ), ); + final child = PopScope( + canPop: canPop, + onPopInvoked: onPopInvoked, + child: dialog, + ); + return showGeneralDialog( barrierColor: Colors.black.withOpacity(0.5), transitionBuilder: (context, anim1, __, widget) { From 531d7c072edd6e353ddcef43ffdc9acb8408ee5b Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 15:01:50 +0200 Subject: [PATCH 03/46] doc: update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b08161..090d38b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [2.1.0] - 04/03/2025 + +- Added `PopScope` widget with `canPop` to prevent unwanted navigation while dialog is showing. +- Updated README + ## [2.0.1] - 06/03/2023 - Updated README From 140463d8812546959de020cb727a40c255144bb6 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 15:02:44 +0200 Subject: [PATCH 04/46] feat!: provide dialog context in button tap* This is to pop the dialog within it's context. Popping in the `CoolAlert.show(context)` pops using the parent context (or root context in the example app) with falls back to a black/blank screen. --- lib/cool_alert.dart | 8 ++++---- lib/src/models/cool_alert_options.dart | 4 ++-- lib/src/widgets/cool_alert_buttons.dart | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/cool_alert.dart b/lib/cool_alert.dart index 160fb0c..a8ca473 100644 --- a/lib/cool_alert.dart +++ b/lib/cool_alert.dart @@ -43,11 +43,11 @@ class CoolAlert { /// Barrier Dissmisable bool barrierDismissible = true, - // Triggered when confirm button is tapped - VoidCallback? onConfirmBtnTap, + /// Triggered when confirm button is tapped, [BuildContext] parameter is scoped to the dialog + void Function(BuildContext)? onConfirmBtnTap, - /// Triggered when cancel button is tapped - VoidCallback? onCancelBtnTap, + /// Triggered when cancel button is tapped, [BuildContext] parameter is scoped to the dialog + void Function(BuildContext)? onCancelBtnTap, /// Confirmation button text String confirmBtnText = 'Ok', diff --git a/lib/src/models/cool_alert_options.dart b/lib/src/models/cool_alert_options.dart index 94a82a3..541eeb5 100644 --- a/lib/src/models/cool_alert_options.dart +++ b/lib/src/models/cool_alert_options.dart @@ -8,8 +8,8 @@ class CoolAlertOptions { CoolAlertType type; CoolAlertAnimType? animType; bool? barrierDismissible = false; - VoidCallback? onConfirmBtnTap; - VoidCallback? onCancelBtnTap; + void Function(BuildContext)? onConfirmBtnTap; + void Function(BuildContext)? onCancelBtnTap; String? confirmBtnText; String? cancelBtnText; Color? confirmBtnColor; diff --git a/lib/src/widgets/cool_alert_buttons.dart b/lib/src/widgets/cool_alert_buttons.dart index 75a16bd..967cdda 100644 --- a/lib/src/widgets/cool_alert_buttons.dart +++ b/lib/src/widgets/cool_alert_buttons.dart @@ -38,7 +38,7 @@ class CoolAlertButtons extends StatelessWidget { isOkayBtn: true, text: options.confirmBtnText!, onTap: () { - options.onConfirmBtnTap?.call(); + options.onConfirmBtnTap?.call(context); // If autoCloseDuration is NOT null, it means the dialg will be auto closed, so disable confirm button tap if (options.autoCloseDuration != null) { @@ -66,7 +66,7 @@ class CoolAlertButtons extends StatelessWidget { isOkayBtn: false, text: options.cancelBtnText!, onTap: () { - options.onCancelBtnTap?.call(); + options.onCancelBtnTap?.call(context); Navigator.pop(context); }, ); From 0bbba9cd7a0d11c0cb700ec5dfecd97d8eec2f8e Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 15:03:28 +0200 Subject: [PATCH 05/46] feat: update example --- example/lib/main.dart | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 0e5bccb..174925b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -138,7 +138,7 @@ class _MyHomePageState extends State { onChanged: (value) => message = value, ), closeOnConfirmBtnTap: false, - onConfirmBtnTap: () async { + onConfirmBtnTap: (_) async { if (message.length < 5) { await CoolAlert.show( context: context, @@ -163,6 +163,33 @@ class _MyHomePageState extends State { color: Colors.orange, ); + final unpoppableAlert = _buildButton( + onTap: () { + CoolAlert.show( + context: context, + type: CoolAlertType.custom, + text: 'You cannot pop this alert except with Navigator(root) pop', + // closeOnConfirmBtnTap: false, + canPop: false, + closeOnConfirmBtnTap: false, + onPopInvoked: (didPop) { + print('Pop invoked, has page been popped? $didPop'); + }, + confirmBtnText: "Pop with dialog context", + onConfirmBtnTap: (context) { + print("Confirm tapped"); + }, + showCancelBtn: true, + cancelBtnText: "Pop with root context", + onCancelBtnTap: (context) { + Navigator.of(context).pop(); + }, + ); + }, + text: 'Unpoppable', + color: Colors.blue, + ); + return Scaffold( appBar: AppBar( title: Text(widget.title), @@ -179,6 +206,7 @@ class _MyHomePageState extends State { confirmAlert, loadingAlert, customAlert, + unpoppableAlert, ], ), ), From 3aa647dc624d90770e96e6c59b1f8ec4a86702c9 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 15:13:30 +0200 Subject: [PATCH 06/46] doc: update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 090d38b..d9fa7c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## [2.1.0] - 04/03/2025 +- **BREAKING CHANGES!**: added dialog context to `confirmBtnTap` and `cancelBtnTap` functions. Signatures now are: +```dart +void Function(BuildContext context); +``` - Added `PopScope` widget with `canPop` to prevent unwanted navigation while dialog is showing. - Updated README From d7992d22f0550fd5ae77d53513fa251c16752b8d Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 15:14:01 +0200 Subject: [PATCH 07/46] doc: update README --- README.md | 75 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 905ce20..2c3e5c0 100644 --- a/README.md +++ b/README.md @@ -22,37 +22,56 @@ CoolAlert.show( ); ``` - ### CoolAlert Class +| Attribute | Data type | Description | Default Value | +|:---------------------|:-----------------------------|:---------------------------------------------------------------------------------|:-------------------------------------------------------------------------:| +| context | BuildContext | @required | Null | +| type | CoolAlertType | @required - Type of alert dialog, ex: CoolAlertType.success for success dialogs | Null | +| title | String | Set a custom title for dialog | Based on the CoolAlertType selected | +| text | String | Set the description text of the dialog. | Null | +| widget | Widget | Set any you expect widget of the dialog. | Null | +| confirmBtnText | String | Text of confirm button | 'Ok' | +| confirmBtnTap | void Function(BuildContext)? | Function that handle click of confirm button, provides dialog context parameter. | (c) => Navigator.pop(c) | +| confirmBtnColor | Color | Color of confirm Button | Theme.of(context).primaryColor | +| cancelBtnText | String | Text of cancel button | 'Cancel' | +| cancelBtnTap | void Function(BuildContext)? | Function that handle click of cancel button, provides dialog context parameter. | (c) => Navigator.pop(c) | +| barrierDismissible | bool | Dismiss dialog on touch overlay | true | +| animType | CoolAlertAnimType | Type of dialogue enter animation | CoolAlertAnimType.scale | +| backgroundColor | Color | Background color of the animation | Color(0xFF515C6F) | +| confirmBtnTextStyle | TextStyle | Confirm button text theme | TextStyle(color: Colors.white, fontWeight:FontWeight.w600,fontSize: 18.0) | +| cancelBtnTextStyle | TextStyle | Cancel button text theme | TextStyle(color: Colors.grey, fontWeight:FontWeight.w600,fontSize: 18.0) | +| flareAsset | String | Custom flare asset | "animation.flr" | +| flareAnimationName | String | The name of the flare animation to play | "play" | +| lottieAsset | String | Custom lottie asset | "animation.json" | +| autoCloseDuration | Duration | Determines how long the dialog stays open for before closing | Null | +| width | double | Dialog width | MediaQuery.of(context).size.width | +| loopAnimation | boolean | Determines if the animation should loop or not | false | +| closeOnConfirmBtnTap | boolean | Detemines if dialog closes when the confirm button is tapped | true | +| reverseBtnOrder | boolean | Reverse the order of the buttons | false | +| canPop | boolean | Prevents undesired navigation unless explicitly desired. | true | +| onPopInvoked | void Function(bool)? | Notifies of whether the context was popped with `didPop` parameter | Null | + +### Popping the dialog + +To pop the dialog from one of the buttons, you have the following options. + +1. Using `closeOnConfirmBtnTap: true` will automatically pop the dialog when the confirm button is tapped. +2. Using `confirmBtnTap` or `cancelBtnTap` functions to pop the dialog manually. This should be done with the context provided (see notes below) +```dart +CoolAlert.show( + context: context, + type: CoolAlertType.success, + text: "Your transaction was successful!", + confirmBtnTap: (dialogContext) { + Navigator.pop(dialogContext); + } +); +``` +**Notes:** -| Attribute | Data type | Description | Default Value | -|:----------------------|:-------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------:| -| context| BuildContext | @required | Null | -| type | CoolAlertType | @required - Type of alert dialog, ex: CoolAlertType.success for success dialogs | Null -title| String | Set a custom title for dialog | Based on the CoolAlertType selected| | -| text| String | Set the description text of the dialog. | Null | -| widget| Widget | Set any you expect widget of the dialog. | Null | -| confirmBtnText | String | Text of confirm button | 'Ok' | | -| confirmBtnTap| Function | Function that handle click of confirm button | () => Navigator.pop(context)| -| confirmBtnColor| Color | Color of confirm Button | Theme.of(context).primaryColor | | -| cancelBtnText| String | Text of cancel button | 'Cancel' | -| cancelBtnTap| Function | Function that handle click of cancel button | () => Navigator.pop(context) -| barrierDismissible| bool | Dismiss dialog on touch overlay | true -| animType | CoolAlertAnimType| Type of dialogue enter animation | CoolAlertAnimType.scale| -| backgroundColor | Color| Background color of the animation | Color(0xFF515C6F)| -| confirmBtnTextStyle | TextStyle | Confirm button text theme | TextStyle(color: Colors.white, fontWeight:FontWeight.w600,fontSize: 18.0)| -| cancelBtnTextStyle | TextStyle | Cancel button text theme | TextStyle(color: Colors.grey, fontWeight:FontWeight.w600,fontSize: 18.0)| -| flareAsset | String | Custom flare asset | "animation.flr" | -| flareAnimationName | String | The name of the flare animation to play | "play" | -| lottieAsset | String | Custom lottie asset | "animation.json" | -|autoCloseDuration|Duration|Determines how long the dialog stays open for before closing|Null| -|width|double|Dialog width|MediaQuery.of(context).size.width| -|loopAnimation|boolean|Determines if the animation should loop or not|false| -|closeOnConfirmBtnTap|boolean|Detemines if dialog closes when the confirm button is tapped|true| -|reverseBtnOrder|boolean|Reverse the order of the buttons|false| - - +- if you have have `closeOnConfirmBtnTap: true` while calling `Navigator.pop(dialogContext)` in the above example, you'll pop twice and may run into some issues. Have either one or the other. +- If you have `autoCloseDuration` set, this is a wrapper for `Navigator.pop(coolAlertParentContext, rootNavigator: true)` after the duration is up. In the above example, if the user taps "confirm" and the dialog auto closes, it will pop twice and you may run into issues. From 8d6fae10b008f589f9a35d638717979855b0bbd0 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 15:21:27 +0200 Subject: [PATCH 08/46] feat: added title & text overflow and align options --- lib/cool_alert.dart | 16 ++++++++++++++++ lib/src/models/cool_alert_options.dart | 8 ++++++++ lib/src/widgets/cool_alert_container.dart | 5 ++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/cool_alert.dart b/lib/cool_alert.dart index a4c6589..f93ce56 100644 --- a/lib/cool_alert.dart +++ b/lib/cool_alert.dart @@ -67,9 +67,21 @@ class CoolAlert { /// TextStyle for title TextStyle? titleTextStyle, + /// TextOverflow for title + TextOverflow? titleOverflow, + + /// TextAlign for title + TextAlign titleTextAlign = TextAlign.center, + /// TextStyle for text TextStyle? textTextStyle, + /// TextOverflow for text + TextOverflow? textOverflow, + + /// TextAlign for text + TextAlign textTextAlign = TextAlign.center, + /// Determines if cancel button is shown or not bool showCancelBtn = false, @@ -129,7 +141,11 @@ class CoolAlert { confirmBtnTextStyle: confirmBtnTextStyle, cancelBtnTextStyle: cancelBtnTextStyle, titleTextStyle: titleTextStyle, + titleOverflow: titleOverflow, + titleTextAlign: titleTextAlign, textTextStyle: textTextStyle, + textTextAlign: textTextAlign, + textOverflow: textOverflow, showCancelBtn: showCancelBtn, borderRadius: borderRadius, backgroundColor: backgroundColor, diff --git a/lib/src/models/cool_alert_options.dart b/lib/src/models/cool_alert_options.dart index 94a82a3..7e0a2b2 100644 --- a/lib/src/models/cool_alert_options.dart +++ b/lib/src/models/cool_alert_options.dart @@ -16,7 +16,11 @@ class CoolAlertOptions { TextStyle? confirmBtnTextStyle; TextStyle? cancelBtnTextStyle; TextStyle? titleTextStyle; + TextAlign? titleTextAlign; + TextOverflow? titleOverflow; TextStyle? textTextStyle; + TextAlign? textTextAlign; + TextOverflow? textOverflow; bool? showCancelBtn; double? borderRadius; Color? backgroundColor; @@ -44,7 +48,11 @@ class CoolAlertOptions { this.confirmBtnTextStyle, this.cancelBtnTextStyle, this.titleTextStyle, + this.titleTextAlign, + this.titleOverflow, this.textTextStyle, + this.textTextAlign, + this.textOverflow, this.showCancelBtn, this.borderRadius, this.backgroundColor, diff --git a/lib/src/widgets/cool_alert_container.dart b/lib/src/widgets/cool_alert_container.dart index 8fec78c..459f08a 100644 --- a/lib/src/widgets/cool_alert_container.dart +++ b/lib/src/widgets/cool_alert_container.dart @@ -135,6 +135,8 @@ class CoolAlertContainer extends StatelessWidget { Theme.of(context).textTheme.titleLarge?.copyWith( fontWeight: FontWeight.bold, ), + textAlign: options.titleTextAlign, + overflow: options.titleOverflow, ), ); } @@ -152,8 +154,9 @@ class CoolAlertContainer extends StatelessWidget { } return Text( text ?? '', - textAlign: TextAlign.center, + textAlign: options.textTextAlign, style: options.textTextStyle, + overflow: options.textOverflow, ); } } From 96500b7fe7e3823482bd01cf99a2a5501009f876 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 15:22:31 +0200 Subject: [PATCH 09/46] doc: update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b08161..a899838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [2.1.0] - 04/03/2025 + +- Added TextAlign & Overflow options for title & text (or body). +- Updated README + ## [2.0.1] - 06/03/2023 - Updated README From 596c1f26a5aeee85c27f23ad5802322c6802fdb9 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Tue, 4 Mar 2025 15:24:55 +0200 Subject: [PATCH 10/46] doc: update README --- README.md | 55 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 905ce20..fc254d5 100644 --- a/README.md +++ b/README.md @@ -25,32 +25,35 @@ CoolAlert.show( ### CoolAlert Class - -| Attribute | Data type | Description | Default Value | -|:----------------------|:-------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------:| -| context| BuildContext | @required | Null | -| type | CoolAlertType | @required - Type of alert dialog, ex: CoolAlertType.success for success dialogs | Null -title| String | Set a custom title for dialog | Based on the CoolAlertType selected| | -| text| String | Set the description text of the dialog. | Null | -| widget| Widget | Set any you expect widget of the dialog. | Null | -| confirmBtnText | String | Text of confirm button | 'Ok' | | -| confirmBtnTap| Function | Function that handle click of confirm button | () => Navigator.pop(context)| -| confirmBtnColor| Color | Color of confirm Button | Theme.of(context).primaryColor | | -| cancelBtnText| String | Text of cancel button | 'Cancel' | -| cancelBtnTap| Function | Function that handle click of cancel button | () => Navigator.pop(context) -| barrierDismissible| bool | Dismiss dialog on touch overlay | true -| animType | CoolAlertAnimType| Type of dialogue enter animation | CoolAlertAnimType.scale| -| backgroundColor | Color| Background color of the animation | Color(0xFF515C6F)| -| confirmBtnTextStyle | TextStyle | Confirm button text theme | TextStyle(color: Colors.white, fontWeight:FontWeight.w600,fontSize: 18.0)| -| cancelBtnTextStyle | TextStyle | Cancel button text theme | TextStyle(color: Colors.grey, fontWeight:FontWeight.w600,fontSize: 18.0)| -| flareAsset | String | Custom flare asset | "animation.flr" | -| flareAnimationName | String | The name of the flare animation to play | "play" | -| lottieAsset | String | Custom lottie asset | "animation.json" | -|autoCloseDuration|Duration|Determines how long the dialog stays open for before closing|Null| -|width|double|Dialog width|MediaQuery.of(context).size.width| -|loopAnimation|boolean|Determines if the animation should loop or not|false| -|closeOnConfirmBtnTap|boolean|Detemines if dialog closes when the confirm button is tapped|true| -|reverseBtnOrder|boolean|Reverse the order of the buttons|false| +| Attribute | Data type | Description | Default Value | +|:---------------------|:------------------|:--------------------------------------------------------------------------------|:-------------------------------------------------------------------------:| +| context | BuildContext | @required | Null | +| type | CoolAlertType | @required - Type of alert dialog, ex: CoolAlertType.success for success dialogs | Null + title | String | Set a custom title for dialog | Based on the CoolAlertType selected | | +| text | String | Set the description text of the dialog. | Null | +| widget | Widget | Set any you expect widget of the dialog. | Null | +| confirmBtnText | String | Text of confirm button | 'Ok' | | +| confirmBtnTap | Function | Function that handle click of confirm button | () => Navigator.pop(context) | +| confirmBtnColor | Color | Color of confirm Button | Theme.of(context).primaryColor | | +| cancelBtnText | String | Text of cancel button | 'Cancel' | +| cancelBtnTap | Function | Function that handle click of cancel button | () => Navigator.pop(context) +| barrierDismissible | bool | Dismiss dialog on touch overlay | true +| animType | CoolAlertAnimType | Type of dialogue enter animation | CoolAlertAnimType.scale | +| backgroundColor | Color | Background color of the animation | Color(0xFF515C6F) | +| confirmBtnTextStyle | TextStyle | Confirm button text theme | TextStyle(color: Colors.white, fontWeight:FontWeight.w600,fontSize: 18.0) | +| cancelBtnTextStyle | TextStyle | Cancel button text theme | TextStyle(color: Colors.grey, fontWeight:FontWeight.w600,fontSize: 18.0) | +| flareAsset | String | Custom flare asset | "animation.flr" | +| flareAnimationName | String | The name of the flare animation to play | "play" | +| lottieAsset | String | Custom lottie asset | "animation.json" | +| autoCloseDuration | Duration | Determines how long the dialog stays open for before closing | Null | +| width | double | Dialog width | MediaQuery.of(context).size.width | +| loopAnimation | boolean | Determines if the animation should loop or not | false | +| closeOnConfirmBtnTap | boolean | Detemines if dialog closes when the confirm button is tapped | true | +| reverseBtnOrder | boolean | Reverse the order of the buttons | false | +| titleTextAlign | TextAlign | Text alignment for title | TextAlign.center | +| titleOverflow | TextOverflow | Text overflow for title | Null | +| textTextAlign | TextAlign | Text alignment for text | TextAlign.center | +| textOverflow | TextOverflow | Text overflow for text | Null | From 6328c44a64bada4f40e4e4e6f2eb6c7306d77b16 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 10:11:50 +0200 Subject: [PATCH 11/46] ci: add firebase integration & deploy with gh actions on 'cooler_alerts' --- .firebaserc | 5 +++ .github/workflows/flutter-prod.yml | 71 ++++++++++++++++++++++++++++++ firebase.json | 10 +++++ 3 files changed, 86 insertions(+) create mode 100644 .firebaserc create mode 100644 .github/workflows/flutter-prod.yml create mode 100644 firebase.json diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..79b3a52 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "cooler-alerts" + } +} diff --git a/.github/workflows/flutter-prod.yml b/.github/workflows/flutter-prod.yml new file mode 100644 index 0000000..3b3ebea --- /dev/null +++ b/.github/workflows/flutter-prod.yml @@ -0,0 +1,71 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Flutter analyze, test & deploy example web app + +on: + push: + branches: [ "cooler_alerts" ] + + workflow_dispatch: + +jobs: + build_and_test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.22.0' + channel: 'stable' + cache: true + + - run: flutter --version + + - name: Install dependencies + run: flutter pub get + + - name: Analyze project source + run: flutter analyze + + - name: Run tests +# run: flutter test --coverage + run: echo "Ignoring tests for now." + + deploy-example-web: + runs-on: ubuntu-latest + needs: build_and_test + + steps: + - uses: actions/checkout@v4 + + - name: Setup Flutter build environment + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.22.0' + channel: 'stable' + cache: true + + - run: flutter config --enable-web + - run: cd ./example; flutter build web --release --target=lib/main.dart --output=build/web + + - name: Archive Production Artifact + uses: actions/upload-artifact@master + with: + name: web-build + path: example/build/web + + - name: Firebase Deploy + uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_COOLER_ALERTS }}' + channelId: live + projectId: cooler-alerts + diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..5d9ba4c --- /dev/null +++ b/firebase.json @@ -0,0 +1,10 @@ +{ + "hosting": { + "public": "example/build/web", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + } +} From 4c4e99d245192fabd2fefea91f2abd52933c3a68 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 10:15:44 +0200 Subject: [PATCH 12/46] ci: add gh issue & pr templates --- .github/ISSUE_TEMPLATE/BUG_REPORT.md | 24 +++++++++++ .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md | 40 +++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 1 + .../pull_request_template.md | 15 +++++++ 4 files changed, 80 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/BUG_REPORT.md create mode 100644 .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md new file mode 100644 index 0000000..94f11ee --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -0,0 +1,24 @@ +--- +name: '🐞 Bug Report' +about: Create a report +title: '' +labels: ['type:Bug', 'status:Unconfirmed'] +assignees: '' +--- + + + +### Issue Summary + + + +### Steps to Reproduce + +1. + +Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead? + diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md new file mode 100644 index 0000000..fc9e136 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md @@ -0,0 +1,40 @@ +--- +name: '🚀 Feature request' +about: Suggest an idea/concept/feature to enhance the project +title: '' +labels: 'type:Enhancement' +assignees: '' +--- + +### Is your proposal related to a problem? + + + +(Write your answer here.) + +### Describe the solution you'd like + + + +(Describe your proposed solution here.) + +### Describe alternatives you've considered + + + +(Write your answer here.) + +### Additional context + + + +(Write your answer here.) \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..a49eab2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..b6e09e7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,15 @@ +# Description + +Please include a summary of the change(s) and which issue(s) are to be fixed/addressed or feature(s) to be added. Please also include relevant motivation and context. List any dependencies that are required for this change. + + +## Type of change + +Please delete options that are not relevant. + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] This change requires a documentation update + +## Screenshots (if appropriate): \ No newline at end of file From 302f8dbbe59e48ad53a63f33a1b0a2406402a12f Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 10:15:48 +0200 Subject: [PATCH 13/46] feat: update package details cooler_alerts --- pubspec.yaml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index fa1e4c7..5406279 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,18 @@ -name: cool_alert -description: A Flutter package to display animated alert dialogs such as - success, error, warning, confirm or even a loading dialog. -version: 2.0.1 -homepage: https://github.com/emrade/flutter_cool_alert.git +name: cooler_alerts +description: A Flutter package to display animated alert dialogs, replacement for cool_alert. +version: 2.1.0 +#homepage: https://github.com/cybex-dev/flutter_cool_alert.git +repository: https://github.com/cybex-dev/flutter_cool_alert.git +issue_tracker: https://github.com/cybex-dev/flutter_cool_alert/issues +topics: + - flutter + - alert + - dialog + - notifications + - popup environment: - sdk: ">=2.18.0 <3.0.0" + sdk: ">=2.18.0 <4.0.0" dependencies: flare_flutter: ^3.0.2 From 01764cb1d67986c15b6fb02e1f0a2ff8186fb797 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 10:19:48 +0200 Subject: [PATCH 14/46] fix: example lib dependency references --- example/lib/main.dart | 2 +- example/pubspec.lock | 84 +++++++++++++++++++++++++++++-------------- example/pubspec.yaml | 2 +- 3 files changed, 60 insertions(+), 28 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 174925b..759cec4 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,4 +1,4 @@ -import 'package:cool_alert/cool_alert.dart'; +import 'package:cooler_alerts/cool_alert.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; diff --git a/example/pubspec.lock b/example/pubspec.lock index ca9e95d..0628717 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -13,10 +13,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -29,10 +29,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.18.0" convert: dependency: transitive description: @@ -57,13 +57,13 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" - cool_alert: + cooler_alerts: dependency: "direct main" description: path: ".." relative: true source: path - version: "2.0.1" + version: "2.1.0" crypto: dependency: transitive description: @@ -162,6 +162,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.5" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -182,34 +206,34 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.12.0" path: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.9.0" path_provider: dependency: transitive description: @@ -299,26 +323,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -339,10 +363,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.7.0" typed_data: dependency: transitive description: @@ -359,6 +383,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.dev" + source: hosted + version: "14.2.1" win32: dependency: transitive description: @@ -376,5 +408,5 @@ packages: source: hosted version: "1.0.0" sdks: - dart: ">=2.19.2 <3.0.0" - flutter: ">=3.3.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 19407f4..3f1208a 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: '>=2.19.2 <3.0.0' dependencies: - cool_alert: + cooler_alerts: path: ../ cupertino_icons: ^1.0.5 flutter: From a86e4f13ec809c6a341965c4261a1c5188094779 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 10:30:17 +0200 Subject: [PATCH 15/46] refactor: separate enums to constants --- lib/src/constants/enums.dart | 18 ++++++++++++++++++ lib/src/models/cool_alert_options.dart | 1 + lib/src/widgets/cool_alert_buttons.dart | 1 + lib/src/widgets/cool_alert_container.dart | 1 + 4 files changed, 21 insertions(+) create mode 100644 lib/src/constants/enums.dart diff --git a/lib/src/constants/enums.dart b/lib/src/constants/enums.dart new file mode 100644 index 0000000..4126845 --- /dev/null +++ b/lib/src/constants/enums.dart @@ -0,0 +1,18 @@ +enum CoolAlertType { + success, + error, + warning, + confirm, + info, + loading, + custom, +} + +enum CoolAlertAnimType { + scale, + rotate, + slideInDown, + slideInUp, + slideInLeft, + slideInRight, +} diff --git a/lib/src/models/cool_alert_options.dart b/lib/src/models/cool_alert_options.dart index ada23ea..d7699b4 100644 --- a/lib/src/models/cool_alert_options.dart +++ b/lib/src/models/cool_alert_options.dart @@ -1,5 +1,6 @@ import 'package:cool_alert/cool_alert.dart'; import 'package:flutter/widgets.dart'; +import '../constants/enums.dart'; class CoolAlertOptions { String? title; diff --git a/lib/src/widgets/cool_alert_buttons.dart b/lib/src/widgets/cool_alert_buttons.dart index 967cdda..b96a204 100644 --- a/lib/src/widgets/cool_alert_buttons.dart +++ b/lib/src/widgets/cool_alert_buttons.dart @@ -1,6 +1,7 @@ import 'package:cool_alert/cool_alert.dart'; import 'package:cool_alert/src/models/cool_alert_options.dart'; import 'package:flutter/material.dart'; +import '../constants/enums.dart'; class CoolAlertButtons extends StatelessWidget { final CoolAlertOptions options; diff --git a/lib/src/widgets/cool_alert_container.dart b/lib/src/widgets/cool_alert_container.dart index 459f08a..465e591 100644 --- a/lib/src/widgets/cool_alert_container.dart +++ b/lib/src/widgets/cool_alert_container.dart @@ -6,6 +6,7 @@ import 'package:cool_alert/src/widgets/cool_alert_buttons.dart'; import 'package:flare_flutter/flare_actor.dart'; import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; +import '../constants/enums.dart'; class CoolAlertContainer extends StatelessWidget { final CoolAlertOptions options; From 25f381afc0a4c827a7fdef9f13b9d74cbfd423b7 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 10:30:39 +0200 Subject: [PATCH 16/46] refactor: rename lib `cool_alert` to `cooler_alerts` --- README.md | 2 +- example/lib/main.dart | 22 +++--- lib/{cool_alert.dart => cooler_alerts.dart} | 16 +---- lib/src/models/cool_alert_options.dart | 2 +- lib/src/widgets/cool_alert_buttons.dart | 10 ++- lib/src/widgets/cool_alert_container.dart | 23 +++--- pubspec.lock | 80 ++++++++++++++------- 7 files changed, 84 insertions(+), 71 deletions(-) rename lib/{cool_alert.dart => cooler_alerts.dart} (96%) diff --git a/README.md b/README.md index ad00054..6060294 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ cool_alert: ^2.0.1 And add this import to your dart file. ```dart -import 'package:cool_alert/cool_alert.dart'; +import 'package:cooler_alerts/cooler_alerts.dart'; ``` ## Image diff --git a/example/lib/main.dart b/example/lib/main.dart index 759cec4..9f3d7b5 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,4 +1,4 @@ -import 'package:cooler_alerts/cool_alert.dart'; +import 'package:cooler_alerts/cooler_alerts.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -34,7 +34,7 @@ class _MyHomePageState extends State { Widget build(BuildContext context) { final successAlert = _buildButton( onTap: () { - CoolAlert.show( + CoolerAlerts.show( context: context, type: CoolAlertType.success, text: 'Transaction completed successfully!', @@ -47,7 +47,7 @@ class _MyHomePageState extends State { final errorAlert = _buildButton( onTap: () { - CoolAlert.show( + CoolerAlerts.show( context: context, type: CoolAlertType.error, title: 'Oops...', @@ -61,7 +61,7 @@ class _MyHomePageState extends State { final warningAlert = _buildButton( onTap: () { - CoolAlert.show( + CoolerAlerts.show( context: context, type: CoolAlertType.warning, text: 'You just broke protocol', @@ -73,7 +73,7 @@ class _MyHomePageState extends State { final infoAlert = _buildButton( onTap: () { - CoolAlert.show( + CoolerAlerts.show( context: context, type: CoolAlertType.info, text: 'Buy two, get one free', @@ -94,7 +94,7 @@ class _MyHomePageState extends State { final confirmAlert = _buildButton( onTap: () { - CoolAlert.show( + CoolerAlerts.show( context: context, type: CoolAlertType.confirm, text: 'Do you want to logout', @@ -109,7 +109,7 @@ class _MyHomePageState extends State { final loadingAlert = _buildButton( onTap: () { - CoolAlert.show( + CoolerAlerts.show( context: context, type: CoolAlertType.loading, ); @@ -121,7 +121,7 @@ class _MyHomePageState extends State { final customAlert = _buildButton( onTap: () { var message = ''; - CoolAlert.show( + CoolerAlerts.show( context: context, type: CoolAlertType.custom, barrierDismissible: true, @@ -140,7 +140,7 @@ class _MyHomePageState extends State { closeOnConfirmBtnTap: false, onConfirmBtnTap: (_) async { if (message.length < 5) { - await CoolAlert.show( + await CoolerAlerts.show( context: context, type: CoolAlertType.error, text: 'Please enter at least 5 characters', @@ -150,7 +150,7 @@ class _MyHomePageState extends State { } Navigator.of(context).pop(); await Future.delayed(const Duration(milliseconds: 500), () async { - await CoolAlert.show( + await CoolerAlerts.show( context: context, type: CoolAlertType.success, text: "Phone number '$message' has been saved!.", @@ -165,7 +165,7 @@ class _MyHomePageState extends State { final unpoppableAlert = _buildButton( onTap: () { - CoolAlert.show( + CoolerAlerts.show( context: context, type: CoolAlertType.custom, text: 'You cannot pop this alert except with Navigator(root) pop', diff --git a/lib/cool_alert.dart b/lib/cooler_alerts.dart similarity index 96% rename from lib/cool_alert.dart rename to lib/cooler_alerts.dart index c66170d..e5ea562 100644 --- a/lib/cool_alert.dart +++ b/lib/cooler_alerts.dart @@ -1,26 +1,16 @@ -library cool_alert; - import 'dart:async'; import 'package:flutter/material.dart'; +import 'src/constants/enums.dart'; import 'src/models/cool_alert_options.dart'; import 'src/utils/animate.dart'; import 'src/widgets/cool_alert_container.dart'; -enum CoolAlertType { success, error, warning, confirm, info, loading, custom } - -enum CoolAlertAnimType { - scale, - rotate, - slideInDown, - slideInUp, - slideInLeft, - slideInRight, -} +export 'src/constants/enums.dart'; /// CoolAlert. -class CoolAlert { +class CoolerAlerts { static Future show({ /// BuildContext required BuildContext context, diff --git a/lib/src/models/cool_alert_options.dart b/lib/src/models/cool_alert_options.dart index d7699b4..30ab7e1 100644 --- a/lib/src/models/cool_alert_options.dart +++ b/lib/src/models/cool_alert_options.dart @@ -1,5 +1,5 @@ -import 'package:cool_alert/cool_alert.dart'; import 'package:flutter/widgets.dart'; + import '../constants/enums.dart'; class CoolAlertOptions { diff --git a/lib/src/widgets/cool_alert_buttons.dart b/lib/src/widgets/cool_alert_buttons.dart index b96a204..85fc37b 100644 --- a/lib/src/widgets/cool_alert_buttons.dart +++ b/lib/src/widgets/cool_alert_buttons.dart @@ -1,7 +1,7 @@ -import 'package:cool_alert/cool_alert.dart'; -import 'package:cool_alert/src/models/cool_alert_options.dart'; import 'package:flutter/material.dart'; + import '../constants/enums.dart'; +import '../models/cool_alert_options.dart'; class CoolAlertButtons extends StatelessWidget { final CoolAlertOptions options; @@ -31,8 +31,7 @@ class CoolAlertButtons extends StatelessWidget { } Widget _okayBtn(context) { - final showCancelBtn = - options.type == CoolAlertType.confirm ? true : options.showCancelBtn!; + final showCancelBtn = options.type == CoolAlertType.confirm ? true : options.showCancelBtn!; final okayBtn = _buildButton( context: context, @@ -59,8 +58,7 @@ class CoolAlertButtons extends StatelessWidget { } Widget _cancelBtn(context) { - final showCancelBtn = - options.type == CoolAlertType.confirm ? true : options.showCancelBtn!; + final showCancelBtn = options.type == CoolAlertType.confirm ? true : options.showCancelBtn!; final cancelBtn = _buildButton( context: context, diff --git a/lib/src/widgets/cool_alert_container.dart b/lib/src/widgets/cool_alert_container.dart index 465e591..6eb3de9 100644 --- a/lib/src/widgets/cool_alert_container.dart +++ b/lib/src/widgets/cool_alert_container.dart @@ -1,12 +1,12 @@ -import 'package:cool_alert/cool_alert.dart'; -import 'package:cool_alert/src/constants/images.dart'; -import 'package:cool_alert/src/models/cool_alert_options.dart'; -import 'package:cool_alert/src/utils/single_loop_controller.dart'; -import 'package:cool_alert/src/widgets/cool_alert_buttons.dart'; import 'package:flare_flutter/flare_actor.dart'; import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; + import '../constants/enums.dart'; +import '../constants/images.dart'; +import '../models/cool_alert_options.dart'; +import '../utils/single_loop_controller.dart'; +import 'cool_alert_buttons.dart'; class CoolAlertContainer extends StatelessWidget { final CoolAlertOptions options; @@ -95,17 +95,10 @@ class CoolAlertContainer extends StatelessWidget { child: options.lottieAsset == null ? FlareActor( anim, - animation: - options.loopAnimation ? options.flareAnimationName : null, - controller: options.loopAnimation - ? null - : SingleLoopController( - options.flareAnimationName!, - 1, - ), + animation: options.loopAnimation ? options.flareAnimationName : null, + controller: options.loopAnimation ? null : SingleLoopController(options.flareAnimationName!, 1), ) - : Lottie.asset(options.lottieAsset!, - repeat: options.loopAnimation), + : Lottie.asset(options.lottieAsset!, repeat: options.loopAnimation), ), ); } diff --git a/pubspec.lock b/pubspec.lock index c58a00e..5a5009c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -13,10 +13,10 @@ packages: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" boolean_selector: dependency: transitive description: @@ -29,10 +29,10 @@ packages: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.18.0" convert: dependency: transitive description: @@ -107,6 +107,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.5" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + url: "https://pub.dev" + source: hosted + version: "10.0.4" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + url: "https://pub.dev" + source: hosted + version: "3.0.3" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" + url: "https://pub.dev" + source: hosted + version: "3.0.1" lints: dependency: transitive description: @@ -127,34 +151,34 @@ packages: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.12.0" path: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.9.0" pointycastle: dependency: transitive description: @@ -172,26 +196,26 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -212,10 +236,10 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.7.0" typed_data: dependency: transitive description: @@ -232,6 +256,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + url: "https://pub.dev" + source: hosted + version: "14.2.1" sdks: - dart: ">=2.18.0 <3.0.0" - flutter: ">=3.3.0" + dart: ">=3.3.0 <4.0.0" + flutter: ">=3.18.0-18.0.pre.54" From d1752288707bfe25f168874942418c85a0b05fe9 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 10:32:47 +0200 Subject: [PATCH 17/46] feat(example): update web index.html with bootstrapping* See: https://docs.flutter.dev/platform-integration/web/initialization#the-_flutter-loader-load-api --- example/web/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/web/index.html b/example/web/index.html index be820e8..29daf5f 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -34,7 +34,7 @@ @@ -43,7 +43,7 @@ From 3a085af278553799d2668b44a33c6a8aa1b31035 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 21:43:34 +0200 Subject: [PATCH 38/46] ci: disable flutter version cache in gh action --- .github/workflows/flutter-prod.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/flutter-prod.yml b/.github/workflows/flutter-prod.yml index 23b7a8f..d5abb9d 100644 --- a/.github/workflows/flutter-prod.yml +++ b/.github/workflows/flutter-prod.yml @@ -24,7 +24,6 @@ jobs: with: flutter-version: '3.27.4' channel: 'stable' - cache: true - run: flutter --version From 00bb7ee87ffcba42d3b437a2f3d3ff7c4e5584dc Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Wed, 5 Mar 2025 21:48:38 +0200 Subject: [PATCH 39/46] fix: downgrade lottie from ^3.3.1 to ^3.3.0* Error: ``` The current Dart SDK version is 3.4.0. Because lottie 3.3.1 requires SDK version ^3.6.0 and no versions of lottie match >3.3.1 <4.0.0, lottie ^3.3.1 is forbidden. So, because cooler_alerts_example depends on cooler_alerts from path which depends on lottie ^3.3.1, version solving failed. ``` --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 82bb90c..fcc7a48 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: flutter: sdk: flutter cool_flare: ^3.1.0 - lottie: ^3.3.1 + lottie: ^3.3.0 vector_math: ^2.1.4 dev_dependencies: From 3eccef40cd595be27289e8564d5d60bb0adee929 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Thu, 6 Mar 2025 10:05:09 +0200 Subject: [PATCH 40/46] Revert "fix: downgrade lottie from ^3.3.1 to ^3.3.0*" This reverts commit 00bb7ee87ffcba42d3b437a2f3d3ff7c4e5584dc. --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index fcc7a48..82bb90c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ dependencies: flutter: sdk: flutter cool_flare: ^3.1.0 - lottie: ^3.3.0 + lottie: ^3.3.1 vector_math: ^2.1.4 dev_dependencies: From 102c2592f70f1ac44cc8d4ed92667ad477a749b7 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Thu, 6 Mar 2025 10:05:44 +0200 Subject: [PATCH 41/46] feat(example): update environment sdk to >=2.19.2 <4.0.0 --- example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 991c29e..3471da2 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,7 +4,7 @@ publish_to: 'none' version: 0.1.0 environment: - sdk: '>=2.19.2 <3.0.0' + sdk: '>=2.19.2 <4.0.0' dependencies: cooler_alerts: From d249fef65950220dff60c4aa34aeeff1a05a82ca Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Thu, 6 Mar 2025 10:16:55 +0200 Subject: [PATCH 42/46] ci: github action using dart 3.4.0 on flutter 3.27.4, disabling caching --- .github/workflows/flutter-prod.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/flutter-prod.yml b/.github/workflows/flutter-prod.yml index d5abb9d..bd33d10 100644 --- a/.github/workflows/flutter-prod.yml +++ b/.github/workflows/flutter-prod.yml @@ -24,8 +24,9 @@ jobs: with: flutter-version: '3.27.4' channel: 'stable' + cache: false - - run: flutter --version + - run: flutter doctor --version - name: Install dependencies run: flutter pub get From 36b13cac0e5dd8140fd4e69ad8048344938a1d22 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Thu, 6 Mar 2025 10:19:07 +0200 Subject: [PATCH 43/46] Revert "ci: github action using dart 3.4.0 on flutter 3.27.4, disabling caching" This reverts commit d249fef65950220dff60c4aa34aeeff1a05a82ca. --- .github/workflows/flutter-prod.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/flutter-prod.yml b/.github/workflows/flutter-prod.yml index bd33d10..d5abb9d 100644 --- a/.github/workflows/flutter-prod.yml +++ b/.github/workflows/flutter-prod.yml @@ -24,9 +24,8 @@ jobs: with: flutter-version: '3.27.4' channel: 'stable' - cache: false - - run: flutter doctor --version + - run: flutter --version - name: Install dependencies run: flutter pub get From 4b0e4e77edc7ea3157b1954082c5777f18afce9c Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Thu, 6 Mar 2025 10:22:07 +0200 Subject: [PATCH 44/46] ci: reenable flutter caching --- .github/workflows/flutter-prod.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/flutter-prod.yml b/.github/workflows/flutter-prod.yml index d5abb9d..23b7a8f 100644 --- a/.github/workflows/flutter-prod.yml +++ b/.github/workflows/flutter-prod.yml @@ -24,6 +24,7 @@ jobs: with: flutter-version: '3.27.4' channel: 'stable' + cache: true - run: flutter --version From c55c3284ca24d8fb91e6fcd248ce53ee558cc9d0 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Thu, 6 Mar 2025 10:22:13 +0200 Subject: [PATCH 45/46] ci: update flutter build version in gh deploy job --- .github/workflows/flutter-prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutter-prod.yml b/.github/workflows/flutter-prod.yml index 23b7a8f..a67cf07 100644 --- a/.github/workflows/flutter-prod.yml +++ b/.github/workflows/flutter-prod.yml @@ -48,7 +48,7 @@ jobs: - name: Setup Flutter build environment uses: subosito/flutter-action@v2 with: - flutter-version: '3.22.0' + flutter-version: '3.27.4' channel: 'stable' cache: true From 26dd8e52d43f9d6e175697a38cf336c1a62bd390 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Thu, 6 Mar 2025 11:24:10 +0200 Subject: [PATCH 46/46] ci: update gh deploy workflow --- .github/workflows/flutter-prod.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flutter-prod.yml b/.github/workflows/flutter-prod.yml index a67cf07..d7be4fe 100644 --- a/.github/workflows/flutter-prod.yml +++ b/.github/workflows/flutter-prod.yml @@ -11,6 +11,9 @@ on: workflow_dispatch: +env: + FLUTTER_VERSION: 3.27.4 + jobs: build_and_test: runs-on: ubuntu-latest @@ -22,7 +25,7 @@ jobs: - name: Install Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.27.4' + flutter-version: ${{ env.FLUTTER_VERSION }} channel: 'stable' cache: true @@ -48,7 +51,7 @@ jobs: - name: Setup Flutter build environment uses: subosito/flutter-action@v2 with: - flutter-version: '3.27.4' + flutter-version: ${{ env.FLUTTER_VERSION }} channel: 'stable' cache: true