mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Start updating manga info view header design
This commit is contained in:
		| @@ -66,7 +66,7 @@ class MangaChaptersHeaderAdapter( | ||||
|             } else { | ||||
|                 view.context.getResourceColor(R.attr.colorOnPrimary) | ||||
|             } | ||||
|             DrawableCompat.setTint(binding.btnChaptersFilter.icon, filterColor) | ||||
|             DrawableCompat.setTint(binding.btnChaptersFilter.drawable, filterColor) | ||||
|  | ||||
|             merge(view.clicks(), binding.btnChaptersFilter.clicks()) | ||||
|                 .onEach { controller.showSettingsSheet() } | ||||
|   | ||||
| @@ -105,13 +105,27 @@ class MangaInfoHeaderAdapter( | ||||
|                     isVisible = true | ||||
|  | ||||
|                     if (trackCount > 0) { | ||||
|                         setIconResource(R.drawable.ic_done_24dp) | ||||
|                         text = view.context.resources.getQuantityString(R.plurals.num_trackers, trackCount, trackCount) | ||||
|                         isChecked = true | ||||
|                         setCompoundDrawablesWithIntrinsicBounds( | ||||
|                             null, | ||||
|                             ContextCompat.getDrawable(context, R.drawable.ic_done_24dp), | ||||
|                             null, | ||||
|                             null | ||||
|                         ) | ||||
|                         text = view.context.resources.getQuantityString( | ||||
|                             R.plurals.num_trackers, | ||||
|                             trackCount, | ||||
|                             trackCount | ||||
|                         ) | ||||
|                         isSelected = true | ||||
|                     } else { | ||||
|                         setIconResource(R.drawable.ic_sync_24dp) | ||||
|                         setCompoundDrawablesWithIntrinsicBounds( | ||||
|                             null, | ||||
|                             ContextCompat.getDrawable(context, R.drawable.ic_sync_24dp), | ||||
|                             null, | ||||
|                             null | ||||
|                         ) | ||||
|                         text = view.context.getString(R.string.manga_tracking_tab) | ||||
|                         isChecked = false | ||||
|                         isSelected = false | ||||
|                     } | ||||
|  | ||||
|                     clicks() | ||||
| @@ -279,14 +293,24 @@ class MangaInfoHeaderAdapter( | ||||
|  | ||||
|                 // Update genres list | ||||
|                 if (!manga.genre.isNullOrBlank()) { | ||||
|                     binding.mangaGenresTagsCompactChips.setChips(manga.getGenres(), controller::performSearch) | ||||
|                     binding.mangaGenresTagsFullChips.setChips(manga.getGenres(), controller::performSearch) | ||||
|                     binding.mangaGenresTagsCompactChips.setChips( | ||||
|                         manga.getGenres(), | ||||
|                         controller::performSearch | ||||
|                     ) | ||||
|                     binding.mangaGenresTagsFullChips.setChips( | ||||
|                         manga.getGenres(), | ||||
|                         controller::performSearch | ||||
|                     ) | ||||
|                 } else { | ||||
|                     binding.mangaGenresTagsWrapper.isVisible = false | ||||
|                 } | ||||
|  | ||||
|                 // Handle showing more or less info | ||||
|                 merge(binding.mangaSummarySection.clicks(), binding.mangaSummaryText.clicks(), binding.mangaInfoToggle.clicks()) | ||||
|                 merge( | ||||
|                     binding.mangaSummarySection.clicks(), | ||||
|                     binding.mangaSummaryText.clicks(), | ||||
|                     binding.mangaInfoToggle.clicks() | ||||
|                 ) | ||||
|                     .onEach { toggleMangaInfo(view.context) } | ||||
|                     .launchIn(scope) | ||||
|  | ||||
| @@ -304,20 +328,22 @@ class MangaInfoHeaderAdapter( | ||||
|  | ||||
|         private fun toggleMangaInfo(context: Context) { | ||||
|             val isExpanded = | ||||
|                 binding.mangaInfoToggle.text == context.getString(R.string.manga_info_collapse) | ||||
|                 binding.mangaInfoToggle.contentDescription == context.getString(R.string.manga_info_collapse) | ||||
|  | ||||
|             with(binding.mangaInfoToggle) { | ||||
|                 text = if (isExpanded) { | ||||
|                 contentDescription = if (isExpanded) { | ||||
|                     context.getString(R.string.manga_info_expand) | ||||
|                 } else { | ||||
|                     context.getString(R.string.manga_info_collapse) | ||||
|                 } | ||||
|  | ||||
|                 icon = if (isExpanded) { | ||||
|                     context.getDrawable(R.drawable.ic_baseline_expand_more_24dp) | ||||
|                 } else { | ||||
|                     context.getDrawable(R.drawable.ic_baseline_expand_less_24dp) | ||||
|                 } | ||||
|                 setImageDrawable( | ||||
|                     if (isExpanded) { | ||||
|                         context.getDrawable(R.drawable.ic_baseline_expand_more_24dp) | ||||
|                     } else { | ||||
|                         context.getDrawable(R.drawable.ic_baseline_expand_less_24dp) | ||||
|                     } | ||||
|                 ) | ||||
|             } | ||||
|  | ||||
|             with(binding.mangaSummaryText) { | ||||
| @@ -349,13 +375,18 @@ class MangaInfoHeaderAdapter( | ||||
|             // Set the Favorite drawable to the correct one. | ||||
|             // Border drawable if false, filled drawable if true. | ||||
|             binding.btnFavorite.apply { | ||||
|                 icon = ContextCompat.getDrawable( | ||||
|                     context, | ||||
|                     if (isFavorite) R.drawable.ic_favorite_24dp else R.drawable.ic_favorite_border_24dp | ||||
|                 setCompoundDrawablesWithIntrinsicBounds( | ||||
|                     null, | ||||
|                     ContextCompat.getDrawable( | ||||
|                         context, | ||||
|                         if (isFavorite) R.drawable.ic_favorite_24dp else R.drawable.ic_favorite_border_24dp | ||||
|                     ), | ||||
|                     null, | ||||
|                     null | ||||
|                 ) | ||||
|                 text = | ||||
|                     context.getString(if (isFavorite) R.string.in_library else R.string.add_to_library) | ||||
|                 isChecked = isFavorite | ||||
|                 isSelected = isFavorite | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user