Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

617 - Update the drop down behavior #639

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
)
}
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ 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))
- \[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

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
* <a href="https://system.design.orange.com/0c1af118d/p/07a69b-menus/b/862cbb" class="external" target="_blank">ODS menus</a>.
Expand Down Expand Up @@ -63,7 +64,7 @@ fun OdsDropdownMenu(
modifier = modifier.background(OdsTheme.colors.surface),
offset = offset,
properties = properties,
content = { items.forEach { it.Content() } }
content = { items.forEach { it.Content(onDismissRequest) } }
)
}

Expand Down Expand Up @@ -152,18 +153,33 @@ 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,
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()
}
Expand Down