fix: Keyboard overlaps FABs #172

This commit is contained in:
Artem Chepurnoy 2024-02-20 13:08:37 +02:00
parent 99af43928d
commit 9e30ff0ce7
No known key found for this signature in database
GPG Key ID: FAC37D0CF674043E
2 changed files with 6 additions and 31 deletions

View File

@ -14,18 +14,15 @@ import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.MutableWindowInsets
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.exclude
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.onConsumedWindowInsetsChanged
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
@ -228,13 +225,9 @@ fun WatchtowerScreen2(
scrollBehavior: TopAppBarScrollBehavior,
) {
val contentWindowInsets = scaffoldContentWindowInsets
val remainingInsets = remember { MutableWindowInsets() }
Scaffold(
modifier = modifier
.nestedScroll(scrollBehavior.nestedScrollConnection)
.onConsumedWindowInsetsChanged { consumedWindowInsets ->
remainingInsets.insets = contentWindowInsets.exclude(consumedWindowInsets)
},
.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
if (tabletUi) {
return@Scaffold
@ -261,7 +254,7 @@ fun WatchtowerScreen2(
)
},
containerColor = LocalSurfaceColor.current,
contentWindowInsets = remainingInsets,
contentWindowInsets = contentWindowInsets,
) { contentPadding ->
ContentLayout(
contentInsets = contentWindowInsets,

View File

@ -1,7 +1,6 @@
package com.artemchep.keyguard.ui
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.expandIn
import androidx.compose.animation.fadeIn
@ -15,21 +14,14 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.MutableWindowInsets
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.exclude
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.onConsumedWindowInsetsChanged
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.union
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
@ -70,8 +62,6 @@ import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.dp
import com.artemchep.keyguard.platform.leDisplayCutout
import com.artemchep.keyguard.platform.leIme
import com.artemchep.keyguard.platform.leNavigationBars
import com.artemchep.keyguard.platform.leStatusBars
import com.artemchep.keyguard.platform.leSystemBars
import com.artemchep.keyguard.res.Res
import com.artemchep.keyguard.ui.scrollbar.ColumnScrollbar
@ -123,12 +113,8 @@ fun ScaffoldLazyColumn(
}
}
val remainingInsets = remember { MutableWindowInsets() }
Scaffold(
modifier = modifier
.onConsumedWindowInsetsChanged { consumedWindowInsets ->
remainingInsets.insets = contentWindowInsets.exclude(consumedWindowInsets)
},
modifier = modifier,
topBar = topBar,
bottomBar = bottomBar,
snackbarHost = snackbarHost,
@ -148,7 +134,7 @@ fun ScaffoldLazyColumn(
floatingActionButtonPosition = floatingActionButtonPosition,
containerColor = containerColor,
contentColor = contentColor,
contentWindowInsets = remainingInsets,
contentWindowInsets = contentWindowInsets,
) { contentPadding ->
val contentPaddingWithFab = calculatePaddingWithFab(
contentPadding = contentPadding,
@ -204,12 +190,8 @@ fun ScaffoldColumn(
columnScrollState: ScrollState = rememberScrollState(),
columnContent: @Composable ColumnScope.() -> Unit,
) {
val remainingInsets = remember { MutableWindowInsets() }
Scaffold(
modifier = modifier
.onConsumedWindowInsetsChanged { consumedWindowInsets ->
remainingInsets.insets = contentWindowInsets.exclude(consumedWindowInsets)
},
modifier = modifier,
topBar = topBar,
bottomBar = bottomBar,
snackbarHost = snackbarHost,
@ -229,7 +211,7 @@ fun ScaffoldColumn(
floatingActionButtonPosition = floatingActionButtonPosition,
containerColor = containerColor,
contentColor = contentColor,
contentWindowInsets = remainingInsets,
contentWindowInsets = contentWindowInsets,
) { contentPadding ->
val contentPaddingWithFab = calculatePaddingWithFab(
contentPadding = contentPadding,