cashapp / redwood

Multiplatform reactive UI for Android, iOS, and web using Kotlin and Jetpack Compose
https://cashapp.github.io/redwood/0.x/docs/
Apache License 2.0
1.63k stars 70 forks source link

Root component’s dimensions inconsistent across platforms #2128

Closed swankjesse closed 1 day ago

swankjesse commented 3 months ago

Here’s a composition with a label that draws wider than the screen.

    @Composable
    override fun Show(flow: CashFlow.Environment, scope: CoroutineScope) {
      Column(
        width = Constraint.Wrap,
      ) {
        Text("hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello ")
      }
    }

And here’s what that looks like on an iOS and Android device: Screenshot 2024-06-20 at 10 40 08 AM

These should be the same.

JakeWharton commented 3 months ago

Related: #1859

swankjesse commented 1 week ago

Looking into this now. On iOS our root view doesn’t care if its child component’s dimensions exceed its own. Here I’ve got a label that’s 965px wide in a parent that’s 393px wide.

Screenshot 2024-09-26 at 2 27 03 PM
swankjesse commented 1 week ago

Root layout is pass-through

The root layout should be a pass-through layout:

I need to confirm we’re doing this on both platforms.

swankjesse commented 1 week ago

Column(width = WRAP) is different between platforms

    Box(
      width = Constraint.Fill,
      height = Constraint.Fill,
    ) {
      Column(
        width = Constraint.Wrap,
      ) {
        Text(
          modifier = Modifier.margin(Margin(start = 350.dp)),
          text = "hello_world"
        )
      }
    }

On Android we don’t permit child components to exceed the columns’ own bounds. On iOS we do.

Android

Screenshot 2024-09-26 at 3 29 35 PM

iOS

Simulator Screenshot - iPhone 15 simulator - 2024-09-26 at 15 30 44

We should pick one and be consistent.