Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update kotlin monorepo to v1.8.20 #889

Merged
merged 14 commits into from
Apr 18, 2023
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ buildscript {
classpath libs.buildConfigPlugin
classpath libs.zipline.gradlePlugin
classpath libs.paparazzi.gradlePlugin
classpath libs.cklib.gradle.plugin
classpath 'app.cash.redwood.build:gradle-plugin'
classpath 'app.cash.redwood:redwood-gradle-plugin'
}
Expand Down
8 changes: 3 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[versions]
kotlin = "1.8.10"
kotlin = "1.8.20"
kotlinx-coroutines = "1.6.4"
kotlinx-serialization = "1.5.0"
androidxComposeCompiler = "1.4.3"
androidxComposeCompiler = "1.4.5"
androidx-activity = "1.3.1"
jbCompose = "1.4.0"
lint = "31.0.0"
Expand Down Expand Up @@ -41,7 +41,7 @@ androidx-test-uiautomator = "androidx.test.uiautomator:uiautomator:2.2.0"

google-material = { module = "com.google.android.material:material", version = "1.8.0" }

jetbrains-compose-compiler = "org.jetbrains.compose.compiler:compiler:1.4.2"
jetbrains-compose-compiler = "org.jetbrains.compose.compiler:compiler:1.4.5"
jetbrains-compose-gradlePlugin = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "jbCompose" }
jetbrains-compose-foundation = { module = "org.jetbrains.compose.foundation:foundation", version.ref = "jbCompose" }
jetbrains-compose-material = { module = "org.jetbrains.compose.material:material", version.ref = "jbCompose" }
Expand Down Expand Up @@ -71,5 +71,3 @@ coil-core = { module = "io.coil-kt:coil", version.ref = "coil" }
turbine = "app.cash.turbine:turbine:0.12.3"

lint-core = { module = "com.android.tools.lint:lint", version.ref = "lint" }

cklib-gradle-plugin = { module = "co.touchlab:cklib-gradle-plugin", version = "0.2.4" }
289 changes: 285 additions & 4 deletions kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

24 changes: 3 additions & 21 deletions redwood-layout-uiview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@ import app.cash.redwood.buildsupport.FlexboxHelpers
apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'com.vanniktech.maven.publish'
apply plugin: 'org.jetbrains.dokka' // Must be applied here for publish plugin.
apply plugin: 'co.touchlab.cklib'

kotlin {
[
iosArm64(),
iosX64(),
iosSimulatorArm64()
].forEach { target ->
target.compilations.main.cinterops.create("uikit") {
includeDirs("$projectDir/native/uikit")
}
}
iosArm64()
iosX64()
iosSimulatorArm64()

sourceSets {
commonMain {
Expand All @@ -39,14 +32,3 @@ kotlin {
}
}
}

cklib {
config.kotlinVersion = libs.versions.kotlin.get()
create("uikit", file("native/uikit"), ["main"]) {ctb ->
ctb.language = co.touchlab.cklib.gradle.CompileToBitcode.Language.OBJC
ctb.compilerArgs.addAll(
["-DKONAN_MI_MALLOC=1", "-DNS_FORMAT_ARGUMENT(A)=", "-D_Nullable_result=_Nullable"]
)
ctb.srcDirs = project.files(file("native/uikit"))
}
}
12 changes: 0 additions & 12 deletions redwood-layout-uiview/native/uikit/RedwoodScrollViewDelegate.h

This file was deleted.

9 changes: 0 additions & 9 deletions redwood-layout-uiview/native/uikit/RedwoodViewDelegate.h

This file was deleted.

28 changes: 0 additions & 28 deletions redwood-layout-uiview/native/uikit/uiview.h

This file was deleted.

65 changes: 0 additions & 65 deletions redwood-layout-uiview/native/uikit/uiview.m

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,19 @@ import app.cash.redwood.layout.api.CrossAxisAlignment
import app.cash.redwood.layout.api.MainAxisAlignment
import app.cash.redwood.layout.api.Margin
import app.cash.redwood.layout.api.Overflow
import app.cash.redwood.layout.uiview.cinterop.FlexContainerHostView
import app.cash.redwood.layout.uiview.cinterop.RedwoodScrollViewDelegateProtocol
import app.cash.redwood.layout.widget.Column
import app.cash.redwood.layout.widget.Row
import app.cash.redwood.widget.UIViewChildren
import kotlinx.cinterop.CValue
import kotlinx.cinterop.cValue
import kotlinx.cinterop.useContents
import platform.CoreGraphics.CGRectMake
import platform.CoreGraphics.CGRectZero
import platform.CoreGraphics.CGSize
import platform.CoreGraphics.CGSizeMake
import platform.UIKit.UIScrollView
import platform.UIKit.UIView
import platform.UIKit.UIViewNoIntrinsicMetric
import platform.UIKit.setFrame
import platform.UIKit.setNeedsLayout
import platform.UIKit.superview
import platform.darwin.NSObject

internal class UIViewFlexContainer(
private val direction: FlexDirection,
Expand All @@ -50,13 +47,13 @@ internal class UIViewFlexContainer(
flexDirection = direction
roundToInt = false
}

override val value = FlexContainerHostView().apply {
kotlinDelegate = UIViewDelegate()
private val view = FlexContainerHostView().apply {
showsHorizontalScrollIndicator = false
showsVerticalScrollIndicator = false
}

override val value: UIView get() = view

override val children = UIViewChildren(value)

override var layoutModifiers: LayoutModifier = LayoutModifier
Expand All @@ -77,7 +74,7 @@ internal class UIViewFlexContainer(
}

override fun overflow(overflow: Overflow) {
value.setScrollEnabled(overflow == Overflow.Scroll)
view.setScrollEnabled(overflow == Overflow.Scroll)
invalidate()
}

Expand Down Expand Up @@ -111,13 +108,16 @@ internal class UIViewFlexContainer(
value.setNeedsLayout()
}

private inner class UIViewDelegate : NSObject(), RedwoodScrollViewDelegateProtocol {
private inner class FlexContainerHostView : UIScrollView(cValue { CGRectZero }) {
private var needsLayout = true

override fun intrinsicContentSize(): CValue<CGSize> = CGSizeMake(noIntrinsicSize.width, noIntrinsicSize.height)
override fun intrinsicContentSize(): CValue<CGSize> {
return CGSizeMake(UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric)
}

override fun sizeThatFits(size: CValue<CGSize>): CValue<CGSize> =
measure(size.useContents { toUnsafeSize() }).run { CGSizeMake(width, height) }
override fun sizeThatFits(size: CValue<CGSize>): CValue<CGSize> {
return measure(size.useContents { toUnsafeSize() }).run { CGSizeMake(width, height) }
}

override fun setNeedsLayout() {
needsLayout = true
Expand All @@ -127,19 +127,19 @@ internal class UIViewFlexContainer(
if (!needsLayout) return
needsLayout = false

val bounds = value.bounds.useContents { size.toUnsafeSize() }
val bounds = bounds.useContents { size.toUnsafeSize() }
measure(bounds)

value.setContentSize(
setContentSize(
CGSizeMake(
width = container.items.maxOfOrNull { it.right } ?: 0.0,
height = container.items.maxOfOrNull { it.top } ?: 0.0,
),
)
value.superview?.setNeedsLayout()
superview?.setNeedsLayout()

container.items.forEachIndexed { index, item ->
value.typedSubviews[index].setFrame(
typedSubviews[index].setFrame(
CGRectMake(
x = item.left,
y = item.top,
Expand Down Expand Up @@ -170,8 +170,6 @@ internal class UIViewFlexContainer(
}
}

private val noIntrinsicSize = UnsafeSize(UIViewNoIntrinsicMetric, UIViewNoIntrinsicMetric)

internal data class UnsafeSize(
val width: Double,
val height: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,19 @@
package app.cash.redwood.layout.uiview

import app.cash.redwood.LayoutModifier
import app.cash.redwood.layout.uiview.cinterop.RedwoodViewDelegateProtocol
import app.cash.redwood.layout.uiview.cinterop.SpacerHostView
import app.cash.redwood.layout.widget.Spacer
import kotlinx.cinterop.cValue
import platform.CoreGraphics.CGRectZero
import platform.CoreGraphics.CGSizeMake
import platform.UIKit.UIView
import platform.UIKit.invalidateIntrinsicContentSize
import platform.UIKit.setNeedsLayout
import platform.darwin.NSObject

internal class UIViewSpacer : Spacer<UIView> {
private var width = 0.0
private var height = 0.0

override val value: UIView = SpacerHostView().apply {
kotlinDelegate = UIViewDelegate()
}
private val view = SpacerHostView()

override val value: UIView get() = view

override var layoutModifiers: LayoutModifier = LayoutModifier

Expand All @@ -52,7 +49,7 @@ internal class UIViewSpacer : Spacer<UIView> {
value.setNeedsLayout()
}

private inner class UIViewDelegate : NSObject(), RedwoodViewDelegateProtocol {
private inner class SpacerHostView : UIView(cValue { CGRectZero }) {
override fun intrinsicContentSize() = CGSizeMake(width, height)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ import platform.CoreGraphics.CGSize
import platform.CoreGraphics.CGSizeMake
import platform.UIKit.UIView
import platform.UIKit.UIViewNoIntrinsicMetric
import platform.UIKit.intrinsicContentSize
import platform.UIKit.sizeThatFits
import platform.UIKit.subviews

// The cross platform density multiples use iOS as an anchor.
internal const val DensityMultiplier = 1.0
Expand Down
3 changes: 0 additions & 3 deletions redwood-layout-uiview/src/nativeInterop/cinterop/uikit.def

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import app.cash.zipline.ZiplineScoped
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.plus

/**
Expand Down Expand Up @@ -52,7 +53,7 @@ private class RedwoodZiplineTreehouseUi(

override fun start(
diffSink: DiffSinkService,
hostConfigurations: FlowWithInitialValue<HostConfiguration>,
hostConfigurations: StateFlow<HostConfiguration>,
) {
val composition = ProtocolRedwoodComposition(
scope = coroutineScope + StandardFrameClock,
Expand All @@ -62,8 +63,7 @@ private class RedwoodZiplineTreehouseUi(
)
this.composition = composition

val (initialHostConfiguration, hostConfigurationFlow) = hostConfigurations
composition.bind(treehouseUi, initialHostConfiguration, hostConfigurationFlow)
composition.bind(treehouseUi, hostConfigurations.value, hostConfigurations)
}

override fun close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private class ViewContentCodeBinding<A : AppService>(
treehouseUiOrNull = treehouseUi
treehouseUi.start(
diffSink = this@ViewContentCodeBinding,
hostConfigurations = hostConfigurationFlow.toFlowWithInitialValue(),
hostConfigurations = hostConfigurationFlow,
)
}
}
Expand Down
Loading