Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ ios/Runner.xcworkspace/xcshareddata/
example/ios/Flutter/flutter_export_environment.sh
flutter_showcaseview.iml
pubspec.lock

# FVM Version Cache
.fvm/
1 change: 1 addition & 0 deletions lib/showcaseview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ library showcaseview;
export 'src/models/action_button_icon.dart';
export 'src/models/tooltip_action_button.dart';
export 'src/models/tooltip_action_config.dart';
export 'src/models/showcase_changed_state.dart';
export 'src/showcase/showcase.dart';
export 'src/showcase/showcase_view.dart';
export 'src/showcase_widget.dart';
Expand Down
9 changes: 9 additions & 0 deletions lib/src/models/showcase_changed_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class ShowcaseChangedState {
final int index;
final int total;

const ShowcaseChangedState({
required this.index,
required this.total,
});
}
6 changes: 4 additions & 2 deletions lib/src/showcase/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class Showcase extends StatefulWidget {
/// ```
const Showcase.withWidget({
required GlobalKey key,
this.height,
this.width,
required this.container,
required this.child,
this.floatingActionWidget,
Expand Down Expand Up @@ -201,8 +203,8 @@ class Showcase extends StatefulWidget {
this.enableAutoScroll,
this.toolTipMargin = 14,
this.targetTooltipGap = 10,
}) : showArrow = false,
onToolTipClick = null,
this.showArrow = true,
}) : onToolTipClick = null,
scaleAnimationDuration = const Duration(milliseconds: 300),
scaleAnimationCurve = Curves.decelerate,
scaleAnimationAlignment = null,
Expand Down
18 changes: 18 additions & 0 deletions lib/src/showcase/showcase_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../../showcaseview.dart';
import '../models/tooltip_action_button.dart';
import '../models/tooltip_action_config.dart';
import '../utils/constants.dart';
Expand Down Expand Up @@ -211,6 +212,10 @@ class ShowcaseView {
<ShowcaseController>[];
}

final _onShowcaseChanged = ValueNotifier<ShowcaseChangedState>(
const ShowcaseChangedState(index: 0, total: 0),
);

/// Starts showcase with given widget ids after the optional delay.
///
/// * [widgetIds] - List of GlobalKeys for widgets to showcase
Expand Down Expand Up @@ -350,6 +355,10 @@ class ShowcaseView {
if (delay == Duration.zero) {
_ids = widgetIds;
_activeWidgetId = 0;
_onShowcaseChanged.value = ShowcaseChangedState(
total: widgetIds.length,
index: 0,
);
_onStart();
OverlayManager.instance.update(show: isShowcaseRunning, scope: scope);
} else {
Expand All @@ -376,6 +385,12 @@ class ShowcaseView {
// Update active widget ID before starting the next showcase
_activeWidgetId = id;

// Update value onShowcaseChanged
onShowcaseChanged.value = ShowcaseChangedState(
total: _ids?.length ?? 0,
index: id,
);

if (_activeWidgetId! >= _ids!.length) {
_cleanupAfterSteps();
onFinish?.call();
Expand Down Expand Up @@ -510,6 +525,9 @@ class ShowcaseView {
OverlayManager.instance.update(show: isShowcaseRunning, scope: scope);
}

ValueNotifier<ShowcaseChangedState> get onShowcaseChanged =>
_onShowcaseChanged;

@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/showcase/target_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class TargetWidget extends StatelessWidget {
top: offset.dy - targetPadding.top,
left: offset.dx - targetPadding.left,
child: disableDefaultChildGestures
? IgnorePointer(child: targetWidgetContent)
? AbsorbPointer(child: targetWidgetContent)
: MouseRegion(
cursor: SystemMouseCursors.click,
child: targetWidgetContent,
Expand Down
Loading