How saket/swipe works
Project Type & Purpose
• This is a Kotlin-based library project (with a sample Android module) that provides customizable swipe composables for Jetpack Compose. It differentiates itself from regular “swipe-to-dismiss” functionality by focusing on swipe actions that reveal options rather than dismiss a view.
• The README clearly shows code samples for creating SwipeAction objects and using a SwipeableActionsBox, indicating that the library’s primary purpose is to offer UI components and behavior for swipe interactions.
File Structure
• The project is organized into multiple modules:
• The “library” module contains the core of the swipe functionality. Under library/src/commonMain/kotlin, you see the primary source files (for example, SwipeAction.kt, SwipeableActionsBox.kt, etc.) that implement the composables.
• The “sample” module serves as an Android sample app. It demonstrates how the library can be incorporated into an actual application. The presence of AndroidManifest.xml and corresponding resource folders under sample/src/main confirms this.
• The “library/src/test” directory contains tests (and snapshot images) ensuring the correct functionality of the swipe components.
• Build and configuration files (like build.gradle.kts, gradle.properties, gradle wrapper files, etc.) show the project uses Gradle for building the modules.
Main Components
• Core Swipe Library: Represents the reusable composables:
• SwipeAction: Defines the properties of individual swipe actions.
• SwipeableActionsBox: The container composable that uses one or more SwipeAction objects.
• Supporting files (such as defaults.kt, horizontalDraggable.kt, etc.) that implement the internal logic.
• Test Suite: Unit tests and snapshot tests housed in library/src/test. These ensure the core functionality is robust.
• Sample Application: An Android application module demonstrating how to integrate and use the swipe library.
• Build System & Configuration: The build.gradle.kts and Gradle wrapper components that handle dependencies, compilation, and module integration.
Relationships and Interactions
• The Sample App module uses APIs from the Core Swipe Library to render swipeable actions in an Android context.
• The Test Suite is connected directly to the Core Swipe Library to validate behavior and catch regressions.
• The Gradle build scripts orchestrate the compilation, testing, and packaging of both the library and sample modules.
• External clients (developers integrating the library) depend on the published library artifact (e.g., via the dependency implementation "me.saket.swipe:swipe:1.3.0").
Architectural Patterns & Technologies
• Modular Design: The clear separation between the reusable library, sample application, and tests.
• API Encapsulation: The library exposes composable functions/components that can be integrated by external applications.
• Use of Kotlin and (implied) Jetpack Compose for UI design.
• Gradle for build automation.
• Android-specific components in the sample module (e.g., AndroidManifest.xml, resource files).