11package com.maxrave.simpmusic.ui.component
22
33import android.annotation.SuppressLint
4+ import android.net.http.SslCertificate.restoreState
5+ import android.net.http.SslCertificate.saveState
46import androidx.annotation.StringRes
57import androidx.compose.animation.AnimatedVisibility
68import androidx.compose.animation.core.spring
@@ -28,6 +30,7 @@ import androidx.compose.material.icons.filled.Search
2830import androidx.compose.material.icons.outlined.Home
2931import androidx.compose.material.icons.outlined.Search
3032import androidx.compose.material.icons.rounded.Home
33+ import androidx.compose.material.icons.rounded.LibraryMusic
3134import androidx.compose.material.icons.rounded.Search
3235import androidx.compose.material3.Button
3336import androidx.compose.material3.ButtonDefaults
@@ -52,6 +55,7 @@ import androidx.compose.ui.Alignment
5255import androidx.compose.ui.Modifier
5356import androidx.compose.ui.graphics.Color
5457import androidx.compose.ui.layout.layoutId
58+ import androidx.compose.ui.layout.onGloballyPositioned
5559import androidx.compose.ui.platform.LocalDensity
5660import androidx.compose.ui.res.stringResource
5761import androidx.compose.ui.unit.dp
@@ -60,6 +64,7 @@ import androidx.constraintlayout.compose.ConstraintSet
6064import androidx.constraintlayout.compose.Dimension
6165import androidx.constraintlayout.compose.Visibility
6266import androidx.lifecycle.compose.collectAsStateWithLifecycle
67+ import androidx.lifecycle.viewmodel.compose.viewModel
6368import androidx.navigation.NavController
6469import androidx.navigation.NavDestination.Companion.hasRoute
6570import androidx.navigation.NavDestination.Companion.hierarchy
@@ -146,9 +151,25 @@ fun LiquidGlassAppBottomNavigationBar(
146151 isExpanded = ! isInSearchDestination
147152 }
148153
149- val constraintSet by remember {
150- derivedStateOf {
154+ var updateConstraints by remember {
155+ mutableStateOf(true )
156+ }
157+
158+ var constraintSet by remember {
159+ mutableStateOf(
151160 decoupledConstraints(isShowMiniPlayer, isExpanded)
161+ )
162+ }
163+
164+ LaunchedEffect (isShowMiniPlayer, isExpanded) {
165+ constraintSet = decoupledConstraints(isShowMiniPlayer, isExpanded)
166+ updateConstraints = false
167+ }
168+
169+ LaunchedEffect (updateConstraints) {
170+ if (updateConstraints) {
171+ constraintSet = decoupledConstraints(isShowMiniPlayer, isExpanded)
172+ updateConstraints = false
152173 }
153174 }
154175
@@ -191,7 +212,9 @@ fun LiquidGlassAppBottomNavigationBar(
191212 } else {
192213 Modifier .wrapContentSize()
193214 },
194- ),
215+ ).onGloballyPositioned {
216+ updateConstraints = true
217+ },
195218 contentPadding =
196219 PaddingValues (
197220 horizontal = if (isExpanded) 4 .dp else 0 .dp,
@@ -341,15 +364,15 @@ fun LiquidGlassAppBottomNavigationBar(
341364 ) {
342365 Icon (
343366 when (selectedIndex) {
344- BottomNavScreen .Home .ordinal -> Icons .Outlined .Home
367+ BottomNavScreen .Home .ordinal -> Icons .Rounded .Home
345368 BottomNavScreen .Search .ordinal ->
346369 when (previousScreen) {
347- BottomNavScreen .Home -> Icons .Outlined .Home
348- BottomNavScreen .Library -> Icons .Filled .LibraryMusic
370+ BottomNavScreen .Home -> Icons .Rounded .Home
371+ BottomNavScreen .Library -> Icons .Rounded .LibraryMusic
349372 else -> Icons .Filled .Search
350373 }
351374
352- BottomNavScreen .Library .ordinal -> Icons .Filled .LibraryMusic
375+ BottomNavScreen .Library .ordinal -> Icons .Rounded .LibraryMusic
353376 else -> Icons .Outlined .Home
354377 },
355378 " " ,
@@ -419,7 +442,6 @@ private fun decoupledConstraints(
419442 isExpanded : Boolean ,
420443): ConstraintSet =
421444 ConstraintSet {
422- Logger .w(TAG , " decoupledConstraints: isExpanded: $isExpanded , isMiniplayerShow: $isMiniplayerShow " )
423445 val toolbar = createRefFor(" toolbar" )
424446 constrain(toolbar) {
425447 bottom.linkTo(parent.bottom)
0 commit comments