Skip to content

Commit

Permalink
Remove public FlexContainer type
Browse files Browse the repository at this point in the history
This only serves internal abstractions which are soon changing in a way that's incompatible with it.
  • Loading branch information
JakeWharton committed Oct 22, 2024
1 parent edeabb1 commit dc56d97
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ import app.cash.redwood.layout.modifier.Shrink as ShrinkModifier
import app.cash.redwood.layout.modifier.Size as SizeModifier
import app.cash.redwood.layout.modifier.VerticalAlignment as VerticalAlignmentModifier
import app.cash.redwood.layout.modifier.Width as WidthModifier
import app.cash.redwood.layout.widget.FlexContainer
import app.cash.redwood.layout.widget.Column
import app.cash.redwood.layout.widget.Row
import app.cash.redwood.ui.Density
import app.cash.redwood.ui.Margin
import app.cash.redwood.yoga.AlignItems
import app.cash.redwood.yoga.AlignSelf
import app.cash.redwood.yoga.JustifyContent
import app.cash.redwood.yoga.Node

internal interface YogaFlexContainer<W : Any> : FlexContainer<W> {
internal interface YogaFlexContainer<W : Any> :
Column<W>,
Row<W> {
val rootNode: Node
val density: Density

Expand All @@ -50,11 +53,27 @@ internal interface YogaFlexContainer<W : Any> : FlexContainer<W> {
}
}

override fun crossAxisAlignment(crossAxisAlignment: CrossAxisAlignment) {
override fun horizontalAlignment(horizontalAlignment: MainAxisAlignment) {
mainAxisAlignment(horizontalAlignment)
}

override fun horizontalAlignment(horizontalAlignment: CrossAxisAlignment) {
crossAxisAlignment(horizontalAlignment)
}

override fun verticalAlignment(verticalAlignment: MainAxisAlignment) {
mainAxisAlignment(verticalAlignment)
}

override fun verticalAlignment(verticalAlignment: CrossAxisAlignment) {
crossAxisAlignment(verticalAlignment)
}

fun crossAxisAlignment(crossAxisAlignment: CrossAxisAlignment) {
rootNode.alignItems = crossAxisAlignment.toAlignItems()
}

override fun mainAxisAlignment(mainAxisAlignment: MainAxisAlignment) {
fun mainAxisAlignment(mainAxisAlignment: MainAxisAlignment) {
rootNode.justifyContent = mainAxisAlignment.toJustifyContent()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import app.cash.redwood.layout.modifier.Size
import app.cash.redwood.layout.modifier.Width
import app.cash.redwood.layout.widget.Box
import app.cash.redwood.layout.widget.Column
import app.cash.redwood.layout.widget.FlexContainer
import app.cash.redwood.layout.widget.RedwoodLayoutWidgetFactory
import app.cash.redwood.layout.widget.Row
import app.cash.redwood.layout.widget.Spacer
Expand Down Expand Up @@ -75,7 +74,8 @@ private class HTMLFlexContainer(
override val value: HTMLDivElement,
direction: String,
private val overflowSetter: HTMLDivElement.(String) -> Unit,
) : FlexContainer<HTMLElement> {
) : Column<HTMLElement>,
Row<HTMLElement> {
init {
value.style.display = "flex"
value.style.flexDirection = direction
Expand Down Expand Up @@ -127,11 +127,27 @@ private class HTMLFlexContainer(
}
}

override fun crossAxisAlignment(crossAxisAlignment: CrossAxisAlignment) {
override fun horizontalAlignment(horizontalAlignment: MainAxisAlignment) {
mainAxisAlignment(horizontalAlignment)
}

override fun horizontalAlignment(horizontalAlignment: CrossAxisAlignment) {
crossAxisAlignment(horizontalAlignment)
}

override fun verticalAlignment(verticalAlignment: MainAxisAlignment) {
mainAxisAlignment(verticalAlignment)
}

override fun verticalAlignment(verticalAlignment: CrossAxisAlignment) {
crossAxisAlignment(verticalAlignment)
}

private fun crossAxisAlignment(crossAxisAlignment: CrossAxisAlignment) {
value.style.alignItems = crossAxisAlignment.toCss()
}

override fun mainAxisAlignment(mainAxisAlignment: MainAxisAlignment) {
private fun mainAxisAlignment(mainAxisAlignment: MainAxisAlignment) {
value.style.justifyContent = mainAxisAlignment.toCss()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import app.cash.redwood.layout.AbstractFlexContainerTest
import app.cash.redwood.layout.TestFlexContainer
import app.cash.redwood.layout.api.Constraint
import app.cash.redwood.layout.api.CrossAxisAlignment
import app.cash.redwood.layout.widget.FlexContainer
import app.cash.redwood.layout.widget.Spacer
import app.cash.redwood.snapshot.testing.UIViewSnapshotCallback
import app.cash.redwood.snapshot.testing.UIViewSnapshotter
Expand Down Expand Up @@ -82,7 +81,7 @@ class UIViewFlexContainerTest(
private val delegate: UIViewFlexContainer,
) : TestFlexContainer<UIView>,
ResizableWidget<UIView>,
FlexContainer<UIView> by delegate,
YogaFlexContainer<UIView> by delegate,
ChangeListener by delegate {
private var childCount = 0

Expand Down
9 changes: 0 additions & 9 deletions redwood-layout-widget/api/redwood-layout-widget.api
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ public abstract interface class app/cash/redwood/layout/widget/Column : app/cash
public abstract fun width-DyLkt4w (I)V
}

public abstract interface class app/cash/redwood/layout/widget/FlexContainer : app/cash/redwood/layout/widget/Column, app/cash/redwood/layout/widget/Row {
public abstract fun crossAxisAlignment-njEs0f8 (I)V
public fun horizontalAlignment-6exqka8 (I)V
public fun horizontalAlignment-njEs0f8 (I)V
public abstract fun mainAxisAlignment-6exqka8 (I)V
public fun verticalAlignment-6exqka8 (I)V
public fun verticalAlignment-njEs0f8 (I)V
}

public abstract interface class app/cash/redwood/layout/widget/RedwoodLayoutWidgetFactory {
public abstract fun Box ()Lapp/cash/redwood/layout/widget/Box;
public abstract fun Column ()Lapp/cash/redwood/layout/widget/Column;
Expand Down
9 changes: 0 additions & 9 deletions redwood-layout-widget/api/redwood-layout-widget.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ abstract interface <#A: kotlin/Any> app.cash.redwood.layout.widget/Column : app.
abstract fun width(app.cash.redwood.layout.api/Constraint) // app.cash.redwood.layout.widget/Column.width|width(app.cash.redwood.layout.api.Constraint){}[0]
}

abstract interface <#A: kotlin/Any> app.cash.redwood.layout.widget/FlexContainer : app.cash.redwood.layout.widget/Column<#A>, app.cash.redwood.layout.widget/Row<#A> { // app.cash.redwood.layout.widget/FlexContainer|null[0]
abstract fun crossAxisAlignment(app.cash.redwood.layout.api/CrossAxisAlignment) // app.cash.redwood.layout.widget/FlexContainer.crossAxisAlignment|crossAxisAlignment(app.cash.redwood.layout.api.CrossAxisAlignment){}[0]
abstract fun mainAxisAlignment(app.cash.redwood.layout.api/MainAxisAlignment) // app.cash.redwood.layout.widget/FlexContainer.mainAxisAlignment|mainAxisAlignment(app.cash.redwood.layout.api.MainAxisAlignment){}[0]
open fun horizontalAlignment(app.cash.redwood.layout.api/CrossAxisAlignment) // app.cash.redwood.layout.widget/FlexContainer.horizontalAlignment|horizontalAlignment(app.cash.redwood.layout.api.CrossAxisAlignment){}[0]
open fun horizontalAlignment(app.cash.redwood.layout.api/MainAxisAlignment) // app.cash.redwood.layout.widget/FlexContainer.horizontalAlignment|horizontalAlignment(app.cash.redwood.layout.api.MainAxisAlignment){}[0]
open fun verticalAlignment(app.cash.redwood.layout.api/CrossAxisAlignment) // app.cash.redwood.layout.widget/FlexContainer.verticalAlignment|verticalAlignment(app.cash.redwood.layout.api.CrossAxisAlignment){}[0]
open fun verticalAlignment(app.cash.redwood.layout.api/MainAxisAlignment) // app.cash.redwood.layout.widget/FlexContainer.verticalAlignment|verticalAlignment(app.cash.redwood.layout.api.MainAxisAlignment){}[0]
}

abstract interface <#A: kotlin/Any> app.cash.redwood.layout.widget/RedwoodLayoutWidgetFactory { // app.cash.redwood.layout.widget/RedwoodLayoutWidgetFactory|null[0]
abstract fun Box(): app.cash.redwood.layout.widget/Box<#A> // app.cash.redwood.layout.widget/RedwoodLayoutWidgetFactory.Box|Box(){}[0]
abstract fun Column(): app.cash.redwood.layout.widget/Column<#A> // app.cash.redwood.layout.widget/RedwoodLayoutWidgetFactory.Column|Column(){}[0]
Expand Down

This file was deleted.

0 comments on commit dc56d97

Please sign in to comment.