Migrating Jetpack Compose for TV from alpha to steady | by Paul Lammertsma | Android Builders

Migrating Jetpack Compose for TV from alpha to steady | by Paul Lammertsma | Android Builders


Thanks for all of your suggestions from utilizing the alphas to assist deliver Compose for TV to the steady launch! It’s terrific that you just’ve been utilizing Compose in your TV apps — then you definately’ve seen how Compose is one of the simplest ways to construct person interfaces throughout all type components in Android and the way it simplifies and accelerates app improvement with customization and styling by means of a contemporary, declarative syntax in Kotlin.

Maybe you’ve observed that we’ve shifted a couple of issues round when Compose for TV graduated out of alpha. Learn on to learn to migrate your code with these adjustments.

Compose for TV consists of two AndroidX Jetpack libraries:

  • androidx.television.material3 is now steady in model 1.0.0
  • androidx.television.basis stays in alpha

Now that Compose for TV has graduated from alpha, we’ve promoted tv-material to steady and moved the scrollable containers in tv-foundation to the place they belong: in compose-foundation itself. The newest alpha model of the tv-foundation library merely marks these parts as deprecated. TvImeOptions continues to reside in tv-foundation.

The roadmap illustrates the history of both Compose for TV libraries starting in 2022. Parts of tv-foundation move to compose-foundation with only TvImeOptions remaining in 1.0.0-alpha. The tv-material library is shown to progress into beta in early 2024, then into RC, then stable as of today.
The Compose for TV roadmap

Based mostly on developer suggestions, we’ve modified numerous APIs, which implies some issues have been renamed, moved, or eliminated fully. Whereas the excellent listing is documented within the library launch notes, listed below are the first adjustments that will help you migrate.

APIs which have been renamed

  • NonInteractiveSurfaceDefaults and NonInteractiveSurfaceColors have been renamed to SurfaceDefaults and SurfaceColors.
  • StandardCardLayout and WideCardLayout have been renamed to StandardCardContainer and WideCardContainer.
  • CardDefaults.ContainerGradient has been renamed to CardDefaults.ScrimBrush.

APIs which have modified

  • ListItem parameters have been rearranged and renamed to require offering headlineContent.
  • TvLazyRow, TvLazyColumn, TvLazyHorizontalGrid and TvLazyVerticalGridhave been eliminated as a result of their performance has been integrated into the scrollable containers in compose-foundation model 1.7.0-beta02.
    The supporting courses TvLazyListState and TvGridCells along with the strategies rememberTvLazyListState and rememberTvLazyGridState have additionally been changed with the Compose basis variations.
    You may migrate by merely eradicating the tv-foundation dependency; you’ll find all the things you want in androidx.compose.basis.lazy by merely swapping all of your composables with the non-TV counterpart; for instance changing TvLazy* with Lazy* and rememberTvLazy*State with rememberLazy*State.

APIs which have been eliminated

  • CardContainerDefaults.ImageCard has been eliminated; you should utilize a Card and comprise a picture inside it as demonstrated in JetStream’s MovieCard.
  • ListItemDefaults.ListItemShape, ListItemDefaults.FocusedDisabledBorder & ListItemDefaults.SelectedContainerColorOpacity at the moment are personal as they aren’t defaults for the ListItem composable.
  • ImmersiveList has been eliminated because of the limitations within the selection within the knowledge sorts that symbolize content material. As a substitute, you’ll be able to create an immersive listing with just some strains of code (a whole snippet is accessible within the immersive listing pattern):
  • With the migration of TvLazy* to Lazy*, scrollable containers not help the pivotOffset parameter. In case your software makes use of pivot offsets, You’ll need to outline a BringIntoViewSpec object implementing the pivot offset, and move it to Lazy* with LocalBringIntoViewSpec.
    See the PositionFocusedItemInLazyLayout snippet for a generic answer that enables specifying the offset ratio.

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.