mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-27 03:27:51 +02:00
New manga info expander (#5771)
* Replace "More" with Arrows We used to have arrows but it was set away from the description which took a lot of space. It was changed to "More" text, but with the recent design changes I think it'd look better to get a mix between them both. * Properly align icons Co-Authored-By: Andreas <6576096+ghostbear@users.noreply.github.com> * Expand support to Tablets Get it... expand... hehe 😎 * Fix expanded width Also fixes so that the constraint for the toggleLess is dependant on the right thing * Give info toggles its own space Uses its own margin now to push info rather than just being attached as a info margin. * Remove weird duplicates I did not add I did not add these but I don't see a reason to keep dupes * Add bottom scrim * Change to centered arrow under info Anyone wanna experiment/build on top off then feel free to tweak * Add background glow to icon for contrast Co-Authored-By: Andreas <6576096+ghostbear@users.noreply.github.com> Co-authored-by: Andreas <6576096+ghostbear@users.noreply.github.com> Co-authored-by: Andreas <andreas.everos@gmail.com>
This commit is contained in:
@ -48,6 +48,8 @@ class MangaInfoHeaderAdapter(
|
||||
|
||||
private var initialLoad: Boolean = true
|
||||
|
||||
private val maxLines = 3
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HeaderViewHolder {
|
||||
binding = MangaInfoHeaderBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||
updateCoverPosition()
|
||||
@ -297,7 +299,10 @@ class MangaInfoHeaderAdapter(
|
||||
binding.mangaSummaryText.text = if (manga.description.isNullOrBlank()) {
|
||||
view.context.getString(R.string.unknown)
|
||||
} else {
|
||||
manga.description
|
||||
// Max lines of 3 with a blank line looks whack so we remove
|
||||
// any line breaks that is 2 or more and replace it with 1
|
||||
manga.description!!
|
||||
.replace(Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE)), "\n")
|
||||
}
|
||||
|
||||
// Update genres list
|
||||
@ -335,7 +340,7 @@ class MangaInfoHeaderAdapter(
|
||||
}
|
||||
|
||||
// Refreshes will change the state and it needs to be set to correct state to display correctly
|
||||
if (binding.mangaSummaryText.maxLines == 2) {
|
||||
if (binding.mangaSummaryText.maxLines == maxLines) {
|
||||
binding.mangaSummarySection.transitionToState(R.id.start)
|
||||
} else {
|
||||
binding.mangaSummarySection.transitionToState(R.id.end)
|
||||
@ -348,7 +353,7 @@ class MangaInfoHeaderAdapter(
|
||||
}
|
||||
|
||||
private fun toggleMangaInfo() {
|
||||
val isCurrentlyExpanded = binding.mangaSummaryText.maxLines != 2
|
||||
val isCurrentlyExpanded = binding.mangaSummaryText.maxLines != maxLines
|
||||
|
||||
if (isCurrentlyExpanded) {
|
||||
binding.mangaSummarySection.transitionToStart()
|
||||
@ -357,7 +362,7 @@ class MangaInfoHeaderAdapter(
|
||||
}
|
||||
|
||||
binding.mangaSummaryText.maxLines = if (isCurrentlyExpanded) {
|
||||
2
|
||||
maxLines
|
||||
} else {
|
||||
Int.MAX_VALUE
|
||||
}
|
||||
|
Reference in New Issue
Block a user