Skip to content

Instantly share code, notes, and snippets.

@denis-ismailaj
denis-ismailaj / ellipsis.d2
Created February 22, 2024 20:42
Ellipsis style for D2
# Usage: "...": @ellipsis
style: {
fill: transparent
stroke: transparent
font-size: 46
}
@denis-ismailaj
denis-ismailaj / SwipeToDelete.kt
Last active May 20, 2024 01:01
SwipeToDelete is a boilerplate-free simple implementation of SwipeToDismiss for bidirectional delete gestures in Jetpack Compose.
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Delete
@denis-ismailaj
denis-ismailaj / OutlinedLabelledRadioButton.kt
Created May 20, 2021 08:11
Selectable outlined radio button
@Composable
fun OutlinedLabelledRadioButton(
selected: Boolean,
onClick: () -> Unit,
label: String,
modifier: Modifier = Modifier
) {
OutlinedButton(
onClick = onClick,
border = BorderStroke(
@Composable
fun LabelledRadioButton(
selected: Boolean,
onClick: () -> Unit,
label: String,
modifier: Modifier = Modifier
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
@denis-ismailaj
denis-ismailaj / WormPageIndicator.kt
Last active August 21, 2023 11:24
Animated worm page indicator composable for Jetpack Compose
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.CornerRadius
@denis-ismailaj
denis-ismailaj / LabelledCheckBox.kt
Last active August 25, 2024 15:45
LabelledCheckBox in Jetpack Compose
@Composable
fun LabelledCheckBox(
checked: Boolean,
onCheckedChange: ((Boolean) -> Unit),
label: String,
modifier: Modifier = Modifier
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = modifier