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

Compose 1.6.0 samples #4382

Merged
merged 6 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/compose-uber-jar/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
compose.version=1.5.11
compose.version=1.6.0
kotlin.code.style=official
4 changes: 2 additions & 2 deletions ci/templates/desktop-template/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions ci/templates/html-library-template/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions ci/templates/multiplatform-template/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/chat/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/cocoapods-ios-example/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ android.minSdk=24
#Compose

#Versions
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/codeviewer/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/graphics-2d/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
compose.version=1.6.0

# TODO: remove when switching to 1.9.10. See: https://youtrack.jetbrains.com/issue/KT-60852
# usage: ./gradlew :jsApp:jsBrowserRun -Pworkaround.kotlin.js.kt60852=true
Expand Down
4 changes: 2 additions & 2 deletions examples/html/compose-bird/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kotlin.code.style=official
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/html/compose-in-js/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official
kotlin.js.webpack.major.version=4
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/html/landing/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kotlin.code.style=official
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/html/with-react/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kotlin.code.style=official
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/imageviewer/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ kotlin.mpp.androidSourceSetLayoutVersion=2
kotlin.native.useEmbeddableCompilerJar=true
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/intellij-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kotlin.code.style=official
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/interop/ios-compose-in-swiftui/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kotlin.code.style=official
xcodeproj=./iosApp
org.gradle.jvmargs=-Xmx3g
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/interop/ios-compose-in-uikit/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ xcodeproj=./iosApp
org.gradle.jvmargs=-Xmx3g
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/interop/ios-swiftui-in-compose/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ xcodeproj=./iosApp
org.gradle.jvmargs=-Xmx3g
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,14 @@ import MapKit

struct ComposeViewControllerRepresentable: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
return Main_iosKt.ComposeEntryPointWithUIView(createUIView: { () -> UIView in
SwiftUIInUIView(
content: VStack {
Text("SwiftUI in Compose Multiplatform")
}
)
return Main_iosKt.ComposeEntryPointWithUIViewController(createUIViewController: { () -> UIViewController in
let swiftUIView = VStack {
Text("SwiftUI in Compose Multiplatform")
}
return UIHostingController(rootView: swiftUIView)
})
}

func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}

private class SwiftUIInUIView<Content: View>: UIView {

init(content: Content) {
super.init(frame: CGRect())
let hostingController = UIHostingController(rootView: content)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
addSubview(hostingController.view)
NSLayoutConstraint.activate([
hostingController.view.topAnchor.constraint(equalTo: topAnchor),
hostingController.view.leadingAnchor.constraint(equalTo: leadingAnchor),
hostingController.view.trailingAnchor.constraint(equalTo: trailingAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: bottomAnchor)
])
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.interop.UIKitView
import androidx.compose.ui.interop.UIKitViewController
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.ComposeUIViewController
import kotlinx.cinterop.ExperimentalForeignApi
import platform.UIKit.UIView
import platform.UIKit.UIViewController

@OptIn(ExperimentalForeignApi::class)
fun ComposeEntryPointWithUIView(createUIView: () -> UIView): UIViewController =
fun ComposeEntryPointWithUIViewController(
createUIViewController: () -> UIViewController
): UIViewController =
ComposeUIViewController {
Column(
Modifier
Expand All @@ -21,8 +24,8 @@ fun ComposeEntryPointWithUIView(createUIView: () -> UIView): UIViewController =
horizontalAlignment = Alignment.CenterHorizontally
) {
Text("How to use SwiftUI inside Compose Multiplatform")
UIKitView(
factory = createUIView,
UIKitViewController(
factory = createUIViewController,
modifier = Modifier.size(300.dp).border(2.dp, Color.Blue),
)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/interop/ios-uikit-in-compose/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ xcodeproj=./iosApp
org.gradle.jvmargs=-Xmx3g
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/issues/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ kotlin.code.style=official
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/notepad/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
kotlin.version=1.9.21
compose.version=1.5.11
kotlin.version=1.9.22
compose.version=1.6.0
4 changes: 2 additions & 2 deletions examples/todoapp-lite/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
compose.version=1.6.0
5 changes: 3 additions & 2 deletions examples/widgets-gallery/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ kotlin.native.useEmbeddableCompilerJar=true
kotlin.mpp.androidSourceSetLayoutVersion=2
# Enable kotlin/native experimental memory model
kotlin.native.binary.memoryModel=experimental
kotlin.version=1.9.21
kotlin.version=1.9.22
agp.version=8.0.2
compose.version=1.5.11
# Replace this with release version when it comes out
compose.version=1.6.0
49 changes: 32 additions & 17 deletions examples/widgets-gallery/shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:Suppress("OPT_IN_IS_NOT_ENABLED")
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree

plugins {
kotlin("multiplatform")
Expand All @@ -9,7 +10,19 @@ plugins {
version = "1.0-SNAPSHOT"

kotlin {
androidTarget()
androidTarget {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
instrumentedTestVariant {
sourceSetTree.set(KotlinSourceSetTree.test)

dependencies {
// Remove the dependency on ui-test-junit4-android when 1.7.0 is released,
// as the needed classes in will have moved to ui-test
implementation("androidx.compose.ui:ui-test-junit4-android:1.6.0")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}
}
}

jvm("desktop")

Expand All @@ -32,33 +45,34 @@ kotlin {
implementation(compose.material)
implementation(compose.materialIconsExtended)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation("org.jetbrains.compose.components:components-resources:1.6.0-dev1306")
implementation("org.jetbrains.compose.components:components-resources:${project.property("compose.version")}")
}
}
val androidMain by getting {
dependencies {
api("androidx.activity:activity-compose:1.7.2")
api("androidx.activity:activity-compose:1.8.2")
api("androidx.appcompat:appcompat:1.6.1")
api("androidx.core:core-ktx:1.10.1")
api("androidx.core:core-ktx:1.12.0")
}
}
val iosMain by creating {
dependsOn(commonMain)
}
val iosX64Main by getting {
dependsOn(iosMain)
}
val iosArm64Main by getting {
dependsOn(iosMain)
}
val iosSimulatorArm64Main by getting {
dependsOn(iosMain)
}
val desktopMain by getting {
dependencies {
implementation(compose.desktop.common)
}
}
val desktopTest by getting {
dependencies {
implementation(compose.desktop.currentOs)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))

@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.uiTest)
}
}
}
}

Expand All @@ -71,6 +85,7 @@ android {

defaultConfig {
minSdk = 26
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.SemanticsProperties
import androidx.compose.ui.semantics.semantics
Expand Down Expand Up @@ -115,6 +116,10 @@ private fun WidgetsListView(widgetsTypeState: MutableState<WidgetsType>) {

}

val WidgetsType.listItemTestTag: String
get() = "${testTag}_list_item"


@Composable
private fun WidgetsListItemViewImpl(
widgetsType: WidgetsType,
Expand All @@ -133,6 +138,7 @@ private fun WidgetsListItemViewImpl(
}
.height(height)
.padding(start = 16.dp)
.testTag(widgetsType.listItemTestTag)
) {
val inFocusInteractionSource = remember { MutableInteractionSource() }
val inFocus by inFocusInteractionSource.collectIsHoveredAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.jetbrains.compose.demo.widgets.ui

import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
Expand All @@ -19,7 +18,7 @@ fun WidgetsView(
modifier: Modifier
) {
ClearFocusBox {
Column(modifier = modifier.verticalScroll(state = rememberScrollState())) {
Box(modifier = modifier.verticalScroll(state = rememberScrollState())) {
@Suppress("UNUSED_VARIABLE")
val exhaustive = when (widgetsTypeState.value) {
WidgetsType.APP_BARS -> AppBars()
Expand Down
Loading
Loading