Skip to content

Commit b25b793

Browse files
rashi-simformSahil-Simform
authored andcommitted
fix!: 🐛 Fixed TitleAlign Issue
Added titleAlignment and descriptionAlignment parameters to align title and description within the tooltip widget Renamed parameters titleAlignment to titleTextAlign and descriptionAlignment to descriptionTextAlign
1 parent 52b6ca7 commit b25b793

File tree

4 files changed

+43
-15
lines changed

4 files changed

+43
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## [4.0.0]
1+
## [4.0.0] (unreleased)
2+
- [BREAKING] Fixed [#457](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/457) titleAlignment property does not work
23
- Feature ✨: Added Action widget for tooltip
34
- Feature [#475](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/475) - Add
45
feasibility to change margin of tooltip with `toolTipMargin`.

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ A Flutter package allows you to Showcase/Highlight your widgets step by step.
1111

1212
![The example app running in Android](https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_showcaseview/master/preview/showcaseview.gif)
1313

14+
## Migration guide for release 4.0.0
15+
Renamed parameters `titleAlignment` to `titleTextAlign` and `descriptionAlignment` to `descriptionTextAlign` to correspond it more with the TextAlign property
16+
1417
## Migration guide for release 3.0.0
1518
Removed builder widget from `ShowCaseWidget` and replaced it with builder function
1619

@@ -147,8 +150,10 @@ WidgetsBinding.instance.addPostFrameCallback((_) =>
147150
| width | double? | | Width of custom tooltip widget | ||
148151
| titleTextStyle | TextStyle? | | Text Style of title || |
149152
| descTextStyle | TextStyle? | | Text Style of description || |
150-
| titleAlignment | TextAlign | TextAlign.start | Alignment of title || |
151-
| descriptionAlignment | TextAlign | TextAlign.start | Alignment of description || |
153+
| titleTextAlign | TextAlign | TextAlign.start | Alignment of title text || |
154+
| descriptionTextAlign | TextAlign | TextAlign.start | Alignment of description text || |
155+
| titleAlignment | AlignmentGeometry | Alignment.center | Alignment of title || |
156+
| descriptionAlignment | AlignmentGeometry | Alignment.center | Alignment of description || |
152157
| targetShapeBorder | ShapeBorder | | If `targetBorderRadius` param is not provided then it applies shape border to target widget |||
153158
| targetBorderRadius | BorderRadius? | | Border radius of target widget |||
154159
| tooltipBorderRadius | BorderRadius? | BorderRadius.circular(8.0) | Border radius of tooltip || |

lib/src/showcase.dart

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ class Showcase extends StatefulWidget {
5151
/// Represents subject line of target widget
5252
final String? title;
5353

54-
/// Title alignment with in tooltip widget
54+
/// Title text alignment with in tooltip widget
5555
///
5656
/// Defaults to [TextAlign.start]
57-
final TextAlign titleAlignment;
57+
/// To understand how text is aligned, check [TextAlign]
58+
final TextAlign titleTextAlign;
5859

5960
/// Represents summary description of target widget
6061
final String? description;
@@ -177,10 +178,11 @@ class Showcase extends StatefulWidget {
177178
/// Default to [BorderRadius.circular(8)]
178179
final BorderRadius? tooltipBorderRadius;
179180

180-
/// Description alignment with in tooltip widget
181+
/// Description text alignment with in tooltip widget
181182
///
182183
/// Defaults to [TextAlign.start]
183-
final TextAlign descriptionAlignment;
184+
/// To understand how text is aligned, check [TextAlign]
185+
final TextAlign descriptionTextAlign;
184186

185187
/// if `disableDefaultTargetGestures` parameter is true
186188
/// onTargetClick, onTargetDoubleTap, onTargetLongPress and
@@ -255,6 +257,16 @@ class Showcase extends StatefulWidget {
255257
/// Defaults to 7.
256258
final double toolTipSlideEndDistance;
257259

260+
/// Title alignment within tooltip widget
261+
///
262+
/// Defaults to [Alignment.center]
263+
final AlignmentGeometry titleAlignment;
264+
265+
/// Description alignment within tooltip widget
266+
///
267+
/// Defaults to [Alignment.center]
268+
final AlignmentGeometry descriptionAlignment;
269+
258270
/// Defines the margin for the tooltip.
259271
/// Which is from 0 to [toolTipSlideEndDistance].
260272
///
@@ -342,8 +354,10 @@ class Showcase extends StatefulWidget {
342354
required this.description,
343355
required this.child,
344356
this.title,
345-
this.titleAlignment = TextAlign.start,
346-
this.descriptionAlignment = TextAlign.start,
357+
this.titleTextAlign = TextAlign.start,
358+
this.descriptionTextAlign = TextAlign.start,
359+
this.titleAlignment = Alignment.center,
360+
this.descriptionAlignment = Alignment.center,
347361
this.targetShapeBorder = const RoundedRectangleBorder(
348362
borderRadius: BorderRadius.all(Radius.circular(8)),
349363
),
@@ -488,8 +502,10 @@ class Showcase extends StatefulWidget {
488502
disableScaleAnimation = null,
489503
title = null,
490504
description = null,
491-
titleAlignment = TextAlign.start,
492-
descriptionAlignment = TextAlign.start,
505+
titleTextAlign = TextAlign.start,
506+
descriptionTextAlign = TextAlign.start,
507+
titleAlignment = Alignment.center,
508+
descriptionAlignment = Alignment.center,
493509
titleTextStyle = null,
494510
descTextStyle = null,
495511
tooltipBackgroundColor = Colors.white,
@@ -745,8 +761,10 @@ class _ShowcaseState extends State<Showcase> {
745761
offset: offset,
746762
screenSize: screenSize,
747763
title: widget.title,
748-
titleAlignment: widget.titleAlignment,
764+
titleTextAlign: widget.titleTextAlign,
749765
description: widget.description,
766+
descriptionTextAlign: widget.descriptionTextAlign,
767+
titleAlignment: widget.titleAlignment,
750768
descriptionAlignment: widget.descriptionAlignment,
751769
titleTextStyle: widget.titleTextStyle,
752770
descTextStyle: widget.descTextStyle,

lib/src/tooltip_widget.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ class ToolTipWidget extends StatefulWidget {
3636
final Offset? offset;
3737
final Size screenSize;
3838
final String? title;
39-
final TextAlign? titleAlignment;
39+
final TextAlign? titleTextAlign;
4040
final String? description;
41-
final TextAlign? descriptionAlignment;
41+
final TextAlign? descriptionTextAlign;
42+
final AlignmentGeometry titleAlignment;
43+
final AlignmentGeometry descriptionAlignment;
4244
final TextStyle? titleTextStyle;
4345
final TextStyle? descTextStyle;
4446
final Widget? container;
@@ -73,7 +75,7 @@ class ToolTipWidget extends StatefulWidget {
7375
required this.offset,
7476
required this.screenSize,
7577
required this.title,
76-
required this.titleAlignment,
78+
required this.titleTextAlign,
7779
required this.description,
7880
required this.titleTextStyle,
7981
required this.descTextStyle,
@@ -85,6 +87,8 @@ class ToolTipWidget extends StatefulWidget {
8587
required this.contentWidth,
8688
required this.onTooltipTap,
8789
required this.movingAnimationDuration,
90+
required this.descriptionTextAlign,
91+
required this.titleAlignment,
8892
required this.descriptionAlignment,
8993
this.tooltipPadding = const EdgeInsets.symmetric(vertical: 8),
9094
required this.disableMovingAnimation,

0 commit comments

Comments
 (0)