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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user