Skip to content

Commit

Permalink
feat: rename ViewModels for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
CnC-Robert committed Jun 3, 2023
1 parent ffa8d9c commit e088d05
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ val viewModelModule = module {
viewModelOf(::PatchesSelectorViewModel)
viewModelOf(::SettingsViewModel)
viewModelOf(::AppSelectorViewModel)
viewModelOf(::SourcesScreenViewModel)
viewModelOf(::InstallerScreenViewModel)
viewModelOf(::SourcesViewModel)
viewModelOf(::InstallerViewModel)
viewModelOf(::UpdateSettingsViewModel)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import app.revanced.manager.compose.R
import app.revanced.manager.compose.domain.sources.LocalSource
import app.revanced.manager.compose.domain.sources.RemoteSource
import app.revanced.manager.compose.domain.sources.Source
import app.revanced.manager.compose.ui.viewmodel.SourcesScreenViewModel
import app.revanced.manager.compose.ui.viewmodel.SourcesViewModel
import app.revanced.manager.compose.util.uiSafe
import kotlinx.coroutines.launch
import java.io.InputStream
Expand Down Expand Up @@ -108,7 +108,7 @@ private fun RemoteSourceItem(source: RemoteSource) {

Button(onClick = {
coroutineScope.launch {
uiSafe(androidContext, R.string.source_download_fail, SourcesScreenViewModel.failLogMsg) {
uiSafe(androidContext, R.string.source_download_fail, SourcesViewModel.failLogMsg) {
source.update()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ import app.revanced.manager.compose.patcher.worker.StepGroup
import app.revanced.manager.compose.patcher.worker.StepStatus
import app.revanced.manager.compose.ui.component.AppScaffold
import app.revanced.manager.compose.ui.component.AppTopBar
import app.revanced.manager.compose.ui.viewmodel.InstallerScreenViewModel
import app.revanced.manager.compose.ui.viewmodel.InstallerViewModel
import app.revanced.manager.compose.util.APK_MIMETYPE
import kotlin.math.floor

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun InstallerScreen(
onBackClick: () -> Unit,
vm: InstallerScreenViewModel
vm: InstallerViewModel
) {
val exportApkLauncher = rememberLauncherForActivityResult(CreateDocument(APK_MIMETYPE), vm::export)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import app.revanced.manager.compose.R
import app.revanced.manager.compose.ui.component.sources.NewSourceDialog
import app.revanced.manager.compose.ui.component.sources.SourceItem
import app.revanced.manager.compose.ui.viewmodel.SourcesScreenViewModel
import app.revanced.manager.compose.ui.viewmodel.SourcesViewModel
import kotlinx.coroutines.launch
import org.koin.androidx.compose.getViewModel

@Composable
fun SourcesScreen(vm: SourcesScreenViewModel = getViewModel()) {
fun SourcesScreen(vm: SourcesViewModel = getViewModel()) {
var showNewSourceDialog by rememberSaveable { mutableStateOf(false) }
val scope = rememberCoroutineScope()

Expand All @@ -39,7 +39,7 @@ fun SourcesScreen(vm: SourcesScreenViewModel = getViewModel()) {

Column(
modifier = Modifier
.fillMaxWidth(),
.fillMaxSize(),
) {
sources.forEach { (name, source) ->
SourceItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageInfo
import android.content.pm.PackageInstaller
import android.net.Uri
import androidx.compose.runtime.derivedStateOf
Expand Down Expand Up @@ -33,7 +32,7 @@ import org.koin.core.component.inject
import java.io.File
import java.nio.file.Files

class InstallerScreenViewModel(
class InstallerViewModel(
input: AppInfo,
selectedPatches: PatchesSelection
) : ViewModel(), KoinComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package app.revanced.manager.compose.ui.viewmodel
import android.app.Application
import android.content.ContentResolver
import android.net.Uri
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import app.revanced.manager.compose.R
Expand All @@ -15,7 +12,7 @@ import app.revanced.manager.compose.util.uiSafe
import io.ktor.http.*
import kotlinx.coroutines.launch

class SourcesScreenViewModel(private val app: Application, private val sourceRepository: SourceRepository) : ViewModel() {
class SourcesViewModel(private val app: Application, private val sourceRepository: SourceRepository) : ViewModel() {
val sources = sourceRepository.sources
private val contentResolver: ContentResolver = app.contentResolver

Expand Down

0 comments on commit e088d05

Please sign in to comment.