@@ -83,6 +83,8 @@ import dev.dimension.flare.R
8383import dev.dimension.flare.data.model.BottomBarBehavior
8484import dev.dimension.flare.data.model.BottomBarStyle
8585import dev.dimension.flare.data.model.LocalAppearanceSettings
86+ import soup.compose.material.motion.animation.materialElevationScaleIn
87+ import soup.compose.material.motion.animation.materialElevationScaleOut
8688
8789val LocalBottomBarHeight = androidx.compose.runtime.staticCompositionLocalOf<Dp > { 0 .dp }
8890val LocalBottomBarShowing = androidx.compose.runtime.staticCompositionLocalOf<Boolean > { false }
@@ -351,12 +353,47 @@ fun NavigationSuiteScaffold2(
351353 ) {
352354 content.invoke()
353355 }
356+
357+ val isFloating =
358+ remember(bottomBarState) {
359+ when (bottomBarState) {
360+ BottomBarState .FloatingNormal -> true
361+ BottomBarState .FloatingMinimized -> true
362+ BottomBarState .FloatingHidden -> true
363+ BottomBarState .ClassicNormal -> false
364+ BottomBarState .ClassicHidden -> false
365+ }
366+ }
367+ val isHidden =
368+ remember(bottomBarState) {
369+ when (bottomBarState) {
370+ BottomBarState .FloatingNormal -> false
371+ BottomBarState .FloatingMinimized -> false
372+ BottomBarState .FloatingHidden -> true
373+ BottomBarState .ClassicNormal -> false
374+ BottomBarState .ClassicHidden -> true
375+ }
376+ }
354377 Column (
355378 modifier =
356379 Modifier
357380 .fillMaxWidth()
358381 .align(Alignment .BottomCenter )
359- .animateContentSize(),
382+ .windowInsetsPadding(
383+ WindowInsets .systemBars.only(
384+ WindowInsetsSides .Horizontal + WindowInsetsSides .Bottom ,
385+ ),
386+ ).let {
387+ if (! isHidden) {
388+ if (isFloating) {
389+ it.padding(bottom = 56 .dp)
390+ } else {
391+ it.padding(bottom = 80 .dp, end = 56 .dp)
392+ }
393+ } else {
394+ it
395+ }
396+ }.animateContentSize(),
360397 horizontalAlignment = Alignment .CenterHorizontally ,
361398 verticalArrangement = Arrangement .Bottom ,
362399 ) {
@@ -378,23 +415,29 @@ fun NavigationSuiteScaffold2(
378415 }
379416 },
380417 )
381- androidx.compose.animation.AnimatedVisibility (
382- layoutType == NavigationSuiteType .NavigationBar &&
383- scope.itemList.any { item -> item.selected } &&
384- (
385- bottomBarState != BottomBarState .FloatingHidden &&
386- bottomBarState != BottomBarState .ClassicHidden
387- ),
388- enter = slideInVertically { it },
389- exit = slideOutVertically { it },
390- ) {
391- Box (
418+ }
419+
420+ androidx.compose.animation.AnimatedVisibility (
421+ layoutType == NavigationSuiteType .NavigationBar &&
422+ scope.itemList.any { item -> item.selected } &&
423+ (
424+ bottomBarState != BottomBarState .FloatingHidden &&
425+ bottomBarState != BottomBarState .ClassicHidden
426+ ),
427+ enter = slideInVertically { it },
428+ exit = slideOutVertically { it },
429+ modifier =
430+ Modifier
431+ .fillMaxWidth()
432+ .align(Alignment .BottomCenter ),
433+ ) {
434+ Box (
392435// horizontalArrangement = Arrangement.SpaceBetween,
393436// verticalAlignment = Alignment.Bottom,
394- contentAlignment = Alignment .BottomCenter ,
395- modifier =
396- Modifier
397- .fillMaxWidth(),
437+ // contentAlignment = Alignment.BottomCenter,
438+ modifier =
439+ Modifier
440+ .fillMaxWidth(),
398441// .windowInsetsPadding(
399442// WindowInsets.systemBars.only(
400443// WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom,
@@ -404,43 +447,51 @@ fun NavigationSuiteScaffold2(
404447// horizontal = 16.dp,
405448// vertical = 8.dp,
406449// ),
450+ ) {
451+ SharedTransitionLayout (
452+ modifier = Modifier .align(Alignment .BottomStart ),
407453 ) {
408- SharedTransitionLayout (
409- modifier = Modifier .align(Alignment .BottomStart ),
410- ) {
454+ AnimatedContent (
455+ bottomBarState,
456+ ) { bottomBarState ->
457+ BottomBar (
458+ state = bottomBarState,
459+ provider = scope,
460+ animatedVisibilityScope = this @AnimatedContent,
461+ )
462+ }
463+ }
464+ androidx.compose.animation.AnimatedVisibility (
465+ showFab,
466+ modifier =
467+ Modifier .align(
468+ if (bottomBarStyle == BottomBarStyle .Classic ) {
469+ Alignment .BottomEnd
470+ } else {
471+ Alignment .CenterEnd
472+ },
473+ ),
474+ enter =
475+ materialElevationScaleIn(
476+ initialAlpha = 0f ,
477+ ),
478+ exit =
479+ materialElevationScaleOut(
480+ targetAlpha = 0f ,
481+ ),
482+ ) {
483+ SharedTransitionLayout {
411484 AnimatedContent (
412485 bottomBarState,
413486 ) { bottomBarState ->
414- BottomBar (
487+ BottomFab (
415488 state = bottomBarState,
416489 provider = scope,
417490 animatedVisibilityScope = this @AnimatedContent,
491+ onFabClicked = onFabClicked,
418492 )
419493 }
420494 }
421- if (showFab) {
422- SharedTransitionLayout (
423- modifier =
424- Modifier .align(
425- if (bottomBarStyle == BottomBarStyle .Classic ) {
426- Alignment .BottomEnd
427- } else {
428- Alignment .CenterEnd
429- },
430- ),
431- ) {
432- AnimatedContent (
433- bottomBarState,
434- ) { bottomBarState ->
435- BottomFab (
436- state = bottomBarState,
437- provider = scope,
438- animatedVisibilityScope = this @AnimatedContent,
439- onFabClicked = onFabClicked,
440- )
441- }
442- }
443- }
444495 }
445496 }
446497 }
0 commit comments