@@ -4,7 +4,10 @@ import androidx.compose.foundation.Image
4
4
import androidx.compose.foundation.background
5
5
import androidx.compose.foundation.border
6
6
import androidx.compose.foundation.layout.Box
7
+ import androidx.compose.foundation.layout.ExperimentalLayoutApi
8
+ import androidx.compose.foundation.layout.WindowInsets
7
9
import androidx.compose.foundation.layout.fillMaxSize
10
+ import androidx.compose.foundation.layout.navigationBarsIgnoringVisibility
8
11
import androidx.compose.foundation.layout.padding
9
12
import androidx.compose.foundation.layout.requiredSize
10
13
import androidx.compose.foundation.shape.CircleShape
@@ -17,6 +20,7 @@ import androidx.compose.ui.Modifier
17
20
import androidx.compose.ui.graphics.Color
18
21
import androidx.compose.ui.layout.ContentScale
19
22
import androidx.compose.ui.platform.LocalContext
23
+ import androidx.compose.ui.platform.LocalDensity
20
24
import androidx.compose.ui.res.painterResource
21
25
import androidx.compose.ui.res.stringResource
22
26
import androidx.compose.ui.unit.dp
@@ -25,6 +29,7 @@ import androidx.lifecycle.compose.LifecycleResumeEffect
25
29
import app.grapheneos.camera.CapturedItem
26
30
import app.grapheneos.camera.ITEM_TYPE_VIDEO
27
31
import app.grapheneos.camera.R
32
+ import app.grapheneos.camera.ktx.pxToDp
28
33
29
34
import coil3.ImageLoader
30
35
@@ -34,13 +39,16 @@ import coil3.video.VideoFrameDecoder
34
39
35
40
private const val TAG = " MediaPreview"
36
41
42
+ @OptIn(ExperimentalLayoutApi ::class )
37
43
@Composable
38
44
fun MediaPreview (
39
45
capturedItem : CapturedItem ,
40
46
modifier : Modifier = Modifier
41
47
) {
42
48
val context = LocalContext .current
43
49
50
+ val density = LocalDensity .current
51
+
44
52
val imageLoader = remember(context, capturedItem) {
45
53
ImageLoader .Builder (context)
46
54
.components {
@@ -76,10 +84,17 @@ fun MediaPreview(
76
84
mediaPreviewErrorType = MediaPreviewErrorType .INFO_MESSAGE
77
85
)
78
86
87
+
88
+ density.density
89
+
79
90
Box (contentAlignment = Alignment .Center ) {
80
91
Image (
81
92
painter = imagePainter,
82
- modifier = modifier.fillMaxSize(),
93
+ modifier = modifier
94
+ .fillMaxSize()
95
+ .padding(
96
+ bottom = WindowInsets .navigationBarsIgnoringVisibility.getBottom(density).pxToDp()
97
+ ),
83
98
contentScale = ContentScale .Fit ,
84
99
contentDescription = stringResource(R .string.preview)
85
100
)
0 commit comments