From 4ff99ce150fd435d4fc0f35199cc4d87fb7111e4 Mon Sep 17 00:00:00 2001 From: Pablo Pajuelo Cabezas Date: Wed, 27 Nov 2024 08:52:59 +0100 Subject: [PATCH 1/2] fix: set dropdownmenu max width to 70% of screen size --- .../java/org/dhis2/utils/customviews/MoreMenuView.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt b/app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt index b01a0607f2..0f745985b7 100644 --- a/app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt +++ b/app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt @@ -1,10 +1,13 @@ package org.dhis2.utils.customviews +import android.content.res.Resources +import androidx.compose.foundation.layout.widthIn import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.MoreVert import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.Dp import org.hisp.dhis.mobile.ui.designsystem.component.IconButton import org.hisp.dhis.mobile.ui.designsystem.component.menu.DropDownMenu import org.hisp.dhis.mobile.ui.designsystem.component.menu.MenuItemData @@ -31,6 +34,7 @@ fun MoreOptionsWithDropDownMenuButton( } DropDownMenu( + modifier = Modifier.widthIn(max = 0.7.dw), items = dropDownMenuItems, expanded = expanded, onDismissRequest = { onMenuToggle(false) }, @@ -39,3 +43,8 @@ fun MoreOptionsWithDropDownMenuButton( onItemClick(itemId) } } + +inline val Double.dw: Dp + get() = Resources.getSystem().displayMetrics.let { + Dp(value = ((this * it.widthPixels) / it.density).toFloat()) + } From 82adf9d39e04e865722e38f8607c52ea81b7821b Mon Sep 17 00:00:00 2001 From: Xavier Molloy Date: Tue, 10 Dec 2024 11:27:21 +0100 Subject: [PATCH 2/2] fix:[ANDROAPP-6579] modify offset for dropdown menu in teiDashboard --- .../org/dhis2/utils/customviews/MoreMenuView.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt b/app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt index 0f745985b7..dbcc3cd84f 100644 --- a/app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt +++ b/app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt @@ -8,9 +8,11 @@ import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.DpOffset import org.hisp.dhis.mobile.ui.designsystem.component.IconButton import org.hisp.dhis.mobile.ui.designsystem.component.menu.DropDownMenu import org.hisp.dhis.mobile.ui.designsystem.component.menu.MenuItemData +import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor @Composable @@ -32,16 +34,17 @@ fun MoreOptionsWithDropDownMenuButton( ) { onMenuToggle(!expanded) } - DropDownMenu( modifier = Modifier.widthIn(max = 0.7.dw), items = dropDownMenuItems, expanded = expanded, + offset = DpOffset(x = -Spacing.Spacing16, y = Spacing.Spacing0), onDismissRequest = { onMenuToggle(false) }, - ) { itemId -> - onMenuToggle(false) - onItemClick(itemId) - } + onItemClick = { itemId -> + onMenuToggle(false) + onItemClick(itemId) + }, + ) } inline val Double.dw: Dp