Skip to content

Commit

Permalink
feat: implement Compose viewModel() function
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Mar 22, 2023
1 parent dfa25eb commit 8e9b4cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.lifecycle.viewmodel.compose.viewModel
import com.geeksville.mesh.ConfigProtos
import com.geeksville.mesh.ConfigProtos.Config.NetworkConfig
import com.geeksville.mesh.R
Expand All @@ -34,7 +35,7 @@ import com.geeksville.mesh.ui.components.RegularPreference
import com.geeksville.mesh.ui.components.SwitchPreference

@Composable
fun DeviceSettingsItemList(viewModel: UIViewModel) {
fun DeviceSettingsItemList(viewModel: UIViewModel = viewModel()) {
val focusManager = LocalFocusManager.current

val hasWifi = viewModel.hasWifi()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.lifecycle.viewmodel.compose.viewModel
import com.geeksville.mesh.ModuleConfigProtos.ModuleConfig
import com.geeksville.mesh.copy
import com.geeksville.mesh.model.UIViewModel
Expand All @@ -27,7 +28,7 @@ import com.geeksville.mesh.ui.components.PreferenceFooter
import com.geeksville.mesh.ui.components.SwitchPreference

@Composable
fun ModuleSettingsItemList(viewModel: UIViewModel) {
fun ModuleSettingsItemList(viewModel: UIViewModel = viewModel()) {
val focusManager = LocalFocusManager.current

val connectionState by viewModel.connectionState.observeAsState()
Expand Down

0 comments on commit 8e9b4cb

Please sign in to comment.