Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add autoShow to showcase.dart #470

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/src/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ class Showcase extends StatefulWidget {
/// Defaults to 7.
final double toolTipSlideEndDistance;

/// if `autoShow` is true, showcase will be shown automatically
final bool autoShow;

/// Cross axis alignment for title and description.
final CrossAxisAlignment? titleDesCrossAxisAlignment;

const Showcase({
required this.key,
required this.description,
Expand Down Expand Up @@ -298,6 +304,8 @@ class Showcase extends StatefulWidget {
this.onBarrierClick,
this.disableBarrierInteraction = false,
this.toolTipSlideEndDistance = 7,
this.autoShow = false,
this.titleDesCrossAxisAlignment,
}) : height = null,
width = null,
container = null,
Expand Down Expand Up @@ -339,6 +347,8 @@ class Showcase extends StatefulWidget {
this.onBarrierClick,
this.disableBarrierInteraction = false,
this.toolTipSlideEndDistance = 7,
this.autoShow = false,
this.titleDesCrossAxisAlignment,
}) : showArrow = false,
onToolTipClick = null,
scaleAnimationDuration = const Duration(milliseconds: 300),
Expand Down Expand Up @@ -410,7 +420,7 @@ class _ShowcaseState extends State<Showcase> {
void showOverlay() {
final activeStep = ShowCaseWidget.activeTargetWidget(context);
setState(() {
_showShowCase = activeStep == widget.key;
_showShowCase = activeStep == widget.key || widget.autoShow;
});

if (activeStep == widget.key) {
Expand Down Expand Up @@ -632,6 +642,7 @@ class _ShowcaseState extends State<Showcase> {
titleTextDirection: widget.titleTextDirection,
descriptionTextDirection: widget.descriptionTextDirection,
toolTipSlideEndDistance: widget.toolTipSlideEndDistance,
titleDesCrossAxisAlignment: widget.titleDesCrossAxisAlignment,
),
],
],
Expand Down
10 changes: 7 additions & 3 deletions lib/src/tooltip_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ToolTipWidget extends StatefulWidget {
final TextDirection? titleTextDirection;
final TextDirection? descriptionTextDirection;
final double toolTipSlideEndDistance;
final CrossAxisAlignment? titleDesCrossAxisAlignment;

const ToolTipWidget({
super.key,
Expand Down Expand Up @@ -97,6 +98,7 @@ class ToolTipWidget extends StatefulWidget {
this.titleTextDirection,
this.descriptionTextDirection,
this.toolTipSlideEndDistance = 7,
this.titleDesCrossAxisAlignment,
});

@override
Expand Down Expand Up @@ -434,9 +436,11 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
padding: widget.tooltipPadding,
color: widget.tooltipBackgroundColor,
child: Column(
crossAxisAlignment: widget.title != null
? CrossAxisAlignment.start
: CrossAxisAlignment.center,
crossAxisAlignment:
widget.titleDesCrossAxisAlignment ??
(widget.title != null
? CrossAxisAlignment.start
: CrossAxisAlignment.center),
children: <Widget>[
if (widget.title != null)
Padding(
Expand Down
Loading