icerockdev / moko-widgets

Multiplatform UI DSL with screen management in common code for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev
Apache License 2.0
387 stars 32 forks source link

Can't constraint two items horizontally with equal width #231

Open ahmetcj4 opened 4 years ago

ahmetcj4 commented 4 years ago

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
Alex009 commented 4 years ago

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