Skip to content

Commit

Permalink
fix: set dropdownmenu max width to 70% of screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
Balcan authored and xavimolloy committed Dec 12, 2024
1 parent 749bfe9 commit 4ff99ce
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/src/main/java/org/dhis2/utils/customviews/MoreMenuView.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -31,6 +34,7 @@ fun <T> MoreOptionsWithDropDownMenuButton(
}

DropDownMenu(
modifier = Modifier.widthIn(max = 0.7.dw),
items = dropDownMenuItems,
expanded = expanded,
onDismissRequest = { onMenuToggle(false) },
Expand All @@ -39,3 +43,8 @@ fun <T> MoreOptionsWithDropDownMenuButton(
onItemClick(itemId)
}
}

inline val Double.dw: Dp
get() = Resources.getSystem().displayMetrics.let {
Dp(value = ((this * it.widthPixels) / it.density).toFloat())
}

0 comments on commit 4ff99ce

Please sign in to comment.