Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co

### Improved
- Show informative error when trying to add unapproved titles to list on MAL ([@MajorTanya](https://github.com/MajorTanya)) ([#3155](https://github.com/mihonapp/mihon/pull/3155))
- Add long click range selection on migrate manga screen ([@NarwhalHorns](https://github.com/NarwhalHorns)) ([#3171](https://github.com/mihonapp/mihon/pull/3171))

## [v0.19.7] - 2026-03-23
Same as v0.19.6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package eu.kanade.presentation.manga.components

import androidx.compose.foundation.clickable
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
Expand All @@ -22,14 +22,18 @@ fun BaseMangaListItem(
manga: Manga,
modifier: Modifier = Modifier,
onClickItem: () -> Unit = {},
onLongClickItem: () -> Unit = {},
onClickCover: () -> Unit = onClickItem,
cover: @Composable RowScope.() -> Unit = { defaultCover(manga, onClickCover) },
actions: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit = { defaultContent(manga) },
) {
Row(
modifier = modifier
.clickable(onClick = onClickItem)
.combinedClickable(
onClick = onClickItem,
onLongClick = onLongClickItem,
)
.height(56.dp)
.padding(horizontal = MaterialTheme.padding.medium),
verticalAlignment = Alignment.CenterVertically,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ data class MigrateMangaScreen(
contentPadding = contentPadding,
state = state,
onClickItem = screenModel::toggleSelection,
onLongClickItem = screenModel::toggleRangeSelection,
onClickCover = { navigator.push(MangaScreen(it.id)) },
)
}
Expand All @@ -129,6 +130,7 @@ data class MigrateMangaScreen(
contentPadding: PaddingValues,
state: MigrateMangaScreenModel.State,
onClickItem: (Manga) -> Unit,
onLongClickItem: (Manga) -> Unit,
onClickCover: (Manga) -> Unit,
) {
FastScrollLazyColumn(
Expand All @@ -140,6 +142,7 @@ data class MigrateMangaScreen(
manga = manga,
isSelected = manga.id in state.selection,
onClickItem = onClickItem,
onLongClickItem = onLongClickItem,
onClickCover = onClickCover,
)
}
Expand All @@ -151,13 +154,15 @@ data class MigrateMangaScreen(
manga: Manga,
isSelected: Boolean,
onClickItem: (Manga) -> Unit,
onLongClickItem: (Manga) -> Unit,
onClickCover: (Manga) -> Unit,
modifier: Modifier = Modifier,
) {
BaseMangaListItem(
modifier = modifier.selectedBackground(isSelected),
manga = manga,
onClickItem = { onClickItem(manga) },
onLongClickItem = { onLongClickItem(manga) },
onClickCover = { onClickCover(manga) },
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,27 @@ class MigrateMangaScreenModel(
}
}

fun toggleRangeSelection(item: Manga) {
mutableState.update { state ->
val newSelection = state.selection.mutate { list ->
val lastSelectedId = list.lastOrNull()
val lastSelectedManga = state.titles.find { it.id == lastSelectedId }
list.add(item.id)
val lastMangaIndex = state.titles.indexOf(lastSelectedManga)
val curMangaIndex = state.titles.indexOf(item)

val selectionRange = when {
lastMangaIndex < curMangaIndex -> lastMangaIndex..curMangaIndex
curMangaIndex < lastMangaIndex -> curMangaIndex..lastMangaIndex
// We shouldn't reach this point
else -> return@mutate
}
selectionRange.mapNotNull { state.titles[it].id }.let(list::addAll)
}
state.copy(selection = newSelection)
}
}

fun clearSelection() {
mutableState.update { it.copy(selection = emptySet()) }
}
Expand Down
Loading