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 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 | 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, ); } }