Skip to content

Commit

Permalink
hiltViewModel.
Browse files Browse the repository at this point in the history
  • Loading branch information
ychescale9 committed Sep 14, 2024
1 parent ac54964 commit 12ce9ea
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions android/feature/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,7 +68,7 @@ public fun ContentViewerScreen(
onNavigateUp: () -> Unit,
modifier: Modifier = Modifier,
): Unit = trace("Screen:ContentViewer") {
val viewModel = viewModel<ContentViewerViewModel>()
val viewModel = hiltViewModel<ContentViewerViewModel>()
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val eventSink = viewModel.eventSink

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,7 +72,7 @@ public fun HomeScreen(
onViewItem: (FeedItem) -> Unit,
modifier: Modifier = Modifier,
) {
val viewModel = viewModel<HomeViewModel>()
val viewModel = hiltViewModel<HomeViewModel>()
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val eventSink = viewModel.eventSink
HomeScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,7 +73,7 @@ public fun KotlinWeeklyIssueScreen(
onNavigateUp: () -> Unit,
modifier: Modifier = Modifier,
): Unit = trace("Screen:KotlinWeeklyIssue") {
val viewModel = viewModel<KotlinWeeklyIssueViewModel>()
val viewModel = hiltViewModel<KotlinWeeklyIssueViewModel>()
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val eventSink = viewModel.eventSink

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,7 +58,7 @@ public fun SavedForLaterScreen(
onViewItem: (FeedItem) -> Unit,
modifier: Modifier = Modifier,
) {
val viewModel = viewModel<SavedForLaterViewModel>()
val viewModel = hiltViewModel<SavedForLaterViewModel>()
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val eventSink = viewModel.eventSink
SavedForLaterScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,7 +74,7 @@ public fun TalkingKotlinEpisodeScreen(
onNavigateUp: () -> Unit,
modifier: Modifier = Modifier,
): Unit = trace("Screen:TalkingKotlinEpisode") {
val viewModel = viewModel<TalkingKotlinEpisodeViewModel>()
val viewModel = hiltViewModel<TalkingKotlinEpisodeViewModel>()
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val eventSink = viewModel.eventSink

Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit 12ce9ea

Please sign in to comment.