From 3817fe63a1a680ced47299dc415f93cdfd242330 Mon Sep 17 00:00:00 2001 From: Florent Maitre Date: Thu, 21 Sep 2023 17:17:06 +0200 Subject: [PATCH 1/2] [#617] Fix a bug where OdsDropdownMenu was not dismissed on user click --- changelog.md | 4 ++++ .../compose/component/menu/OdsDropdownMenu.kt | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 07d4a5fc1..7de033927 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - \[Lib\] Update `OdsHorizontalCard`, `OdsSmallCard`, `OdsVerticalHeaderFirstCard` and `OdsVerticalImageFirstCard` APIs ([#597](https://github.com/Orange-OpenSource/ods-android/issues/597)) +### Fixed + +- \[Lib\] Fix a bug where `OdsDropdownMenu` was not dismissed on user click ([#617](https://github.com/Orange-OpenSource/ods-android/issues/617)) + ## [0.15.0](https://github.com/Orange-OpenSource/ods-android/compare/0.14.0...0.15.0) - 2023-09-12 ### Added diff --git a/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt b/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt index bc3153347..c69d2702e 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt @@ -63,7 +63,7 @@ fun OdsDropdownMenu( modifier = modifier.background(OdsTheme.colors.surface), offset = offset, properties = properties, - content = { items.forEach { it.Content() } } + content = { items.forEach { it.Content(onDismissRequest) } } ) } @@ -152,9 +152,23 @@ class OdsDropdownMenuItem private constructor( onClick: () -> Unit ) : this(text, icon as Any?, enabled, divider, onClick) + private var onDismissRequest: () -> Unit = {} + + @Composable + internal fun Content(onDismissRequest: () -> Unit) { + this.onDismissRequest = onDismissRequest + Content() + } + @Composable override fun Content(modifier: Modifier) { - DropdownMenuItem(onClick = onClick, enabled = enabled) { + DropdownMenuItem( + onClick = { + onClick() + onDismissRequest() + }, + enabled = enabled + ) { icon?.let { OdsIcon( graphicsObject = icon, From bcff3df7863c29151bd0a1cae0ab7eca12319e44 Mon Sep 17 00:00:00 2001 From: Florent Maitre Date: Thu, 21 Sep 2023 17:20:21 +0200 Subject: [PATCH 2/2] [#617] Fix disabled color of text and icon in OdsDropdownMenu --- .../com/orange/ods/app/ui/components/menus/MenuDropdown.kt | 1 + changelog.md | 1 + .../com/orange/ods/compose/component/menu/OdsDropdownMenu.kt | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/orange/ods/app/ui/components/menus/MenuDropdown.kt b/app/src/main/java/com/orange/ods/app/ui/components/menus/MenuDropdown.kt index d039e322e..e902fcee3 100644 --- a/app/src/main/java/com/orange/ods/app/ui/components/menus/MenuDropdown.kt +++ b/app/src/main/java/com/orange/ods/app/ui/components/menus/MenuDropdown.kt @@ -101,6 +101,7 @@ fun MenuDropdown() { text = recipe.title, icon = if (hasIcons && recipe.iconResId != null) painterResource(id = recipe.iconResId) else null, divider = hasDividerExample && index == dividerIndex, + enabled = index != MenuDropdownCustomizationState.MenuItemCount - 2, onClick = { clickOnElement(context, recipe.title) } ) } diff --git a/changelog.md b/changelog.md index 7de033927..7d0e85caa 100644 --- a/changelog.md +++ b/changelog.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - \[Lib\] Fix a bug where `OdsDropdownMenu` was not dismissed on user click ([#617](https://github.com/Orange-OpenSource/ods-android/issues/617)) +- \[Lib\] Fix disabled color of text and icon in `OdsDropdownMenu` ([#617](https://github.com/Orange-OpenSource/ods-android/issues/617)) ## [0.15.0](https://github.com/Orange-OpenSource/ods-android/compare/0.14.0...0.15.0) - 2023-09-12 diff --git a/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt b/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt index c69d2702e..bc8017671 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt @@ -33,6 +33,7 @@ import com.orange.ods.compose.component.icon.OdsIcon import com.orange.ods.compose.component.utilities.Preview import com.orange.ods.compose.component.utilities.UiModePreviews import com.orange.ods.compose.theme.OdsTheme +import com.orange.ods.compose.utilities.extension.enable /** * ODS menus. @@ -174,10 +175,11 @@ class OdsDropdownMenuItem private constructor( graphicsObject = icon, contentDescription = "", tint = OdsTheme.colors.onSurface, + enabled = enabled, modifier = Modifier.padding(end = dimensionResource(id = R.dimen.spacing_m)), ) } - Text(text = text, style = OdsTheme.typography.body1, color = OdsTheme.colors.onSurface) + Text(text = text, style = OdsTheme.typography.body1, color = OdsTheme.colors.onSurface.enable(enabled = enabled)) } if (divider) OdsDivider() }