Thanks for all of your suggestions from utilizing the alphas to assist convey Compose for TV to the secure launch! It’s terrific that you simply’ve been utilizing Compose in your TV apps — then you definitely’ve seen how Compose is one of the simplest ways to construct consumer interfaces throughout all kind elements in Android and the way it simplifies and accelerates app growth with customization and styling via a contemporary, declarative syntax in Kotlin.
Maybe you’ve seen that we’ve shifted just a few issues round when Compose for TV graduated out of alpha. Learn on to discover ways to migrate your code with these adjustments.
Compose for TV consists of two AndroidX Jetpack libraries:
androidx.television.material3is now secure in model 1.0.0androidx.television.basisstays in alpha
Now that Compose for TV has graduated from alpha, we’ve promoted tv-material to secure 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.
Based mostly on developer suggestions, we’ve modified numerous APIs, which implies some issues have been renamed, moved, or eliminated utterly. Whereas the great record is documented within the library launch notes, listed below are the first adjustments that will help you migrate.
APIs which were renamed
NonInteractiveSurfaceDefaultsandNonInteractiveSurfaceColorshave been renamed toSurfaceDefaultsandSurfaceColors.StandardCardLayoutandWideCardLayouthave been renamed toStandardCardContainerandWideCardContainer.CardDefaults.ContainerGradienthas been renamed toCardDefaults.ScrimBrush.
APIs which have modified
ListItemparameters have been rearranged and renamed to require offeringheadlineContent.TvLazyRow,TvLazyColumn,TvLazyHorizontalGridandTvLazyVerticalGridhave 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 coursesTvLazyListStateandTvGridCellsalong with the strategiesrememberTvLazyListStateandrememberTvLazyGridStatehave additionally been changed with the Compose basis variations.
You may migrate by merely eradicating the tv-foundation dependency; yow will discover every little thing you want inandroidx.compose.basis.lazyby merely swapping all of your composables with the non-TV counterpart; for instance changingTvLazy*withLazy*andrememberTvLazy*StatewithrememberLazy*State.
APIs which were eliminated
CardContainerDefaults.ImageCardhas been eliminated; you need to use a Card and comprise a picture inside it as demonstrated in JetStream’s MovieCard.ListItemDefaults.ListItemShape,ListItemDefaults.FocusedDisabledBorder&ListItemDefaults.SelectedContainerColorOpacityat the moment are personal as they aren’t defaults for the ListItem composable.ImmersiveListhas been eliminated as a result of limitations within the selection within the knowledge sorts that signify content material. As a substitute, you may create an immersive record with just some traces of code (a whole snippet is out there within the immersive record pattern):
- With the migration of
TvLazy*toLazy*, scrollable containers now not help thepivotOffsetparameter. In case your utility makes use of pivot offsets, You’ll need to outline aBringIntoViewSpecobject implementing the pivot offset, and go it to Lazy* withLocalBringIntoViewSpec.
See thePositionFocusedItemInLazyLayoutsnippet for a generic resolution that permits specifying the offset ratio.
