Skip to content

Instantly share code, notes, and snippets.

@KlassenKonstantin
KlassenKonstantin / Sample.kt
Created May 7, 2024 08:13
animateItem not fading out
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
setContent {
TheTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
val items = remember {
mutableStateListOf(
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.animation.ExperimentalSharedTransitionApi
import androidx.compose.animation.SharedTransitionLayout
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
@KlassenKonstantin
KlassenKonstantin / ContainerTransformExample.kt
Created April 11, 2024 06:00 — forked from Rahkeen/ContainerTransformExample.kt
A really simple grid-to-full-screen transition using Shared Elements
data class ColorItemState(
val id: Int,
val color: Color,
val name: String,
)
val CoolColors = listOf(
ColorItemState(
id = 1,
color = Color(0xFFEF4444),
@KlassenKonstantin
KlassenKonstantin / SharedTrans.kt
Last active April 25, 2024 12:01
Popup shared transition test
private val products = listOf(
Product("🍎", "Apples"),
Product("🍪", "Cookies"),
Product("🍉", "Watermelon"),
Product("🫐", "Blueberries"),
Product("🍊", "Oranges"),
Product("🍑", "Peaches"),
Product("🥦", "Broccoli"),
)
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
ColorPickerTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
@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
@KlassenKonstantin
KlassenKonstantin / RubberBandSlider.kt
Created January 15, 2024 17:16
Rubber Band Slider Compose
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(savedInstanceState)
setContent {
RubberBandSliderTheme {
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
Box(contentAlignment = Alignment.Center) {
RubberBandSlider(modifier = Modifier
.height(200.dp)
@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
@KlassenKonstantin
KlassenKonstantin / TextTransition.kt
Created October 1, 2023 17:42
Cascading Text Transition
@Composable
fun TextTransition(textAndColor: Pair<String, Color>) {
AnimatedContent(
targetState = textAndColor,
transitionSpec = {
fadeIn() togetherWith fadeOut()
}
) { (text, color) ->
Row {
text.forEachIndexed { index, char ->
@KlassenKonstantin
KlassenKonstantin / RoundedCornerSurface.kt
Created August 9, 2023 15:21
Keep inner radii appealing
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
InnerRadiusTheme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) {
Column(
verticalArrangement = Arrangement.Center
) {