From 76ac94bcc7003a07aa298c1bf9e450d3f9684cca Mon Sep 17 00:00:00 2001 From: Pablo Pajuelo Cabezas Date: Fri, 29 Nov 2024 10:58:10 +0100 Subject: [PATCH] fix: [ANDROAPP-6457] limit max height of expanded cards in maps --- .../java/org/dhis2/maps/views/MapScreen.kt | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/dhis2_android_maps/src/main/java/org/dhis2/maps/views/MapScreen.kt b/dhis2_android_maps/src/main/java/org/dhis2/maps/views/MapScreen.kt index f4401b5b89..ca390f532e 100644 --- a/dhis2_android_maps/src/main/java/org/dhis2/maps/views/MapScreen.kt +++ b/dhis2_android_maps/src/main/java/org/dhis2/maps/views/MapScreen.kt @@ -5,16 +5,23 @@ import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyItemScope import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.Icon +import androidx.compose.material3.Icon import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import org.dhis2.maps.R import org.dhis2.maps.location.LocationState @@ -34,7 +41,15 @@ fun MapScreen( onItem: @Composable LazyItemScope.(item: MapItemModel) -> Unit, ) { - Box(modifier = Modifier.fillMaxSize()) { + var pagerMaxHeight by remember { mutableStateOf(Dp.Unspecified) } + + Box( + modifier = Modifier + .fillMaxSize() + .onGloballyPositioned { + pagerMaxHeight = (it.size.height * 0.7).dp + }, + ) { map() Column( modifier = Modifier @@ -46,7 +61,8 @@ fun MapScreen( MapItemHorizontalPager( modifier = Modifier .align(Alignment.BottomCenter) - .testTag("MAP_CAROUSEL"), + .testTag("MAP_CAROUSEL") + .heightIn(max = pagerMaxHeight), state = listState, items = items, onItem = onItem,