Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Quick View] Merging compose-latest to main #985

Merged
merged 43 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
40ad9dc
Merge pull request #919 from android/ben/merge_main_latest
bentrengrove Aug 5, 2022
c733b55
Upgrade to Compose 1.3
bentrengrove Aug 4, 2022
fbb1e66
Fix lint on JetNews
bentrengrove Aug 5, 2022
0f862df
Make reply work with upgrade script
bentrengrove Aug 5, 2022
f1ebfe3
Upgrade samples to compiler 1.3.0-rc02
bentrengrove Aug 8, 2022
12764b6
Merge pull request #918 from android/ben/1.3
JolandaVerhoef Aug 9, 2022
69f4ea7
Update compose-latest | Compose 1.3.0-alpha03 | Compiler 1.3.0 | Kotl…
JolandaVerhoef Aug 12, 2022
9302ed0
[compose-latest Crane] Bugfix for destinations not found in Crane (#939)
riggaroo Aug 15, 2022
dc6d23c
Merge branch 'main' into compose-latest
riggaroo Aug 23, 2022
58d8728
Main into Compose-latest (#965)
JolandaVerhoef Aug 24, 2022
d3aa517
[compose-latest] Update samples on compose-latest branch to Compose 1…
simona-anomis Aug 29, 2022
7a9fa37
[Jetsurvey] Converted to use Material 3 (#954) (#971)
IanGClifton Sep 2, 2022
c6812c6
Update to Compose 1.3.0-beta02 (#974)
bentrengrove Sep 10, 2022
172bd85
[All] Updated to Compose 1.3.0-beta03, AGP 7.3.0 (#979)
IanGClifton Sep 23, 2022
8ecabc5
main > compose-latest (#984)
JolandaVerhoef Sep 30, 2022
b83ce65
Ben/merge main into latest (#988)
bentrengrove Oct 3, 2022
4d17b11
Merge branch 'main' into ben/merge_main_into_latest2
bentrengrove Oct 5, 2022
f21dbbe
Merge main into latest (#991)
bentrengrove Oct 5, 2022
90145a6
[All] Update to 1.3.0-rc01-SNAP
astamato Sep 30, 2022
148b4d8
[All] Update to 1.3.0-rc01-SNAP
astamato Oct 5, 2022
734ab7f
[All] Update to 1.3.0-rc01-SNAP
astamato Oct 5, 2022
7bf22ba
[All] Update to 1.3.0-rc01-SNAP - Compose compiler 1.3.2
astamato Oct 5, 2022
90ee320
[All] Update Accompanist to 0.26.5-rc
astamato Oct 6, 2022
fab8511
[All] Update to 1.3.0-rc01 (#983)
astamato Oct 6, 2022
c278506
Updating Material3 to RC01
florina-muntenescu Oct 7, 2022
67e1e32
[All] Update all to material3 and compose-materialWindow to rc01
astamato Oct 7, 2022
1079eaa
Fix snapshot script not working on unix runners
bentrengrove Oct 7, 2022
b20ef93
Fix snapshot script not working on unix runners (#994)
bentrengrove Oct 7, 2022
b94906f
[All] Update to collectAsStateWithLifecycle to latest alpha
astamato Oct 8, 2022
fd05483
[All] Update to collectAsStateWithLifecycle to latest alpha
astamato Oct 8, 2022
0a3ac4d
Updating Material3 to RC01 (#993)
florina-muntenescu Oct 8, 2022
0a38a42
Update Jetcaster/README.md with correct refdoc
astamato Oct 10, 2022
9dad1d8
[All] Update to collectAsStateWithLifecycle to latest alpha (#995)
astamato Oct 10, 2022
316b8c6
[Jetsurvey] Removed Slider workaround for M3 bug
IanGClifton Oct 11, 2022
e56a368
[Jetsurvey] Removed Slider workaround for M3 bug (#998)
IanGClifton Oct 11, 2022
07b0a26
Merge remote-tracking branch 'origin/main' into compose-latest
JolandaVerhoef Oct 20, 2022
9c8064e
[All] Update non-compose dependencies
JolandaVerhoef Oct 20, 2022
2389cf5
[All] Update Compose dependencies to Snapshot
JolandaVerhoef Oct 20, 2022
47f4777
[All] Update dependencies to use Compose BOM
JolandaVerhoef Oct 20, 2022
1933558
[All] Update dependencies to use Compose BOM
JolandaVerhoef Oct 20, 2022
d526aaa
Merge main into compose-latest (#1002)
JolandaVerhoef Oct 20, 2022
7484956
[All] Revert faulty Androidx window library version update
JolandaVerhoef Oct 24, 2022
7659a1d
Update Compose version (#1003)
JolandaVerhoef Oct 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[All] Update to collectAsStateWithLifecycle to latest alpha
  • Loading branch information
astamato committed Oct 8, 2022
commit b94906f4a2a85e22d6069728bb5426ca5e82a8d6
2 changes: 1 addition & 1 deletion Crane/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ androidx-benchmark = "1.1.0"
androidx-benchmark-junit4 = "1.1.0-beta04"
androidx-constraintlayout = "1.0.1"
androidx-corektx = "1.8.0"
androidx-lifecycle-compose = "2.5.1"
androidx-lifecycle-compose = "2.6.0-alpha02"
androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha
androidx-navigation = "2.5.1"
androidx-palette = "1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion JetNews/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ dependencies {
implementation(libs.androidx.lifecycle.viewmodel.savedstate)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.viewModelCompose)

implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.window)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.example.jetnews.ui.article.ArticleScreen
import com.example.jetnews.ui.home.HomeScreenType.ArticleDetails
import com.example.jetnews.ui.home.HomeScreenType.Feed
Expand All @@ -40,6 +41,7 @@ import com.example.jetnews.ui.home.HomeScreenType.FeedWithArticleDetails
* @param openDrawer (event) request opening the app drawer
* @param snackbarHostState (state) state for the [Scaffold] component on this screen
*/
@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun HomeRoute(
homeViewModel: HomeViewModel,
Expand All @@ -48,7 +50,7 @@ fun HomeRoute(
snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }
) {
// UiState of the HomeScreen
val uiState by homeViewModel.uiState.collectAsState()
val uiState by homeViewModel.uiState.collectAsStateWithLifecycle()

HomeRoute(
uiState = uiState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
Expand All @@ -69,6 +68,8 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.constrainHeight
import androidx.compose.ui.unit.constrainWidth
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.example.jetnews.R
import com.example.jetnews.data.Result
import com.example.jetnews.data.interests.InterestSection
Expand Down Expand Up @@ -166,15 +167,16 @@ fun InterestsScreen(
* Remembers the content for each tab on the Interests screen
* gathering application data from [InterestsViewModel]
*/
@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun rememberTabContent(interestsViewModel: InterestsViewModel): List<TabContent> {
// UiState of the InterestsScreen
val uiState by interestsViewModel.uiState.collectAsState()
val uiState by interestsViewModel.uiState.collectAsStateWithLifecycle()

// Describe the screen sections here since each section needs 2 states and 1 event.
// Pass them to the stateless InterestsScreen using a tabContent.
val topicsSection = TabContent(Sections.Topics) {
val selectedTopics by interestsViewModel.selectedTopics.collectAsState()
val selectedTopics by interestsViewModel.selectedTopics.collectAsStateWithLifecycle()
TabWithSections(
sections = uiState.topics,
selectedTopics = selectedTopics,
Expand All @@ -183,7 +185,7 @@ fun rememberTabContent(interestsViewModel: InterestsViewModel): List<TabContent>
}

val peopleSection = TabContent(Sections.People) {
val selectedPeople by interestsViewModel.selectedPeople.collectAsState()
val selectedPeople by interestsViewModel.selectedPeople.collectAsStateWithLifecycle()
TabWithTopics(
topics = uiState.people,
selectedTopics = selectedPeople,
Expand All @@ -192,7 +194,8 @@ fun rememberTabContent(interestsViewModel: InterestsViewModel): List<TabContent>
}

val publicationSection = TabContent(Sections.Publications) {
val selectedPublications by interestsViewModel.selectedPublications.collectAsState()
val selectedPublications by interestsViewModel.selectedPublications
.collectAsStateWithLifecycle()
TabWithTopics(
topics = uiState.publications,
selectedTopics = selectedPublications,
Expand Down
2 changes: 1 addition & 1 deletion JetNews/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ androidx-benchmark = "1.1.0"
androidx-benchmark-junit4 = "1.1.0-beta04"
androidx-constraintlayout = "1.0.1"
androidx-corektx = "1.8.0"
androidx-lifecycle-compose = "2.5.1"
androidx-lifecycle-compose = "2.6.0-alpha02"
androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha
androidx-navigation = "2.5.1"
androidx-palette = "1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions Jetcaster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ Using the example of the home screen in the [`com.example.jetcaster.ui.home`](ap

- The ViewModel is implemented as [`HomeViewModel`][homevm], which exposes a `StateFlow<HomeViewState>` for the UI to observe.
- [`HomeViewState`][homevm] contains the complete view state for the home screen as an [`@Immutable`](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Immutable) `data class`.
- The Home Compose UI in [`Home.kt`][homeui] uses [`HomeViewModel`][homevm], and observes it's [`HomeViewState`][homevm] as Compose [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State), using [`collectAsState()`](https://developer.android.com/reference/kotlin/androidx/compose/package-summary#collectasstate):
- The Home Compose UI in [`Home.kt`][homeui] uses [`HomeViewModel`][homevm], and observes it's [`HomeViewState`][homevm] as Compose [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State), using [`collectAsStateWithLifecycle()`](https://developer.android.com/reference/kotlin/androidx/compose/package-summary#collectasstate):

``` kotlin
val viewModel: HomeViewModel = viewModel()
val viewState by viewModel.state.collectAsState()
val viewState by viewModel.state.collectAsStateWithLifecycle()
```

This pattern is used across the different screens:
Expand Down
1 change: 1 addition & 0 deletions Jetcaster/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ dependencies {

implementation(libs.androidx.lifecycle.runtime)
implementation(libs.androidx.lifecycle.viewModelCompose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.navigation.compose)

implementation(libs.androidx.window)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import androidx.compose.material.icons.filled.Search
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -68,6 +67,8 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import coil.compose.AsyncImage
import com.example.jetcaster.R
Expand All @@ -90,12 +91,13 @@ import java.time.Duration
import java.time.LocalDateTime
import java.time.OffsetDateTime

@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun Home(
navigateToPlayer: (String) -> Unit,
viewModel: HomeViewModel = viewModel()
) {
val viewState by viewModel.state.collectAsState()
val viewState by viewModel.state.collectAsStateWithLifecycle()
Surface(Modifier.fillMaxSize()) {
HomeContent(
featuredPodcasts = viewState.featuredPodcasts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import androidx.compose.material.icons.rounded.PlayCircleFilled
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand All @@ -68,6 +67,8 @@ import androidx.compose.ui.unit.dp
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.constraintlayout.compose.Dimension.Companion.fillToConstraints
import androidx.constraintlayout.compose.Dimension.Companion.preferredWrapContent
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import coil.compose.AsyncImage
import coil.request.ImageRequest
Expand All @@ -85,6 +86,7 @@ import com.example.jetcaster.util.viewModelProviderFactoryOf
import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle

@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun PodcastCategory(
categoryId: Long,
Expand All @@ -101,7 +103,7 @@ fun PodcastCategory(
factory = viewModelProviderFactoryOf { PodcastCategoryViewModel(categoryId) }
)

val viewState by viewModel.state.collectAsState()
val viewState by viewModel.state.collectAsStateWithLifecycle()

/**
* TODO: reset scroll position when category changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ import androidx.compose.material.Tab
import androidx.compose.material.TabPosition
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.jetcaster.data.Category
import com.example.jetcaster.ui.home.category.PodcastCategory
import com.example.jetcaster.ui.theme.Keyline1

@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun Discover(
navigateToPlayer: (String) -> Unit,
modifier: Modifier = Modifier
) {
val viewModel: DiscoverViewModel = viewModel()
val viewState by viewModel.state.collectAsState()
val viewState by viewModel.state.collectAsStateWithLifecycle()

val selectedCategory = viewState.selectedCategory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import androidx.compose.material.icons.rounded.PlayCircleFilled
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -77,6 +76,8 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.window.layout.FoldingFeature
import coil.compose.AsyncImage
import coil.request.ImageRequest
Expand All @@ -94,14 +95,15 @@ import kotlinx.coroutines.flow.StateFlow
/**
* Stateful version of the Podcast player
*/
@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun PlayerScreen(
viewModel: PlayerViewModel,
devicePosture: StateFlow<DevicePosture>,
onBackPress: () -> Unit
) {
val uiState = viewModel.uiState
val devicePostureValue by devicePosture.collectAsState()
val devicePostureValue by devicePosture.collectAsStateWithLifecycle()
PlayerScreen(uiState, devicePostureValue, onBackPress)
}

Expand Down
2 changes: 1 addition & 1 deletion Jetcaster/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ androidx-benchmark = "1.1.0"
androidx-benchmark-junit4 = "1.1.0-beta04"
androidx-constraintlayout = "1.0.1"
androidx-corektx = "1.8.0"
androidx-lifecycle-compose = "2.5.1"
androidx-lifecycle-compose = "2.6.0-alpha02"
androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha
androidx-navigation = "2.5.1"
androidx-palette = "1.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private val initialMessages = listOf(
),
Message(
"Taylor Brooks",
"@aliconors Take a look at the `Flow.collectAsState()` APIs",
"@aliconors Take a look at the `Flow.collectAsStateWithLifecycle()` APIs",
"8:05 PM"
),
Message(
Expand Down
2 changes: 1 addition & 1 deletion Jetchat/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ androidx-benchmark = "1.1.0"
androidx-benchmark-junit4 = "1.1.0-beta04"
androidx-constraintlayout = "1.0.1"
androidx-corektx = "1.8.0"
androidx-lifecycle-compose = "2.5.1"
androidx-lifecycle-compose = "2.6.0-alpha02"
androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha
androidx-navigation = "2.5.1"
androidx-palette = "1.0.0"
Expand Down
1 change: 1 addition & 0 deletions Jetsnack/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.viewModelCompose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.constraintlayout.compose)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.DeleteForever
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand All @@ -70,6 +69,8 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.constraintlayout.compose.ChainStyle
import androidx.constraintlayout.compose.ConstraintLayout
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.jetsnack.R
import com.example.jetsnack.model.OrderLine
Expand All @@ -86,13 +87,14 @@ import com.example.jetsnack.ui.theme.AlphaNearOpaque
import com.example.jetsnack.ui.theme.JetsnackTheme
import com.example.jetsnack.ui.utils.formatPrice

@OptIn(ExperimentalLifecycleComposeApi::class)
@Composable
fun Cart(
onSnackClick: (Long) -> Unit,
modifier: Modifier = Modifier,
viewModel: CartViewModel = viewModel(factory = CartViewModel.provideFactory())
) {
val orderLines by viewModel.orderLines.collectAsState()
val orderLines by viewModel.orderLines.collectAsStateWithLifecycle()
val inspiredByCart = remember { SnackRepo.getInspiredByCart() }
Cart(
orderLines = orderLines,
Expand Down
2 changes: 1 addition & 1 deletion Jetsnack/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ androidx-benchmark = "1.1.0"
androidx-benchmark-junit4 = "1.1.0-beta04"
androidx-constraintlayout = "1.0.1"
androidx-corektx = "1.8.0"
androidx-lifecycle-compose = "2.5.1"
androidx-lifecycle-compose = "2.6.0-alpha02"
androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha
androidx-navigation = "2.5.1"
androidx-palette = "1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion Jetsurvey/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ androidx-benchmark = "1.1.0"
androidx-benchmark-junit4 = "1.1.0-beta04"
androidx-constraintlayout = "1.0.1"
androidx-corektx = "1.8.0"
androidx-lifecycle-compose = "2.5.1"
androidx-lifecycle-compose = "2.6.0-alpha02"
androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha
androidx-navigation = "2.5.1"
androidx-palette = "1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion Owl/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ androidx-benchmark = "1.1.0"
androidx-benchmark-junit4 = "1.1.0-beta04"
androidx-constraintlayout = "1.0.1"
androidx-corektx = "1.8.0"
androidx-lifecycle-compose = "2.5.1"
androidx-lifecycle-compose = "2.6.0-alpha02"
androidx-lifecycle-runtime-compose = "2.6.0-alpha02" # merge with above when not alpha
androidx-navigation = "2.5.1"
androidx-palette = "1.0.0"
Expand Down
1 change: 1 addition & 0 deletions Reply/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ dependencies {

implementation(libs.androidx.lifecycle.runtime)
implementation(libs.androidx.lifecycle.viewModelCompose)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.navigation.compose)

implementation(libs.androidx.activity.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSiz
import androidx.compose.material3.windowsizeclass.WindowSizeClass
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import androidx.window.layout.FoldingFeature
Expand All @@ -46,7 +47,7 @@ class MainActivity : ComponentActivity() {

private val viewModel: ReplyHomeViewModel by viewModels()

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class, ExperimentalLifecycleComposeApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand Down Expand Up @@ -79,8 +80,8 @@ class MainActivity : ComponentActivity() {
setContent {
ReplyTheme {
val windowSize = calculateWindowSizeClass(this)
val devicePosture by devicePostureFlow.collectAsState()
val uiState by viewModel.uiState.collectAsState()
val devicePosture by devicePostureFlow.collectAsStateWithLifecycle()
val uiState by viewModel.uiState.collectAsStateWithLifecycle()

ReplyApp(
windowSize = windowSize,
Expand Down
Loading