moko-widgets icon indicating copy to clipboard operation
moko-widgets copied to clipboard

Can't constraint two items horizontally with equal width

Open ahmetcj4 opened this issue 5 years ago • 1 comments

I want to put two items in with the same with in constraint builder but currently it seems not working.

Sample Code:

    override fun createContentWidget() = with(theme) {
        constraint(size = WidgetSize.AsParent) {
            val loginButton = +button(
                size = Const(MatchConstraint, WrapContent),
                content = Text(Value.data("Login".desc() as StringDesc))
            ) { }

            val registerButton = +button(
                size = Const(MatchConstraint, WrapContent),
                content = Text(Value.data("Register".desc() as StringDesc))
            ) { }

            constraints {
                loginButton topToTop root
                loginButton leftToLeft root
                loginButton rightToLeft registerButton offset 8

                registerButton centerYToCenterY loginButton
                registerButton rightToRight root
                registerButton leftToRight loginButton offset 8
            }
        }
    }

Previews:

Android iOS
Screen Shot 2020-04-14 at 21 23 48 Screen Shot 2020-04-14 at 21 24 00

ahmetcj4 avatar Apr 14 '20 18:04 ahmetcj4

on both platforms we can create vertical/horizontal guidelines: https://developer.android.com/reference/android/support/constraint/Guideline https://developer.apple.com/documentation/uikit/uilayoutguide

if we add to common api guidelines support we support case from issue description

Alex009 avatar Apr 19 '20 13:04 Alex009