mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-25 18:47:51 +02:00
Move manga info summary more/less button toggle
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
package eu.kanade.tachiyomi.ui.manga.info
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -302,21 +300,23 @@ class MangaInfoHeaderAdapter(
|
||||
controller::performSearch
|
||||
)
|
||||
} else {
|
||||
binding.mangaGenresTagsWrapper.isVisible = false
|
||||
binding.mangaGenresTagsCompactChips.isVisible = false
|
||||
binding.mangaGenresTagsFullChips.isVisible = false
|
||||
}
|
||||
|
||||
// Handle showing more or less info
|
||||
merge(
|
||||
binding.mangaSummarySection.clicks(),
|
||||
binding.mangaSummaryText.clicks(),
|
||||
binding.mangaInfoToggle.clicks()
|
||||
binding.mangaInfoToggleMore.clicks(),
|
||||
binding.mangaInfoToggleLess.clicks()
|
||||
)
|
||||
.onEach { toggleMangaInfo(view.context) }
|
||||
.onEach { toggleMangaInfo() }
|
||||
.launchIn(scope)
|
||||
|
||||
// Expand manga info if navigated from source listing
|
||||
if (initialLoad && fromSource) {
|
||||
toggleMangaInfo(view.context)
|
||||
toggleMangaInfo()
|
||||
initialLoad = false
|
||||
}
|
||||
}
|
||||
@ -326,44 +326,21 @@ class MangaInfoHeaderAdapter(
|
||||
binding.mangaSummarySection.isVisible = visible
|
||||
}
|
||||
|
||||
private fun toggleMangaInfo(context: Context) {
|
||||
val isExpanded =
|
||||
binding.mangaInfoToggle.contentDescription == context.getString(R.string.manga_info_collapse)
|
||||
private fun toggleMangaInfo() {
|
||||
val isCurrentlyExpanded = binding.mangaSummaryText.maxLines != 2
|
||||
|
||||
with(binding.mangaInfoToggle) {
|
||||
contentDescription = if (isExpanded) {
|
||||
context.getString(R.string.manga_info_expand)
|
||||
} else {
|
||||
context.getString(R.string.manga_info_collapse)
|
||||
}
|
||||
binding.mangaInfoToggleMoreScrim.isVisible = isCurrentlyExpanded
|
||||
binding.mangaInfoToggleMore.isVisible = isCurrentlyExpanded
|
||||
binding.mangaInfoToggleLess.isVisible = !isCurrentlyExpanded
|
||||
|
||||
setImageDrawable(
|
||||
if (isExpanded) {
|
||||
context.getDrawable(R.drawable.ic_baseline_expand_more_24dp)
|
||||
} else {
|
||||
context.getDrawable(R.drawable.ic_baseline_expand_less_24dp)
|
||||
}
|
||||
)
|
||||
binding.mangaSummaryText.maxLines = if (isCurrentlyExpanded) {
|
||||
2
|
||||
} else {
|
||||
Int.MAX_VALUE
|
||||
}
|
||||
|
||||
with(binding.mangaSummaryText) {
|
||||
maxLines =
|
||||
if (isExpanded) {
|
||||
2
|
||||
} else {
|
||||
Int.MAX_VALUE
|
||||
}
|
||||
|
||||
ellipsize =
|
||||
if (isExpanded) {
|
||||
TextUtils.TruncateAt.END
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
binding.mangaGenresTagsCompact.isVisible = isExpanded
|
||||
binding.mangaGenresTagsFullChips.isVisible = !isExpanded
|
||||
binding.mangaGenresTagsCompact.isVisible = isCurrentlyExpanded
|
||||
binding.mangaGenresTagsFullChips.isVisible = !isCurrentlyExpanded
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user