Skip to content

Instantly share code, notes, and snippets.

View pablichjenkov's full-sized avatar

pablichjenkov pablichjenkov

View GitHub Profile
@KlassenKonstantin
KlassenKonstantin / Pull2Refresh.kt
Created March 26, 2024 11:23
Fitbit style Pull 2 Refresh
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
P2RTheme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
CompositionLocalProvider(
LocalOverscrollConfiguration provides null // Disable overscroll otherwise it consumes the drag before we get the chance
@bmc08gt
bmc08gt / SegmentedControl.android.kt
Last active March 18, 2024 09:27
Compose Multiplatform Segmented Control
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
@bmc08gt
bmc08gt / Currency.kt
Last active November 2, 2023 18:14
All Global currencies in a nice easy use to enum
@Suppress("EnumEntryName")
@Serializable
enum class Currency(
val code: String,
val symbol: String,
) {
Australian_dollar("AUD", "$"),
Brazilian_real("BRL", "R$"),
Bulgarian_lev("BGN", "лв."),
Canadian_dollar("CAD", "$"),
@KlassenKonstantin
KlassenKonstantin / ListSections.kt
Last active November 25, 2023 22:25
List sections
@file:OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
package de.kuno.listsections
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.animation.core.animateRectAsState
import androidx.compose.foundation.ExperimentalFoundationApi
@StylianosGakis
StylianosGakis / Results as of 2023-10-07
Last active October 30, 2023 19:49
Get all contributors for all repos of a GitHub account
Number of contributors: 192
@erdevasconcellos
erdevasconcellos / DatePicker.kt
Created July 27, 2023 14:41
DatePicker for Compose Desktop
/*
Composable DatePicker for Compose Desktop and other platforms.
How to use:
var showDatePicker by remember { mutableStateOf(false) }
var selectedDate by remember { mutableStateOf(Date()) }
//implement here the logic to show datepicker and use de return value
if (showDatePicker) {
DatePicker(
@KlassenKonstantin
KlassenKonstantin / ClippedForeground.kt
Last active August 20, 2023 07:48
evervault.com inspired animation
import androidx.compose.foundation.layout.Box
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.BlendMode
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.nativeCanvas
@Composable
@Peanuuutz
Peanuuutz / GridScope.kt
Created April 7, 2023 14:22
Non-lazy Grid (Primitive)
package net.peanuuutz.compose.desktop
import androidx.compose.runtime.Immutable
import androidx.compose.ui.Modifier
@Immutable
interface GridScope {
fun Modifier.span(
span: GridSpanScope.() -> Int
): Modifier
@fvilarino
fvilarino / ticker_final.kt
Last active February 9, 2024 16:04
Ticker Final
private val TickerCycleMillis = 150
private object AlphabetMapper {
private val Alphabet = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789•".toList()
val size: Int = Alphabet.size
fun getLetterAt(index: Int): Char = Alphabet[index % size]
fun getIndexOf(letter: Char, offset: Int = 0): TickerIndex {
@oleksandrbalan
oleksandrbalan / GooeyEffect.kt
Created February 8, 2023 16:42
Gooey effect
import androidx.compose.animation.core.InfiniteRepeatableSpec
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier