Leland Richardson [G]
12/13/2019, 6:38 PMZach Klippenstein (he/him) [MOD]
12/13/2019, 6:59 PMView
subclass from a composable function? Are there any requirements about which view constructors are required or anything? I’m trying to do this with a custom view and I’m only seeing the constructors I’ve defined, no versions with ref
or anything.
So I’ve got a custom View that looks like this:
class WorkflowViewStub
@JvmOverloads constructor(
context: Context,
attributeSet: AttributeSet? = null,
defStyle: Int = 0,
defStyleRes: Int = 0
) : View(context, attributeSet, defStyle, defStyleRes) { … }
And I should just be able to do something like this?
@Composable fun myComponent() {
WorkflowViewStub()
}
(https://github.com/square/workflow/pull/703/commits/6fc61720a281055ee410ad41566546a640481661#diff-f3d0030f5e5c4962c8c2e1b4d5300553R47-R54)Leland Richardson [G]
12/13/2019, 7:15 PM(Context) -> T
where T: View
.
3. Properties (and getters/setters from java) will be resolvable as name = T
in the argument list of the call. ALL parameters must be named in order for this to work. For example, TextView(text="hello world")
works because of setText(String)
and TextView(text=R.string.foo)
works because of the setter overload.@JvmOverloads
constructor like you showed will get properly intercepted. if it’s not working, try splitting it out and creating one with just Context
Zach Klippenstein (he/him) [MOD]
12/13/2019, 8:35 PMContext
, and it compiles but i’m getting a runtime crash: IllegalStateException: Could not convert WorkflowViewStub to an Emittable
. ViewComposer
seems to be trying to find an adapter for my view, but the adapters
list is empty.Leland Richardson [G]
12/13/2019, 10:23 PMsetViewContent
instead of setContent
Zach Klippenstein (he/him) [MOD]
12/13/2019, 10:24 PMsetViewContent
on a FrameLayout
.Leland Richardson [G]
12/13/2019, 10:26 PMWorkFlowViewStub
as a child to a ComponentNodeZach Klippenstein (he/him) [MOD]
12/13/2019, 10:28 PMContainer
).Leland Richardson [G]
12/13/2019, 10:46 PM