mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: show toast when no patches are selected
This commit is contained in:
parent
e70c10adbd
commit
65f8d38c59
@ -19,6 +19,7 @@ import androidx.compose.runtime.derivedStateOf
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
@ -32,6 +33,7 @@ import app.revanced.manager.ui.viewmodel.PatchesSelectorViewModel
|
|||||||
import app.revanced.manager.ui.viewmodel.SelectedAppInfoViewModel
|
import app.revanced.manager.ui.viewmodel.SelectedAppInfoViewModel
|
||||||
import app.revanced.manager.util.Options
|
import app.revanced.manager.util.Options
|
||||||
import app.revanced.manager.util.PatchesSelection
|
import app.revanced.manager.util.PatchesSelection
|
||||||
|
import app.revanced.manager.util.toast
|
||||||
import dev.olshevski.navigation.reimagined.AnimatedNavHost
|
import dev.olshevski.navigation.reimagined.AnimatedNavHost
|
||||||
import dev.olshevski.navigation.reimagined.NavBackHandler
|
import dev.olshevski.navigation.reimagined.NavBackHandler
|
||||||
import dev.olshevski.navigation.reimagined.navigate
|
import dev.olshevski.navigation.reimagined.navigate
|
||||||
@ -46,6 +48,7 @@ fun SelectedAppInfoScreen(
|
|||||||
onBackClick: () -> Unit,
|
onBackClick: () -> Unit,
|
||||||
vm: SelectedAppInfoViewModel
|
vm: SelectedAppInfoViewModel
|
||||||
) {
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
val bundles by remember(vm.selectedApp.packageName, vm.selectedApp.version) {
|
val bundles by remember(vm.selectedApp.packageName, vm.selectedApp.version) {
|
||||||
vm.bundlesRepo.bundleInfoFlow(vm.selectedApp.packageName, vm.selectedApp.version)
|
vm.bundlesRepo.bundleInfoFlow(vm.selectedApp.packageName, vm.selectedApp.version)
|
||||||
}.collectAsStateWithLifecycle(initialValue = emptyList())
|
}.collectAsStateWithLifecycle(initialValue = emptyList())
|
||||||
@ -74,7 +77,12 @@ fun SelectedAppInfoScreen(
|
|||||||
AnimatedNavHost(controller = navController) { destination ->
|
AnimatedNavHost(controller = navController) { destination ->
|
||||||
when (destination) {
|
when (destination) {
|
||||||
is SelectedAppInfoDestination.Main -> SelectedAppInfoScreen(
|
is SelectedAppInfoDestination.Main -> SelectedAppInfoScreen(
|
||||||
onPatchClick = {
|
onPatchClick = patchClick@{
|
||||||
|
if (selectedPatchCount == 0) {
|
||||||
|
context.toast(context.getString(R.string.no_patches_selected))
|
||||||
|
|
||||||
|
return@patchClick
|
||||||
|
}
|
||||||
onPatchClick(
|
onPatchClick(
|
||||||
vm.selectedApp,
|
vm.selectedApp,
|
||||||
patches,
|
patches,
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
<string name="patch_item_description">Start patching the application</string>
|
<string name="patch_item_description">Start patching the application</string>
|
||||||
<string name="patch_selector_item">Patch selection and options</string>
|
<string name="patch_selector_item">Patch selection and options</string>
|
||||||
<string name="patch_selector_item_description">%d patches selected</string>
|
<string name="patch_selector_item_description">%d patches selected</string>
|
||||||
|
<string name="no_patches_selected">No patches selected</string>
|
||||||
|
|
||||||
<string name="version_selector_item">Change version</string>
|
<string name="version_selector_item">Change version</string>
|
||||||
<string name="version_selector_item_description">%s selected</string>
|
<string name="version_selector_item_description">%s selected</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user