diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt index 35f381102..af2ff95ee 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt @@ -4,7 +4,9 @@ import android.content.Context import android.content.Intent import android.graphics.Color import android.os.Bundle +import android.text.style.DynamicDrawableSpan import android.text.style.ForegroundColorSpan +import android.text.style.ImageSpan import android.text.style.RelativeSizeSpan import android.transition.AutoTransition import android.transition.Slide @@ -318,6 +320,18 @@ class DetailsActivity : val branches = viewModel.branches.value for ((i, branch) in branches.withIndex()) { val title = buildSpannedString { + if (branch.isCurrent) { + inSpans( + ImageSpan( + this@DetailsActivity, + R.drawable.ic_current_chapter, + DynamicDrawableSpan.ALIGN_BASELINE, + ), + ) { + append(' ') + } + append(' ') + } append(branch.name ?: getString(R.string.system_default)) append(' ') append(' ') diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsViewModel.kt index fe40a4c21..b40073093 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsViewModel.kt @@ -25,6 +25,7 @@ import okio.FileNotFoundException import org.koitharu.kotatsu.R import org.koitharu.kotatsu.bookmarks.domain.Bookmark import org.koitharu.kotatsu.bookmarks.domain.BookmarksRepository +import org.koitharu.kotatsu.core.model.findById import org.koitharu.kotatsu.core.model.getPreferredBranch import org.koitharu.kotatsu.core.parser.MangaIntent import org.koitharu.kotatsu.core.prefs.AppSettings @@ -171,10 +172,21 @@ class DetailsViewModel @Inject constructor( val branches: StateFlow> = combine( details, selectedBranch, - ) { m, b -> - (m?.chapters ?: return@combine emptyList()) - .map { x -> MangaBranch(x.key, x.value.size, x.key == b) } - .sortedWith(BranchComparator()) + history, + ) { m, b, h -> + val c = m?.chapters + if (c.isNullOrEmpty()) { + return@combine emptyList() + } + val currentBranch = h?.let { m.allChapters.findById(it.chapterId) }?.branch + c.map { x -> + MangaBranch( + name = x.key, + count = x.value.size, + isSelected = x.key == b, + isCurrent = h != null && x.key == currentBranch, + ) + }.sortedWith(BranchComparator()) }.stateIn(viewModelScope + Dispatchers.Default, SharingStarted.Eagerly, emptyList()) val isChaptersEmpty: StateFlow = details.map { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/model/MangaBranch.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/model/MangaBranch.kt index 841621277..520f1de41 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/model/MangaBranch.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/model/MangaBranch.kt @@ -7,6 +7,7 @@ data class MangaBranch( val name: String?, val count: Int, val isSelected: Boolean, + val isCurrent: Boolean, ) : ListModel { override fun areItemsTheSame(other: ListModel): Boolean {