Skip to content

Commit

Permalink
🌟 add int state sample and refactor sample package
Browse files Browse the repository at this point in the history
  • Loading branch information
theapache64 committed Oct 21, 2021
1 parent 7553f3e commit b0f6b7c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
@@ -1,4 +1,4 @@
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.color
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty

import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.tween
Expand Down
@@ -1,4 +1,4 @@
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.dp
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty

import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.layout.size
Expand Down
@@ -1,4 +1,4 @@
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.floatt
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty

import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.animateFloatAsState
Expand Down
@@ -0,0 +1,21 @@
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty

import androidx.compose.animation.core.animateIntAsState
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.theapache64.composeanimationplayground.ui.composable.TeslaLogo

@Composable
fun AnimateIntAsStateDemo(
isActive: Boolean
) {
val targetInt = if (isActive) 50 else 100
val animatedInt by animateIntAsState(targetValue = targetInt)

TeslaLogo(
modifier = Modifier.size(animatedInt.dp)
)
}
@@ -1,4 +1,4 @@
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.offset
package com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty

import androidx.compose.animation.core.animateOffsetAsState
import androidx.compose.foundation.layout.offset
Expand Down
Expand Up @@ -8,21 +8,16 @@ import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.runtime.Composable
import com.theapache64.composeanimationplayground.model.AnimationItem
import com.theapache64.composeanimationplayground.ui.composable.AnimationItem
import com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.color.AnimateColorAsStateDemo
import com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.dp.AnimateDpAsStateDemo
import com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.floatt.AnimateFloatAsStateDemo
import com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.offset.AnimateOffsetAsStateDemo
import com.theapache64.composeanimationplayground.ui.screen.animation.animateproperty.rect.AnimateRectAsStateDemo

private val animations: List<AnimationItem> by lazy {
mutableListOf(

// TODO: Int, IntOffset, and IntSize, AnimateShape (Rectangle to Triangle)
AnimationItem(
title = "animateFloatAsState",
description = "animates the float value"
) { isActive ->
AnimateFloatAsStateDemo(isActive)
AnimateIntAsStateDemo(isActive)
},

AnimationItem(
Expand Down Expand Up @@ -59,6 +54,13 @@ private val animations: List<AnimationItem> by lazy {
) { isActive ->
AnimateRectAsStateDemo(isActive)
},
// TODO: IntOffset, and IntSize, AnimateShape (Rectangle to Triangle)
AnimationItem(
title = "animateIntAsState",
description = "animates the int value"
) { isActive ->
AnimateIntAsStateDemo(isActive)
}
)
}

Expand Down

0 comments on commit b0f6b7c

Please sign in to comment.