Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Custom component using multiple built-in components doesn't nested #1839

Closed
brianchu opened this issue Jan 20, 2023 · 3 comments
Closed

Custom component using multiple built-in components doesn't nested #1839

brianchu opened this issue Jan 20, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@brianchu
Copy link

I create a custom component and reusing some container, text, image from build-in components. For single case (just a container), it works. but if I add more container and other components, they did not show up. I thought when the first outmost container's buildView(rootView) is called, it will go down the chain and create all components, or is that not support?

@RegisterWidget("testWidget")
data class TestWidget(
    val backgroundImageUrl: Bind<ImagePath>,
    val icon: Bind<ImagePath>,
    val styleId: String? = null,
    val text: Bind<String>
) : WidgetView() {

    override fun buildView(rootView: RootView): View {
        return Container(
            children =
            listOf(
                Image(backgroundImageUrl).also {
                    style = Style(
                        positionType = PositionType.ABSOLUTE,
                        size = Size(
                            height = UnitValue(constant(100.0), UnitType.PERCENT),
                            width = UnitValue(constant(100.0), UnitType.PERCENT)
                        )
                    )
                },

                Container(
                    children = listOf(
                        Container(
                            children = listOf(
                                Container(
                                    children = listOf(
                                        Container(
                                            children =
                                            listOf(
                                                Text(
                                                    text = text,
                                                    textColor = constant("#ffff00")
                                                ).apply {
                                                    style = Style(
                                                        margin = EdgeValue(bottom = UnitValue(constant(7.0), UnitType.REAL))
                                                    )
                                                },
                                                Text(text = text),
                                            )
                                        ),
                                        // etc etc etc
                                        Container()
                                    )
                                ).apply {
                                    style = Style(
                                        flex = Flex(
                                            justifyContent = JustifyContent.SPACE_BETWEEN,
                                            flex = 1.0
                                        ),
                                        positionType = PositionType.ABSOLUTE,
                                        padding = EdgeValue(
                                            left = UnitValue(constant(16.0), UnitType.REAL),
                                            right = UnitValue(constant(16.0), UnitType.REAL)
                                        )
                                    )
                                }
                            )
                        )
                    )
                ).also {
                    style = Style(
                        size = Size(
                            height = UnitValue(constant(100.0), UnitType.PERCENT),
                            width = UnitValue(constant(100.0), UnitType.PERCENT)
                        )
                    )
                }
            ),
            styleId = styleId
        ).also {
            style = Style(
                size = Size(height = UnitValue(constant(250.0), UnitType.REAL), width = UnitValue(constant(160.0), UnitType.REAL)),
                margin = EdgeValue(all = UnitValue(constant(10.0), UnitType.REAL)),
            )
        }
            .buildView(rootView)
    }

}
@brianchu brianchu added the bug Something isn't working label Jan 20, 2023
@Tiagoperes
Copy link
Contributor

Tiagoperes commented Jan 20, 2023

Hi Brian.

We decided not to support this kind of view construction on version 1.10. In that version, support for declarative UI writing from within Beagle Android was deprecated. On version 2.0 it was removed.

We did this because we don't want developers to use Beagle for writing declarative UIs in the frontend. We understand that Jetpack Compose is a much better tool for this and we want Beagle Components to be used only in Server Driven Views.

However, if there are cases where this is needed, we're open to return this feature to Beagle. Can you please explain us your use case? Why exactly are you creating this component in the frontend instead of the backend? Does this relate to the issue #1837? If yes, I think your suggestion there would be a better approach.

@Tiagoperes
Copy link
Contributor

Hi, I'm passing here just to let you know that the Beagle team is taking some vacation time.

We'll take 2 weeks off and be back at Feb 06. Feel free to keep commenting in this issue and we'll address it as soon as we're back.

@Tiagoperes
Copy link
Contributor

Closing this due to inactivity.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants