Skip to content

Commit da42f73

Browse files
committed
Update navigation bar background
1 parent 55bb938 commit da42f73

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

scaffold/src/commonMain/kotlin/com/tunjid/heron/scaffold/scaffold/PaneNavigation.kt

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import androidx.compose.animation.BoundsTransform
2121
import androidx.compose.animation.EnterTransition
2222
import androidx.compose.animation.ExitTransition
2323
import androidx.compose.animation.animateBounds
24+
import androidx.compose.animation.core.animateDpAsState
2425
import androidx.compose.animation.core.snap
2526
import androidx.compose.animation.slideInHorizontally
2627
import androidx.compose.animation.slideInVertically
@@ -31,6 +32,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
3132
import androidx.compose.foundation.layout.height
3233
import androidx.compose.foundation.layout.navigationBarsPadding
3334
import androidx.compose.foundation.layout.size
35+
import androidx.compose.foundation.shape.RoundedCornerShape
3436
import androidx.compose.material3.Badge
3537
import androidx.compose.material3.BadgedBox
3638
import androidx.compose.material3.BottomAppBarDefaults
@@ -42,8 +44,10 @@ import androidx.compose.material3.Surface
4244
import androidx.compose.material3.Text
4345
import androidx.compose.material3.contentColorFor
4446
import androidx.compose.runtime.Composable
47+
import androidx.compose.runtime.getValue
4548
import androidx.compose.ui.Alignment
4649
import androidx.compose.ui.Modifier
50+
import androidx.compose.ui.graphics.Shape
4751
import androidx.compose.ui.layout.LookaheadScope
4852
import androidx.compose.ui.unit.dp
4953
import com.tunjid.heron.ui.UiTokens
@@ -125,8 +129,9 @@ internal fun AppState.PaneNavigationBar(
125129
modifier = modifier
126130
.fillMaxWidth()
127131
.animateBounds(lookaheadScope = this@LookaheadScope),
128-
color = BottomAppBarDefaults.containerColor,
132+
color = BottomAppBarDefaults.containerColor.copy(alpha = BackgroundAlpha),
129133
contentColor = contentColorFor(BottomAppBarDefaults.containerColor),
134+
shape = navigationBarShape(prefersCompactBottomNav),
130135
) {
131136
Row(
132137
modifier = Modifier
@@ -225,9 +230,28 @@ fun Modifier.bottomNavigationSharedBounds(
225230
}
226231
}
227232

233+
@Composable
234+
fun navigationBarShape(
235+
prefersCompactBottomNav: Boolean,
236+
): Shape {
237+
val topCornerSize by animateDpAsState(
238+
if (prefersCompactBottomNav) CompactCornerSize else RegularCornerSize,
239+
)
240+
241+
return RoundedCornerShape(
242+
topStart = topCornerSize,
243+
topEnd = topCornerSize,
244+
)
245+
}
246+
228247
private data object NavigationBarSharedElementKey
229248
private data object NavigationRailSharedElementKey
230249

250+
private val CompactCornerSize = 0.dp
251+
private val RegularCornerSize = 16.dp
252+
231253
private const val MaxBadgeCount = 100L
232254

255+
private const val BackgroundAlpha = 0.98f
256+
233257
private val NavigationRailBoundsTransform = BoundsTransform { _, _ -> snap() }

0 commit comments

Comments
 (0)