Skip to content

Commit

Permalink
Use same weight for HomeNavigationRail when player is active or not
Browse files Browse the repository at this point in the history
  • Loading branch information
alashow committed Dec 18, 2021
1 parent ab6b684 commit 0b367c1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/main/kotlin/tm/alashow/datmusic/ui/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal fun Home(
val bottomBarHeight = HomeBottomNavigationHeight * (if (isPlayerActive) 1.15f else 1f)
Row(Modifier.fillMaxSize()) {
if (isWideScreen)
ResizableHomeNavigationRail(isPlayerActive, selectedTab, navController)
ResizableHomeNavigationRail(selectedTab = selectedTab, navController = navController)
Scaffold(
modifier = Modifier.weight(12f),
scaffoldState = scaffoldState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ import tm.alashow.ui.theme.AppTheme
@OptIn(ExperimentalMaterialApi::class)
@Composable
internal fun RowScope.ResizableHomeNavigationRail(
isPlayerActive: Boolean,
selectedTab: RootScreen,
navController: NavHostController,
configuration: Configuration = LocalConfiguration.current,
navigationRailWeightWithPlayer: Float = 4.5f,
navigationRailWeightWithoutPlayer: Float = 3.5f,
navigationRailBaseWeight: Float = 4.5f,
navigationRailWeightMinWeight: Float = 0.9f,
viewModel: ResizableHomeNavigationRailViewModel = hiltViewModel(),
dividerDragOffset: State<Float> = rememberFlowWithLifecycle(viewModel.dragOffset).collectAsState(initial = 0f),
Expand All @@ -61,8 +59,6 @@ internal fun RowScope.ResizableHomeNavigationRail(
val dragSnapAnchors = listOf(0f, dragRange.endInclusive, dragRange.start)
var dragSnapCurrentAnchor by remember { mutableStateOf(0) }
val dividerDragOffsetWeight by derivedStateOf { (dividerDragOffset.value / screenWidth) * 12 }

val navigationRailBaseWeight = if (isPlayerActive) navigationRailWeightWithPlayer else navigationRailWeightWithoutPlayer
val navigationRailWeight = navigationRailBaseWeight + dividerDragOffsetWeight

Box(Modifier.weight(navigationRailWeight.coerceAtLeast(navigationRailWeightMinWeight))) {
Expand Down

0 comments on commit 0b367c1

Please sign in to comment.