Repository: cashapp/redwood
Pull request #398 (2022-09-27 18:26:18)

Move flexbox classes into a flexbox subpackage.
Fixes: https://github.com/cashapp/redwood/issues/395


Patch:
diff --git a/redwood-flexbox-engine/build.gradle b/redwood-flexbox-engine/build.gradle
index 9f13de6f7..5dfea48d8 100644
--- a/redwood-flexbox-engine/build.gradle
+++ b/redwood-flexbox-engine/build.gradle
@@ -18,10 +18,10 @@ spotless {
   kotlin {
     targetExclude(
       // Apache 2-licensed files from Google.
-      "src/commonMain/kotlin/app/cash/redwood/FlexboxEngine.kt",
-      "src/commonMain/kotlin/app/cash/redwood/FlexLine.kt",
-      "src/commonMain/kotlin/app/cash/redwood/Node.kt",
-      "src/commonTest/kotlin/app/cash/redwood/FlexboxEngineTest.kt",
+      "src/commonMain/kotlin/app/cash/redwood/flexbox/FlexboxEngine.kt",
+      "src/commonMain/kotlin/app/cash/redwood/flexbox/FlexLine.kt",
+      "src/commonMain/kotlin/app/cash/redwood/flexbox/Node.kt",
+      "src/commonTest/kotlin/app/cash/redwood/flexbox/FlexboxEngineTest.kt",
     )
   }
 }
diff --git a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Direction.kt b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Direction.kt
similarity index 98%
rename from redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Direction.kt
rename to redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Direction.kt
index 23f0231cf..1c03be998 100644
--- a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Direction.kt
+++ b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Direction.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 internal fun FlexDirection.toDirection(): Direction {
   if (this == FlexDirection.Row || this == FlexDirection.RowReverse) {
diff --git a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/FlexLine.kt b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/FlexLine.kt
similarity index 98%
rename from redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/FlexLine.kt
rename to redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/FlexLine.kt
index c1bdaf0c4..d08174bcd 100644
--- a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/FlexLine.kt
+++ b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/FlexLine.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 import kotlin.jvm.JvmField
 
diff --git a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/FlexboxEngine.kt b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/FlexboxEngine.kt
similarity index 99%
rename from redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/FlexboxEngine.kt
rename to redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/FlexboxEngine.kt
index 2328ef73f..ac0c29b8f 100644
--- a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/FlexboxEngine.kt
+++ b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/FlexboxEngine.kt
@@ -15,12 +15,12 @@
  */
 @file:Suppress("MemberVisibilityCanBePrivate")
 
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
-import app.cash.redwood.Measurable.Companion.MatchParent
-import app.cash.redwood.Node.Companion.DefaultFlexBasisPercent
-import app.cash.redwood.Node.Companion.DefaultFlexGrow
-import app.cash.redwood.Node.Companion.UndefinedFlexShrink
+import app.cash.redwood.flexbox.Measurable.Companion.MatchParent
+import app.cash.redwood.flexbox.Node.Companion.DefaultFlexBasisPercent
+import app.cash.redwood.flexbox.Node.Companion.DefaultFlexGrow
+import app.cash.redwood.flexbox.Node.Companion.UndefinedFlexShrink
 import kotlin.math.roundToInt
 
 /**
diff --git a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Measurable.kt b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Measurable.kt
similarity index 98%
rename from redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Measurable.kt
rename to redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Measurable.kt
index 983f27961..6a933dabc 100644
--- a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Measurable.kt
+++ b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Measurable.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 public open class Measurable {
   /**
diff --git a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Node.kt b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Node.kt
similarity index 99%
rename from redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Node.kt
rename to redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Node.kt
index db718675d..b931c64b7 100644
--- a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/Node.kt
+++ b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/Node.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 /**
  * A node with properties that can be measured and laid out inside a flexbox.
diff --git a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/ObservableMutableList.kt b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/ObservableMutableList.kt
similarity index 97%
rename from redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/ObservableMutableList.kt
rename to redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/ObservableMutableList.kt
index ac1cdf600..6889bbfb0 100644
--- a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/ObservableMutableList.kt
+++ b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/ObservableMutableList.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 internal class ObservableMutableList<T>(
   private val onChange: () -> Unit = {},
diff --git a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/properties.kt b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/properties.kt
similarity index 99%
rename from redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/properties.kt
rename to redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/properties.kt
index 9010f2fe7..a1df0f1fc 100644
--- a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/properties.kt
+++ b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/properties.kt
@@ -15,7 +15,7 @@
  */
 @file:Suppress("MemberVisibilityCanBePrivate")
 
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 import kotlin.jvm.JvmInline
 import kotlin.math.abs
diff --git a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/utils.kt b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/utils.kt
similarity index 95%
rename from redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/utils.kt
rename to redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/utils.kt
index 6296eb4ac..24d1918cf 100644
--- a/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/utils.kt
+++ b/redwood-flexbox-engine/src/commonMain/kotlin/app/cash/redwood/flexbox/utils.kt
@@ -13,10 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
-import app.cash.redwood.Measurable.Companion.MatchParent
-import app.cash.redwood.Measurable.Companion.WrapContent
+import app.cash.redwood.flexbox.Measurable.Companion.MatchParent
+import app.cash.redwood.flexbox.Measurable.Companion.WrapContent
 
 internal fun packLong(lower: Int, higher: Int): Long {
   return (higher.toLong() shl 32) or (lower.toLong() and 0xFFFFFFFFL)


Test patch:
diff --git a/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/FlexboxEngineTest.kt b/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/FlexboxEngineTest.kt
similarity index 99%
rename from redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/FlexboxEngineTest.kt
rename to redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/FlexboxEngineTest.kt
index abe65910f..beb15eea1 100644
--- a/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/FlexboxEngineTest.kt
+++ b/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/FlexboxEngineTest.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 import kotlin.test.Test
 import kotlin.test.assertEquals
diff --git a/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/FlexboxTest.kt b/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/FlexboxTest.kt
similarity index 97%
rename from redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/FlexboxTest.kt
rename to redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/FlexboxTest.kt
index 52a1347e3..5465c9205 100644
--- a/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/FlexboxTest.kt
+++ b/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/FlexboxTest.kt
@@ -13,10 +13,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
-import app.cash.redwood.FlexDirection.Companion.Row
-import app.cash.redwood.FlexDirection.Companion.RowReverse
+import app.cash.redwood.flexbox.FlexDirection.Companion.Row
+import app.cash.redwood.flexbox.FlexDirection.Companion.RowReverse
 import kotlin.test.Test
 import kotlin.test.assertEquals
 
diff --git a/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/StringCanvas.kt b/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/StringCanvas.kt
similarity index 97%
rename from redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/StringCanvas.kt
rename to redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/StringCanvas.kt
index abcf4a8f6..f48c12989 100644
--- a/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/StringCanvas.kt
+++ b/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/StringCanvas.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 /**
  * A 2D grid of characters. Attempts to draw beyond the bounds are silently ignored.
diff --git a/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/StringWidget.kt b/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/StringWidget.kt
similarity index 99%
rename from redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/StringWidget.kt
rename to redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/StringWidget.kt
index 2265bae68..46f5500a8 100644
--- a/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/StringWidget.kt
+++ b/redwood-flexbox-engine/src/commonTest/kotlin/app/cash/redwood/flexbox/StringWidget.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package app.cash.redwood
+package app.cash.redwood.flexbox
 
 /**
  * A string that wraps on space characters, and is wrapped with an ASCII-art box. We use a string