Skip to content

Commit

Permalink
fix: hide patch button
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko committed Sep 20, 2023
1 parent c4b9bb1 commit 65a3d78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ fun PatchesSelectorScreen(
)
},
floatingActionButton = {
ExtendedFloatingActionButton(
text = { Text(stringResource(R.string.patch)) },
icon = { Icon(Icons.Default.Build, null) },
onClick = {
composableScope.launch {
// TODO: only allow this if all required options have been set.
onPatchClick(vm.getAndSaveSelection(), vm.getOptions())
if (!vm.isSelectionEmpty()) {
ExtendedFloatingActionButton(
text = { Text(stringResource(R.string.patch)) },
icon = { Icon(Icons.Default.Build, null) },
onClick = {
composableScope.launch {
onPatchClick(vm.getAndSaveSelection(), vm.getOptions())
}
}
}
)
)
}
}
) { paddingValues ->
Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class PatchesSelectorViewModel(
if (patches.contains(name)) patches.remove(name) else patches.add(name)
}

fun isSelectionEmpty() = selectedPatches.values.all { it.isEmpty() }

suspend fun getAndSaveSelection(): PatchesSelection =
selectedPatches.also {
withContext(Dispatchers.Default) {
Expand Down

0 comments on commit 65a3d78

Please sign in to comment.