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
35 changes: 35 additions & 0 deletions .github/workflows/flutter_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Flutter Tests

on:
pull_request:

jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.10.0'
cache: true
cache-key: 'flutter-macos-stable-3.10.0-apple'
cache-path: '${{ runner.tool_cache }}/flutter/macos-stable-3.10.0-apple'
pub-cache-key: 'flutter-pub-macos-stable-3.10.0-apple'

- name: Get dependencies
run: flutter pub get

- name: Analyze project
run: flutter analyze

- name: Run tests
run: flutter test --coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage/lcov.info
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# ShowCaseView

[![Build](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/actions/workflows/flutter.yaml/badge.svg?branch=master)](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/actions) [![showcaseview](https://img.shields.io/pub/v/showcaseview?label=showcaseview)](https://pub.dev/packages/showcaseview)
[![showcaseview](https://img.shields.io/pub/v/showcaseview?label=showcaseview)](https://pub.dev/packages/showcaseview) [![Build](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/actions/workflows/flutter.yaml/badge.svg?branch=master)](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/actions) [![Tests](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/actions/workflows/flutter_tests.yaml/badge.svg?branch=master)](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/actions)

A Flutter package allows you to Showcase/Highlight your widgets.

Expand Down
19 changes: 16 additions & 3 deletions lib/src/showcase/showcase_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,16 @@ class ShowcaseView {
_onComplete().then(
(_) {
if (!_mounted) return;
// Update active widget ID before starting the next showcase
_activeWidgetId = id;

if (_activeWidgetId! >= _ids!.length) {
_cleanupAfterSteps();
onFinish?.call();
} else {
_onStart();
// Add a short delay before starting the next showcase to ensure proper state update
// Then start the new showcase
Future.microtask(_onStart);
}
},
);
Expand Down Expand Up @@ -402,6 +405,7 @@ class ShowcaseView {
Future<void> _onStart() async {
_activeWidgetId ??= 0;
if (_activeWidgetId! < _ids!.length) {
// Call onStart callback with current index and key
onStart?.call(_activeWidgetId, _ids![_activeWidgetId!]);
final controllers = _getCurrentActiveControllers;
final controllerLength = controllers.length;
Expand All @@ -414,18 +418,27 @@ class ShowcaseView {
if (controllerLength == 1 && isAutoScroll) {
await firstController?.scrollIntoView();
} else {
// Setup showcases after data is updated
for (var i = 0; i < controllerLength; i++) {
controllers[i].setupShowcase(shouldUpdateOverlay: i == 0);
}

// Make sure the overlay is updated to reflect new properties
OverlayManager.instance.update(show: isShowcaseRunning, scope: scope);
}
}

// Cancel any existing timer before setting up a new one

if (autoPlay) {
_cancelTimer();
// Showcase is first.
// Get the config from the current showcase if available
final config = _getCurrentActiveControllers.firstOrNull?.config;
final effectiveDelay = config?.autoPlayDelay ?? autoPlayDelay;

// Create a new timer with the effective delay
_timer = Timer(
config?.autoPlayDelay ?? autoPlayDelay,
effectiveDelay,
() => next(force: true),
);
}
Expand Down
19 changes: 19 additions & 0 deletions lib/src/tooltip/arrow_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@
*/
part of 'tooltip.dart';

class ShowcaseArrow extends StatelessWidget {
const ShowcaseArrow({
super.key,
required this.strokeColor,
});

final Color strokeColor;

@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _ArrowPainter(
strokeColor: strokeColor,
),
size: const Size(Constants.arrowWidth, Constants.arrowHeight),
);
}
}

class _ArrowPainter extends CustomPainter {
_ArrowPainter({
this.strokeColor = Colors.black,
Expand Down
30 changes: 6 additions & 24 deletions lib/src/tooltip/tooltip_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
: SystemMouseCursors.click,
child: GestureDetector(
onTap: widget.onTooltipTap,
child: Center(child: widget.container ?? const SizedBox.shrink()),
child: widget.container ?? const SizedBox.shrink(),
),
)
: MouseRegion(
Expand All @@ -183,7 +183,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
child: GestureDetector(
onTap: widget.onTooltipTap,
child: Container(
padding: widget.tooltipPadding.copyWith(left: 0, right: 0),
padding: widget.tooltipPadding,
decoration: BoxDecoration(
color: widget.tooltipBackgroundColor,
borderRadius: widget.tooltipBorderRadius ??
Expand All @@ -194,12 +194,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
children: <Widget>[
if (widget.title case final title?)
DefaultTooltipTextWidget(
padding: (widget.titlePadding ?? EdgeInsets.zero).add(
EdgeInsets.only(
left: widget.tooltipPadding.left,
right: widget.tooltipPadding.right,
),
),
padding: widget.titlePadding ?? EdgeInsets.zero,
text: title,
textAlign: widget.titleTextAlign,
alignment: widget.titleAlignment,
Expand All @@ -212,13 +207,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
),
if (widget.description case final desc?)
DefaultTooltipTextWidget(
padding:
(widget.descriptionPadding ?? EdgeInsets.zero).add(
EdgeInsets.only(
left: widget.tooltipPadding.left,
right: widget.tooltipPadding.right,
),
),
padding: widget.descriptionPadding ?? EdgeInsets.zero,
text: desc,
textAlign: widget.descriptionTextAlign,
alignment: widget.descriptionAlignment,
Expand All @@ -233,10 +222,6 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
widget.tooltipActionConfig.position.isInside)
ActionWidget(
tooltipActionConfig: widget.tooltipActionConfig,
outsidePadding: EdgeInsets.only(
left: widget.tooltipPadding.left,
right: widget.tooltipPadding.right,
),
alignment: widget.tooltipActionConfig.alignment,
crossAxisAlignment:
widget.tooltipActionConfig.crossAxisAlignment,
Expand Down Expand Up @@ -295,11 +280,8 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
if (widget.showArrow)
_TooltipLayoutId(
id: TooltipLayoutSlot.arrow,
child: CustomPaint(
painter: _ArrowPainter(
strokeColor: widget.tooltipBackgroundColor,
),
size: const Size(Constants.arrowWidth, Constants.arrowHeight),
child: ShowcaseArrow(
strokeColor: widget.tooltipBackgroundColor,
),
),
],
Expand Down
7 changes: 6 additions & 1 deletion lib/src/utils/overlay_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class OverlayManager {
ShowcaseService.instance.updateCurrentScope(scope);
}
_shouldShow = show;
_rebuild();
_sync();
}

Expand Down Expand Up @@ -131,6 +130,8 @@ class OverlayManager {
_hide();
} else if (!_isShowing && _shouldShow) {
_show(_getBuilder);
} else {
_rebuild();
}
}

Expand Down Expand Up @@ -177,6 +178,10 @@ class OverlayManager {
);

return Stack(
// This key is used to force rebuild the overlay when needed.
// this key enables `_overlayEntry?.markNeedsBuild();` to detect that
// output of the builder has changed.
key: ValueKey(firstShowcaseConfig.hashCode),
children: [
GestureDetector(
onTap: firstController.handleBarrierTap,
Expand Down
Loading