Mikael Alfredsson
02/07/2024, 12:40 PMvide
02/07/2024, 12:46 PMweight(1f)
always? you could also pass a modifier for your custom button from the parent:
fun MyButton(modifier: Modifier) = { Box(modifier.[...]) }
Mikael Alfredsson
02/07/2024, 12:47 PMMikael Alfredsson
02/07/2024, 12:48 PMMikael Alfredsson
02/07/2024, 12:50 PMweight
is also a different function depending on if its in a columnscope or a rowscope, and as far as i understand it, it has to be known at compiletime?vide
02/07/2024, 12:58 PMvide
02/07/2024, 1:01 PMMikael Alfredsson
02/07/2024, 1:05 PMcreate
method
it also contains a map of all components that I have access to in my framework, driven from a “presenter” class (i.e ButtonPresenter(title:String) -> {MyButton(presenterClass)}
so I parse a Json file, getting all the different presenters in a polymorphic list. In the general case I can just read that list, call the factorys createFromPresenter(presenter) function and it will call the correct component constructor to create for example the button
are you with me so far?Mikael Alfredsson
02/07/2024, 1:06 PMMikael Alfredsson
02/07/2024, 1:08 PMval registry = mutableMapOf<KClass<out Presenter>, @Composable (Presenter) -> Unit>()
registry[ButtonPresenter::class] = { MyButton(it as ButtonPresenter) }
fun create(presenter:Presenter){
registry[presenter::class]?.invoke(presenter)
}
Mikael Alfredsson
02/07/2024, 1:13 PMephemient
02/07/2024, 1:51 PM@Composable (Presenter, Modifier) -> Unit
then rows can pass down Modifier.weight(1f)
, others can pass down Modifier
, and the mapper builds off of the given modifierephemient
02/07/2024, 1:51 PMMikael Alfredsson
02/07/2024, 1:51 PMephemient
02/07/2024, 1:52 PMMikael Alfredsson
02/07/2024, 1:52 PMephemient
02/07/2024, 1:54 PMregistry[MyRow::class] = { row, modifier ->
Row(modifier = modifier) {
for (child in row.children) {
registry[child::class]?.invoke(child, Modifier.weight(1f))
Mikael Alfredsson
02/07/2024, 1:56 PMvide
02/07/2024, 3:23 PMephemient
02/07/2024, 4:46 PM