diff --git a/redwood-layout-schema/README.md b/redwood-layout-schema/README.md new file mode 100644 index 0000000000..273a0e55e4 --- /dev/null +++ b/redwood-layout-schema/README.md @@ -0,0 +1,92 @@ +# Redwood Layout + +Redwood's layout system provides common layout primitives to support arranging and laying out +widgets. It provides widgets for: + +- `Row`: Lays wigets out along the X axis (horizontally). +- `Column`: Lays widgets out along the Y axis (vertically). +- `Box`: Lays widgets out along the Z axis (on top of eachother). +- `Spacer`: Adds space between widgets. + +Internally the layout system uses a common layout engine written in Kotlin Multiplatform. The +layout engine operates on a virtual DOM (document object model) composed of simple nodes +where each node is mapped to a widget in the real DOM. This lets the layout engine perform +operations on the DOM with consistent rendering across platforms. The system provides widget +bindings for for Android Views (`redwood-layout-view`), iOS UiKit (`redwood-layout-uiview`), and +Compose UI (`redwood-layout-composeui`). + +## Widgets + +### Row + +Lays widgets out along the X axis (horizontally). + +```kotlin +Row { + Text("One") + Text("Two") + Text("Three") +} +``` + +

+ +

+ +### Column + +Lays widgets out along the Y axis (vertically). + +```kotlin +Column { + Text("One") + Text("Two") + Text("Three") +} +``` + +

+ +

+ +### Box + +Lays widgets out along the Z axis (on top of eachother). Widgets are laid from lowest Z index +(first) to highest Z index (last). + +```kotlin +Box { + Color( + color = Red, + modifier = Modifier.size(24.dp), + ) + Color( + color = Green, + modifier = Modifier.size(16.dp), + ) + Color( + color = Blue, + modifier = Modifier.size(8.dp), + ) +} +``` + +

+ +

+ +### Spacer + +Adds space between widgets. + +```kotlin +Column { + Text("Top") + Spacer(height = 24.dp) + Text("Bottom") +} +``` + +

+ +

diff --git a/redwood-layout-schema/docs_images/box1.png b/redwood-layout-schema/docs_images/box1.png new file mode 100644 index 0000000000..5f86c7e2bb --- /dev/null +++ b/redwood-layout-schema/docs_images/box1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:909e4ca4b6ac44939173f3626ab3b5d912853f7ebccc688730eac44a652c4602 +size 23831 diff --git a/redwood-layout-schema/docs_images/column1.png b/redwood-layout-schema/docs_images/column1.png new file mode 100644 index 0000000000..742fb8e3d5 --- /dev/null +++ b/redwood-layout-schema/docs_images/column1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:535dbfbfb5ac7025da5c75a6a295a31c2804c280fb379bfd1cf9ecc69c71e241 +size 4501 diff --git a/redwood-layout-schema/docs_images/row1.png b/redwood-layout-schema/docs_images/row1.png new file mode 100644 index 0000000000..24eb3252fe --- /dev/null +++ b/redwood-layout-schema/docs_images/row1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4674392ab23ef7699b9546da1d6f6207fcd805a518abcdbb3edfbe4dea7401f +size 3933 diff --git a/redwood-layout-schema/docs_images/spacer1.png b/redwood-layout-schema/docs_images/spacer1.png new file mode 100644 index 0000000000..26a058223c --- /dev/null +++ b/redwood-layout-schema/docs_images/spacer1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd337157b942a2ca674aeca7a6bd84b54a577dd47959a3ba0b0717c3dbced12e +size 3913