Skip to content

Instantly share code, notes, and snippets.

View bitsbyumair's full-sized avatar
🙃

Umair Abdullah bitsbyumair

🙃
View GitHub Profile
@lighttigerXIV
lighttigerXIV / SwipeAction.kt
Last active September 7, 2024 09:31
Swipe to action component
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SwipeToDelete(
onDelete: () -> Unit
) {
var value by remember { mutableFloatStateOf(0f) }
val source = remember { MutableInteractionSource() }
val scale = remember { 12f }
val height = remember { (4 * scale).dp }
var initialDragValue: Float? by remember { mutableStateOf(null) } //To prevent accidental deletes and make sure the user actually swipes