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 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() | |
) { |
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
// 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
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
// Simply put the Demo composable in a Compose tree and observe the logs | |
// Focus on how dependency changes affect the recomposition. | |
// How does Ambient work? | |
// When basic callbacks fire: onCommit, launchInComposition, onActive, remember | |
@Composable | |
fun Demo() { | |
var textCounter by mutableStateOf(0) | |
Column { |
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
/** | |
* - 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
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
ComposeTubeTheme { | |
var source by remember { | |
mutableStateOf( | |
"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" | |
) | |
} |
NewerOlder