5
5
package at.bitfire.davdroid.ui
6
6
7
7
import androidx.activity.SystemBarStyle
8
+ import androidx.activity.compose.LocalActivity
8
9
import androidx.activity.enableEdgeToEdge
9
10
import androidx.appcompat.app.AppCompatActivity
10
11
import androidx.compose.foundation.isSystemInDarkTheme
12
+ import androidx.compose.foundation.layout.Box
13
+ import androidx.compose.foundation.layout.WindowInsets
14
+ import androidx.compose.foundation.layout.safeDrawing
15
+ import androidx.compose.foundation.layout.windowInsetsPadding
11
16
import androidx.compose.material3.MaterialTheme
12
17
import androidx.compose.runtime.Composable
13
18
import androidx.compose.runtime.CompositionLocalProvider
14
19
import androidx.compose.runtime.SideEffect
20
+ import androidx.compose.ui.Modifier
15
21
import androidx.compose.ui.graphics.toArgb
16
22
import androidx.compose.ui.platform.LocalContext
17
23
import androidx.compose.ui.platform.LocalUriHandler
@@ -22,13 +28,14 @@ import at.bitfire.davdroid.ui.composable.SafeAndroidUriHandler
22
28
@Composable
23
29
fun AppTheme (
24
30
darkTheme : Boolean = isSystemInDarkTheme(),
31
+ windowInsets : WindowInsets = WindowInsets .safeDrawing,
25
32
content : @Composable () -> Unit
26
33
) {
27
- val view = LocalView .current
34
+ val activity = LocalActivity .current
28
35
SideEffect {
29
36
// If applicable, call Activity.enableEdgeToEdge to enable edge-to-edge layout on Android <15, too.
30
37
// When we have moved everything into one Activity with Compose navigation, we can call it there instead.
31
- (view.context as ? AppCompatActivity )?.enableEdgeToEdge(
38
+ (activity as ? AppCompatActivity )?.enableEdgeToEdge(
32
39
navigationBarStyle = SystemBarStyle .auto(
33
40
lightScrim = M3ColorScheme .lightScheme.scrim.toArgb(),
34
41
darkScrim = M3ColorScheme .darkScheme.scrim.toArgb()
@@ -44,11 +51,15 @@ fun AppTheme(
44
51
M3ColorScheme .lightScheme
45
52
else
46
53
M3ColorScheme .darkScheme,
47
- content = content
48
- )
54
+ ) {
55
+ Box (Modifier .windowInsetsPadding(windowInsets)) {
56
+ content()
57
+ }
58
+ }
49
59
}
50
60
51
61
// Track if the app is in the foreground
62
+ val view = LocalView .current
52
63
LifecycleResumeEffect (view) {
53
64
ForegroundTracker .onResume()
54
65
onPauseOrDispose {
0 commit comments