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

Expect material3.ExposedDropdownMenuBox in common #787

Merged
merged 6 commits into from Sep 6, 2023

Conversation

MatkovIvan
Copy link
Member

@MatkovIvan MatkovIvan commented Sep 4, 2023

Proposed Changes

  • Expect ExposedDropdownMenuBox in common and implement for skiko
  • Add test usage in mpp demo app

API Changes

+@ExperimentalMaterial3Api
+@Composable
+fun ExposedDropdownMenuBox(
+    expanded: Boolean,
+    onExpandedChange: (Boolean) -> Unit,
+    modifier: Modifier = Modifier,
+    content: @Composable ExposedDropdownMenuBoxScope.() -> Unit
+)

Testing

Test: Try to use ExposedDropdownMenuBox from common or look at mpp demo

Issues Fixed

Fixes JetBrains/compose-multiplatform#2037

transformOriginState.value = calculateTransformOrigin(anchorBounds, menuBounds)
}
@Composable
actual fun ExposedDropdownMenuBoxScope.ExposedDropdownMenu(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break binary backwards-compatibility on Android; not sure how important it is, though. @igordmn can say better.

Copy link
Collaborator

@igordmn igordmn Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interface and extensions functions also differ on source level, so it is undesirable to have such difference.

It seems, we can just copy ExposedDropdownMenuBoxScope to commonMain, and make only ExposedDropdownMenuPopup expect/actual, instead of the full interface?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted expect/actual into internal function

}

@OptIn(ExperimentalComposeUiApi::class)
private fun updateHeight(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to just return the new height, but could make it harder to merge changes from upstream. Not sure what takes precedence.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would simplify it. Most probably we won't be updating updateHeight from upstream, as it depends on other pieces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplified

Base automatically changed from ivan.matkov/windowinfo-size to jb-main September 5, 2023 10:41
@MatkovIvan MatkovIvan force-pushed the ivan.matkov/common-exposed-dropdown3 branch from 6404eeb to 23c9367 Compare September 5, 2023 10:44
@MatkovIvan MatkovIvan changed the title Expect material3.ExposedDropdownMenuBox in common Expect material3.ExposedDropdownMenuBox in common Sep 6, 2023
@MatkovIvan MatkovIvan merged commit 8c89803 into jb-main Sep 6, 2023
3 checks passed
@MatkovIvan MatkovIvan deleted the ivan.matkov/common-exposed-dropdown3 branch September 6, 2023 12:10
igordmn pushed a commit that referenced this pull request Nov 15, 2023
* Expect ExposedDropdownMenuBox in common

* Add ExposedDropdownMenu3Sample

* Update to windowInfo.containerSize

* Move ExposedDropdownMenuDefaults to common

* Simplify updateHeight

* Fix import
igordmn pushed a commit that referenced this pull request Nov 16, 2023
…enuBox` in common (#787)

* Expect ExposedDropdownMenuBox in common

* Add ExposedDropdownMenu3Sample

* Update to windowInfo.containerSize

* Move ExposedDropdownMenuDefaults to common

* Simplify updateHeight

* Fix import
igordmn pushed a commit that referenced this pull request Jan 30, 2024
* Expect ExposedDropdownMenuBox in common

* Add ExposedDropdownMenu3Sample

* Update to windowInfo.containerSize

* Move ExposedDropdownMenuDefaults to common

* Simplify updateHeight

* Fix import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants