@@ -41,11 +41,16 @@ import androidx.compose.foundation.layout.Arrangement
4141import androidx.compose.foundation.layout.Box
4242import androidx.compose.foundation.layout.PaddingValues
4343import androidx.compose.foundation.layout.Row
44+ import androidx.compose.foundation.layout.WindowInsets
45+ import androidx.compose.foundation.layout.defaultMinSize
4446import androidx.compose.foundation.layout.fillMaxSize
4547import androidx.compose.foundation.layout.fillMaxWidth
4648import androidx.compose.foundation.layout.height
49+ import androidx.compose.foundation.layout.navigationBars
50+ import androidx.compose.foundation.layout.navigationBarsPadding
4751import androidx.compose.foundation.layout.padding
4852import androidx.compose.foundation.layout.size
53+ import androidx.compose.foundation.layout.statusBarsPadding
4954import androidx.compose.foundation.shape.RoundedCornerShape
5055import androidx.compose.material.icons.Icons
5156import androidx.compose.material.icons.automirrored.filled.ArrowBack
@@ -87,13 +92,15 @@ import androidx.compose.ui.draw.shadow
8792import androidx.compose.ui.graphics.Color
8893import androidx.compose.ui.graphics.graphicsLayer
8994import androidx.compose.ui.platform.LocalContext
95+ import androidx.compose.ui.platform.LocalDensity
9096import androidx.compose.ui.platform.LocalInspectionMode
9197import androidx.compose.ui.res.stringResource
9298import androidx.compose.ui.semantics.contentDescription
9399import androidx.compose.ui.semantics.semantics
94100import androidx.compose.ui.text.font.FontWeight
95101import androidx.compose.ui.text.style.TextOverflow
96102import androidx.compose.ui.tooling.preview.Preview
103+ import androidx.compose.ui.unit.Dp
97104import androidx.compose.ui.unit.DpSize
98105import androidx.compose.ui.unit.dp
99106import androidx.compose.ui.unit.sp
@@ -174,16 +181,14 @@ fun LoginView() {
174181 }
175182
176183 val bottomAppBarButton = bioAuthButton ? : idpButton ? : customButton
177- val bottomAppBar = viewModel.bottomAppBar ? : bottomAppBarButton?.let { button ->
178- {
179- DefaultBottomAppBar (
180- backgroundColor = viewModel.dynamicBackgroundColor,
181- button = button,
182- loading = viewModel.loading.value,
183- showButton = ! viewModel.authFinished.value
184- )
185- }
186- } ? : {}
184+ val bottomAppBar = viewModel.bottomAppBar ? : {
185+ DefaultBottomAppBar (
186+ backgroundColor = viewModel.dynamicBackgroundColor,
187+ button = bottomAppBarButton,
188+ loading = viewModel.loading.value,
189+ showButton = ! viewModel.authFinished.value
190+ )
191+ }
187192
188193 LoginView (
189194 loginUrlData = viewModel.loginUrl,
@@ -368,21 +373,28 @@ internal fun DefaultBottomAppBar(
368373 targetValue = if (loading) LOADING_ALPHA else VISIBLE_ALPHA ,
369374 animationSpec = tween(durationMillis = SLOW_ANIMATION_MS ),
370375 )
376+ val heightModifier = if (button == null ) {
377+ Modifier .height(WindowInsets .navigationBars.getBottom(LocalDensity .current).pxToDp())
378+ } else {
379+ Modifier .defaultMinSize()
380+ }
371381
372- AnimatedVisibility (
373- visible = showButton,
374- enter = fadeIn(animationSpec = tween(durationMillis = SLOW_ANIMATION_MS )),
375- exit = fadeOut(animationSpec = tween(durationMillis = SLOW_ANIMATION_MS )),
382+ BottomAppBar (
383+ containerColor = backgroundColor.value,
384+ contentPadding = PaddingValues (0 .dp),
385+ modifier = heightModifier.graphicsLayer(alpha = alpha),
386+ windowInsets = WindowInsets .navigationBars,
376387 ) {
377- BottomAppBar (
378- containerColor = backgroundColor.value,
379- modifier = Modifier .graphicsLayer(alpha = alpha)
388+ AnimatedVisibility (
389+ visible = showButton && (button != null ),
390+ enter = fadeIn(animationSpec = tween(durationMillis = SLOW_ANIMATION_MS )),
391+ exit = fadeOut(animationSpec = tween(durationMillis = SLOW_ANIMATION_MS )),
380392 ) {
381- Row (
382- modifier = Modifier .fillMaxWidth(),
383- horizontalArrangement = Arrangement . Center ,
384- ) {
385- if (button != null ) {
393+ if (button != null ) {
394+ Row (
395+ modifier = Modifier .fillMaxWidth() ,
396+ horizontalArrangement = Arrangement . Center ,
397+ ) {
386398 val buttonShape = RoundedCornerShape (CORNER_RADIUS .dp)
387399 CompositionLocalProvider (
388400 LocalRippleConfiguration provides RippleConfiguration (color = colorScheme.onSecondary)
@@ -442,6 +454,9 @@ internal fun ToolTipWrapper(contentDescription: Int, content: @Composable (descr
442454 }
443455}
444456
457+ @Composable
458+ internal fun Int.pxToDp () = with (LocalDensity .current) { this @pxToDp.toDp() }
459+
445460// Get access to host activity from within Compose. tail rec makes this safe.
446461private tailrec fun Context.getActivity (): FragmentActivity ? = when (this ) {
447462 is FragmentActivity -> this
0 commit comments