mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-11-04 08:08:55 +01:00 
			
		
		
		
	Handle toolbar title in manga details on tablets similar to on phones
This commit is contained in:
		@@ -253,6 +253,15 @@ class MangaController :
 | 
			
		||||
        // Tablet layout
 | 
			
		||||
        binding.infoRecycler?.let {
 | 
			
		||||
            it.adapter = mangaInfoAdapter
 | 
			
		||||
 | 
			
		||||
            it.scrollEvents()
 | 
			
		||||
                .onEach { updateToolbarTitleAlpha() }
 | 
			
		||||
                .launchIn(viewScope)
 | 
			
		||||
 | 
			
		||||
            // Delayed in case we need to jump to chapters
 | 
			
		||||
            it.post {
 | 
			
		||||
                updateToolbarTitleAlpha()
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        binding.chaptersRecycler?.let {
 | 
			
		||||
            it.adapter = ConcatAdapter(chaptersHeaderAdapter, chaptersAdapter)
 | 
			
		||||
@@ -284,19 +293,17 @@ class MangaController :
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private fun updateToolbarTitleAlpha(alpha: Int? = null) {
 | 
			
		||||
        if (binding.fullRecycler == null) {
 | 
			
		||||
            return
 | 
			
		||||
        }
 | 
			
		||||
        val scrolledList = binding.fullRecycler ?: binding.infoRecycler!!
 | 
			
		||||
 | 
			
		||||
        val calculatedAlpha = when {
 | 
			
		||||
            // Specific alpha provided
 | 
			
		||||
            alpha != null -> alpha
 | 
			
		||||
 | 
			
		||||
            // First item isn't in view, full opacity
 | 
			
		||||
            ((binding.fullRecycler!!.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() > 0) -> 255
 | 
			
		||||
            ((scrolledList.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() > 0) -> 255
 | 
			
		||||
 | 
			
		||||
            // Based on scroll amount when first item is in view
 | 
			
		||||
            else -> min(binding.fullRecycler!!.computeVerticalScrollOffset(), 255)
 | 
			
		||||
            else -> min(scrolledList.computeVerticalScrollOffset(), 255)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        (activity as? MainActivity)?.binding?.toolbar?.setTitleTextColor(
 | 
			
		||||
 
 | 
			
		||||
@@ -195,16 +195,10 @@ class MangaInfoHeaderAdapter(
 | 
			
		||||
         */
 | 
			
		||||
        private fun setMangaInfo(manga: Manga, source: Source?) {
 | 
			
		||||
            // Update full title TextView.
 | 
			
		||||
            with(binding.mangaFullTitle) {
 | 
			
		||||
                if (isTablet) {
 | 
			
		||||
                    isVisible = false
 | 
			
		||||
                } else {
 | 
			
		||||
                    text = if (manga.title.isBlank()) {
 | 
			
		||||
                        view.context.getString(R.string.unknown)
 | 
			
		||||
                    } else {
 | 
			
		||||
                        manga.title
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            binding.mangaFullTitle.text = if (manga.title.isBlank()) {
 | 
			
		||||
                view.context.getString(R.string.unknown)
 | 
			
		||||
            } else {
 | 
			
		||||
                manga.title
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Update author TextView.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user