mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
refactor(di): use constructor DSL for VMs
Instead of doing it manually with viewModel { }
This commit is contained in:
parent
5cb31dbe9d
commit
36c4e2dfe0
@ -1,27 +1,14 @@
|
||||
package app.revanced.manager.compose.di
|
||||
|
||||
import app.revanced.manager.compose.ui.viewmodel.*
|
||||
import org.koin.androidx.viewmodel.dsl.viewModel
|
||||
import org.koin.androidx.viewmodel.dsl.viewModelOf
|
||||
import org.koin.dsl.module
|
||||
|
||||
val viewModelModule = module {
|
||||
viewModel {
|
||||
PatchesSelectorViewModel(
|
||||
packageInfo = it.get(),
|
||||
bundleRepository = get()
|
||||
)
|
||||
}
|
||||
viewModelOf(::PatchesSelectorViewModel)
|
||||
viewModelOf(::SettingsViewModel)
|
||||
viewModelOf(::AppSelectorViewModel)
|
||||
viewModelOf(::SourcesScreenViewModel)
|
||||
viewModel {
|
||||
InstallerScreenViewModel(
|
||||
input = it.get(),
|
||||
selectedPatches = it.get(),
|
||||
app = get(),
|
||||
signerService = get(),
|
||||
)
|
||||
}
|
||||
viewModelOf(::InstallerScreenViewModel)
|
||||
viewModelOf(::UpdateSettingsViewModel)
|
||||
}
|
||||
|
@ -27,15 +27,17 @@ import app.revanced.manager.compose.util.PatchesSelection
|
||||
import app.revanced.manager.compose.util.toast
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
|
||||
class InstallerScreenViewModel(
|
||||
input: PackageInfo,
|
||||
selectedPatches: PatchesSelection,
|
||||
private val app: Application,
|
||||
private val signerService: SignerService
|
||||
) : ViewModel() {
|
||||
selectedPatches: PatchesSelection
|
||||
) : ViewModel(), KoinComponent {
|
||||
private val signerService: SignerService by inject()
|
||||
private val app: Application by inject()
|
||||
var stepGroups by mutableStateOf<List<StepGroup>>(
|
||||
PatcherProgressManager.generateGroupsList(
|
||||
app,
|
||||
|
@ -7,9 +7,11 @@ import app.revanced.manager.compose.patcher.patch.PatchInfo
|
||||
import app.revanced.manager.compose.util.PackageInfo
|
||||
import app.revanced.manager.compose.util.PatchesSelection
|
||||
import kotlinx.coroutines.flow.map
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.get
|
||||
|
||||
class PatchesSelectorViewModel(packageInfo: PackageInfo, bundleRepository: BundleRepository) : ViewModel() {
|
||||
val bundlesFlow = bundleRepository.bundles.map { bundles ->
|
||||
class PatchesSelectorViewModel(packageInfo: PackageInfo) : ViewModel(), KoinComponent {
|
||||
val bundlesFlow = get<BundleRepository>().bundles.map { bundles ->
|
||||
bundles.mapValues { (_, bundle) -> bundle.patches }.map { (name, patches) ->
|
||||
val supported = mutableListOf<PatchInfo>()
|
||||
val unsupported = mutableListOf<PatchInfo>()
|
||||
|
Loading…
x
Reference in New Issue
Block a user