Skip to content

feat: shortcut to skip slide #154

@orestesgaolin

Description

@orestesgaolin

Description

Provide a way to define skip slide shorcut (SkipSlideIntent) and handle it with some default combination (e.g. meta + arrowRight)

Requirements

  • Pressing the combination navigates to the following slide without stepping

Additional Context

I have built a simple implementation for myself, happy to propose a PR if interested

diff --git a/packages/flutter_deck/lib/src/controls/actions/actions.dart b/packages/flutter_deck/lib/src/controls/actions/actions.dart
index 2098ef3..111637f 100644
--- a/packages/flutter_deck/lib/src/controls/actions/actions.dart
+++ b/packages/flutter_deck/lib/src/controls/actions/actions.dart
@@ -1,4 +1,5 @@
 export 'go_next_action.dart';
 export 'go_previous_action.dart';
+export 'skip_slide_action.dart';
 export 'toggle_drawer_action.dart';
-export 'toggle_marker_action.dart';
+export 'toggle_marker_action.dart';
\ No newline at end of file
diff --git a/packages/flutter_deck/lib/src/controls/flutter_deck_controls_configuration.dart b/packages/flutter_deck/lib/src/controls/flutter_deck_controls_configuration.dart
index b8a54b5..2a3f32b 100644
--- a/packages/flutter_deck/lib/src/controls/flutter_deck_controls_configuration.dart
+++ b/packages/flutter_deck/lib/src/controls/flutter_deck_controls_configuration.dart
@@ -88,6 +88,7 @@ class FlutterDeckShortcutsConfiguration {
     this.previousSlide = const SingleActivator(LogicalKeyboardKey.arrowLeft),
     this.toggleMarker = const SingleActivator(LogicalKeyboardKey.keyM),
     this.toggleNavigationDrawer = const SingleActivator(LogicalKeyboardKey.period),
+    this.skipSlide = const SingleActivator(LogicalKeyboardKey.arrowRight, meta: true),
   });
 
   /// Creates a configuration for the slide deck keyboard shortcuts where they
@@ -108,4 +109,7 @@ class FlutterDeckShortcutsConfiguration {
 
   /// The key combination to use for toggling the navigation drawer.
   final SingleActivator toggleNavigationDrawer;
+
+  /// The key combination to use for skipping the current slide.
+  final SingleActivator skipSlide;
 }
diff --git a/packages/flutter_deck/lib/src/controls/flutter_deck_controls_listener.dart b/packages/flutter_deck/lib/src/controls/flutter_deck_controls_listener.dart
index 2929a5a..4618a2d 100644
--- a/packages/flutter_deck/lib/src/controls/flutter_deck_controls_listener.dart
+++ b/packages/flutter_deck/lib/src/controls/flutter_deck_controls_listener.dart
@@ -104,6 +104,7 @@ class FlutterDeckControlsListener extends StatelessWidget {
       widget = Actions(
         actions: <Type, Action<Intent>>{
           GoNextIntent: GoNextAction(controlsNotifier),
+          SkipSlideIntent: SkipSlideAction(controlsNotifier),
           GoPreviousIntent: GoPreviousAction(controlsNotifier),
           ToggleDrawerIntent: ToggleDrawerAction(controlsNotifier),
           ToggleMarkerIntent: ToggleMarkerAction(controlsNotifier),
@@ -115,6 +116,7 @@ class FlutterDeckControlsListener extends StatelessWidget {
         widget = Shortcuts(
           shortcuts: <SingleActivator, Intent>{
             shortcuts.nextSlide: const GoNextIntent(),
+            shortcuts.skipSlide: const SkipSlideIntent(),
             shortcuts.previousSlide: const GoPreviousIntent(),
             shortcuts.toggleMarker: const ToggleMarkerIntent(),
             shortcuts.toggleNavigationDrawer: const ToggleDrawerIntent(),
diff --git a/packages/flutter_deck/lib/src/controls/flutter_deck_controls_notifier.dart b/packages/flutter_deck/lib/src/controls/flutter_deck_controls_notifier.dart
index f0cae52..cc71829 100644
--- a/packages/flutter_deck/lib/src/controls/flutter_deck_controls_notifier.dart
+++ b/packages/flutter_deck/lib/src/controls/flutter_deck_controls_notifier.dart
@@ -48,6 +48,16 @@ class FlutterDeckControlsNotifier with ChangeNotifier implements FlutterDeckFull
     notifyListeners();
   }
 
+  void skip() {
+    _autoplayNotifier.pause();
+    final currentIndex = _router.currentSlideIndex;
+    if (currentIndex < _router.slides.length - 1) {
+      _router.goToSlide(currentIndex + 2);
+    }
+
+    notifyListeners();
+  }
+
   /// Go to the previous slide.
   void previous() {
     _autoplayNotifier.pause();

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions