From 88c4e27d6e312c5b81445878d92040e02dbe26e0 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Sun, 1 Aug 2021 14:22:46 +0300 Subject: [PATCH] Move intellijPlugin to 1.0.0-alpha1-rc1 --- examples/intelliJPlugin/build.gradle.kts | 9 ++-- .../jetbrains/compose/ComposeDemoAction.kt | 47 +++++++++---------- .../compose/ComposeSizeAdjustmentWrapper.kt | 45 ------------------ 3 files changed, 25 insertions(+), 76 deletions(-) delete mode 100755 examples/intelliJPlugin/src/main/kotlin/com/jetbrains/compose/ComposeSizeAdjustmentWrapper.kt diff --git a/examples/intelliJPlugin/build.gradle.kts b/examples/intelliJPlugin/build.gradle.kts index 26b273e4b6..769f444ae9 100644 --- a/examples/intelliJPlugin/build.gradle.kts +++ b/examples/intelliJPlugin/build.gradle.kts @@ -3,9 +3,9 @@ import org.jetbrains.compose.compose plugins { id("org.jetbrains.intellij") version "0.6.5" java - kotlin("jvm") version "1.5.10" + kotlin("jvm") version "1.5.21" // __LATEST_COMPOSE_RELEASE_VERSION__ - id("org.jetbrains.compose") version "0.4.0" + id("org.jetbrains.compose") version "1.0.0-alpha1-rc1" } group = "org.example" @@ -13,19 +13,18 @@ version = "1.0-SNAPSHOT" repositories { mavenCentral() + google() maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") } } dependencies { - implementation(kotlin("stdlib")) - implementation("org.jetbrains.compose.material:material:") implementation(compose.desktop.currentOs) testCompile("junit", "junit", "4.12") } // See https://github.com/JetBrains/gradle-intellij-plugin/ intellij { - version = "2021.1" + version = "2021.2" } tasks.getByName("patchPluginXml") { changeNotes(""" diff --git a/examples/intelliJPlugin/src/main/kotlin/com/jetbrains/compose/ComposeDemoAction.kt b/examples/intelliJPlugin/src/main/kotlin/com/jetbrains/compose/ComposeDemoAction.kt index 8b32298ff9..581c8cbe91 100755 --- a/examples/intelliJPlugin/src/main/kotlin/com/jetbrains/compose/ComposeDemoAction.kt +++ b/examples/intelliJPlugin/src/main/kotlin/com/jetbrains/compose/ComposeDemoAction.kt @@ -1,6 +1,5 @@ package com.jetbrains.compose -import androidx.compose.desktop.ComposePanel import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -8,12 +7,14 @@ import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.material.Surface import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.IntSize +import androidx.compose.ui.awt.ComposePanel +import androidx.compose.ui.layout.Layout +import androidx.compose.ui.layout.MeasurePolicy +import androidx.compose.ui.layout.onGloballyPositioned import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.project.Project import com.intellij.openapi.ui.DialogWrapper -import com.intellij.ui.layout.panel import com.jetbrains.compose.theme.WidgetTheme import com.jetbrains.compose.widgets.Buttons import com.jetbrains.compose.widgets.LazyScrollable @@ -22,6 +23,7 @@ import com.jetbrains.compose.widgets.TextInputs import com.jetbrains.compose.widgets.Toggles import java.awt.Dimension import javax.swing.JComponent +import javax.swing.SwingUtilities /** @@ -39,31 +41,24 @@ class ComposeDemoAction : DumbAwareAction() { } override fun createCenterPanel(): JComponent { - val dialog = this return ComposePanel().apply { - preferredSize = Dimension(800, 600) + setBounds(0, 0, 800, 600) setContent { - ComposeSizeAdjustmentWrapper( - window = dialog, - panel = this, - preferredSize = IntSize(800, 600) - ) { - WidgetTheme(darkTheme = true) { - Surface(modifier = Modifier.fillMaxSize()) { - Row { - Column( - modifier = Modifier.fillMaxHeight().weight(1f) - ) { - Buttons() - Loaders() - TextInputs() - Toggles() - } - Box( - modifier = Modifier.fillMaxHeight().weight(1f) - ) { - LazyScrollable() - } + WidgetTheme(darkTheme = true) { + Surface(modifier = Modifier.fillMaxSize()) { + Row { + Column( + modifier = Modifier.fillMaxHeight().weight(1f) + ) { + Buttons() + Loaders() + TextInputs() + Toggles() + } + Box( + modifier = Modifier.fillMaxHeight().weight(1f) + ) { + LazyScrollable() } } } diff --git a/examples/intelliJPlugin/src/main/kotlin/com/jetbrains/compose/ComposeSizeAdjustmentWrapper.kt b/examples/intelliJPlugin/src/main/kotlin/com/jetbrains/compose/ComposeSizeAdjustmentWrapper.kt deleted file mode 100755 index 5fc21da40a..0000000000 --- a/examples/intelliJPlugin/src/main/kotlin/com/jetbrains/compose/ComposeSizeAdjustmentWrapper.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.jetbrains.compose - -import androidx.compose.desktop.ComposePanel -import androidx.compose.foundation.layout.Box -import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.Layout -import androidx.compose.ui.layout.onGloballyPositioned -import androidx.compose.ui.unit.IntSize -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import com.intellij.openapi.ui.DialogWrapper -import java.awt.Dimension -import java.awt.Window -import javax.swing.JComponent - -@Composable -fun ComposeSizeAdjustmentWrapper( - window: DialogWrapper, - panel: ComposePanel, - preferredSize: IntSize, - content: @Composable () -> Unit -) { - var packed = false - Box { - content() - Layout( - content = {}, - modifier = Modifier.onGloballyPositioned { childCoordinates -> - // adjust size of the dialog - if (!packed) { - val contentSize = childCoordinates.parentCoordinates!!.size - panel.preferredSize = Dimension( - if (contentSize.width < preferredSize.width) preferredSize.width else contentSize.width, - if (contentSize.height < preferredSize.height) preferredSize.height else contentSize.height, - ) - window.pack() - packed = true - } - }, - measurePolicy = { _, _ -> - layout(0, 0) {} - } - ) - } -}