mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Mostly move to 1.0.0-alpha4-build361
This commit is contained in:
@@ -8,10 +8,10 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1")
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha4-build361")
|
||||
classpath("com.android.tools.build:gradle:4.0.1")
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
classpath(kotlin("gradle-plugin", version = "1.5.21"))
|
||||
classpath(kotlin("gradle-plugin", version = "1.5.31"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,6 @@ actual fun VerticalScrollbar(
|
||||
itemCount: Int,
|
||||
averageItemSize: Dp
|
||||
) = androidx.compose.foundation.VerticalScrollbar(
|
||||
rememberScrollbarAdapter(scrollState, itemCount, averageItemSize),
|
||||
rememberScrollbarAdapter(scrollState),
|
||||
modifier
|
||||
)
|
||||
@@ -4,9 +4,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
kotlin("jvm") version "1.5.21"
|
||||
kotlin("jvm") version "1.5.31"
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
id("org.jetbrains.compose") version "1.0.0-alpha1"
|
||||
id("org.jetbrains.compose") version "1.0.0-alpha4-build361"
|
||||
}
|
||||
|
||||
group = "me.user"
|
||||
|
||||
@@ -7,9 +7,9 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1")
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha4-build361")
|
||||
classpath("com.android.tools.build:gradle:4.1.0")
|
||||
classpath(kotlin("gradle-plugin", version = "1.5.21"))
|
||||
classpath(kotlin("gradle-plugin", version = "1.5.31"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ allprojects {
|
||||
mavenCentral()
|
||||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ import java.awt.image.BufferedImage
|
||||
import java.io.File
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
import org.jetbrains.skija.Image.makeFromEncoded
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import org.jetbrains.skia.Image
|
||||
|
||||
object ContentState {
|
||||
val drag = DragHandler()
|
||||
@@ -241,7 +241,7 @@ object ContentState {
|
||||
}
|
||||
|
||||
fun updateMainImage() {
|
||||
MainImageWrapper.mainImageAsImageBitmap.value = makeFromEncoded(
|
||||
MainImageWrapper.mainImageAsImageBitmap.value = Image.makeFromEncoded(
|
||||
toByteArray(
|
||||
cropBitmapByScale(
|
||||
mainImage.value,
|
||||
@@ -363,4 +363,4 @@ private object MainImageWrapper {
|
||||
graphics.drawImage(bitmap, 0, 0, result.width, result.height, null)
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ fun Miniature(
|
||||
}
|
||||
) {
|
||||
Image(
|
||||
org.jetbrains.skija.Image.makeFromEncoded(
|
||||
org.jetbrains.skia.Image.makeFromEncoded(
|
||||
toByteArray(picture.image)
|
||||
).asImageBitmap(),
|
||||
contentDescription = null,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package example.imageviewer.view
|
||||
|
||||
import androidx.compose.foundation.BoxWithTooltip
|
||||
import androidx.compose.foundation.TooltipArea
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.MaterialTheme
|
||||
@@ -16,7 +17,7 @@ fun Tooltip(
|
||||
text: String = "Tooltip",
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
BoxWithTooltip(
|
||||
TooltipArea(
|
||||
tooltip = {
|
||||
Surface(
|
||||
color = Color(210, 210, 210),
|
||||
|
||||
@@ -3,9 +3,9 @@ import org.jetbrains.compose.compose
|
||||
plugins {
|
||||
id("org.jetbrains.intellij") version "1.1.4"
|
||||
java
|
||||
kotlin("jvm") version "1.5.21"
|
||||
kotlin("jvm") version "1.5.31"
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
id("org.jetbrains.compose") version "1.0.0-alpha1"
|
||||
id("org.jetbrains.compose") version "1.0.0-alpha4-build361"
|
||||
id("idea")
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha1")
|
||||
classpath("org.jetbrains.compose:compose-gradle-plugin:1.0.0-alpha4-build361")
|
||||
classpath("com.android.tools.build:gradle:4.1.0")
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
classpath(kotlin("gradle-plugin", version = "1.5.21"))
|
||||
classpath(kotlin("gradle-plugin", version = "1.5.31"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
|
||||
plugins {
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
kotlin("jvm") version "1.5.30"
|
||||
kotlin("jvm") version "1.5.31"
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha4-build328")
|
||||
id("org.jetbrains.compose") version (System.getenv("COMPOSE_TEMPLATE_COMPOSE_VERSION") ?: "1.0.0-alpha4-build361")
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -109,32 +109,49 @@ In this example Text/TextField context menus will be extended with two additiona
|
||||
There is a possibility to create a context menu for an arbitrary application window area. This is implemented using ContextMenuArea API that is
|
||||
similar to ContextMenuDataProvider.
|
||||
```kotlin
|
||||
import androidx.compose.desktop.DesktopMaterialTheme
|
||||
import androidx.compose.foundation.ContextMenuArea
|
||||
import androidx.compose.foundation.ContextMenuDataProvider
|
||||
import androidx.compose.foundation.ContextMenuItem
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextField
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.singleWindowApplication
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class, androidx.compose.foundation.ExperimentalFoundationApi::class)
|
||||
fun main() = singleWindowApplication(title = "Context menu") {
|
||||
DesktopMaterialTheme { //it is mandatory for Context Menu
|
||||
ContextMenuArea(items = {
|
||||
listOf(
|
||||
ContextMenuItem("User-defined Action") {/*do something here*/},
|
||||
ContextMenuItem("Another user-defined action") {/*do something else*/}
|
||||
)
|
||||
}) {
|
||||
Box(modifier = Modifier.background(Color.Blue).height(100.dp).width(100.dp)) {
|
||||
MaterialTheme { //it is mandatory for Context Menu
|
||||
val text = remember {mutableStateOf("Hello!")}
|
||||
Column {
|
||||
ContextMenuDataProvider(
|
||||
items = {
|
||||
listOf(
|
||||
ContextMenuItem("User-defined Action") {/*do something here*/},
|
||||
ContextMenuItem("Another user-defined action") {/*do something else*/}
|
||||
)
|
||||
}
|
||||
) {
|
||||
TextField(
|
||||
value = text.value,
|
||||
onValueChange = { text.value = it },
|
||||
label = { Text(text = "Input") }
|
||||
)
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
SelectionContainer {
|
||||
Text("Hello World!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Right click on the Blue Square will show a context menu with two items
|
||||
|
||||
@@ -264,7 +264,8 @@ The main arguments of the `BoxWithTooltip` function:
|
||||
- delay - time delay in milliseconds after which the tooltip will be shown (default is 500 ms)
|
||||
|
||||
```kotlin
|
||||
import androidx.compose.foundation.BoxWithTooltip
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.TooltipArea
|
||||
import androidx.compose.foundation.TooltipPlacement
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -285,7 +286,7 @@ import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.application
|
||||
import androidx.compose.ui.window.rememberWindowState
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@OptIn(ExperimentalComposeUiApi::class, ExperimentalFoundationApi::class)
|
||||
fun main() = application {
|
||||
Window(
|
||||
onCloseRequest = ::exitApplication,
|
||||
@@ -296,8 +297,7 @@ fun main() = application {
|
||||
Column(Modifier.fillMaxSize(), Arrangement.spacedBy(5.dp)) {
|
||||
buttons.forEachIndexed { index, name ->
|
||||
// wrap button in BoxWithTooltip
|
||||
BoxWithTooltip(
|
||||
modifier = Modifier.padding(start = 40.dp),
|
||||
TooltipArea(
|
||||
tooltip = {
|
||||
// composable tooltip content
|
||||
Surface(
|
||||
@@ -311,7 +311,8 @@ fun main() = application {
|
||||
)
|
||||
}
|
||||
},
|
||||
delay = 600, // in milliseconds
|
||||
modifier = Modifier.padding(start = 40.dp),
|
||||
delayMillis = 600, // in milliseconds
|
||||
tooltipPlacement = TooltipPlacement.CursorPoint(
|
||||
alignment = Alignment.BottomEnd,
|
||||
offset = if (index % 2 == 0) DpOffset(-16.dp, 0.dp) else DpOffset.Zero // tooltip offset
|
||||
|
||||
@@ -159,7 +159,7 @@ fun main() = singleWindowApplication {
|
||||
Compose for Desktop contains desktop-only `Modifier.mouseClickable`, where data about pressed mouse buttons and keyboard modifiers is available. This is an experimental API, which means that it's likely to be changed before release.
|
||||
|
||||
```kotlin
|
||||
import androidx.compose.foundation.ExperimentalDesktopApi
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.mouseClickable
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -176,7 +176,7 @@ import androidx.compose.ui.input.pointer.isShiftPressed
|
||||
import androidx.compose.ui.input.pointer.isTertiaryPressed
|
||||
import androidx.compose.ui.window.singleWindowApplication
|
||||
|
||||
@OptIn(ExperimentalDesktopApi::class)
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
fun main() = singleWindowApplication {
|
||||
var clickableText by remember { mutableStateOf("Click me!") }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user