[core][ui] add matchContents support to jetpack-compose#41553
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
The Pull Request introduced fingerprint changes against the base commit: 8c3eb21 Fingerprint diff[
{
"op": "changed",
"beforeSource": {
"type": "dir",
"filePath": "../../packages/expo-modules-core",
"reasons": [
"expoAutolinkingIos",
"expoAutolinkingAndroid",
"expoAutolinkingIos"
],
"hash": "afd37a8c3be40784eded2300155c1f20fdee279d"
},
"afterSource": {
"type": "dir",
"filePath": "../../packages/expo-modules-core",
"reasons": [
"expoAutolinkingIos",
"expoAutolinkingAndroid",
"expoAutolinkingIos"
],
"hash": "21de5fd9788af15123b136b66ca0b84111bce239"
}
},
{
"op": "changed",
"beforeSource": {
"type": "dir",
"filePath": "../../packages/expo-ui/android",
"reasons": [
"expoAutolinkingAndroid"
],
"hash": "f4beff0c1eca98c0a1e5f89a64c89f58d40c3d8a"
},
"afterSource": {
"type": "dir",
"filePath": "../../packages/expo-ui/android",
"reasons": [
"expoAutolinkingAndroid"
],
"hash": "95b52132157464d4e3bfcc5da03b72fd4599928e"
}
}
]Generated by PR labeler 🤖 |
|
Subscribed to pull request
Generated by CodeMention |
| if (child is ComposeView) { | ||
| val offsetX = paddingLeft | ||
| val offsetY = paddingRight | ||
| child.layout(offsetX, offsetY, offsetX + width, offsetY + height) |
There was a problem hiding this comment.
| child.layout(offsetX, offsetY, offsetX + width, offsetY + height) | |
| child.layout(left, top, right, bottom) |
Can't we just pass data from onLayout to the children?
Also, will this work for more than one child?
There was a problem hiding this comment.
Can't we just pass data from onLayout to the children?
that won't work. because the left/top/right/bottom from onLayout is the relative position for the ExpoComposeView to its parent. however, we need to layout the child with the relative position from child to the ExpoComposeView.
Also, will this work for more than one child?
no, i don't expect there were multiple ComposeView in its children. currently we add the ComposeView at
if there were multiple ComposeView, possibly some turbo module has direct ComposeView inserted as child in JSX. do you think if that's something we should supported? if so, we may need to keep our ComposeView reference or having tag for indication.
|
Hi @Kudo! I noticed in your test plan that some screens are still breaking due to I've been working on a follow-up change that addresses this by:
This way, all sizing is handled by Host's For example, instead of: // Old: Component handles its own sizing
class SwitchView(...) : ExpoComposeView<SwitchProps>(...) {
@Composable
override fun ComposableScope.Content() {
AutoSizingComposable(shadowNodeProxy, ...) {
Switch(...)
}
}
}It becomes: // New: DSL pattern, Host handles sizing
View("SwitchView", events = { Events("onValueChange") }) { props: SwitchProps ->
val onValueChange by remember { EventDispatcher<ValueChangeEvent>() }
SwitchContent(props) { onValueChange(it) }
}I'll submit a separate PR with these changes that builds on top of this PR's |
|
@kimchi-developer for AutosizingCompable, there's the other pr for it: #41595. does it align what you had in mind? |
|
@Kudo Yes, PR #41595 aligns exactly with what we had in mind! Moving In our PR #41622, we did the same thing but also included a DSL refactoring - converting class-based Question: Would you like us to:
Happy to go either way - just let us know what works best for the expo-ui roadmap! |
|
@kimchi-developer yes, let's keep your refactoring. let me merge my prs first so that you can rebase #41622 onto latest main and keep pure refactoring work in #41622. |
|
@lukmccall going to merge this beforehand. if there's any further comments, please let me know and i'll follow up in a separate pr |
--------- Co-authored-by: Łukasz Kosmaty <kosmatylukasz@gmail.com>
3f745b1 to
8c3eb21
Compare
faef212 to
831d4c3
Compare
# Why add `matchContents` support for jetpack-compose Host as swift-ui close ENG-18108 # How - pass matchContents from js to native as swift-ui - call `setStyleSize` as swift-ui - add `onLayoutContent` callback as swift-ui - use `Modifier.onSizeChanged` to listen for size changed - when matchContents is true, use wrap_content layout and MeasureSpec.UNSPECIFIED to allow ComposeView exceeds its parent HostView - fix a bug where after `setStyleSize` layout change, the ComposeView doesn't stick position with HostView
# Why add `matchContents` support for jetpack-compose Host as swift-ui close ENG-18108 # How - pass matchContents from js to native as swift-ui - call `setStyleSize` as swift-ui - add `onLayoutContent` callback as swift-ui - use `Modifier.onSizeChanged` to listen for size changed - when matchContents is true, use wrap_content layout and MeasureSpec.UNSPECIFIED to allow ComposeView exceeds its parent HostView - fix a bug where after `setStyleSize` layout change, the ComposeView doesn't stick position with HostView

Why
add
matchContentssupport for jetpack-compose Host as swift-uiclose ENG-18108
How
setStyleSizeas swift-uionLayoutContentcallback as swift-uiModifier.onSizeChangedto listen for size changedsetStyleSizelayout change, the ComposeView doesn't stick position with HostViewTest Plan
Checklist
changelog.mdentry and rebuilt the package sources according to this short guidenpx expo prebuild& EAS Build (eg: updated a module plugin).