diff --git a/android/feature/common/build.gradle.kts b/android/feature/common/build.gradle.kts index f6c2588b..712b68cb 100644 --- a/android/feature/common/build.gradle.kts +++ b/android/feature/common/build.gradle.kts @@ -18,6 +18,7 @@ dependencies { api(libs.androidx.compose.ui.tooling) api(libs.androidx.lifecycle.runtimeCompose) api(libs.androidx.lifecycle.viewmodelCompose) + api(libs.androidx.hilt.navigationCompose) implementation(libs.androidx.browser) // Image loading diff --git a/android/feature/content-viewer/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/contentviewer/ContentViewerScreen.kt b/android/feature/content-viewer/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/contentviewer/ContentViewerScreen.kt index 0fe9d1a5..f4752412 100644 --- a/android/feature/content-viewer/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/contentviewer/ContentViewerScreen.kt +++ b/android/feature/content-viewer/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/contentviewer/ContentViewerScreen.kt @@ -40,8 +40,8 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.viewmodel.compose.viewModel import androidx.tracing.trace import coil3.compose.AsyncImage import io.github.reactivecircus.kstreamlined.android.feature.common.openShareSheet @@ -68,7 +68,7 @@ public fun ContentViewerScreen( onNavigateUp: () -> Unit, modifier: Modifier = Modifier, ): Unit = trace("Screen:ContentViewer") { - val viewModel = viewModel() + val viewModel = hiltViewModel() val uiState by viewModel.uiState.collectAsStateWithLifecycle() val eventSink = viewModel.eventSink diff --git a/android/feature/home/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/home/HomeScreen.kt b/android/feature/home/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/home/HomeScreen.kt index efb1fd23..b1c69ded 100644 --- a/android/feature/home/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/home/HomeScreen.kt +++ b/android/feature/home/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/home/HomeScreen.kt @@ -39,8 +39,8 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.viewmodel.compose.viewModel import androidx.tracing.trace import coil3.compose.AsyncImage import io.github.reactivecircus.kstreamlined.android.feature.home.component.FeedFilterChip @@ -72,7 +72,7 @@ public fun HomeScreen( onViewItem: (FeedItem) -> Unit, modifier: Modifier = Modifier, ) { - val viewModel = viewModel() + val viewModel = hiltViewModel() val uiState by viewModel.uiState.collectAsStateWithLifecycle() val eventSink = viewModel.eventSink HomeScreen( diff --git a/android/feature/kotlin-weekly-issue/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/kotlinweeklyissue/KotlinWeeklyIssueScreen.kt b/android/feature/kotlin-weekly-issue/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/kotlinweeklyissue/KotlinWeeklyIssueScreen.kt index ee51e2e2..b7a7ad7d 100644 --- a/android/feature/kotlin-weekly-issue/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/kotlinweeklyissue/KotlinWeeklyIssueScreen.kt +++ b/android/feature/kotlin-weekly-issue/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/kotlinweeklyissue/KotlinWeeklyIssueScreen.kt @@ -39,8 +39,8 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex +import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.viewmodel.compose.viewModel import androidx.tracing.trace import coil3.compose.AsyncImage import io.github.reactivecircus.kstreamlined.android.feature.common.openCustomTab @@ -73,7 +73,7 @@ public fun KotlinWeeklyIssueScreen( onNavigateUp: () -> Unit, modifier: Modifier = Modifier, ): Unit = trace("Screen:KotlinWeeklyIssue") { - val viewModel = viewModel() + val viewModel = hiltViewModel() val uiState by viewModel.uiState.collectAsStateWithLifecycle() val eventSink = viewModel.eventSink diff --git a/android/feature/saved-for-later/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/savedforlater/SavedForLaterScreen.kt b/android/feature/saved-for-later/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/savedforlater/SavedForLaterScreen.kt index 7ae36ea2..8d20feb1 100644 --- a/android/feature/saved-for-later/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/savedforlater/SavedForLaterScreen.kt +++ b/android/feature/saved-for-later/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/savedforlater/SavedForLaterScreen.kt @@ -32,8 +32,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.viewmodel.compose.viewModel import coil3.compose.AsyncImage import io.github.reactivecircus.kstreamlined.android.foundation.commonui.feed.KotlinBlogCard import io.github.reactivecircus.kstreamlined.android.foundation.commonui.feed.KotlinWeeklyCard @@ -58,7 +58,7 @@ public fun SavedForLaterScreen( onViewItem: (FeedItem) -> Unit, modifier: Modifier = Modifier, ) { - val viewModel = viewModel() + val viewModel = hiltViewModel() val uiState by viewModel.uiState.collectAsStateWithLifecycle() val eventSink = viewModel.eventSink SavedForLaterScreen( diff --git a/android/feature/talking-kotlin-episode/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/talkingkotlinepisode/TalkingKotlinEpisodeScreen.kt b/android/feature/talking-kotlin-episode/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/talkingkotlinepisode/TalkingKotlinEpisodeScreen.kt index 719aff8f..4e450582 100644 --- a/android/feature/talking-kotlin-episode/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/talkingkotlinepisode/TalkingKotlinEpisodeScreen.kt +++ b/android/feature/talking-kotlin-episode/src/main/kotlin/io/github/reactivecircus/kstreamlined/android/feature/talkingkotlinepisode/TalkingKotlinEpisodeScreen.kt @@ -39,8 +39,8 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex +import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.lifecycle.viewmodel.compose.viewModel import androidx.tracing.trace import coil3.compose.AsyncImage import io.github.reactivecircus.kstreamlined.android.feature.common.openCustomTab @@ -74,7 +74,7 @@ public fun TalkingKotlinEpisodeScreen( onNavigateUp: () -> Unit, modifier: Modifier = Modifier, ): Unit = trace("Screen:TalkingKotlinEpisode") { - val viewModel = viewModel() + val viewModel = hiltViewModel() val uiState by viewModel.uiState.collectAsStateWithLifecycle() val eventSink = viewModel.eventSink diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 67d1c606..1e8c053a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -106,8 +106,9 @@ androidx-lifecycle-viewmodelCompose = { module = "androidx.lifecycle:lifecycle-v androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" } androidx-datastore = { module = "androidx.datastore:datastore", version.ref = "androidx-datastore" } androidx-work-runtime = { module = "androidx.work:work-runtime", version.ref = "androidx-work" } -androidx-hilt-work = { module = "androidx.hilt:hilt-work", version.ref = "androidx-hilt" } androidx-hilt-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "androidx-hilt" } +androidx-hilt-navigationCompose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "androidx-hilt" } +androidx-hilt-work = { module = "androidx.hilt:hilt-work", version.ref = "androidx-hilt" } androidx-browser = { module = "androidx.browser:browser", version.ref = "androidx-browser" } androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "androidx-media3" } androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version.ref = "androidx-profileinstaller" }