jim
01/23/2021, 7:46 PMAndroidView
directly in their apps, and maybe it's because we made the API too pleasant to use or maybe it's because we never really communicated the intent to the community. 🤷. Certainly I never expected to see people remembering the view and then just referencing that view in the viewBlock
, I suppose no API survives first encounter with the user.
Composables are epitomized by their convenient declarative APIs. The older android Views often have imperative APIs with sometimes surprising semantics that need to be papered over, and this wallpaper isn't always straight forward to get right. The intent/expectation was that users would write a composable function who's sole purpose was to wrap a particular Android View, and would provide this wallpaper, such that the widget was pleasant to use in the rest of their application.
Maybe we need to make AndroidView have some more boilerplate and look uglier 😛 😉🤣John O'Reilly
01/23/2021, 7:51 PMTimo Drick
01/23/2021, 7:52 PMjudrummer
01/23/2021, 7:52 PMjim
01/23/2021, 7:53 PMjudrummer
01/23/2021, 7:54 PMjim
01/23/2021, 7:58 PMAndroidView
to ever have any siblings within a given widget. I would expect it to ALWAYS be of the form:
@Composable
fun EditText(text: String, onChange: (newValue: String)->Unit, ...) {
AndroidView(
viewBlock={
android.widget.EditText(context)
.apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
}
},
editBlock={
// Deal with logic to add/remove change listeners, etc.
}
)
}
Now EditText looks like a composable function and has a declarative API, hiding the details of adding/updating change listeners, etc. It now provides an API that makes it look much more like a native composable.judrummer
01/23/2021, 8:07 PMjim
01/23/2021, 8:08 PMjudrummer
01/23/2021, 8:11 PMjim
01/23/2021, 8:13 PMjudrummer
01/23/2021, 8:14 PMZach Klippenstein (he/him) [MOD]
01/23/2021, 8:21 PMColton Idle
01/23/2021, 8:53 PMAdam Powell
01/23/2021, 9:12 PMjim
01/23/2021, 9:24 PMpawegio
01/23/2021, 11:14 PMAdam Powell
01/23/2021, 11:49 PMkenkyee
01/24/2021, 2:27 AMColton Idle
01/24/2021, 2:28 AM