Add swipe to dismiss functionality and duration control #8
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.
Add Swipe-to-Dismiss and Duration Control Features
This PR introduces swipe-to-dismiss functionality and enhanced duration control for AirySnackbar, making it more interactive and customizable.
Key Features
1. Swipe-to-Dismiss Implementation
Added
SwipeConfig
data class to manage swipe behavior with configurable parameters:dismissThreshold
: Determines how far the user needs to swipe (default: 30% of width)animationDuration
: Controls dismiss/reset animation speed (default: 200ms)minAlpha
andmaxAlpha
: Controls opacity during swipe (0.8 to 1.0)swipeDirection
: Supports LEFT_ONLY, RIGHT_ONLY, or BOTH directionsalphaProgressFactor
: Controls opacity change rate during swipeImplemented
SwipeDismissTouchListener
with:2. Duration Control Enhancement
DurationAttribute
sealed class with multiple duration options:Indefinite
: Snackbar stays visible until dismissedShort
: Uses Material's LENGTH_SHORTLong
: Uses Material's LENGTH_LONG (new default)Custom
: Allows custom duration in millisecondstoDuration()
extension function for easy conversion to BaseTransientBottomBar duration values3. Integration and Usage
SwipeAttribute
sealed class for easy configuration:Enable
: Activates swipe with customizable parametersDisable
: Turns off swipe functionalityAirySnackbar
to handle swipe configuration and duration settingsSampleUsageActivity
demonstrating:Example Usage
Impact
Testing
@akndmr Please review the implementation, particularly the swipe threshold and animation parameters. Let me know if you'd like any adjustments to the default values or additional configuration options.