This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.textfieldtypinganimation | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.activity.enableEdgeToEdge | |
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.AnimationVector1D | |
import androidx.compose.animation.core.Spring | |
import androidx.compose.animation.core.spring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Bitmap | |
import android.graphics.Picture | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.runtime.Composable | |
import androidx.compose.runtime.getValue | |
import androidx.compose.runtime.mutableIntStateOf | |
import androidx.compose.runtime.setValue | |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.draw.drawWithCache | |
import androidx.compose.ui.graphics.Canvas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.ui.draw.drawWithCache | |
import androidx.compose.ui.geometry.CornerRadius | |
import androidx.compose.ui.geometry.Offset | |
import androidx.compose.ui.geometry.Rect | |
import androidx.compose.ui.geometry.Size | |
import androidx.compose.ui.graphics.BlendMode | |
import androidx.compose.ui.graphics.Brush | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.ColorFilter | |
import androidx.compose.ui.graphics.ImageBitmap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Download the varimoji font from https://crt-mate.github.io/varimoji/varimojiVF.woff2 | |
// Convert it to TTF and put that under res/font/ | |
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun VariableFontEmoji() { | |
var actv by remember { mutableFloatStateOf(50f) } | |
var vlnc by remember { mutableFloatStateOf(50f) } | |
Column( | |
modifier = Modifier.padding(32.dp), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* - Requires two frames | |
* - Need to hide BasicText from view | |
* - Unnecessary extra composition, way too hacky | |
* - Can do everything that a BasicText can do | |
* - Constraints must be applied to BasicText | |
*/ | |
@Composable | |
fun UsingBasicText() { | |
Box(Modifier.fillMaxSize()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Parent() { | |
Column { | |
var length by remember { mutableStateOf(1) } | |
val stringy by remember { derivedStateOf { { "a".repeat(length) } } } | |
ThingCounter(stringy) | |
Button(onClick = { length++ }) { | |
Text(text = "Change stringy") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configurations.all { | |
resolutionStrategy.eachDependency { DependencyResolveDetails details -> | |
if (details.requested.group.contains('org.jetbrains.compose')) { | |
def groupName = details.requested.group.replace("org.jetbrains.compose", "androidx.compose") | |
details.useTarget( | |
[group: groupName, name: details.requested.name, version: details.requested.version] | |
) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.compose.animation.ExperimentalAnimationApi | |
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.CubicBezierEasing | |
import androidx.compose.animation.core.animateFloatAsState | |
import androidx.compose.animation.core.tween | |
import androidx.compose.desktop.Window | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.layout.* | |
import androidx.compose.foundation.shape.CircleShape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun <T: Comparable<T>> SlideInOutLayout( | |
targetState: T, | |
modifier: Modifier = Modifier, | |
animationSpec: FiniteAnimationSpec<Float> = tween(), | |
content: @Composable (T) -> Unit | |
) { | |
val items = remember { mutableStateListOf<CrossSlideAnimationItem<T>>() } | |
val transitionState = remember { MutableTransitionState(targetState) } | |
val targetChanged = (targetState != transitionState.targetState) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun CalendarView( | |
modifier: Modifier = Modifier, | |
selectedDay: CalendarDay = CalendarDay.create(), | |
onSelectedDayChange: (CalendarDay) -> Unit = {}, | |
visibleMonth: CalendarDay = CalendarDay.create(), | |
onVisibleMonthChange: (CalendarDay) -> Unit = {}, | |
today: CalendarDay = CalendarDay.create(), | |
events: Set<CalendarDay> = emptySet() | |
) { |
NewerOlder