feat: add enableSwipe parameter for gesture-based selection (#71)#104
Open
Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Open
feat: add enableSwipe parameter for gesture-based selection (#71)#104Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds optional swipe gestures to ToggleSwitch so users can change the selected index via horizontal/vertical swipes when enableSwipe is enabled (default off), addressing issue #71.
Changes:
- Introduces
enableSwipeparameter and wraps the switch layout with aGestureDetectorto handle swipe gestures. - Adds
_handleSwipeto advance/retreat selection based on swipe direction. - Adds example usage and widget tests for basic swipe behavior and the default-disabled behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| lib/toggle_switch.dart | Adds enableSwipe API and swipe gesture handling via GestureDetector + _handleSwipe. |
| test/toggle_switch_test.dart | Adds widget tests for swipe right/left when enabled and no effect when disabled. |
| example/lib/main.dart | Demonstrates enableSwipe: true usage in the example app. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…shi#71) ## Problem Users requested the ability to swipe between toggle options (issue PramodJoshi#71), especially useful for 2-option switches. ## Solution Added an `enableSwipe` parameter (default: `false`). When enabled, a swipe right/down advances selection by one step and swipe left/up retreats selection by one step. Swipes beyond the first or last switch are ignored. ## Changes - lib/toggle_switch.dart: added `enableSwipe` field, constructor param, and `_handleSwipe` method; wrapped RowToColumn in GestureDetector - test/toggle_switch_test.dart: three new tests covering swipe right, swipe left, and swipe disabled (default) Fixes PramodJoshi#71
b699325 to
dc75deb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Users requested the ability to swipe between toggle options (issue #71), especially useful for 2-option switches.
Solution
Added an
enableSwipeparameter (default:false). When enabled, a swipe right/down advances selection by one step and swipe left/up retreats selection by one step. Swipes beyond the first or last switch are ignored.Changes
enableSwipefield, constructor param, and_handleSwipemethod; wrapped RowToColumn in GestureDetectorFixes #71