Skip to content

Commit 0e8294a

Browse files
committedFeb 1, 2021
[Jetcaster] Hide deprecation warnings for animations
1 parent b484d54 commit 0e8294a

File tree

9 files changed

+31
-23
lines changed

9 files changed

+31
-23
lines changed
 

‎Jetcaster/app/build.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ android {
8888
}
8989

9090
composeOptions {
91-
kotlinCompilerVersion Libs.Kotlin.version
9291
kotlinCompilerExtensionVersion Libs.AndroidX.Compose.version
9392
}
9493
}

‎Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/Home.kt

+1
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ private fun FollowedPodcastCarouselItem(
358358
if (podcastImageUrl != null) {
359359
CoilImage(
360360
data = podcastImageUrl,
361+
contentDescription = null,
361362
contentScale = ContentScale.Crop,
362363
loading = { /* TODO do something better here */ },
363364
modifier = Modifier

‎Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/category/PodcastCategory.kt

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ fun EpisodeListItem(
147147
// If we have an image Url, we can show it using [CoilImage]
148148
CoilImage(
149149
data = podcast.imageUrl,
150+
contentDescription = null,
150151
fadeIn = true,
151152
contentScale = ContentScale.Crop,
152153
loading = { /* TODO do something better here */ },
@@ -330,6 +331,7 @@ private fun TopPodcastRowItem(
330331
if (podcastImageUrl != null) {
331332
CoilImage(
332333
data = podcastImageUrl,
334+
contentDescription = null,
333335
fadeIn = true,
334336
contentScale = ContentScale.Crop,
335337
loading = { /* TODO do something better here */ },

‎Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/discover/Discover.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.example.jetcaster.ui.home.discover
1820

1921
import androidx.compose.animation.core.FloatPropKey
@@ -22,7 +24,6 @@ import androidx.compose.animation.core.LinearOutSlowInEasing
2224
import androidx.compose.animation.core.TransitionDefinition
2325
import androidx.compose.animation.core.transitionDefinition
2426
import androidx.compose.animation.core.tween
25-
import androidx.compose.animation.core.updateTransition
2627
import androidx.compose.foundation.layout.Column
2728
import androidx.compose.foundation.layout.Spacer
2829
import androidx.compose.foundation.layout.fillMaxSize
@@ -36,11 +37,11 @@ import androidx.compose.material.Tab
3637
import androidx.compose.material.TabPosition
3738
import androidx.compose.material.Text
3839
import androidx.compose.runtime.Composable
40+
import androidx.compose.runtime.DisposableEffect
3941
import androidx.compose.runtime.collectAsState
4042
import androidx.compose.runtime.emptyContent
4143
import androidx.compose.runtime.getValue
4244
import androidx.compose.runtime.mutableStateOf
43-
import androidx.compose.runtime.onCommit
4445
import androidx.compose.runtime.remember
4546
import androidx.compose.runtime.setValue
4647
import androidx.compose.ui.Modifier
@@ -111,9 +112,10 @@ fun Discover(
111112
)
112113
}
113114

114-
onCommit(selectedCategory) {
115+
DisposableEffect(selectedCategory) {
115116
// Update our tracking of the previously selected category
116117
previousSelectedCategory = selectedCategory
118+
onDispose {}
117119
}
118120
}
119121
} else {

‎Jetcaster/app/src/main/java/com/example/jetcaster/ui/theme/Type.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ package com.example.jetcaster.ui.theme
1818

1919
import androidx.compose.material.Typography
2020
import androidx.compose.ui.text.TextStyle
21+
import androidx.compose.ui.text.font.Font
22+
import androidx.compose.ui.text.font.FontFamily
2123
import androidx.compose.ui.text.font.FontWeight
22-
import androidx.compose.ui.text.font.font
23-
import androidx.compose.ui.text.font.fontFamily
2424
import androidx.compose.ui.unit.sp
2525
import com.example.jetcaster.R
2626

27-
private val Montserrat = fontFamily(
28-
font(R.font.montserrat_light, FontWeight.Light),
29-
font(R.font.montserrat_regular, FontWeight.Normal),
30-
font(R.font.montserrat_medium, FontWeight.Medium),
31-
font(R.font.montserrat_semibold, FontWeight.SemiBold)
27+
private val Montserrat = FontFamily(
28+
Font(R.font.montserrat_light, FontWeight.Light),
29+
Font(R.font.montserrat_regular, FontWeight.Normal),
30+
Font(R.font.montserrat_medium, FontWeight.Medium),
31+
Font(R.font.montserrat_semibold, FontWeight.SemiBold)
3232
)
3333

3434
val JetcasterTypography = Typography(

‎Jetcaster/app/src/main/java/com/example/jetcaster/util/Buttons.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package com.example.jetcaster.util
1818

19-
import androidx.compose.animation.animateAsState
20-
import androidx.compose.animation.core.animateAsState
19+
import androidx.compose.animation.animateColorAsState
20+
import androidx.compose.animation.core.animateDpAsState
2121
import androidx.compose.foundation.background
2222
import androidx.compose.foundation.layout.padding
2323
import androidx.compose.material.AmbientContentColor
@@ -56,19 +56,19 @@ fun ToggleFollowPodcastIconButton(
5656
isFollowed -> stringResource(R.string.cd_unfollow)
5757
else -> stringResource(R.string.cd_follow)
5858
},
59-
tint = animateAsState(
59+
tint = animateColorAsState(
6060
when {
6161
isFollowed -> AmbientContentColor.current
6262
else -> Color.Black.copy(alpha = ContentAlpha.high)
6363
}
6464
).value,
6565
modifier = Modifier
6666
.shadow(
67-
elevation = animateAsState(if (isFollowed) 0.dp else 1.dp).value,
67+
elevation = animateDpAsState(if (isFollowed) 0.dp else 1.dp).value,
6868
shape = MaterialTheme.shapes.small
6969
)
7070
.background(
71-
color = animateAsState(
71+
color = animateColorAsState(
7272
when {
7373
isFollowed -> MaterialTheme.colors.surface.copy(0.38f)
7474
else -> Color.White

‎Jetcaster/app/src/main/java/com/example/jetcaster/util/DynamicTheming.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package com.example.jetcaster.util
1818

1919
import android.content.Context
2020
import androidx.collection.LruCache
21-
import androidx.compose.animation.animateAsState
21+
import androidx.compose.animation.animateColorAsState
2222
import androidx.compose.animation.core.Spring
2323
import androidx.compose.animation.core.spring
2424
import androidx.compose.material.MaterialTheme
@@ -61,11 +61,11 @@ fun DynamicThemePrimaryColorsFromImage(
6161
content: @Composable () -> Unit
6262
) {
6363
val colors = MaterialTheme.colors.copy(
64-
primary = animateAsState(
64+
primary = animateColorAsState(
6565
dominantColorState.color,
6666
spring(stiffness = Spring.StiffnessLow)
6767
).value,
68-
onPrimary = animateAsState(
68+
onPrimary = animateColorAsState(
6969
dominantColorState.onColor,
7070
spring(stiffness = Spring.StiffnessLow)
7171
).value

‎Jetcaster/app/src/main/java/com/example/jetcaster/util/ItemSwitcher.kt

+7-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
@file:Suppress("DEPRECATION")
18+
1719
package com.example.jetcaster.util
1820

1921
import androidx.compose.animation.asDisposableClock
@@ -22,9 +24,9 @@ import androidx.compose.animation.core.TransitionState
2224
import androidx.compose.animation.core.createAnimation
2325
import androidx.compose.foundation.layout.Box
2426
import androidx.compose.runtime.Composable
27+
import androidx.compose.runtime.DisposableEffect
2528
import androidx.compose.runtime.invalidate
2629
import androidx.compose.runtime.key
27-
import androidx.compose.runtime.onCommit
2830
import androidx.compose.runtime.remember
2931
import androidx.compose.ui.Modifier
3032
import androidx.compose.ui.platform.AmbientAnimationClock
@@ -72,7 +74,7 @@ fun <T> ItemSwitcher(
7274
)
7375
}
7476

75-
onCommit(visible) {
77+
DisposableEffect(visible) {
7678
anim.onStateChangeFinished = { _ ->
7779
if (key == state.current) {
7880
// leave only the current in the list
@@ -87,6 +89,8 @@ fun <T> ItemSwitcher(
8789
else -> ItemTransitionState.BecomingNotVisible
8890
}
8991
anim.toState(targetState)
92+
93+
onDispose { }
9094
}
9195

9296
children(anim)
@@ -118,7 +122,7 @@ private class ItemTransitionInnerState<T> {
118122

119123
private data class ItemTransitionItem<T>(
120124
val key: T,
121-
val content: ItemTransitionContent
125+
@Suppress("TYPEALIAS_EXPANSION_DEPRECATION") val content: ItemTransitionContent
122126
)
123127

124128
private typealias ItemTransitionContent = @Composable (children: @Composable (TransitionState) -> Unit) -> Unit

‎Jetcaster/buildSrc/src/main/java/com/example/jetcaster/buildsrc/dependencies.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object Libs {
2929
const val material = "com.google.android.material:material:1.1.0"
3030

3131
object Accompanist {
32-
private const val version = "0.4.2"
32+
private const val version = "0.5.0"
3333
const val coil = "dev.chrisbanes.accompanist:accompanist-coil:$version"
3434
const val insets = "dev.chrisbanes.accompanist:accompanist-insets:$version"
3535
}

0 commit comments

Comments
 (0)