detail: add layout for small screens

Add a layout for especially small screens so that they do not have to
scroll as much.
This commit is contained in:
OxygenCobalt
2021-12-17 14:32:14 -07:00
parent 8e1da1bfc7
commit 284108678b
3 changed files with 82 additions and 5 deletions
@@ -3,23 +3,22 @@ package org.oxycblt.auxio.home
import android.content.Context
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import org.oxycblt.auxio.util.logD
class AdaptiveTabStrategy(
context: Context,
private val homeModel: HomeViewModel
) : TabLayoutMediator.TabConfigurationStrategy {
private val screenSize = context.resources.configuration.screenWidthDp
private val width = context.resources.configuration.screenWidthDp
override fun onConfigureTab(tab: TabLayout.Tab, position: Int) {
val tabMode = homeModel.tabs[position]
when {
screenSize < 370 ->
width < 370 ->
tab.setIcon(tabMode.icon)
.setContentDescription(tabMode.string)
screenSize < 600 -> tab.setText(tabMode.string)
width < 600 -> tab.setText(tabMode.string)
else ->
tab.setIcon(tabMode.icon)