Colton Idle
07/23/2021, 2:02 PMviewModel()
to compile. I've added the lifecycle compose vm dependencyIan Lake
07/23/2021, 2:03 PMsteelahhh
07/23/2021, 2:05 PMIan Lake
07/23/2021, 2:06 PMColton Idle
07/23/2021, 2:07 PMimport androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.ViewModel
import androidx.navigation.NavController
Colton Idle
07/23/2021, 2:07 PMColton Idle
07/23/2021, 2:08 PM// Compose helpers
implementation("androidx.activity:activity-compose:1.3.0-rc02")
implementation("androidx.navigation:navigation-compose:2.4.0-alpha04")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07")
implementation("androidx.hilt:hilt-navigation-compose:1.0.0-alpha03")
I assume I'm missing something basic here. Maybe another dep? But I've been going through the docs and I seem pretty solid.Ian Lake
07/23/2021, 2:08 PMandroidx.lifecycle.viewmodel.compose.viewModel
importColton Idle
07/23/2021, 2:10 PMColton Idle
07/23/2021, 2:10 PMColton Idle
07/23/2021, 2:11 PMColton Idle
07/23/2021, 2:11 PMIan Lake
07/23/2021, 2:17 PMIan Lake
07/23/2021, 2:17 PMColton Idle
07/23/2021, 2:19 PMColton Idle
07/23/2021, 2:20 PMKefas
07/24/2021, 7:07 PMviewModel
Ian Lake
07/24/2021, 11:43 PMviewModel()
for a parameter is perfectly fine (although relying on actual state, etc. from your ViewModel will make it more testable if you don't want to mock your ViewModel / have your own set of fakes). All Colton was missing was the importColton Idle
07/24/2021, 11:45 PMKefas
07/25/2021, 1:47 AMviewModel
, the auto-import doesn't work. But if I use something else for the name (e.g. homeViewModel
), the auto-import works.Colton Idle
07/25/2021, 1:52 AMIan Lake
07/25/2021, 3:54 AMviewModel
and call its invoke()
method, which is shorthanded to ()
, which is why it was recommending creating that method. Calling the variable anything else removes the ambiguity and lets Studio recognize it as an unknown symbol which it can then offer to solve via an importColton Idle
07/25/2021, 3:55 AM