Skip to content

A highly customisable slide to trigger action view for Compose!

License

Notifications You must be signed in to change notification settings

lilstiffy/SlideView

Folders and files

NameName
Last commit message
Last commit date
Aug 21, 2024
Aug 22, 2024
Aug 21, 2024
Aug 21, 2024
Aug 22, 2024
Aug 21, 2024
Aug 22, 2024
Aug 21, 2024
Aug 21, 2024
Aug 21, 2024
Aug 21, 2024
Aug 21, 2024
Aug 21, 2024

Repository files navigation

SlideView

SlideView is a highly customizable UI component for Jetpack Compose that allows you to create slide-to-trigger actions in your Android apps. It's perfect for implementing features like slide-to-unlock or slide-to-confirm actions.

Demo

All support is greatly appreciated

https://buymeacoffee.com/lilstiffy

Features

  • Customizable: Easily modify the appearance and behavior.
  • Jetpack Compose: Built with modern Android UI toolkit.
  • Lightweight: Minimal dependencies for easy integration.

Installation

Add the following to your build.gradle.kts:

dependencies {
    implementation("com.lilstiffy:slideview:1.0.0")
}

Usage

Here's a basic example:

SlideView(
    onSlideComplete = { /* Your action here */ },
    modifier = Modifier.fillMaxWidth()
)

Here's how to customise the theming of the component:

SlideView(
    text = "Slide to confirm",
    onSlideDone = {
        Log.d("Fancy log", "Slide completed!")
    },
    config = SlideViewConfig().copy(backgroundColor = Color.Cyan, thumbColor = Color.Black),
    modifier = Modifier.padding(horizontal = 32.dp)
)

The theming is held within the SlideViewConfig object:

/**
 * Configuration for the colors of the SwipeView.
 *
 * @param backgroundColor The background color of the SwipeView.
 * @param thumbColor The color of the thumb icon.
 * @param iconColor The color of the icon.
 * @param textColor The color of the text.
 * @param thumbIcon The icon to be displayed on the thumb.
 * @param thumbIconDone The icon to be displayed on the thumb when the swipe is done.
 *
 * @author lilstiffy
 */
data class SlideViewConfig(
    val backgroundColor: Color = Color.Black,
    val thumbColor: Color = Color.White,
    val iconColor: Color = Color.Black,
    val textColor: Color = Color.White,

    val thumbIcon: ImageVector = Icons.AutoMirrored.Outlined.KeyboardArrowRight,
    val thumbIconDone:  ImageVector = Icons.Outlined.Check,
)

License

This project is licensed under the MIT License - see the LICENSE file for details.