Guowei

1 minute read

When I was very young, like in primary school, I got a cassette of anime songs, I was so shocked and immediately fallen in love with. It’s a collection of songs from Macross 7. To this day, I have never watched that anime, but the songs are so touching I have to post it here. I found this amazing live concert that contains all the familiar melodies:

Guowei Lv

1 minute read

I’m starting a new series, mostly just me taking notes while I go through the PointFree videos. The pipe operator The |> operator is defined as: precedencegroup ForwardApplication { associativity: left } infix operator |>: ForwardApplication func |> <A, B>(x: A, f: (A) -> B) -> B { return f(x) } It can be used as:: func incr(_ x: Int) -> Int { return x + 1 } func square(_ x: Int) -> Int { return x * x } 2 |> incr |> square Function composition operator This operator is defined as: precedencegroup ForwardComposition { higherThan: ForwardApplication associativity: left } infix operator >>>: ForwardComposition func >>> <A, B, C>(_ f: @escaping (A) -> B, _ g: @escaping (B) -> C) -> ((A) -> C) { return { a in g(f(a)) } }

Bites of Compose 16

Animatable

Guowei Lv

1 minute read

In previous post we talked about how to do animation in Compose using animateXXXAsState() function. And also see that though easy to use, it has limited customization capabilities. Now, let’s take a look at a lower level(and more powerful) way: Animatable. @Composable fun AnimatableDemo() { val coroutineScope = rememberCoroutineScope() val anim = remember { Animatable(48.dp, Dp.VectorConverter) } Box( modifier = Modifier .size(anim.value) .background(Color.Green) .clickable { coroutineScope.launch { val current = anim.

Bites of Compose 15

animateXXXAsState()

Guowei Lv

2 minute read

Let’s take a look at the simplest way to implement animation in Compose, which is using animateXXXAsState() set of functions. Let’s say we want to increase the size of a Box by 10.dp every time we click on it. We already know how to do it without animation: @Preview @Composable fun AnimationDemo() { var target by remember { mutableStateOf(48.dp) } Box( modifier = Modifier .size(target) .background(Color.Green) .clickable { target += 10.