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.runtime.MutableState | |
import androidx.compose.runtime.SnapshotMutationPolicy | |
import androidx.compose.runtime.structuralEqualityPolicy | |
/** | |
* Returns a [MutableState] object that only accepts writes that happen [debounceMillis] after the | |
* previously-accepted write. Writes that happen less than [debounceMillis] after a previous write | |
* are ignored. | |
* | |
* Write times are determined using [System.currentTimeMillis]. |
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
#!/bin/bash | |
# Tells an Android emulator to take a snapshot of itself and then | |
# delete that snapshot immediately. The act of taking a snapshot | |
# forces the emulator to temporarily pause and trigger unexpected | |
# system behaviors. When it happens during a test run, it can | |
# trigger certain hard-to-reproduce flakes. | |
SNAPSHOT=__TEMPORARY_SNAPSHOT | |
AUTH="$(cat ~/.emulator_console_auth_token)" | |
PORT=$1 |
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
@Preview(showBackground = true, showSystemUi = true) | |
@Composable | |
fun App() { | |
Column { | |
MarxistRow { | |
Text("Left Text", Modifier.background(Color.Red)) | |
Text("Right Text", Modifier.background(Color.Blue)) | |
} | |
MarxistRow { |
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.desktop.ui.tooling.preview.Preview | |
import androidx.compose.foundation.Canvas | |
import androidx.compose.foundation.layout.Column | |
import androidx.compose.foundation.layout.Row | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.material.Checkbox | |
import androidx.compose.material.MaterialTheme | |
import androidx.compose.material.Surface | |
import androidx.compose.material.Text | |
import androidx.compose.runtime.* |
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
// Paste this code into shaders.skia.org | |
float tileSize = 12; | |
float dotMinDiameter = 9; | |
vec2 maxRedShift = vec2(-2, 3); | |
vec2 maxGreenShift = vec2(2.5, 0); | |
vec2 maxBlueShift = vec2(1, -2); | |
half3 baseColor = half3(0, 0, 0); | |
half4 main(vec2 fragcoord) { |
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
fun Modifier.saturate(saturation: Float): Modifier = | |
drawWithCache { | |
// Cache the paint object so it can be reused between draw calls. | |
val contentPaint = Paint().apply { | |
colorFilter = ColorFilter.saturate(saturation) | |
} | |
onDrawWithContent { | |
drawIntoCanvas { | |
it.saveLayer(Rect(Offset.Zero, size), contentPaint) |
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 <C> ChipField( | |
chips: List<C>, | |
chipContent: @Composable (C) -> Unit. | |
modifier: Modifier = Modifier | |
) { | |
SelectionContainer( | |
allowCursor = true, | |
// some sort of callback or hoisted state for reading/mutating selection | |
modifier.textFieldFocusable() | |
) { |
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.core.Animatable | |
import androidx.compose.animation.core.Spring | |
import androidx.compose.animation.core.animateFloatAsState | |
import androidx.compose.animation.core.spring | |
import androidx.compose.foundation.background | |
import androidx.compose.foundation.gestures.detectDragGestures | |
import androidx.compose.foundation.layout.aspectRatio | |
import androidx.compose.foundation.layout.fillMaxSize | |
import androidx.compose.foundation.layout.wrapContentSize | |
import androidx.compose.integration.demos.BlockFilter.Companion.Lighting |
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
/** | |
* Fork of AppCompat ContextThemeWrapper (barely) to correctly support applying override | |
* configurations – all the features we don't need are dropped, it always extends the base context's | |
* theme, the theme can't be set explicitly, and it adds one critical piece of functionality: the new | |
* theme is [rebased][Theme.rebase] after being cloned from the base context's theme. | |
*/ | |
open class ContextConfigThemeWrapper( | |
base: Context, | |
private val overrideConfiguration: Configuration | |
) : ContextWrapper(base) { |
NewerOlder