Move settings module to use koin

pull/2064/head
lihenggui 1 year ago
parent be3f330f24
commit 5fdea5ace2

@ -82,11 +82,12 @@ import nowinandroid.feature.settings.generated.resources.feature_settings_theme
import nowinandroid.feature.settings.generated.resources.feature_settings_title
import org.jetbrains.compose.resources.stringResource
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.koin.compose.viewmodel.koinViewModel
@Composable
fun SettingsDialog(
onDismiss: () -> Unit,
viewModel: SettingsViewModel,
viewModel: SettingsViewModel = koinViewModel(),
) {
val settingsUiState by viewModel.settingsUiState.collectAsStateWithLifecycle()
SettingsDialog(

@ -30,7 +30,7 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.seconds
class SettingsViewModel constructor(
class SettingsViewModel(
private val userDataRepository: UserDataRepository,
) : ViewModel() {
val settingsUiState: StateFlow<SettingsUiState> =

@ -0,0 +1,27 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.samples.apps.nowinandroid.feature.settings.di
import com.google.samples.apps.nowinandroid.feature.settings.SettingsViewModel
import org.koin.core.module.dsl.viewModel
import org.koin.dsl.module
val settingModule = module {
viewModel {
SettingsViewModel(get())
}
}
Loading…
Cancel
Save