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
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 |
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
@OptIn(ExperimentalMaterialApi::class) | |
@Composable | |
fun PullToRefreshAnimation() { | |
val path = remember { | |
GitHubLogoPath.path.toPath() | |
} | |
val lines = remember { | |
path.asAndroidPath().flatten(error = 0.5f).toList() | |
} |
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
@Composable | |
fun TextTransition(textAndColor: Pair<String, Color>) { | |
AnimatedContent( | |
targetState = textAndColor, | |
transitionSpec = { | |
fadeIn() togetherWith fadeOut() | |
} | |
) { (text, color) -> | |
Row { | |
text.forEachIndexed { index, char -> |
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
val uiColor = MaterialTheme.colors.surface.toUIColor() | |
@OptIn(ExperimentalForeignApi::class) | |
fun Color.toUIColor(): UIColor { | |
val colorSpace = CGColorSpaceCreateDeviceRGB() | |
val components = nativeHeap.allocArray<DoubleVar>(4) | |
components[0] = red.toDouble() | |
components[1] = green.toDouble() | |
components[2] = blue.toDouble() | |
components[3] = alpha.toDouble() |
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
/* | |
* ---------------------------------------------------------------------------- | |
* "THE BEER-WARE LICENSE" (Revision 42): | |
* Sebastiano Poggi wrote this file. As long as you retain this notice you | |
* can do whatever you want with this stuff. If we meet some day, and you think | |
* this stuff is worth it, you can buy me a beer in return. Seb | |
* ---------------------------------------------------------------------------- | |
*/ | |
package dev.sebastiano.bundel |
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
/* Copyright 2023 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
import androidx.compose.foundation.ExperimentalFoundationApi | |
import androidx.compose.foundation.MarqueeSpacing | |
import androidx.compose.foundation.basicMarquee | |
import androidx.compose.foundation.layout.Box | |
import androidx.compose.foundation.layout.offset | |
import androidx.compose.foundation.layout.padding | |
import androidx.compose.foundation.layout.width |
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
/* Copyright 2022 Google LLC. | |
SPDX-License-Identifier: Apache-2.0 */ | |
@Composable | |
fun GraphicsLayerCompositingStrategyExample() { | |
Image(painter = painterResource(id = R.drawable.dog), | |
contentDescription = "Dog", | |
contentScale = ContentScale.Crop, | |
modifier = Modifier | |
.size(120.dp) | |
.aspectRatio(1f) |
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 de.apuri.boing | |
import android.os.Bundle | |
import androidx.activity.ComponentActivity | |
import androidx.activity.compose.setContent | |
import androidx.compose.animation.core.Animatable | |
import androidx.compose.animation.core.Spring | |
import androidx.compose.animation.core.spring | |
import androidx.compose.foundation.BorderStroke | |
import androidx.compose.foundation.gestures.awaitFirstDown |
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 org.json.JSONObject | |
import java.io.File | |
const val tinyPngApiKey = "<YOUR-API-KEY-GOES-HERE>" | |
val projectDir = File("<PATH-TOPROJECT-ROOT>") | |
val supportedExtensions = listOf("png", "jpg") | |
fun main() { | |
projectDir.walk().forEach { srcFile -> | |
if (supportedExtensions.contains(srcFile.extension)) { |
NewerOlder