Skip to content

Commit

Permalink
feat: show toast when no patches are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelen123 committed Oct 20, 2023
1 parent e70c10a commit 65f8d38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand All @@ -32,6 +33,7 @@ import app.revanced.manager.ui.viewmodel.PatchesSelectorViewModel
import app.revanced.manager.ui.viewmodel.SelectedAppInfoViewModel
import app.revanced.manager.util.Options
import app.revanced.manager.util.PatchesSelection
import app.revanced.manager.util.toast
import dev.olshevski.navigation.reimagined.AnimatedNavHost
import dev.olshevski.navigation.reimagined.NavBackHandler
import dev.olshevski.navigation.reimagined.navigate
Expand All @@ -46,6 +48,7 @@ fun SelectedAppInfoScreen(
onBackClick: () -> Unit,
vm: SelectedAppInfoViewModel
) {
val context = LocalContext.current
val bundles by remember(vm.selectedApp.packageName, vm.selectedApp.version) {
vm.bundlesRepo.bundleInfoFlow(vm.selectedApp.packageName, vm.selectedApp.version)
}.collectAsStateWithLifecycle(initialValue = emptyList())
Expand Down Expand Up @@ -74,7 +77,12 @@ fun SelectedAppInfoScreen(
AnimatedNavHost(controller = navController) { destination ->
when (destination) {
is SelectedAppInfoDestination.Main -> SelectedAppInfoScreen(
onPatchClick = {
onPatchClick = patchClick@{
if (selectedPatchCount == 0) {
context.toast(context.getString(R.string.no_patches_selected))

return@patchClick
}
onPatchClick(
vm.selectedApp,
patches,
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<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_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_description">%s selected</string>
Expand Down

0 comments on commit 65f8d38

Please sign in to comment.