Browse Source

Merge remote-tracking branch 'origin/release/1.2'

pull/2331/merge
Igor Demin 2 years ago
parent
commit
59d4e677b6
  1. 8
      .gitignore
  2. 100
      CHANGELOG.md
  3. 1
      README.md
  4. 2
      ci/compose-uber-jar/gradle.properties
  5. 4
      components/gradle.properties
  6. 9
      examples/codeviewer/README.md
  7. 8
      examples/codeviewer/android/build.gradle.kts
  8. 2
      examples/codeviewer/android/src/main/AndroidManifest.xml
  9. 8
      examples/codeviewer/build.gradle.kts
  10. 17
      examples/codeviewer/common/build.gradle.kts
  11. 6
      examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt
  12. 4
      examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  13. 1
      examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt
  14. 7
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt
  15. 2
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  16. 18
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt
  17. 21
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt
  18. 11
      examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt
  19. 2
      examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  20. 1
      examples/codeviewer/desktop/build.gradle.kts
  21. 6
      examples/codeviewer/gradle.properties
  22. 2
      examples/codeviewer/gradle/wrapper/gradle-wrapper.properties
  23. BIN
      examples/codeviewer/screenshots/desktop-run-configuration.png
  24. 23
      examples/falling-balls/.run/desktop.run.xml
  25. 7
      examples/falling-balls/README.md
  26. 1
      examples/falling-balls/build.gradle.kts
  27. 4
      examples/falling-balls/gradle.properties
  28. 2
      examples/falling-balls/gradle/wrapper/gradle-wrapper.properties
  29. BIN
      examples/falling-balls/screenshots/desktop-run-configuration.png
  30. 8
      examples/imageviewer/README.md
  31. 8
      examples/imageviewer/android/build.gradle.kts
  32. 2
      examples/imageviewer/android/src/main/AndroidManifest.xml
  33. 12
      examples/imageviewer/common/build.gradle.kts
  34. 10
      examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AndroidHover.kt
  35. 3
      examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Draggable.kt
  36. 10
      examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/PointerMoveFilter.kt
  37. 10
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt
  38. 74
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullscreenImage.kt
  39. 67
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt
  40. 13
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MouseHover.kt
  41. 18
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Toast.kt
  42. 1
      examples/imageviewer/desktop/build.gradle.kts
  43. 6
      examples/imageviewer/gradle.properties
  44. 2
      examples/imageviewer/gradle/wrapper/gradle-wrapper.properties
  45. BIN
      examples/imageviewer/screenshots/desktop-run-configuration.png
  46. 23
      examples/intellij-plugin/.run/runIde.run.xml
  47. 5
      examples/intellij-plugin/README.md
  48. 4
      examples/intellij-plugin/build.gradle.kts
  49. 4
      examples/intellij-plugin/gradle.properties
  50. 2
      examples/intellij-plugin/gradle/wrapper/gradle-wrapper.properties
  51. BIN
      examples/intellij-plugin/screenshots/ide-run-configuration.png
  52. 35
      examples/intellij-plugin/src/main/kotlin/com/jetbrains/compose/widgets/LazyScrollable.kt
  53. 23
      examples/issues/.run/desktop.run.xml
  54. 8
      examples/issues/README.md
  55. 6
      examples/issues/android/build.gradle.kts
  56. 2
      examples/issues/android/src/main/AndroidManifest.xml
  57. 10
      examples/issues/common/build.gradle.kts
  58. 13
      examples/issues/common/src/jvmAndAndroidMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt
  59. 1
      examples/issues/desktop/build.gradle.kts
  60. 6
      examples/issues/gradle.properties
  61. 2
      examples/issues/gradle/wrapper/gradle-wrapper.properties
  62. BIN
      examples/issues/screenshots/desktop-run-configuration.png
  63. 8
      examples/notepad/README.md
  64. 1
      examples/notepad/build.gradle.kts
  65. 4
      examples/notepad/gradle.properties
  66. 2
      examples/notepad/gradle/wrapper/gradle-wrapper.properties
  67. BIN
      examples/notepad/screenshots/desktop-run-configuration.png
  68. 1
      examples/notepad/src/main/kotlin/common/AppResources.kt
  69. 23
      examples/todoapp-lite/.run/desktop.run.xml
  70. 8
      examples/todoapp-lite/README.md
  71. 10
      examples/todoapp-lite/android/build.gradle.kts
  72. 2
      examples/todoapp-lite/android/src/main/AndroidManifest.xml
  73. 8
      examples/todoapp-lite/common/build.gradle.kts
  74. 1
      examples/todoapp-lite/desktop/build.gradle.kts
  75. 6
      examples/todoapp-lite/gradle.properties
  76. 2
      examples/todoapp-lite/gradle/wrapper/gradle-wrapper.properties
  77. BIN
      examples/todoapp-lite/screenshots/desktop-run-configuration.png
  78. 23
      examples/todoapp/.run/browser.run.xml
  79. 23
      examples/todoapp/.run/desktop.run.xml
  80. 14
      examples/todoapp/README.md
  81. 8
      examples/todoapp/android/build.gradle.kts
  82. 5
      examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt
  83. 4
      examples/todoapp/buildSrc/gradle.properties
  84. 2
      examples/todoapp/buildSrc/src/main/kotlin/multiplatform-compose-setup.gradle.kts
  85. 2
      examples/todoapp/common/compose-ui/src/commonMain/kotlin/example/todo/common/ui/TodoEditUi.kt
  86. 2
      examples/todoapp/desktop/build.gradle.kts
  87. 6
      examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt
  88. 6
      examples/todoapp/gradle.properties
  89. 2
      examples/todoapp/gradle/wrapper/gradle-wrapper.properties
  90. BIN
      examples/todoapp/screenshots/browser-run-configuration.png
  91. BIN
      examples/todoapp/screenshots/desktop-run-configuration.png
  92. 4
      examples/todoapp/web/build.gradle.kts
  93. 4
      examples/todoapp/web/src/jsMain/kotlin/example/todo/web/App.kt
  94. 5
      examples/todoapp/web/src/jsMain/kotlin/example/todo/web/Components.kt
  95. 23
      examples/visual-effects/.run/desktop.run.xml
  96. 6
      examples/visual-effects/README.md
  97. 1
      examples/visual-effects/build.gradle.kts
  98. 4
      examples/visual-effects/gradle.properties
  99. 2
      examples/visual-effects/gradle/wrapper/gradle-wrapper.properties
  100. BIN
      examples/visual-effects/screenshots/desktop-run-configuration.png
  101. Some files were not shown because too many files have changed in this diff Show More

8
.gitignore vendored

@ -4,13 +4,7 @@ out
*.iml
.gradle
/local.properties
/.idea
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.idea/
.DS_Store
build/
/captures

100
CHANGELOG.md

@ -1,3 +1,84 @@
# 1.2.0 (October 2022)
## Common
### Features
* [Allow to use Compose on multiple Kotlin versions](https://github.com/JetBrains/compose-jb/pull/2366)
* [`import org.jetbrains.compose.compose` is no longer needed in build.gradle.kts](https://github.com/JetBrains/compose-jb/pull/2215)
* [Allow to use a custom Compose Compiler](https://github.com/JetBrains/compose-jb/pull/2347)
## Desktop
### Features
* [Support Kotlin 1.7.20](https://github.com/JetBrains/compose-jb/pull/2357)
* [ProGuard integration for packaging](https://github.com/JetBrains/compose-jb/pull/2313)
* [New experimental event API (onClick, onDrag, WindowInfo.keyboardModifiers)](https://github.com/JetBrains/compose-jb/tree/master/tutorials/Mouse_Events#new-experimental-onclick-handlers-only-for-desktop-jvm-platform)
* Focus
* [Make clickable, mouseClickable, toggleable request focus onClick](https://github.com/JetBrains/androidx/pull/257)
* [Toggle a toggleable component on Space key](https://github.com/JetBrains/androidx/pull/262)
* [Make Slider change the value with onKeyEvent for: all arrows, PgDn, PdUp, Home, End buttons](https://github.com/JetBrains/androidx/pull/254)
* [Navigate drop down menu items using up and down arrows](https://github.com/JetBrains/androidx/pull/259)
* [Ability to override text context menu globally](https://github.com/JetBrains/compose-jb/tree/master/tutorials/Context_Menu#custom-text-context-menu)
* [Context menu implementation for integrating into Swing applications](https://github.com/JetBrains/compose-jb/tree/master/tutorials/Context_Menu#swing-interoperability)
* [Animated image component](https://github.com/JetBrains/compose-jb/pull/2015)
* [Show a new window/dialog on the same display](https://github.com/JetBrains/androidx/pull/312)
* [Change default Font on MacOs to San Francisco](https://github.com/JetBrains/androidx/pull/296)
* Support [performKeyInput](https://github.com/JetBrains/androidx/pull/278), [performMouseInput, performTextInput](https://github.com/JetBrains/androidx/pull/260) in tests.
* Focus switches seamlessly between Swing and Compose components using [SwingPanel](https://github.com/JetBrains/androidx/pull/229) or [ComposePanel](https://github.com/JetBrains/androidx/pull/228)
* [Documentation for how to package apps using Conveyor](https://github.com/JetBrains/compose-jb/tree/master/tutorials/Native_distributions_and_local_execution#available-tools)
### Fixes
* [Fix IDEA plugin compatability](https://github.com/JetBrains/compose-jb/pull/2318)
* Fixes for Right-to-Left languages support
* [LayoutDirection is detected from the system settings](https://github.com/JetBrains/androidx/pull/264)
* [Fix RTL selection in a multiline text](https://github.com/JetBrains/androidx/pull/285)
* [Fix cursor visual position at BiDi transition](https://github.com/JetBrains/androidx/pull/286)
* [Fix the cursor position after the '\n' character in RTL](https://github.com/JetBrains/androidx/pull/268)
* [In placeAutoMirrored for RTL, calculate the placement position using the placeable width respecting the constraints](https://github.com/JetBrains/androidx/pull/267)
* [Placing the root content properly for RTL layout](https://github.com/JetBrains/androidx/pull/265)
* TextField
* [Fix the cursor position when clicking at a position after a line-break](https://github.com/JetBrains/androidx/pull/284)
* [Fix selection with End, Home](https://github.com/JetBrains/androidx/pull/279)
* [Fix the cursor height on a new empty line](https://github.com/JetBrains/androidx/pull/277)
* [Fix DesktopMenu and DesktopAlertDialog to invoke dismiss callback once](https://github.com/JetBrains/androidx/pull/256)
* [Fix a large icon in macOs menu](https://github.com/JetBrains/androidx/pull/248)
* [Fix hover in LazyColumn](https://github.com/JetBrains/androidx/pull/249)
* [Fix pointerHoverIcon: update icon when it's changed conditionally](https://github.com/JetBrains/androidx/pull/231)
* [Fix focusable parameter for Window and Dialog](https://github.com/JetBrains/androidx/pull/225)
* [Fix 2 SplitPanel minor bugs](https://github.com/JetBrains/compose-jb/pull/2175)
* [Fix `java.lang.IllegalStateException: cannot open system clipboard` crash](https://github.com/JetBrains/skiko/pull/586)
* [Fix `System.setProperty("skiko.renderApi", "SOFTWARE"` on macOS](https://github.com/JetBrains/skiko/pull/599)
### API changes
* [Deprecate experimental pointerMoveFilter in favor of onPointerEvent](https://github.com/JetBrains/androidx/pull/247)
* [Deprecate experimental Modifier.mouseClickable in favor of Modifier.onClick](https://github.com/JetBrains/androidx/pull/243)
## Web
### Features
* Support Kotlin 1.7.10
* [Add support for transition in CSS api](https://github.com/JetBrains/compose-jb/pull/2228)
* [Add missing `background-blend-mode` property](https://github.com/JetBrains/compose-jb/pull/2128)
* [SVG: Publish custom attr functions](https://github.com/JetBrains/compose-jb/pull/2127)
* [Add list overload for `classes`](https://github.com/JetBrains/compose-jb/pull/2094)
* [Add support of dl, dt and dd](https://github.com/JetBrains/compose-jb/pull/1922)
### Fixes
* [Add pom information and license to Web artifacts](https://github.com/JetBrains/compose-jb/pull/2195)
### API changes
* [Deprecate 3 overloads of StyleScope.borderWidth with wrong parameter names](https://github.com/JetBrains/compose-jb/pull/2297)
* [Remove deprecated compose.web.web-widgets from the source code](https://github.com/JetBrains/compose-jb/pull/2294)
* [Remove unnecessary parameter for `required` attribute](https://github.com/JetBrains/compose-jb/pull/1988)
## Updated dependencies
This version of Compose Multiplatform is based on the next Jetpack Compose libraries:
* [Compiler 1.3.2](https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.3.2)
* [Runtime 1.2.1](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.2.1)
* [UI 1.2.1](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.2.1)
* [Foundation 1.2.1](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.2.1)
* [Material 1.2.1](https://developer.android.com/jetpack/androidx/releases/compose-material#1.2.1)
* [Material3 1.0.0-alpha14](https://developer.android.com/jetpack/androidx/releases/compose-material3#1.0.0-alpha14)
# 1.1.1 (Mar 2022)
## Desktop
@ -42,7 +123,6 @@ fun main() = application {
- [Implement experimental accessibility support for Windows](https://github.com/JetBrains/compose-jb/tree/master/tutorials/Accessibility)
- [Implement accessibility focus tracking by Tab](https://github.com/JetBrains/compose-jb/issues/1772)
- All bugfixes/features between Jetpack Compose 1.1.0-beta02 and 1.1.0 (see the release notes for each module [here](https://developer.android.com/jetpack/androidx/releases/compose))
- Android target depends on Jetpack Compose 1.1.0.
### Fixes
- Fixes for TextField ([1](https://github.com/JetBrains/compose-jb/issues/1834), [2](https://github.com/JetBrains/compose-jb/issues/1615), [3](https://github.com/JetBrains/compose-jb/issues/1781), [4](https://github.com/JetBrains/compose-jb/issues/1670))
@ -77,6 +157,15 @@ fun main() = singleWindowApplication {
```
- [`PointerEvent.awtEvent`, `KeyEvent.awtEvent` are deprecated](https://github.com/JetBrains/androidx/pull/198), use `PointerEvent.awtEventOrNull`, `KeyEvent.awtEventOrNull` instead. The event can be null, if it isn't sent by AWT (for example, Compose can send synthetic Move events on relayout)
## Updated dependencies
This version of Compose Multiplatform is based on the next Jetpack Compose libraries:
* [Compiler 1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.1.0)
* [Runtime 1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.1.0)
* [UI 1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)
* [Foundation 1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.1.0)
* [Material 1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-material#1.1.0)
* [Material3 1.0.0-alpha05](https://developer.android.com/jetpack/androidx/releases/compose-material3#1.0.0-alpha05)
# 1.0.1 (Dec 2021)
This is basically 1.0.0 that works with Kotlin 1.6.10
@ -103,6 +192,15 @@ This is basically 1.0.0 that works with Kotlin 1.6.10
- [Some functions were made internal (either not related to compose-web or not intended for usage in apps): buildCSS , StylePropertyList.nativeEquals , variableValue , buildCSSStyleRule , buildKeyframes , jsObject , CSSKeyframesRule.appendRule](https://github.com/JetBrains/compose-jb/pull/1509/files)
- CSSMediaRule: functions feature and combine were made extensions functions on GenericStyleSheetBuilder. This makes them consistent with the rest of functions which create CSSMediaQuery.MediaFeature instances
## Updated dependencies
This version of Compose Multiplatform is based on the next Jetpack Compose libraries:
* [Compiler 1.1.0-beta02](https://developer.android.com/jetpack/androidx/releases/compose-compiler#1.1.0-beta02)
* [Runtime 1.1.0-beta02](https://developer.android.com/jetpack/androidx/releases/compose-runtime#1.1.0-beta02)
* [UI 1.1.0-beta02](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0-beta02)
* [Foundation 1.1.0-beta02](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.1.0-beta02)
* [Material 1.1.0-beta02](https://developer.android.com/jetpack/androidx/releases/compose-material#1.1.0-beta02)
* [Material3 1.0.0-alpha03](https://developer.android.com/jetpack/androidx/releases/compose-material3#1.0.0-alpha03)
# 1.0.0-beta (Oct 2021)
## Common
- no Android artifacts are published anymore. Google-published artifacts are referenced instead. This approach eliminates compatibility issues.

1
README.md

@ -67,6 +67,7 @@ Note that when you use Compose Multiplatform, you setup your project differently
* [components](components) - custom components of Compose Multiplatform
* [Split Pane](components/SplitPane)
* [experimental](experimental) - experimental components and examples
* [examples](experimental/examples) - examples that use new experimental functionality
* [cef](experimental/cef) - CEF integration in Jetpack Compose (somewhat outdated)
* [Video Player](experimental/components/VideoPlayer)
* [LWJGL integration](experimental/lwjgl-integration) - An example showing how to integrate Compose with [LWJGL](https://www.lwjgl.org)

2
ci/compose-uber-jar/gradle.properties

@ -1,2 +1,2 @@
compose.version=1.1.0
compose.version=1.2.0
kotlin.code.style=official

4
components/gradle.properties

@ -3,6 +3,6 @@ android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
# __KOTLIN_COMPOSE_VERSION__
kotlin.version=1.6.10
kotlin.version=1.7.20
# __LATEST_COMPOSE_RELEASE_VERSION__
compose.version=1.1.0
compose.version=1.2.0

9
examples/codeviewer/README.md

@ -1,13 +1,14 @@
MPP Code Viewer example for desktop/android written in Multiplatform Compose library.
### Running desktop application
```
./gradlew :desktop:run
```
* To run, launch command: `./gradlew :desktop:run`
* Or choose **desktop** configuration in IDE and run it.
![desktop-run-configuration.png](screenshots/desktop-run-configuration.png)
### Building native desktop distribution
```
./gradlew :desktop:package
./gradlew :desktop:packageDistributionForCurrentOS
# outputs are written to desktop/build/compose/binaries
```

8
examples/codeviewer/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
}
android {
compileSdkVersion(31)
compileSdk = 32
defaultConfig {
minSdkVersion(26)
targetSdkVersion(31)
minSdk = 26
targetSdk = 32
versionCode = 1
versionName = "1.0"
}
@ -22,5 +22,5 @@ android {
dependencies {
implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.4.0")
implementation("androidx.activity:activity-compose:1.5.0")
}

2
examples/codeviewer/android/src/main/AndroidManifest.xml

@ -12,7 +12,7 @@
<activity
android:exported="true"
android:name="MainActivity"
android:label="@string/app_name">
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

8
examples/codeviewer/build.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
// this is necessary to avoid the plugins to be loaded multiple times
// in each subproject's classloader
@ -17,10 +15,4 @@ subprojects {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
plugins.withId("org.jetbrains.kotlin.multiplatform") {
tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
}
}

17
examples/codeviewer/common/build.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.compose.compose
plugins {
id("com.android.library")
kotlin("multiplatform")
@ -22,8 +20,8 @@ kotlin {
named("androidMain") {
kotlin.srcDirs("src/jvmMain/kotlin")
dependencies {
api("androidx.appcompat:appcompat:1.4.1")
api("androidx.core:core-ktx:1.7.0")
api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.8.0")
}
}
named("desktopMain") {
@ -36,16 +34,11 @@ kotlin {
}
android {
compileSdkVersion(31)
compileSdk = 32
defaultConfig {
minSdkVersion(21)
targetSdkVersion(31)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
minSdk = 26
targetSdk = 32
}
sourceSets {

6
examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt

@ -3,10 +3,4 @@ package org.jetbrains.codeviewer.platform
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
actual fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this
actual fun Modifier.cursorForHorizontalResize() = this

4
examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -1,13 +1,15 @@
package org.jetbrains.codeviewer.platform
import android.annotation.SuppressLint
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
@SuppressLint("DiscouragedApi")
@Composable
actual fun Font(name: String, res: String, weight: FontWeight, style: FontStyle): Font {
actual fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font {
val context = LocalContext.current
val id = context.resources.getIdentifier(res, "font", context.packageName)
return Font(id, weight, style)

1
examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt

@ -4,7 +4,6 @@ import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
@Composable
actual fun VerticalScrollbar(

7
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt

@ -1,12 +1,5 @@
package org.jetbrains.codeviewer.platform
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
expect fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean = { true },
onExit: () -> Boolean = { true },
onMove: (Offset) -> Boolean = { true }
): Modifier
expect fun Modifier.cursorForHorizontalResize(): Modifier

2
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -6,4 +6,4 @@ import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
@Composable
expect fun Font(name: String, res: String, weight: FontWeight, style: FontStyle): Font
expect fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font

18
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt

@ -4,57 +4,57 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import org.jetbrains.codeviewer.platform.Font
import org.jetbrains.codeviewer.platform.font
object Fonts {
@Composable
fun jetbrainsMono() = FontFamily(
Font(
font(
"JetBrains Mono",
"jetbrainsmono_regular",
FontWeight.Normal,
FontStyle.Normal
),
Font(
font(
"JetBrains Mono",
"jetbrainsmono_italic",
FontWeight.Normal,
FontStyle.Italic
),
Font(
font(
"JetBrains Mono",
"jetbrainsmono_bold",
FontWeight.Bold,
FontStyle.Normal
),
Font(
font(
"JetBrains Mono",
"jetbrainsmono_bold_italic",
FontWeight.Bold,
FontStyle.Italic
),
Font(
font(
"JetBrains Mono",
"jetbrainsmono_extrabold",
FontWeight.ExtraBold,
FontStyle.Normal
),
Font(
font(
"JetBrains Mono",
"jetbrainsmono_extrabold_italic",
FontWeight.ExtraBold,
FontStyle.Italic
),
Font(
font(
"JetBrains Mono",
"jetbrainsmono_medium",
FontWeight.Medium,
FontStyle.Normal
),
Font(
font(
"JetBrains Mono",
"jetbrainsmono_medium_italic",
FontWeight.Medium,

21
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/filetree/FileTreeView.kt

@ -1,6 +1,9 @@
package org.jetbrains.codeviewer.ui.filetree
import androidx.compose.foundation.clickable
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
@ -11,6 +14,7 @@ import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
@ -24,7 +28,6 @@ import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.jetbrains.codeviewer.platform.VerticalScrollbar
import org.jetbrains.codeviewer.platform.pointerMoveFilter
import org.jetbrains.codeviewer.util.withoutWidthConstraints
@Composable
@ -76,25 +79,17 @@ private fun FileTreeItemView(fontSize: TextUnit, height: Dp, model: FileTree.Ite
.height(height)
.fillMaxWidth()
) {
val active = remember { mutableStateOf(false) }
val interactionSource = remember { MutableInteractionSource() }
val active by interactionSource.collectIsHoveredAsState()
FileItemIcon(Modifier.align(Alignment.CenterVertically), model)
Text(
text = model.name,
color = if (active.value) LocalContentColor.current.copy(alpha = 0.60f) else LocalContentColor.current,
color = if (active) LocalContentColor.current.copy(alpha = 0.60f) else LocalContentColor.current,
modifier = Modifier
.align(Alignment.CenterVertically)
.clipToBounds()
.pointerMoveFilter(
onEnter = {
active.value = true
true
},
onExit = {
active.value = false
true
}
),
.hoverable(interactionSource),
softWrap = true,
fontSize = fontSize,
overflow = TextOverflow.Ellipsis,

11
examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Mouse.kt

@ -2,20 +2,9 @@ package org.jetbrains.codeviewer.platform
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
import androidx.compose.ui.input.pointer.pointerMoveFilter
import java.awt.Cursor
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.pointerMoveFilter(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove)
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.cursorForHorizontalResize(): Modifier =
this.pointerHoverIcon(PointerIcon(Cursor(Cursor.E_RESIZE_CURSOR)))

2
examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -6,5 +6,5 @@ import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
@Composable
actual fun Font(name: String, res: String, weight: FontWeight, style: FontStyle): Font =
actual fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font =
androidx.compose.ui.text.platform.Font("font/$res.ttf", weight, style)

1
examples/codeviewer/desktop/build.gradle.kts

@ -1,4 +1,3 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {

6
examples/codeviewer/gradle.properties

@ -19,6 +19,6 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.version=1.6.10
agp.version=7.0.4
compose.version=1.1.0
kotlin.version=1.7.20
agp.version=7.1.3
compose.version=1.2.0

2
examples/codeviewer/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/codeviewer/screenshots/desktop-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

23
examples/falling-balls/.run/desktop.run.xml

@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="desktop" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="run" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>

7
examples/falling-balls/README.md

@ -0,0 +1,7 @@
Falling Balls game
### Running desktop application
* To run, launch command: `./gradlew run`
* Or choose **desktop** configuration in IDE and run it.
![desktop-run-configuration.png](screenshots/desktop-run-configuration.png)

1
examples/falling-balls/build.gradle.kts

@ -1,4 +1,3 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

4
examples/falling-balls/gradle.properties

@ -1,3 +1,3 @@
kotlin.code.style=official
kotlin.version=1.6.10
compose.version=1.1.0
kotlin.version=1.7.20
compose.version=1.2.0

2
examples/falling-balls/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/falling-balls/screenshots/desktop-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

8
examples/imageviewer/README.md

@ -1,13 +1,13 @@
An example of image gallery for remote server image viewing, based on Jetpack Compose UI library (desktop and android).
### Running desktop application
```
./gradlew :desktop:run
```
* To run, launch command: `./gradlew :desktop:run`
* Or choose **desktop** configuration in IDE and run it.
![desktop-run-configuration.png](screenshots/desktop-run-configuration.png)
### Building native desktop distribution
```
./gradlew :desktop:package
./gradlew :desktop:packageDistributionForCurrentOS
# outputs are written to desktop/build/compose/binaries
```

8
examples/imageviewer/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
}
android {
compileSdk = 31
compileSdk = 32
defaultConfig {
minSdk = 21
targetSdk = 31
minSdk = 26
targetSdk = 32
versionCode = 1
versionName = "1.0"
}
@ -22,5 +22,5 @@ android {
dependencies {
implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.3.1")
implementation("androidx.activity:activity-compose:1.5.0")
}

2
examples/imageviewer/android/src/main/AndroidManifest.xml

@ -17,7 +17,7 @@
<activity
android:exported="true"
android:name="example.imageviewer.MainActivity"
android:label="@string/app_name">
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

12
examples/imageviewer/common/build.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.compose.compose
plugins {
id("com.android.library")
kotlin("multiplatform")
@ -20,8 +18,8 @@ kotlin {
}
named("androidMain") {
dependencies {
api("androidx.appcompat:appcompat:1.3.1")
api("androidx.core:core-ktx:1.3.1")
api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.8.0")
implementation("io.ktor:ktor-client-cio:1.4.1")
}
}
@ -35,11 +33,11 @@ kotlin {
}
android {
compileSdk = 31
compileSdk = 32
defaultConfig {
minSdk = 21
targetSdk = 31
minSdk = 26
targetSdk = 32
}
compileOptions {

10
examples/imageviewer/common/src/androidMain/kotlin/example/imageviewer/view/AndroidHover.kt

@ -1,10 +0,0 @@
package example.imageviewer.view
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
actual fun Modifier.hover(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this

3
examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/Draggable.kt

@ -4,7 +4,6 @@ import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.input.pointer.consumePositionChange
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
@ -28,7 +27,7 @@ fun Draggable(
) { change, dragAmount ->
dragHandler.drag(dragAmount)
onUpdate?.invoke()
change.consumePositionChange()
change.consume()
}
}
) {

10
examples/imageviewer/common/src/commonMain/kotlin/example/imageviewer/view/PointerMoveFilter.kt

@ -1,10 +0,0 @@
package example.imageviewer.view
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
expect fun Modifier.hover(
onEnter: () -> Boolean = { true },
onExit: () -> Boolean = { true },
onMove: (Offset) -> Boolean = { true }
): Modifier

10
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/model/DesktopContentState.kt

@ -3,8 +3,8 @@ package example.imageviewer.model
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.toComposeImageBitmap
import example.imageviewer.ResString
import example.imageviewer.core.FilterType
import example.imageviewer.model.filtration.FiltersManager
@ -18,13 +18,9 @@ import example.imageviewer.utils.cropBitmapByScale
import example.imageviewer.utils.toByteArray
import java.awt.image.BufferedImage
import java.io.File
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
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 {
@ -250,7 +246,7 @@ object ContentState {
drag
)
)
).asImageBitmap()
).toComposeImageBitmap()
}
fun swipeNext() {
@ -358,7 +354,7 @@ private object MainImageWrapper {
}
private fun copy(bitmap: BufferedImage) : BufferedImage {
var result = BufferedImage(bitmap.width, bitmap.height, bitmap.type)
val result = BufferedImage(bitmap.width, bitmap.height, bitmap.type)
val graphics = result.createGraphics()
graphics.drawImage(bitmap, 0, 0, result.width, result.height, null)
return result

74
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullscreenImage.kt

@ -1,8 +1,6 @@
package example.imageviewer.view
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@ -12,22 +10,20 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.key
@ -36,14 +32,12 @@ import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.WindowSize
import example.imageviewer.core.FilterType
import example.imageviewer.model.AppState
import example.imageviewer.model.ContentState
import example.imageviewer.model.ScreenType
import example.imageviewer.ResString
import example.imageviewer.style.DarkGray
import example.imageviewer.style.DarkGreen
import example.imageviewer.style.Foreground
import example.imageviewer.style.MiniatureColor
import example.imageviewer.style.TranslucentBlack
@ -74,7 +68,8 @@ fun ToolBar(
text: String,
content: ContentState
) {
val backButtonHover = remember { mutableStateOf(false) }
val backButtonInteractionSource = remember { MutableInteractionSource() }
val backButtonHover by backButtonInteractionSource.collectIsHoveredAsState()
Surface(
color = MiniatureColor,
modifier = Modifier.height(44.dp)
@ -87,16 +82,9 @@ fun ToolBar(
) {
Tooltip(ResString.back) {
Clickable(
modifier = Modifier.hover(
onEnter = {
backButtonHover.value = true
false
},
onExit = {
backButtonHover.value = false
false
})
.background(color = if (backButtonHover.value) TranslucentBlack else Transparent),
modifier = Modifier
.hoverable(backButtonInteractionSource)
.background(color = if (backButtonHover) TranslucentBlack else Transparent),
onClick = {
if (content.isContentReady()) {
content.restoreMainImage()
@ -145,33 +133,27 @@ fun FilterButton(
type: FilterType,
modifier: Modifier = Modifier.size(38.dp)
) {
val filterButtonHover = remember { mutableStateOf(false) }
Box(
modifier = Modifier.background(color = Transparent).clip(CircleShape)
) {
Tooltip("$type") {
Clickable(
modifier = Modifier.hover(
onEnter = {
filterButtonHover.value = true
false
},
onExit = {
filterButtonHover.value = false
false
})
.background(color = if (filterButtonHover.value) TranslucentBlack else Transparent),
onClick = { content.toggleFilter(type)}
) {
Image(
getFilterImage(type = type, content = content),
contentDescription = null,
modifier
)
}
val interactionSource = remember { MutableInteractionSource() }
val filterButtonHover by interactionSource.collectIsHoveredAsState()
Box(
modifier = Modifier.background(color = Transparent).clip(CircleShape)
) {
Tooltip("$type") {
Clickable(
modifier = Modifier
.hoverable(interactionSource)
.background(color = if (filterButtonHover) TranslucentBlack else Transparent),
onClick = { content.toggleFilter(type)}
) {
Image(
getFilterImage(type = type, content = content),
contentDescription = null,
modifier
)
}
}
Spacer(Modifier.width(20.dp))
}
Spacer(Modifier.width(20.dp))
}
@Composable

67
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt

@ -1,9 +1,6 @@
package example.imageviewer.view
import androidx.compose.foundation.Image
import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@ -12,32 +9,26 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsHoveredAsState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Card
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Divider
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.toComposeImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import example.imageviewer.ResString
@ -81,7 +72,8 @@ fun TopContent(content: ContentState) {
@Composable
fun TitleBar(text: String, content: ContentState) {
val refreshButtonHover = remember { mutableStateOf(false) }
val interactionSource = remember { MutableInteractionSource() }
val refreshButtonHover by interactionSource.collectIsHoveredAsState()
TopAppBar(
backgroundColor = DarkGreen,
title = {
@ -98,17 +90,9 @@ fun TitleBar(text: String, content: ContentState) {
) {
Tooltip(ResString.refresh) {
Clickable(
modifier = Modifier.hover(
onEnter = {
refreshButtonHover.value = true
false
},
onExit = {
refreshButtonHover.value = false
false
}
)
.background(color = if (refreshButtonHover.value) TranslucentBlack else Transparent),
modifier = Modifier
.hoverable(interactionSource)
.background(color = if (refreshButtonHover) TranslucentBlack else Transparent),
onClick = {
if (content.isContentReady()) {
content.refresh()
@ -160,20 +144,15 @@ fun Miniature(
picture: Picture,
content: ContentState
) {
val cardHover = remember { mutableStateOf(false) }
val infoButtonHover = remember { mutableStateOf(false) }
val cardHoverInteractionSource = remember { MutableInteractionSource() }
val cardHover by cardHoverInteractionSource.collectIsHoveredAsState()
val infoButtonInteractionSource = remember { MutableInteractionSource() }
val infoButtonHover by infoButtonInteractionSource.collectIsHoveredAsState()
Card(
backgroundColor = if (cardHover.value) MiniatureHoverColor else MiniatureColor,
backgroundColor = if (cardHover) MiniatureHoverColor else MiniatureColor,
modifier = Modifier.padding(start = 10.dp, end = 18.dp).height(70.dp)
.fillMaxWidth()
.hover(onEnter = {
cardHover.value = true
false
},
onExit = {
cardHover.value = false
false
})
.hoverable(cardHoverInteractionSource)
.clickable {
content.setMainImage(picture)
},
@ -188,7 +167,7 @@ fun Miniature(
Image(
org.jetbrains.skia.Image.makeFromEncoded(
toByteArray(picture.image)
).asImageBitmap(),
).toComposeImageBitmap(),
contentDescription = null,
modifier = Modifier.height(70.dp)
.width(90.dp)
@ -209,16 +188,8 @@ fun Miniature(
Clickable(
modifier = Modifier.height(70.dp)
.width(30.dp)
.hover(
onEnter = {
infoButtonHover.value = true
false
},
onExit = {
infoButtonHover.value = false
false
})
.background(color = if (infoButtonHover.value) TranslucentWhite else Transparent),
.hoverable(infoButtonInteractionSource)
.background(color = if (infoButtonHover) TranslucentWhite else Transparent),
onClick = {
showPopUpMessage(
"${ResString.picture} " +

13
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MouseHover.kt

@ -1,13 +0,0 @@
package example.imageviewer.view
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.pointerMoveFilter
@OptIn(ExperimentalComposeUiApi::class)
actual fun Modifier.hover(
onEnter: () -> Boolean,
onExit: () -> Boolean,
onMove: (Offset) -> Boolean
): Modifier = this.pointerMoveFilter(onEnter = onEnter, onExit = onExit, onMove = onMove)

18
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Toast.kt

@ -7,18 +7,13 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import example.imageviewer.style.Foreground
import example.imageviewer.style.ToastBackground
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
enum class ToastDuration(val value: Int) {
Short(1000), Long(3000)
@ -53,13 +48,10 @@ fun Toast(
color = Foreground
)
}
DisposableEffect(Unit) {
GlobalScope.launch {
delay(duration.value.toLong())
isShown = false
visibility.value = false
}
onDispose { }
LaunchedEffect(Unit) {
delay(duration.value.toLong())
isShown = false
visibility.value = false
}
}
}

1
examples/imageviewer/desktop/build.gradle.kts

@ -1,4 +1,3 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {

6
examples/imageviewer/gradle.properties

@ -19,6 +19,6 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.version=1.6.10
agp.version=7.0.4
compose.version=1.1.0
kotlin.version=1.7.20
agp.version=7.1.3
compose.version=1.2.0

2
examples/imageviewer/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/imageviewer/screenshots/desktop-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

23
examples/intellij-plugin/.run/runIde.run.xml

@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="runIde" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="runIde" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>

5
examples/intellij-plugin/README.md

@ -2,7 +2,10 @@
To run the example:
1. from directory `compose-jb/examples/intellij-plugin` run command in terminal: `./gradlew runIde`
1. from directory `compose-jb/examples/intellij-plugin`:
* Run command in terminal `./gradlew runIde`.
* Or choose **runIde** configuration in IDE and run it.
![ide-run-configuration.png](screenshots/ide-run-configuration.png)
2. create project or open any existing
3. from menu `Tools` select `Show Compose Demo...`

4
examples/intellij-plugin/build.gradle.kts

@ -1,7 +1,5 @@
import org.jetbrains.compose.compose
plugins {
id("org.jetbrains.intellij") version "1.6.0"
id("org.jetbrains.intellij") version "1.9.0"
java
kotlin("jvm")
id("org.jetbrains.compose")

4
examples/intellij-plugin/gradle.properties

@ -1,3 +1,3 @@
kotlin.code.style=official
kotlin.version=1.6.10
compose.version=1.1.0
kotlin.version=1.7.20
compose.version=1.2.0

2
examples/intellij-plugin/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/intellij-plugin/screenshots/ide-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

35
examples/intellij-plugin/src/main/kotlin/com/jetbrains/compose/widgets/LazyScrollable.kt

@ -1,6 +1,5 @@
package com.jetbrains.compose.widgets
import androidx.compose.desktop.DesktopTheme
import androidx.compose.foundation.background
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.lazy.LazyColumn
@ -27,28 +26,26 @@ import androidx.compose.ui.unit.dp
@Composable
fun LazyScrollable() {
MaterialTheme {
DesktopTheme {
Box(
modifier = Modifier.fillMaxSize()
.padding(10.dp)
) {
Box(
modifier = Modifier.fillMaxSize()
.padding(10.dp)
) {
val state = rememberLazyListState()
val itemCount = 100
val state = rememberLazyListState()
val itemCount = 100
LazyColumn(Modifier.fillMaxSize().padding(end = 12.dp), state) {
items(itemCount) { x ->
TextBox("Item in ScrollableColumn #$x")
Spacer(modifier = Modifier.height(5.dp))
}
LazyColumn(Modifier.fillMaxSize().padding(end = 12.dp), state) {
items(itemCount) { x ->
TextBox("Item in ScrollableColumn #$x")
Spacer(modifier = Modifier.height(5.dp))
}
VerticalScrollbar(
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
adapter = rememberScrollbarAdapter(
scrollState = state
)
)
}
VerticalScrollbar(
modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
adapter = rememberScrollbarAdapter(
scrollState = state
)
)
}
}
}

23
examples/issues/.run/desktop.run.xml

@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="desktop" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":desktop:run" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>

8
examples/issues/README.md

@ -2,13 +2,13 @@ Github Issues viewer example written in Jetpack Compose UI library.
### Running desktop application
```
./gradlew :desktop:run
```
* To run, launch command: `./gradlew :desktop:run`
* Or choose **desktop** configuration in IDE and run it.
![desktop-run-configuration.png](screenshots/desktop-run-configuration.png)
### Building native desktop distribution
```
./gradlew :desktop:package
./gradlew :desktop:packageDistributionForCurrentOS
# outputs are written to desktop/build/compose/binaries
```

6
examples/issues/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
}
android {
compileSdk = 31
compileSdk = 32
defaultConfig {
minSdk = 26
targetSdk = 31
targetSdk = 32
versionCode = 1
versionName = "1.0"
}
@ -22,5 +22,5 @@ android {
dependencies {
implementation(project(":common"))
implementation("androidx.activity:activity-compose:1.3.1")
implementation("androidx.activity:activity-compose:1.5.0")
}

2
examples/issues/android/src/main/AndroidManifest.xml

@ -12,7 +12,7 @@
<activity
android:exported="true"
android:name="androidx.ui.examples.jetissues.MainActivity"
android:label="@string/app_name">
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />

10
examples/issues/common/build.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.compose.compose
plugins {
id("com.android.library")
kotlin("multiplatform")
@ -24,8 +22,8 @@ kotlin {
named("androidMain") {
kotlin.srcDirs("src/jvmAndAndroidMain/kotlin")
dependencies {
api("androidx.appcompat:appcompat:1.3.1")
api("androidx.core:core-ktx:1.3.1")
api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.8.0")
}
}
named("desktopMain") {
@ -40,11 +38,11 @@ apollo {
}
android {
compileSdk = 31
compileSdk = 32
defaultConfig {
minSdk = 26
targetSdk = 31
targetSdk = 32
}
compileOptions {

13
examples/issues/common/src/jvmAndAndroidMain/kotlin/androidx/ui/examples/jetissues/view/JetIssuesView.kt

@ -19,6 +19,8 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -31,6 +33,7 @@ import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.ui.examples.jetissues.data.*
import androidx.ui.examples.jetissues.query.IssueQuery
import androidx.ui.examples.jetissues.query.IssuesQuery
@ -83,10 +86,12 @@ fun SingleColumnLayout(currentIssue: MutableState<IssuesQuery.Node?>) {
)
},
navigationIcon = {
Button(onClick = {
currentIssue.value = null
}) {
Text(text = "Back")
IconButton(
onClick = {
currentIssue.value = null
}
) {
Icon(Icons.Default.ArrowBack, contentDescription = "Back")
}
}
)

1
examples/issues/desktop/build.gradle.kts

@ -1,4 +1,3 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {

6
examples/issues/gradle.properties

@ -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.6.10
agp.version=7.0.4
compose.version=1.1.0
kotlin.version=1.7.20
agp.version=7.1.3
compose.version=1.2.0

2
examples/issues/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/issues/screenshots/desktop-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

8
examples/notepad/README.md

@ -1,13 +1,13 @@
Notepad example for desktop written in Compose for Desktop library, using Composable Window API
### Running desktop application
```
./gradlew run
```
* To run, launch command: `./gradlew run`
* Or choose **desktop** configuration in IDE and run it.
![desktop-run-configuration.png](screenshots/desktop-run-configuration.png)
### Building native desktop distribution
```
./gradlew package
./gradlew packageDistributionForCurrentOS
# outputs are written to build/compose/binaries
```
![Desktop](screenshots/notepad.gif)

1
examples/notepad/build.gradle.kts

@ -1,4 +1,3 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {

4
examples/notepad/gradle.properties

@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
kotlin.version=1.6.10
compose.version=1.1.0
kotlin.version=1.7.20
compose.version=1.2.0

2
examples/notepad/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/notepad/screenshots/desktop-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

1
examples/notepad/src/main/kotlin/common/AppResources.kt

@ -34,5 +34,6 @@ fun rememberVectorPainter(image: ImageVector, tintColor: Color) =
name = image.name,
tintColor = tintColor,
tintBlendMode = image.tintBlendMode,
autoMirror = false,
content = { _, _ -> RenderVectorGroup(group = image.root) }
)

23
examples/todoapp-lite/.run/desktop.run.xml

@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="desktop" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":desktop:run" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>

8
examples/todoapp-lite/README.md

@ -3,13 +3,13 @@ A simplified version of the [TodoApp example](https://github.com/JetBrains/compo
Supported targets: Android and Desktop.
### Running desktop application
```
./gradlew :desktop:run
```
* To run, launch command: `./gradlew :desktop:run`
* Or choose **desktop** configuration in IDE and run it.
![desktop-run-configuration.png](screenshots/desktop-run-configuration.png)
### Building native desktop distribution
```
./gradlew :desktop:package
./gradlew :desktop:packageDistributionForCurrentOS
# outputs are written to desktop/build/compose/binaries
```

10
examples/todoapp-lite/android/build.gradle.kts

@ -5,11 +5,11 @@ plugins {
}
android {
compileSdk = 31
compileSdk = 32
defaultConfig {
minSdk = 21
targetSdk = 31
minSdk = 26
targetSdk = 32
versionCode = 1
versionName = "1.0"
}
@ -23,7 +23,7 @@ android {
dependencies {
implementation(project(":common"))
implementation(compose.material)
implementation("androidx.appcompat:appcompat:1.3.0")
implementation("androidx.activity:activity-compose:1.3.0")
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("androidx.activity:activity-compose:1.5.0")
}

2
examples/todoapp-lite/android/src/main/AndroidManifest.xml

@ -13,7 +13,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name">
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

8
examples/todoapp-lite/common/build.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.compose.compose
plugins {
id("com.android.library")
kotlin("multiplatform")
@ -22,11 +20,11 @@ kotlin {
}
android {
compileSdk = 31
compileSdk = 32
defaultConfig {
minSdk = 21
targetSdk = 31
minSdk = 26
targetSdk = 32
}
compileOptions {

1
examples/todoapp-lite/desktop/build.gradle.kts

@ -1,4 +1,3 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {

6
examples/todoapp-lite/gradle.properties

@ -19,6 +19,6 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
kotlin.version=1.6.10
agp.version=7.0.4
compose.version=1.1.0
kotlin.version=1.7.20
agp.version=7.1.3
compose.version=1.2.0

2
examples/todoapp-lite/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/todoapp-lite/screenshots/desktop-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

23
examples/todoapp/.run/browser.run.xml

@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="browser" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":web:jsBrowserDevelopmentRun" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>

23
examples/todoapp/.run/desktop.run.xml

@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="desktop" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":desktop:run" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>

14
examples/todoapp/README.md

@ -34,13 +34,13 @@ Features:
- Pluggable UI - Compose UI for Android, Desktop and Web, SwiftUI (not Compose) for iOS
### Running desktop application
```
./gradlew :desktop:run
```
* To run, launch command: `./gradlew :desktop:run`
* Or choose **desktop** configuration in IDE and run it.
![desktop-run-configuration.png](screenshots/desktop-run-configuration.png)
#### Building native desktop distribution
```
./gradlew :desktop:package
./gradlew :desktop:packageDistributionForCurrentOS
# outputs are written to desktop/build/compose/binaries
```
@ -49,9 +49,9 @@ Features:
Open project in Intellij IDEA or Android Studio and run "android" configuration.
### Running Web browser application
```
./gradlew :web:jsBrowserDevelopmentRun
```
* To run, launch command: `./gradlew :web:jsBrowserDevelopmentRun`
* Or choose **browser** configuration in IDE and run it.
![browser-run-configuration.png](screenshots/browser-run-configuration.png)
### Running iOS application

8
examples/todoapp/android/build.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.compose.compose
plugins {
id("com.android.application")
kotlin("android")
@ -7,11 +5,11 @@ plugins {
}
android {
compileSdkVersion(31)
compileSdk = 32
defaultConfig {
minSdkVersion(23)
targetSdkVersion(31)
minSdk = 26
targetSdk = 32
versionCode = 1
versionName = "1.0"
}

5
examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt

@ -20,6 +20,11 @@ object Deps {
val testAnnotationsCommon get() = "org.jetbrains.kotlin:kotlin-test-annotations-common:$VERSION"
}
object Coroutines {
private val VERSION get() = "1.6.4"
val swing get() = "org.jetbrains.kotlinx:kotlinx-coroutines-swing:$VERSION"
}
object Compose {
private val VERSION get() = properties["compose.version"]
val gradlePlugin get() = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"

4
examples/todoapp/buildSrc/gradle.properties

@ -1,3 +1,3 @@
# TODO can we get rid of duplication with root gradle.properties?
kotlin.version=1.6.10
compose.version=1.1.0
kotlin.version=1.7.10
compose.version=1.2.0-rc02

2
examples/todoapp/buildSrc/src/main/kotlin/multiplatform-compose-setup.gradle.kts

@ -1,5 +1,3 @@
import org.jetbrains.compose.compose
plugins {
id("com.android.library")
id("kotlin-multiplatform")

2
examples/todoapp/common/compose-ui/src/commonMain/kotlin/example/todo/common/ui/TodoEditUi.kt

@ -46,7 +46,7 @@ fun TodoEditContent(component: TodoEdit) {
onValueChange = component::onTextChanged
)
Row(modifier = Modifier.padding(8.dp)) {
Row(modifier = Modifier.padding(8.dp), verticalAlignment = Alignment.CenterVertically) {
Text(text = "Completed")
Spacer(modifier = Modifier.width(8.dp))

2
examples/todoapp/desktop/build.gradle.kts

@ -1,4 +1,3 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
@ -19,6 +18,7 @@ kotlin {
implementation(project(":common:database"))
implementation(project(":common:root"))
implementation(project(":common:compose-ui"))
implementation(Deps.JetBrains.Coroutines.swing)
implementation(Deps.ArkIvanov.Decompose.decompose)
implementation(Deps.ArkIvanov.Decompose.extensionsCompose)
implementation(Deps.ArkIvanov.MVIKotlin.mvikotlin)

6
examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/Main.kt

@ -1,6 +1,5 @@
package example.todo.desktop
import androidx.compose.desktop.DesktopTheme
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
@ -11,7 +10,6 @@ import androidx.compose.ui.window.rememberWindowState
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.decompose.DefaultComponentContext
import com.arkivanov.decompose.extensions.compose.jetbrains.lifecycle.LifecycleController
import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent
import com.arkivanov.essenty.lifecycle.LifecycleRegistry
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
import com.badoo.reaktive.coroutinesinterop.asScheduler
@ -40,9 +38,7 @@ fun main() {
) {
Surface(modifier = Modifier.fillMaxSize()) {
MaterialTheme {
DesktopTheme {
TodoRootContent(root)
}
TodoRootContent(root)
}
}
}

6
examples/todoapp/gradle.properties

@ -23,6 +23,6 @@ org.gradle.parallel=true
org.gradle.caching=true
kotlin.native.disableCompilerDaemon=true
#todo remove -Pkotlin.version=1.6.20 from Xcode project, when stable version on Compose with Koltin 1.6.20 or later released
kotlin.version=1.6.10
compose.version=1.1.0
#TODO also change version in buildSrc/gradle.properties
kotlin.version=1.7.10
compose.version=1.2.0

2
examples/todoapp/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/todoapp/screenshots/browser-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
examples/todoapp/screenshots/desktop-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

4
examples/todoapp/web/build.gradle.kts

@ -18,7 +18,7 @@ kotlin {
named("jsMain") {
dependencies {
implementation(compose.runtime)
implementation(compose.web.widgets)
implementation(compose.web.core)
implementation(project(":common:utils"))
implementation(project(":common:database"))
implementation(project(":common:root"))
@ -38,6 +38,6 @@ kotlin {
afterEvaluate {
rootProject.extensions.configure<NodeJsRootExtension> {
versions.webpackDevServer.version = "4.0.0"
versions.webpackCli.version = "4.9.0"
versions.webpackCli.version = "4.10.0"
}
}

4
examples/todoapp/web/src/jsMain/kotlin/example/todo/web/App.kt

@ -8,9 +8,7 @@ import example.todo.common.database.DefaultTodoSharedDatabase
import example.todo.common.database.todoDatabaseDriver
import example.todo.common.root.integration.TodoRootComponent
import kotlinx.browser.document
import org.jetbrains.compose.web.css.Style
import org.jetbrains.compose.web.renderComposable
import org.jetbrains.compose.web.ui.Styles
import org.w3c.dom.HTMLElement
fun main() {
@ -28,8 +26,6 @@ fun main() {
lifecycle.resume()
renderComposable(root = rootElement) {
Style(Styles)
TodoRootUi(root)
}
}

5
examples/todoapp/web/src/jsMain/kotlin/example/todo/web/Components.kt

@ -1,8 +1,6 @@
package example.todo.web
import androidx.compose.runtime.Composable
import org.jetbrains.compose.common.material.Text
import org.jetbrains.compose.common.ui.ExperimentalComposeWebWidgetsApi
import org.jetbrains.compose.web.attributes.InputType
import org.jetbrains.compose.web.css.AlignItems
import org.jetbrains.compose.web.css.DisplayStyle
@ -66,7 +64,6 @@ fun Card(attrs: AttrBuilderContext<*> = {}, content: @Composable () -> Unit) {
}
}
@OptIn(ExperimentalComposeWebWidgetsApi::class)
@Composable
fun MaterialTextArea(
id: String,
@ -95,7 +92,7 @@ fun MaterialTextArea(
)
Label(forId = id) {
Text(text = label)
Text(value = label)
}
}
}

23
examples/visual-effects/.run/desktop.run.xml

@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="desktop" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":run" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>

6
examples/visual-effects/README.md

@ -1 +1,7 @@
Several visual effects implmented with Compose Multiplatform, used in 1.0 release announce video.
### Running desktop application
* To run, launch command: `./gradlew run`
* Or choose **desktop** configuration in IDE and run it.
![desktop-run-configuration.png](screenshots/desktop-run-configuration.png)

1
examples/visual-effects/build.gradle.kts

@ -1,4 +1,3 @@
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

4
examples/visual-effects/gradle.properties

@ -1,3 +1,3 @@
kotlin.code.style=official
kotlin.version=1.6.10
compose.version=1.1.0
kotlin.version=1.7.20
compose.version=1.2.0

2
examples/visual-effects/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

BIN
examples/visual-effects/screenshots/desktop-run-configuration.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save