Skip to content

Commit

Permalink
Fix Tablet UI quickly before release!
Browse files Browse the repository at this point in the history
  • Loading branch information
CraftWorksMC committed Sep 12, 2024
1 parent b783bfe commit b95b7d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 4 additions & 5 deletions app/src/main/java/com/craftworks/music/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import androidx.compose.material3.NavigationRailItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SheetState
import androidx.compose.material3.SheetValue
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
Expand Down Expand Up @@ -107,7 +106,6 @@ class MainActivity : ComponentActivity() {
),
snackbarHostState = SnackbarHostState()
)
val snackbarHostState = SnackbarHostState()

setContent {
MusicPlayerTheme {
Expand All @@ -122,7 +120,6 @@ class MainActivity : ComponentActivity() {
println("Recomposing EVERYTHING!!!!! VERY BAD")

Scaffold(
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
bottomBar = {
AnimatedBottomNavBar(navController, scaffoldState)
}
Expand All @@ -131,7 +128,8 @@ class MainActivity : ComponentActivity() {
Log.d("RECOMPOSITION", "Recomposing scaffold!")

// No BottomSheetScaffold for Android TV
if (LocalConfiguration.current.uiMode and Configuration.UI_MODE_TYPE_MASK != Configuration.UI_MODE_TYPE_TELEVISION) {
if ((LocalConfiguration.current.uiMode and Configuration.UI_MODE_TYPE_MASK != Configuration.UI_MODE_TYPE_TELEVISION) &&
LocalConfiguration.current.orientation == Configuration.ORIENTATION_PORTRAIT) {
BottomSheetScaffold(
sheetContainerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(
3.dp
Expand Down Expand Up @@ -296,8 +294,9 @@ fun AnimatedBottomNavBar(
} else {
NavigationRail {
val uiMode = LocalConfiguration.current.uiMode and Configuration.UI_MODE_TYPE_MASK
val orientation = LocalConfiguration.current.orientation
LaunchedEffect(orderedNavItems) {
if (orderedNavItems.firstOrNull { it.screenRoute == "playing_tv_screen" } == null && uiMode == Configuration.UI_MODE_TYPE_TELEVISION) {
if (orderedNavItems.firstOrNull { it.screenRoute == "playing_tv_screen" } == null && (uiMode == Configuration.UI_MODE_TYPE_TELEVISION || orientation == Configuration.ORIENTATION_LANDSCAPE)) {

val updatedItems = orderedNavItems.toMutableList()
updatedItems.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ fun NowPlayingContent(
// }
// }

when (LocalConfiguration.current.uiMode and Configuration.UI_MODE_TYPE_MASK){
Configuration.UI_MODE_TYPE_TELEVISION -> NowPlayingTV(mediaController, navHostController)
else -> NowPlayingPortrait(mediaController, navHostController)
if ((LocalConfiguration.current.uiMode and Configuration.UI_MODE_TYPE_MASK == Configuration.UI_MODE_TYPE_TELEVISION) ||
LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE){
NowPlayingTV(mediaController, navHostController)
}
else NowPlayingPortrait(mediaController, navHostController)
}

@Composable
Expand Down

0 comments on commit b95b7d1

Please sign in to comment.