Browse Source

Migrate all samples to the new resources library (#4386)

pull/4396/head v1.6.10-dev1457
Konstantin 10 months ago committed by GitHub
parent
commit
e8e7afa795
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      examples/chat/gradle.properties
  2. 2
      examples/chat/gradle/wrapper/gradle-wrapper.properties
  3. 8
      examples/chat/shared/build.gradle.kts
  4. 0
      examples/chat/shared/src/commonMain/composeResources/drawable/background.jpg
  5. 0
      examples/chat/shared/src/commonMain/composeResources/drawable/stock1.jpg
  6. 0
      examples/chat/shared/src/commonMain/composeResources/drawable/stock2.jpg
  7. 0
      examples/chat/shared/src/commonMain/composeResources/drawable/stock3.jpg
  8. 0
      examples/chat/shared/src/commonMain/composeResources/drawable/stock4.jpg
  9. 11
      examples/chat/shared/src/commonMain/kotlin/ChatApp.kt
  10. 4
      examples/chat/shared/src/commonMain/kotlin/Data.kt
  11. 2
      examples/cocoapods-ios-example/gradle.properties
  12. 2
      examples/cocoapods-ios-example/gradle/wrapper/gradle-wrapper.properties
  13. 5
      examples/cocoapods-ios-example/shared/build.gradle.kts
  14. 0
      examples/cocoapods-ios-example/shared/src/commonMain/composeResources/drawable/compose-multiplatform.xml
  15. 4
      examples/cocoapods-ios-example/shared/src/commonMain/kotlin/App.kt
  16. 2
      examples/codeviewer/gradle.properties
  17. 2
      examples/codeviewer/gradle/wrapper/gradle-wrapper.properties
  18. 7
      examples/codeviewer/shared/build.gradle.kts
  19. 16
      examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  20. 0
      examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_bold.ttf
  21. 0
      examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_bold_italic.ttf
  22. 0
      examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_extrabold.ttf
  23. 0
      examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_extrabold_italic.ttf
  24. 0
      examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_italic.ttf
  25. 0
      examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_medium.ttf
  26. 0
      examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_medium_italic.ttf
  27. 0
      examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_regular.ttf
  28. 9
      examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  29. 44
      examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/common/Fonts.kt
  30. 10
      examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  31. 0
      examples/codeviewer/shared/src/iosMain/composeResources/EditorView.kt
  32. 4
      examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/File.kt
  33. 23
      examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt
  34. 2
      examples/graphics-2d/gradle.properties
  35. 2
      examples/graphics-2d/gradle/wrapper/gradle-wrapper.properties
  36. 10
      examples/graphics-2d/shared/build.gradle.kts
  37. 0
      examples/graphics-2d/shared/src/commonMain/composeResources/drawable/clock.png
  38. 0
      examples/graphics-2d/shared/src/commonMain/composeResources/drawable/compose_community_primary.xml
  39. 0
      examples/graphics-2d/shared/src/commonMain/composeResources/drawable/flag.png
  40. 0
      examples/graphics-2d/shared/src/commonMain/composeResources/drawable/mine.png
  41. 12
      examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt
  42. 14
      examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt
  43. 6
      examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt
  44. 2
      examples/html/compose-bird/gradle.properties
  45. 2
      examples/html/compose-bird/gradle/wrapper/gradle-wrapper.properties
  46. 2
      examples/html/compose-in-js/gradle.properties
  47. 2
      examples/html/compose-in-js/gradle/wrapper/gradle-wrapper.properties
  48. 2
      examples/html/landing/gradle.properties
  49. 2
      examples/html/landing/gradle/wrapper/gradle-wrapper.properties
  50. 2
      examples/html/with-react/gradle.properties
  51. 2
      examples/html/with-react/gradle/wrapper/gradle-wrapper.properties
  52. 2
      examples/imageviewer/gradle.properties
  53. 2
      examples/imageviewer/gradle/wrapper/gradle-wrapper.properties
  54. 2
      examples/intellij-plugin/build.gradle.kts
  55. 2
      examples/intellij-plugin/gradle.properties
  56. 2
      examples/intellij-plugin/gradle/wrapper/gradle-wrapper.properties
  57. 2
      examples/interop/ios-compose-in-swiftui/gradle/wrapper/gradle-wrapper.properties
  58. 2
      examples/interop/ios-compose-in-swiftui/shared/build.gradle.kts
  59. 2
      examples/interop/ios-compose-in-uikit/gradle/wrapper/gradle-wrapper.properties
  60. 2
      examples/interop/ios-compose-in-uikit/shared/build.gradle.kts
  61. 2
      examples/interop/ios-swiftui-in-compose/gradle/wrapper/gradle-wrapper.properties
  62. 2
      examples/interop/ios-swiftui-in-compose/shared/build.gradle.kts
  63. 2
      examples/interop/ios-uikit-in-compose/gradle/wrapper/gradle-wrapper.properties
  64. 2
      examples/interop/ios-uikit-in-compose/shared/build.gradle.kts
  65. 2
      examples/issues/gradle/wrapper/gradle-wrapper.properties
  66. 2
      examples/notepad/gradle.properties
  67. 2
      examples/notepad/gradle/wrapper/gradle-wrapper.properties
  68. 2
      examples/todoapp-lite/gradle.properties
  69. 2
      examples/todoapp-lite/gradle/wrapper/gradle-wrapper.properties
  70. 3
      examples/todoapp-lite/shared/build.gradle.kts
  71. 2
      examples/widgets-gallery/gradle.properties
  72. 2
      examples/widgets-gallery/gradle/wrapper/gradle-wrapper.properties
  73. 5
      examples/widgets-gallery/shared/build.gradle.kts

2
examples/chat/gradle.properties

@ -2,6 +2,8 @@ kotlin.code.style=official
xcodeproj=./iosApp
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g
org.gradle.configuration-cache=true
org.gradle.caching=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
kotlin.native.useEmbeddableCompilerJar=true

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

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

8
examples/chat/shared/build.gradle.kts

@ -46,12 +46,16 @@ kotlin {
}
sourceSets {
all {
languageSettings {
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi")
}
}
val commonMain by getting {
dependencies {
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.5.0")
}
@ -97,8 +101,6 @@ android {
compileSdk = 34
namespace = "org.jetbrains.chat"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig {
minSdk = 26

0
examples/chat/shared/src/commonMain/resources/background.jpg → examples/chat/shared/src/commonMain/composeResources/drawable/background.jpg

Before

Width:  |  Height:  |  Size: 468 KiB

After

Width:  |  Height:  |  Size: 468 KiB

0
examples/chat/shared/src/commonMain/resources/stock1.jpg → examples/chat/shared/src/commonMain/composeResources/drawable/stock1.jpg

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

0
examples/chat/shared/src/commonMain/resources/stock2.jpg → examples/chat/shared/src/commonMain/composeResources/drawable/stock2.jpg

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

0
examples/chat/shared/src/commonMain/resources/stock3.jpg → examples/chat/shared/src/commonMain/composeResources/drawable/stock3.jpg

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

0
examples/chat/shared/src/commonMain/resources/stock4.jpg → examples/chat/shared/src/commonMain/composeResources/drawable/stock4.jpg

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

11
examples/chat/shared/src/commonMain/kotlin/ChatApp.kt

@ -18,6 +18,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.sp
import chat_mpp.shared.generated.resources.*
import chat_mpp.shared.generated.resources.Res
import chat_mpp.shared.generated.resources.background
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.delay
@ -26,9 +29,9 @@ import org.jetbrains.compose.resources.painterResource
val myUser = User("Me", picture = null)
val friends = listOf(
User("Alex", picture = "stock1.jpg"),
User("Casey", picture = "stock2.jpg"),
User("Sam", picture = "stock3.jpg")
User("Alex", picture = Res.drawable.stock1),
User("Casey", picture = Res.drawable.stock2),
User("Sam", picture = Res.drawable.stock3)
)
val friendMessages = listOf(
"How's everybody doing today?",
@ -66,7 +69,7 @@ fun ChatApp(displayTextField: Boolean = true) {
Theme {
Surface {
Box(modifier = Modifier.fillMaxSize()) {
Image(painterResource("background.jpg"), null, contentScale = ContentScale.Crop)
Image(painterResource(Res.drawable.background), null, contentScale = ContentScale.Crop)
Column(
modifier = Modifier.fillMaxSize()
) {

4
examples/chat/shared/src/commonMain/kotlin/Data.kt

@ -1,5 +1,7 @@
import androidx.compose.ui.graphics.Color
import kotlinx.datetime.Clock
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.ExperimentalResourceApi
import kotlin.random.Random
import kotlin.random.nextInt
@ -23,7 +25,7 @@ data class Message(
data class User(
val name: String,
val color: Color = ColorProvider.getColor(),
val picture: String?
val picture: DrawableResource?
)
object ColorProvider {

2
examples/cocoapods-ios-example/gradle.properties

@ -1,5 +1,7 @@
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.configuration-cache=true
org.gradle.caching=true
#Kotlin
kotlin.code.style=official

2
examples/cocoapods-ios-example/gradle/wrapper/gradle-wrapper.properties vendored

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

5
examples/cocoapods-ios-example/shared/build.gradle.kts

@ -32,7 +32,6 @@ kotlin {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
}
@ -49,11 +48,7 @@ kotlin {
android {
compileSdk = (findProperty("android.compileSdk") as String).toInt()
namespace = "com.myapplication.common"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig {
minSdk = (findProperty("android.minSdk") as String).toInt()
}

0
examples/cocoapods-ios-example/shared/src/commonMain/resources/compose-multiplatform.xml → examples/cocoapods-ios-example/shared/src/commonMain/composeResources/drawable/compose-multiplatform.xml

4
examples/cocoapods-ios-example/shared/src/commonMain/kotlin/App.kt

@ -12,6 +12,8 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import cocoapodsiosexample.shared.generated.resources.Res
import cocoapodsiosexample.shared.generated.resources.compose_multiplatform
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.painterResource
@ -30,7 +32,7 @@ fun App() {
}
AnimatedVisibility(showImage) {
Image(
painterResource("compose-multiplatform.xml"),
painterResource(Res.drawable.compose_multiplatform),
null
)
}

2
examples/codeviewer/gradle.properties

@ -2,6 +2,8 @@ kotlin.code.style=official
xcodeproj=./iosApp
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g
org.gradle.configuration-cache=true
org.gradle.caching=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
kotlin.native.useEmbeddableCompilerJar=true

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-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

7
examples/codeviewer/shared/build.gradle.kts

@ -25,13 +25,17 @@ kotlin {
}
sourceSets {
all {
languageSettings {
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi")
}
}
val commonMain by getting {
dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.materialIconsExtended)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
}
@ -68,7 +72,6 @@ android {
compileSdk = 34
namespace = "org.jetbrains.codeviewer.common"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res", "src/commonMain/resources")
defaultConfig {
minSdk = 26
}

16
examples/codeviewer/shared/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -1,16 +0,0 @@
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 {
val context = LocalContext.current
val id = context.resources.getIdentifier(res, "font", context.packageName)
return Font(id, weight, style)
}

0
examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold.ttf → examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_bold.ttf

0
examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_bold_italic.ttf → examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_bold_italic.ttf

0
examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold.ttf → examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_extrabold.ttf

0
examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_extrabold_italic.ttf → examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_extrabold_italic.ttf

0
examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_italic.ttf → examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_italic.ttf

0
examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium.ttf → examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_medium.ttf

0
examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_medium_italic.ttf → examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_medium_italic.ttf

0
examples/codeviewer/shared/src/commonMain/resources/font/jetbrainsmono_regular.ttf → examples/codeviewer/shared/src/commonMain/composeResources/font/jetbrainsmono_regular.ttf

9
examples/codeviewer/shared/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -1,9 +0,0 @@
package org.jetbrains.codeviewer.platform
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.font.Font
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

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

@ -4,59 +4,53 @@ 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 codeviewer.shared.generated.resources.Res
import codeviewer.shared.generated.resources.*
import org.jetbrains.compose.resources.Font
object Fonts {
@Composable
fun jetbrainsMono() = FontFamily(
font(
"JetBrains Mono",
"jetbrainsmono_regular",
Font(
Res.font.jetbrainsmono_regular,
FontWeight.Normal,
FontStyle.Normal
),
font(
"JetBrains Mono",
"jetbrainsmono_italic",
Font(
Res.font.jetbrainsmono_italic,
FontWeight.Normal,
FontStyle.Italic
),
font(
"JetBrains Mono",
"jetbrainsmono_bold",
Font(
Res.font.jetbrainsmono_bold,
FontWeight.Bold,
FontStyle.Normal
),
font(
"JetBrains Mono",
"jetbrainsmono_bold_italic",
Font(
Res.font.jetbrainsmono_bold_italic,
FontWeight.Bold,
FontStyle.Italic
),
font(
"JetBrains Mono",
"jetbrainsmono_extrabold",
Font(
Res.font.jetbrainsmono_extrabold,
FontWeight.ExtraBold,
FontStyle.Normal
),
font(
"JetBrains Mono",
"jetbrainsmono_extrabold_italic",
Font(
Res.font.jetbrainsmono_extrabold_italic,
FontWeight.ExtraBold,
FontStyle.Italic
),
font(
"JetBrains Mono",
"jetbrainsmono_medium",
Font(
Res.font.jetbrainsmono_medium,
FontWeight.Medium,
FontStyle.Normal
),
font(
"JetBrains Mono",
"jetbrainsmono_medium_italic",
Font(
Res.font.jetbrainsmono_medium_italic,
FontWeight.Medium,
FontStyle.Italic
)

10
examples/codeviewer/shared/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -1,10 +0,0 @@
package org.jetbrains.codeviewer.platform
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.font.Font
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 =
androidx.compose.ui.text.platform.Font("font/$res.ttf", weight, style)

0
examples/codeviewer/shared/src/iosMain/resources/EditorView.kt → examples/codeviewer/shared/src/iosMain/composeResources/EditorView.kt

4
examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/File.kt

@ -2,12 +2,12 @@
package org.jetbrains.codeviewer.platform
import codeviewer.shared.generated.resources.Res
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.runBlocking
import org.jetbrains.codeviewer.util.EmptyTextLines
import org.jetbrains.codeviewer.util.TextLines
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.resource
class VirtualFile(override val name: String, override val isDirectory: Boolean, val textLines: TextLines, override val children: List<File> = listOf()): File {
override val hasChildren: Boolean
@ -34,7 +34,7 @@ actual val HomeFolder: File get() = VirtualFile("files",
VirtualFile("EditorView.kt",
isDirectory = false,
textLines = runBlocking {
resource("EditorView.kt").readBytes()
Res.readBytes("EditorView.kt")
}.toTextLines()
)
)

23
examples/codeviewer/shared/src/iosMain/kotlin/org/jetbrains/codeviewer/platform/Resources.kt

@ -1,23 +0,0 @@
package org.jetbrains.codeviewer.platform
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import kotlinx.coroutines.runBlocking
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.resource
private val cache: MutableMap<String, Font> = mutableMapOf()
@OptIn(ExperimentalResourceApi::class)
@Composable
actual fun font(name: String, res: String, weight: FontWeight, style: FontStyle): Font {
return cache.getOrPut(res) {
val byteArray = runBlocking {
resource("font/$res.ttf").readBytes()
}
androidx.compose.ui.text.platform.Font(res, byteArray, weight, style)
}
}

2
examples/graphics-2d/gradle.properties

@ -2,6 +2,8 @@ kotlin.code.style=official
xcodeproj=./iosApp
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g
org.gradle.configuration-cache=true
org.gradle.caching=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
kotlin.native.useEmbeddableCompilerJar=true

2
examples/graphics-2d/gradle/wrapper/gradle-wrapper.properties vendored

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

10
examples/graphics-2d/shared/build.gradle.kts

@ -38,13 +38,17 @@ kotlin {
}
sourceSets {
all {
languageSettings {
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi")
}
}
commonMain.dependencies {
implementation(compose.ui)
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation("org.jetbrains.compose.components:components-resources:1.6.0-dev1306")
implementation(compose.components.resources)
}
commonTest.dependencies {
implementation(kotlin("test"))
@ -66,8 +70,6 @@ android {
compileSdk = 34
namespace = "org.jetbrains.Graphics2D"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig {
minSdk = 26

0
examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/clock.png → examples/graphics-2d/shared/src/commonMain/composeResources/drawable/clock.png

Before

Width:  |  Height:  |  Size: 896 B

After

Width:  |  Height:  |  Size: 896 B

0
examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/compose_community_primary.xml → examples/graphics-2d/shared/src/commonMain/composeResources/drawable/compose_community_primary.xml

0
examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/flag.png → examples/graphics-2d/shared/src/commonMain/composeResources/drawable/flag.png

Before

Width:  |  Height:  |  Size: 780 B

After

Width:  |  Height:  |  Size: 780 B

0
examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/mine.png → examples/graphics-2d/shared/src/commonMain/composeResources/drawable/mine.png

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

12
examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt

@ -9,16 +9,10 @@ import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.unit.*
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.ImageResource
import org.jetbrains.compose.resources.painterResource
import graphics_2d.shared.generated.resources.*
import kotlin.math.max
@OptIn(ExperimentalResourceApi::class)
@Composable
fun loadImage(img: ImageResource): Painter = painterResource(img)
expect fun hasRightClick(): Boolean
@ -78,9 +72,9 @@ fun MineSweeper(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) =
Row {
Column {
val bombsLeft = max(game.bombs - game.flagsSet, 0)
IndicatorWithIcon(ImageResource("composeRes/images/clock.png"), "Seconds", game.seconds)
IndicatorWithIcon(Res.drawable.clock, "Seconds", game.seconds)
Box(modifier = Modifier.size(2.dp)) {}
IndicatorWithIcon(ImageResource("composeRes/images/mine.png"), "Bombs Left", bombsLeft)
IndicatorWithIcon(Res.drawable.mine, "Bombs Left", bombsLeft)
}
Column(modifier = Modifier.padding(8.dp)) {

14
examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt

@ -17,7 +17,9 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.jetbrains.compose.resources.ImageResource
import graphics_2d.shared.generated.resources.*
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.painterResource
@Composable
fun OpenedCell(cell: Cell) {
@ -31,9 +33,9 @@ fun OpenedCell(cell: Cell) {
}
@Composable
fun CellWithIcon(img: ImageResource, alt: String) {
fun CellWithIcon(img: DrawableResource, alt: String) {
Image(
painter = loadImage(img),
painter = painterResource(img),
contentDescription = alt,
modifier = Modifier.fillMaxSize().padding(Dp(4.0f))
)
@ -41,16 +43,16 @@ fun CellWithIcon(img: ImageResource, alt: String) {
@Composable
fun Mine() {
CellWithIcon(ImageResource("composeRes/images/mine.png"), alt = "Bomb")
CellWithIcon(Res.drawable.mine, alt = "Bomb")
}
@Composable
fun Flag() {
CellWithIcon(ImageResource("composeRes/images/flag.png"), alt = "Flag")
CellWithIcon(Res.drawable.flag, alt = "Flag")
}
@Composable
fun IndicatorWithIcon(img: ImageResource, alt: String, value: Int) {
fun IndicatorWithIcon(img: DrawableResource, alt: String, value: Int) {
Box(modifier = Modifier.background(Color(0x8e, 0x6e, 0x0e))) {
Row(verticalAlignment = Alignment.CenterVertically) {
Box(modifier = Modifier.size(40.dp, 40.dp)) {

6
examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt

@ -20,11 +20,9 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.jetbrains.compose.resources.ImageResource
import graphics_2d.shared.generated.resources.*
import org.jetbrains.compose.resources.painterResource
@OptIn(ExperimentalResourceApi::class)
@Composable
fun Words() {
val duration = 5000
@ -47,7 +45,7 @@ fun Words() {
)
)
val logoImg = painterResource(ImageResource("composeRes/images/compose_community_primary.xml"))
val logoImg = painterResource(Res.drawable.compose_community_primary)
val baseLogo = DpOffset(350.dp, 270.dp)

2
examples/html/compose-bird/gradle.properties

@ -1,3 +1,5 @@
kotlin.code.style=official
kotlin.version=1.9.22
compose.version=1.6.0
org.gradle.configuration-cache=true
org.gradle.caching=true

2
examples/html/compose-bird/gradle/wrapper/gradle-wrapper.properties vendored

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

2
examples/html/compose-in-js/gradle.properties

@ -2,3 +2,5 @@ kotlin.code.style=official
kotlin.js.webpack.major.version=4
kotlin.version=1.9.22
compose.version=1.6.0
org.gradle.configuration-cache=true
org.gradle.caching=true

2
examples/html/compose-in-js/gradle/wrapper/gradle-wrapper.properties vendored

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

2
examples/html/landing/gradle.properties

@ -1,3 +1,5 @@
kotlin.code.style=official
kotlin.version=1.9.22
compose.version=1.6.0
org.gradle.configuration-cache=true
org.gradle.caching=true

2
examples/html/landing/gradle/wrapper/gradle-wrapper.properties vendored

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

2
examples/html/with-react/gradle.properties

@ -1,3 +1,5 @@
kotlin.code.style=official
kotlin.version=1.9.22
compose.version=1.6.0
org.gradle.configuration-cache=true
org.gradle.caching=true

2
examples/html/with-react/gradle/wrapper/gradle-wrapper.properties vendored

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

2
examples/imageviewer/gradle.properties

@ -2,6 +2,8 @@ kotlin.code.style=official
xcodeproj=iosApp
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g
org.gradle.configuration-cache=true
org.gradle.caching=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
kotlin.mpp.androidSourceSetLayoutVersion=2

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-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

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

@ -1,5 +1,5 @@
plugins {
id("org.jetbrains.intellij") version "1.15.0"
id("org.jetbrains.intellij") version "1.17.2"
java
kotlin("jvm")
id("org.jetbrains.compose")

2
examples/intellij-plugin/gradle.properties

@ -1,3 +1,5 @@
kotlin.code.style=official
kotlin.version=1.9.22
compose.version=1.6.0
org.gradle.configuration-cache=true
org.gradle.caching=true

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-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
examples/interop/ios-compose-in-swiftui/gradle/wrapper/gradle-wrapper.properties vendored

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

2
examples/interop/ios-compose-in-swiftui/shared/build.gradle.kts

@ -27,8 +27,6 @@ kotlin {
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
}
val iosMain by creating {

2
examples/interop/ios-compose-in-uikit/gradle/wrapper/gradle-wrapper.properties vendored

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

2
examples/interop/ios-compose-in-uikit/shared/build.gradle.kts

@ -27,8 +27,6 @@ kotlin {
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
}
val iosMain by creating {

2
examples/interop/ios-swiftui-in-compose/gradle/wrapper/gradle-wrapper.properties vendored

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

2
examples/interop/ios-swiftui-in-compose/shared/build.gradle.kts

@ -27,8 +27,6 @@ kotlin {
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
}
val iosMain by creating {

2
examples/interop/ios-uikit-in-compose/gradle/wrapper/gradle-wrapper.properties vendored

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

2
examples/interop/ios-uikit-in-compose/shared/build.gradle.kts

@ -27,8 +27,6 @@ kotlin {
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
}
val iosMain by creating {

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-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
examples/notepad/gradle.properties

@ -2,3 +2,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
kotlin.code.style=official
kotlin.version=1.9.22
compose.version=1.6.0
org.gradle.configuration-cache=true
org.gradle.caching=true

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-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
examples/todoapp-lite/gradle.properties

@ -2,6 +2,8 @@ kotlin.code.style=official
xcodeproj=./iosApp
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g
org.gradle.configuration-cache=true
org.gradle.caching=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
kotlin.native.useEmbeddableCompilerJar=true

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-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

3
examples/todoapp-lite/shared/build.gradle.kts

@ -30,8 +30,6 @@ kotlin {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
}
}
val androidMain by getting {
@ -66,7 +64,6 @@ android {
namespace = "example.todoapp.lite.common"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig {
minSdk = 26

2
examples/widgets-gallery/gradle.properties

@ -2,6 +2,8 @@ kotlin.code.style=official
xcodeproj=./iosApp
android.useAndroidX=true
org.gradle.jvmargs=-Xmx3g
org.gradle.configuration-cache=true
org.gradle.caching=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
kotlin.native.useEmbeddableCompilerJar=true

2
examples/widgets-gallery/gradle/wrapper/gradle-wrapper.properties vendored

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

5
examples/widgets-gallery/shared/build.gradle.kts

@ -44,8 +44,7 @@ kotlin {
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.materialIconsExtended)
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation("org.jetbrains.compose.components:components-resources:${project.property("compose.version")}")
implementation(compose.components.resources)
}
}
val androidMain by getting {
@ -80,8 +79,6 @@ android {
compileSdk = 34
namespace = "org.jetbrains.compose.demo.widgets.platform"
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
sourceSets["main"].res.srcDirs("src/androidMain/res")
sourceSets["main"].resources.srcDirs("src/commonMain/resources")
defaultConfig {
minSdk = 26

Loading…
Cancel
Save