Skip to content

Commit 2fa3461

Browse files
committed
fix: nested drawer doesn't receive insets on older Android version
1 parent 9eaec50 commit 2fa3461

File tree

3 files changed

+11
-79
lines changed

3 files changed

+11
-79
lines changed

core/ui/compose/common/src/main/kotlin/net/thunderbird/core/ui/compose/common/modifier/SafeDrawingCompat.kt

Lines changed: 0 additions & 77 deletions
This file was deleted.

feature/navigation/drawer/dropdown/src/main/kotlin/net/thunderbird/feature/navigation/drawer/dropdown/DropDownDrawer.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package net.thunderbird.feature.navigation.drawer.dropdown
33
import androidx.appcompat.app.AppCompatActivity
44
import androidx.compose.ui.platform.ComposeView
55
import androidx.core.view.GravityCompat
6+
import androidx.core.view.ViewCompat
67
import androidx.drawerlayout.widget.DrawerLayout
78
import androidx.lifecycle.compose.collectAsStateWithLifecycle
89
import kotlinx.coroutines.flow.MutableStateFlow
@@ -46,6 +47,12 @@ class DropDownDrawer(
4647
init {
4748
drawer.addDrawerListener(createDrawerListener())
4849

50+
// Make insets available to the drawer's Compose content
51+
ViewCompat.setOnApplyWindowInsetsListener(drawer) { _, insets ->
52+
drawerContent.dispatchApplyWindowInsets(insets.toWindowInsets())
53+
insets
54+
}
55+
4956
drawerContent.setContent {
5057
themeProvider.WithTheme {
5158
val state = drawerState.collectAsStateWithLifecycle()

feature/navigation/drawer/dropdown/src/main/kotlin/net/thunderbird/feature/navigation/drawer/dropdown/ui/DrawerContent.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ import androidx.compose.animation.slideInVertically
66
import androidx.compose.animation.slideOutVertically
77
import androidx.compose.animation.togetherWith
88
import androidx.compose.foundation.layout.Column
9+
import androidx.compose.foundation.layout.WindowInsets
910
import androidx.compose.foundation.layout.fillMaxHeight
1011
import androidx.compose.foundation.layout.fillMaxSize
12+
import androidx.compose.foundation.layout.safeDrawing
1113
import androidx.compose.foundation.layout.width
14+
import androidx.compose.foundation.layout.windowInsetsPadding
1215
import androidx.compose.runtime.Composable
1316
import androidx.compose.ui.Modifier
1417
import androidx.compose.ui.unit.IntOffset
1518
import app.k9mail.core.ui.compose.designsystem.atom.DividerHorizontal
1619
import app.k9mail.core.ui.compose.designsystem.atom.Surface
1720
import app.k9mail.core.ui.compose.theme2.MainTheme
18-
import net.thunderbird.core.ui.compose.common.modifier.safeDrawingPaddingCompat
1921
import net.thunderbird.core.ui.compose.common.modifier.testTagAsResourceId
2022
import net.thunderbird.feature.navigation.drawer.dropdown.domain.entity.DisplayAccount
2123
import net.thunderbird.feature.navigation.drawer.dropdown.domain.entity.UnifiedDisplayAccount
@@ -49,7 +51,7 @@ internal fun DrawerContent(
4951
val selectedAccount = state.accounts.firstOrNull { it.id == state.selectedAccountId }
5052

5153
Column(
52-
modifier = Modifier.safeDrawingPaddingCompat(),
54+
modifier = Modifier.windowInsetsPadding(WindowInsets.safeDrawing),
5355
) {
5456
selectedAccount?.let {
5557
AccountView(

0 commit comments

Comments
 (0)