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