Selecting recipes for deletion with a short tap if there's already selected recipes

master
Wynd 2026-03-13 16:36:58 +02:00
parent 143555c22e
commit 68a4cecaa4
2 changed files with 21 additions and 2 deletions

View File

@ -147,8 +147,21 @@ fun MainScreen(ctx: MainActivity, padding: PaddingValues, view: RecipesView) {
val entry = recipes[entryId] val entry = recipes[entryId]
val isSelected = selectedEntries.contains(entry) val isSelected = selectedEntries.contains(entry)
RecipePreview(entry, isSelected, onClick = { RecipePreview(entry, isSelected, onClick = {
view.setActive(entry) if (selectedEntries.isNotEmpty()) {
navController.navigate("info") selectedEntries =
selectedEntries.toMutableList().apply {
val flag = !selectedEntries.contains(entry)
if (flag) {
add(entry)
} else {
remove(entry)
}
}.toList()
}
else {
view.setActive(entry)
navController.navigate("info")
}
}, onSelected = { flag -> }, onSelected = { flag ->
selectedEntries = selectedEntries =
selectedEntries.toMutableList().apply { selectedEntries.toMutableList().apply {

View File

@ -66,6 +66,12 @@ fun sync(ctx: MainActivity, nav: NavHostController, setLoading: (Boolean) -> Uni
parentDir.mkdirs() parentDir.mkdirs()
val newFile = File(parentDir, fileName) val newFile = File(parentDir, fileName)
if (!newFile.exists()) {
newFile.createNewFile()
}
else if (newFile.isDirectory) {
continue
}
val fos = FileOutputStream(newFile, false) val fos = FileOutputStream(newFile, false)
var usedBytes = 0 var usedBytes = 0