Skip to content

Instantly share code, notes, and snippets.

@inidamleader
inidamleader / InAppUpdater.kt
Last active December 5, 2024 12:52
In-app update composable function implementation
package com.inidamleader.ovtracker.util.compose.update
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.platform.LocalContext
@inidamleader
inidamleader / ListPicker.kt
Last active December 17, 2024 13:48
ListPicker: Generic compose picker (Number picker, date or any other type) function to select an item from a list by scrolling through the list with: possibility of editing and wrapSelectorWheel parameter
package com.inidamleader.ovtracker.util.compose
import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.snapping.rememberSnapFlingBehavior
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@inidamleader
inidamleader / UnorderedListText.kt
Last active September 10, 2024 20:18
UnorderedListText: Composable function that creates a bullet text with the given text
package com.inidamleader.ovtracker.util.compose
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
/**
* A custom slider composable that allows selecting a value within a given range.
*
* @param value The current value of the slider.
* @param onValueChange The callback invoked when the value of the slider changes.
* @param modifier The modifier to be applied to the slider.
* @param valueRange The range of values the slider can represent.
* @param gap The spacing between indicators on the slider.
* @param showIndicator Determines whether to show indicators on the slider.
* @param showLabel Determines whether to show a label above the slider.
@inidamleader
inidamleader / AutoSizeText.kt
Last active February 4, 2025 02:43
AutoSizeText: Composable function that automatically adjusts the text size to fit within given constraints with optimal performance by using a binary search algorithm
/*
MIT License
Copyright (c) 2024 Reda El Madini
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@dovahkiin98
dovahkiin98 / AutoSizeText.kt
Created October 4, 2021 09:03
AutoSize text implementation in Jetpack Compose
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.BoxWithConstraintsScope
import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.foundation.text.InternalFoundationTextApi
import androidx.compose.foundation.text.TextDelegate
import androidx.compose.material.LocalTextStyle
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@leshchenko
leshchenko / ColoredShadow.kt
Created September 30, 2021 15:19 — forked from cedrickring/ColoredShadow.kt
Draw a colored shadow in Android Jetpack Compose
import androidx.compose.ui.Modifier
import androidx.compose.ui.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Paint
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
fun Modifier.drawColoredShadow(
color: Color,