Fixed window insets

This commit is contained in:
himalia416
2025-08-04 13:02:51 +02:00
parent 4daf549034
commit e221b2cee2
2 changed files with 5 additions and 18 deletions

View File

@@ -5,13 +5,11 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.displayCutout
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.union
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
@@ -47,7 +45,8 @@ internal fun HomeView() {
val onEvent: (UiEvent) -> Unit = { viewModel.onClickEvent(it) }
Scaffold(
contentWindowInsets = WindowInsets(0, 0, 0, 0),
contentWindowInsets = WindowInsets.displayCutout
.only(WindowInsetsSides.Horizontal),
topBar = {
NordicAppBar(
title = { Text(stringResource(id = R.string.app_name)) },
@@ -74,18 +73,11 @@ internal fun HomeView() {
}
}
) { paddingValues ->
// Get notch padding for devices with a display cutout (notch)
val notchPadding = WindowInsets.displayCutout
.union(WindowInsets(left = 8.dp, right = 8.dp, top = 8.dp, bottom = 8.dp))
.only(WindowInsetsSides.Horizontal)
.asPaddingValues()
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
.padding(paddingValues),
contentPadding = notchPadding,
verticalArrangement = Arrangement.spacedBy(16.dp),
) {
item {

View File

@@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.displayCutout
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.imePadding
@@ -47,9 +46,9 @@ import no.nordicsemi.android.toolbox.profile.view.rscs.RSCSScreen
import no.nordicsemi.android.toolbox.profile.view.throughput.ThroughputScreen
import no.nordicsemi.android.toolbox.profile.view.uart.UARTScreen
import no.nordicsemi.android.toolbox.profile.viewmodel.ConnectionEvent
import no.nordicsemi.android.toolbox.profile.viewmodel.ProfileViewModel
import no.nordicsemi.android.toolbox.profile.viewmodel.DeviceConnectionState
import no.nordicsemi.android.toolbox.profile.viewmodel.DeviceData
import no.nordicsemi.android.toolbox.profile.viewmodel.ProfileViewModel
import no.nordicsemi.android.ui.view.internal.DeviceConnectingView
import no.nordicsemi.android.ui.view.internal.DisconnectReason
import no.nordicsemi.android.ui.view.internal.LoadingView
@@ -65,6 +64,8 @@ internal fun ProfileScreen() {
}
Scaffold(
contentWindowInsets = WindowInsets.displayCutout
.only(WindowInsetsSides.Horizontal),
topBar = {
ProfileAppBar(
deviceName = when (val state = deviceDataState) {
@@ -83,11 +84,6 @@ internal fun ProfileScreen() {
)
},
) { paddingValues ->
// Get notch padding for devices with a display cutout (notch)
val notchPadding = WindowInsets.displayCutout
.only(WindowInsetsSides.Horizontal)
.asPaddingValues()
RequireBluetooth {
RequireLocation {
RequestNotificationPermission {
@@ -96,7 +92,6 @@ internal fun ProfileScreen() {
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
.padding(notchPadding)
.verticalScroll(rememberScrollState())
.imePadding(),
horizontalAlignment = Alignment.CenterHorizontally,