Skip to content

Commit

Permalink
General improvements include background dropdown background vfsfitvnm…
Browse files Browse the repository at this point in the history
  • Loading branch information
fast4x committed Apr 20, 2024
1 parent 6747312 commit eae32a3
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 316 deletions.
169 changes: 3 additions & 166 deletions app/src/main/kotlin/it/fast4x/rimusic/ui/components/Scaffold.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import it.fast4x.rimusic.enums.NavigationBarPosition
import it.fast4x.rimusic.enums.UiType
import it.fast4x.rimusic.ui.components.NavigationRail
import it.fast4x.rimusic.ui.components.ScaffoldTB
import it.fast4x.rimusic.ui.components.themed.appBar
import it.fast4x.rimusic.ui.styling.LocalAppearance
import it.fast4x.rimusic.ui.styling.favoritesIcon
import it.fast4x.rimusic.utils.UiTypeKey
Expand Down Expand Up @@ -139,178 +140,14 @@ fun Scaffold(
Modifier.nestedScroll(scrollBehavior.nestedScrollConnection)
else Modifier

var expanded by remember { mutableStateOf(false) }
//var expanded by remember { mutableStateOf(false) }

androidx.compose.material3.Scaffold(
modifier = customModifier,
containerColor = colorPalette.background0,
topBar = {
if(uiType == UiType.RiMusic) {
TopAppBar(
navigationIcon = {
//val currentRoute = navController.currentBackStackEntry?.destination?.route
//println("navController current destination and route ${navController.currentDestination} $currentRoute")
if (getCurrentRoute(navController) != "home")
IconButton(
onClick = {
if (navController.currentBackStackEntry?.lifecycle?.currentState == Lifecycle.State.RESUMED)
navController.popBackStack()
}
) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.chevron_back),
tint = colorPalette.favoritesIcon,
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}
},
title = {
Row(
horizontalArrangement = Arrangement.spacedBy(5.dp),
verticalAlignment = Alignment.CenterVertically
) {
Image(
painter = painterResource(R.drawable.app_icon),
colorFilter = ColorFilter.tint(colorPalette.favoritesIcon),
contentDescription = null,
modifier = Modifier
.size(36.dp)
.clickable {
//onHomeClick()
navController.navigate(NavRoutes.home.name)
}
)
BasicText(
text = "Music",
style = TextStyle(
fontSize = typography.xxl.semiBold.fontSize,
fontWeight = typography.xxxl.semiBold.fontWeight,
color = colorPalette.text
),
modifier = Modifier
.clickable {
//onHomeClick()
navController.navigate(NavRoutes.home.name)
}
)
}
},
actions = {
//if (showTopActions == true) {
IconButton(
onClick = {
//if (onSearchClick != null) {
//onSearchClick()
navController.navigate(NavRoutes.search.name)
//}
}
) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.search),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}
IconButton(onClick = { expanded = !expanded }) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.burger),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}

DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
modifier = Modifier.background(colorPalette.background0)
) {
DropdownMenuItem(
colors = menuItemColors(),
text = { Text(stringResource(R.string.history)) },
leadingIcon = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.history),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
},
onClick = {
expanded = false
//if (onHistoryClick != null) {
//onHistoryClick()
navController.navigate(NavRoutes.history.name)
//}
}
)
DropdownMenuItem(
colors = menuItemColors(),
text = { Text(stringResource(R.string.statistics)) },
leadingIcon = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.stats_chart),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
},
onClick = {
expanded = false
//if (onStatisticsClick != null) {
//onStatisticsClick()
navController.navigate(NavRoutes.statistics.name)
//}
}
)
HorizontalDivider()
DropdownMenuItem(
colors = menuItemColors(),
text = { Text("Settings") },
leadingIcon = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.settings),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
},
onClick = {
expanded = false
//if (onSettingsClick != null) {
//onSettingsClick()
navController.navigate(NavRoutes.settings.name)
//}
}
)
}

/*
IconButton(onClick = { }) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.stats_chart),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}
if (onSettingsClick != null) {
IconButton(onClick = onSettingsClick) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.settings),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}
}
*/
//}
},
scrollBehavior = scrollBehavior,
colors = TopAppBarColors(
containerColor = colorPalette.background0,
titleContentColor = colorPalette.text,
scrolledContainerColor = colorPalette.background0,
navigationIconContentColor = colorPalette.background0,
actionIconContentColor = colorPalette.text
)
)
appBar(navController)
}
},

Expand Down
154 changes: 4 additions & 150 deletions app/src/main/kotlin/it/fast4x/rimusic/ui/components/ScaffoldTB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import androidx.navigation.NavGraph.Companion.findStartDestination
import it.fast4x.rimusic.R
import it.fast4x.rimusic.enums.NavRoutes
import it.fast4x.rimusic.enums.NavigationBarPosition
import it.fast4x.rimusic.ui.components.themed.appBar
import it.fast4x.rimusic.ui.styling.LocalAppearance
import it.fast4x.rimusic.ui.styling.favoritesIcon
import it.fast4x.rimusic.utils.getCurrentRoute
Expand Down Expand Up @@ -118,10 +119,10 @@ fun ScaffoldTB(
)
}

val topPadding = if (navigationBarPosition == NavigationBarPosition.Top) 60.dp else 10.dp
//val topPadding = if (navigationBarPosition == NavigationBarPosition.Top) 60.dp else 10.dp
//val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
var expanded by remember { mutableStateOf(false) }
//var expanded by remember { mutableStateOf(false) }

androidx.compose.material3.Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
Expand All @@ -130,154 +131,7 @@ fun ScaffoldTB(
Column(
modifier = Modifier.fillMaxWidth()
) {
TopAppBar(
navigationIcon = {
//val currentRoute = navController.currentBackStackEntry?.destination?.route
//println("navController current destination and route ${navController.currentDestination} $currentRoute")
if (getCurrentRoute(navController) != "home")
IconButton(
onClick = {
if (navController.currentBackStackEntry?.lifecycle?.currentState == Lifecycle.State.RESUMED)
navController.popBackStack()
}
) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.chevron_back),
tint = colorPalette.favoritesIcon,
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}
},
title = {
Row(
horizontalArrangement = Arrangement.spacedBy(5.dp),
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth()
) {
Image(
painter = painterResource(R.drawable.app_icon),
colorFilter = ColorFilter.tint(colorPalette.favoritesIcon),
contentDescription = null,
modifier = Modifier
.size(36.dp)
.clickable {
//onHomeClick()
navController.navigate(NavRoutes.home.name)
}
)
BasicText(
text = "Music",
style = TextStyle(
fontSize = typography.xxl.semiBold.fontSize,
fontWeight = typography.xxxl.semiBold.fontWeight,
color = colorPalette.text
),
modifier = Modifier
.clickable {
//onHomeClick()
navController.navigate(NavRoutes.home.name)
}
)
}
},
actions = {
//if (showTopActions == true) {
IconButton(
onClick = {
//if (onSearchClick != null) {
//onSearchClick()
navController.navigate(NavRoutes.search.name)
//}
}
) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.search),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}
IconButton(onClick = { expanded = !expanded }) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.burger),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
}

DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false },
modifier = Modifier.background(colorPalette.background0)
) {
DropdownMenuItem(
colors = menuItemColors(),
text = { Text(stringResource(R.string.history)) },
leadingIcon = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.history),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
},
onClick = {
expanded = false
//if (onHistoryClick != null) {
//onHistoryClick()
navController.navigate(NavRoutes.history.name)
//}
}
)
DropdownMenuItem(
colors = menuItemColors(),
text = { Text(stringResource(R.string.statistics)) },
leadingIcon = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.stats_chart),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
},
onClick = {
expanded = false
//if (onStatisticsClick != null) {
//onStatisticsClick()
navController.navigate(NavRoutes.statistics.name)
//}
}
)
HorizontalDivider()
DropdownMenuItem(
colors = menuItemColors(),
text = { Text("Settings") },
leadingIcon = {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.settings),
contentDescription = null,
modifier = Modifier.size(24.dp)
)
},
onClick = {
expanded = false
//if (onSettingsClick != null) {
//onSettingsClick()
navController.navigate(NavRoutes.settings.name)
//}
}
)
}

//}
},
scrollBehavior = scrollBehavior,
colors = TopAppBarColors(
containerColor = colorPalette.background0,
titleContentColor = colorPalette.text,
scrolledContainerColor = colorPalette.background0,
navigationIconContentColor = colorPalette.background0,
actionIconContentColor = colorPalette.text
)
)
appBar(navController)

if (navigationBarPosition == NavigationBarPosition.Top)
navigationRailTB()
Expand Down

0 comments on commit eae32a3

Please sign in to comment.