[ui][Android] Refactor leaf components to DSL pattern#41622
Conversation
|
Subscribed to pull request
Generated by CodeMention |
0d2013b to
1b81b02
Compare
c6965b8 to
b4427b4
Compare
d753b23 to
4f287bf
Compare
Bug Fixes
|
26ecbda to
65f9767
Compare
4db34f5 to
a426080
Compare
c712cfc to
6881139
Compare
1717e2c to
bc0c34e
Compare
DSL Pattern Refactoring + Modifiers FixChanges
Architecture Decision: JSON Config Pattern for ModifiersContextexpo-ui needs to pass native view modifiers (Jetpack Compose Technical Constraints:
Decision: JSON Config PatternModifierConfig (JS) export interface ModifierConfig {
$type: string;
$scope?: string;
[key: string]: unknown;
}ModifierConfig (Android Record) data class ModifierConfig(
@Field(key = "\$type") val type: String = "",
...
) : RecordWhy JSON Config over SharedRef?
The SharedRef + ID Registry approach is deprecated. References
|
7976f13 to
7270ce2
Compare
7270ce2 to
2b7912c
Compare
aed511a to
c1fb650
Compare
c1fb650 to
f0abf6a
Compare
@aleqsio Hey! This builds on your compose modifiers work (#38630, #39155). Would appreciate your review when you have time. |
86bb3a1 to
6cc5803
Compare
- Migrate Button, Chip, IconButton, Shape, and other components to DSL pattern - Fix modifiers passing: remove __expo_shared_object_id__ mapping for JSON Config - Restore onSizeChanged in HostView for proper React Native layout integration - ContextMenu remains class-based due to positioning requirements
6cc5803 to
e4c80be
Compare
Kudo
left a comment
There was a problem hiding this comment.
such an awesome pr! thanks for having all together.
leaving some nit comments but it's generally good to me. the only question is the modifiers change. let me discuss this with team.
| /** | ||
| * The background color of the button. | ||
| */ | ||
| containerColor?: string; |
There was a problem hiding this comment.
| containerColor?: string; | |
| containerColor?: ColorValue; |
import { type ColorValue } from 'react-native';
personally prefer to have explicit ColorValue type if that's supported
| /** | ||
| * The text color of the button. | ||
| */ | ||
| contentColor?: string; |
There was a problem hiding this comment.
| contentColor?: string; | |
| contentColor?: ColorValue; |
ditto
|
|
||
| // Utility | ||
| @Field val testID: String? = null, | ||
| @Field val shape: ShapeRecord? = null, |
There was a problem hiding this comment.
currently the modifier registry is not scalable. would be good to improve that. in our mind, we also have plan to make swift-ui ModifierRegistry extensible, so that people can add their own modifiers
|
i would update expo-ui code soon and don't want to keep the pr conflict again. i'm going to merge it and will follow my comment in a separate pr. thanks again for the great work 👏 |
# Why following up #41622 and improve integration for jetpack-compose # How - [js] use ColorValue type for colors - [js] move modifiers into `@expo/ui/jetpack-compose/modifiers` as swift-ui - [core] rename `ExpoViewComposableScope` to `FunctionalComposableScope`. it's confusing between ComposableScope and ExpoViewComposableScope - [ui] introduce `ExpoUIView` DSL as swift-ui. currently it's the same as View DSL. keeping that allows us to introduce more expo-ui dedicated features. - [ui] fix broken scoped modifiers like `matchParentSize`. - [ui] make ModifierRegistry extensible. each modifier can have it's own parameter convertible (Record). - [core] add `recordFromMap` that allows Record conversion from Map.
Summary
This PR refactors Android expo-ui leaf components from class-based
ExpoComposeViewpattern to the new DSLView()pattern (introduced in #40653).Components refactored:
SwitchViewPickerViewSliderViewProgressViewChipViewDatePickerViewShapeViewAlertDialogViewCarouselViewNot refactored:
TextInputView: Remains class-based because it requires instance properties (textgetter/setter) for the ref system to support imperative text access.Key changes:
MutableState<T>→ plainTvaluesContent()method → standalone@ComposablefunctionView(Class::class)→View("Name") { props -> Content(props) }Example transformation:
Before (class pattern):
After (DSL pattern):
Related
This PR builds on top of the following merged PRs:
matchContentssupport to HostViewAutoSizingComposablefrom leaf componentsTest plan