Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f46e8f3
reworked strings generator
ExNDY Jun 6, 2026
3192243
Batch generated resource accessors
ExNDY Jun 11, 2026
5961623
Cover batched string generation
ExNDY Jun 11, 2026
5f45425
Update samples for batched resource access
ExNDY Jun 11, 2026
70d4d23
reformat
ExNDY Jun 11, 2026
8edf172
fixed gradle cache problems
ExNDY Jun 11, 2026
518cb96
rollback hidden platformDetails
ExNDY Jun 11, 2026
3213e39
#731 fixed apple svg image color with opacity
ExNDY Jun 11, 2026
253a34a
#731 added svg with color with opacity, fixed run on ios simulator
ExNDY Jun 11, 2026
f1f8fcc
muted MagicNumber for object
ExNDY Jun 11, 2026
3e184d0
reformat
ExNDY Jun 11, 2026
42652ad
samples update
ExNDY Jun 11, 2026
76b421a
updated last samples
ExNDY Jun 14, 2026
222d776
fix: gradle 9 sample
ExNDY Jun 14, 2026
a9c3821
updated generator api, removed unused code
ExNDY Jun 14, 2026
a01adac
reformat
ExNDY Jun 14, 2026
ce9bc41
fixed sample resource-gallery commonTest imports
ExNDY Jun 18, 2026
89aefbf
#870 Add watchosDeviceArm64 target support
ExNDY Aug 10, 2026
7c7bd82
ensure deterministic output
bwitt Jul 8, 2026
dd610ba
Fix SVG alpha color handling
ExNDY Sep 1, 2026
f799be2
fixed moko.graphics version
ExNDY Sep 1, 2026
dede444
Merge pull request #883 from bwitt/deterministic-builds
ExNDY Sep 2, 2026
a9caa1b
Merge remote-tracking branch 'icerock/develop' into rework-resource-g…
ExNDY Sep 2, 2026
f182540
fixed Builder imports
ExNDY Sep 2, 2026
3d10bd0
#758 register generated Android resources for Paparazzi
ExNDY Sep 2, 2026
a26a364
added info about default resource catalog in README
ExNDY Sep 2, 2026
0b9dff3
Merge pull request #887 from icerockdev/add-resources-config-in-readme
ExNDY Sep 2, 2026
99228bb
Merge pull request #881 from ExNDY/rework-resource-generation
ExNDY Sep 2, 2026
6269157
#885 fix usage of LocalSystemTheme on compose 1.12+
ExNDY Sep 2, 2026
ccca0ad
Merge pull request #888 from icerockdev/fix-ios-compose-multiplatform…
ExNDY Sep 3, 2026
248c170
added paparazzi test case
ExNDY Sep 3, 2026
3922f46
Merge pull request #889 from icerockdev/paparazzi-sample
ExNDY Sep 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,37 @@ multiplatformResources {
}
```

#### Default resource source sets

By default, resources for each Kotlin source set must be placed in
`src/<sourceSetName>/moko-resources`. No additional `resourcesSourceSets` configuration is required.
For example, common resources belong in `src/commonMain/moko-resources`, Android-only resources in
`src/androidMain/moko-resources`, and common test resources in `src/commonTest/moko-resources`.

The default common resource directory has the following structure:

```
projectDirectory
└── src
└── commonMain
└── moko-resources
├── base
│ ├── strings.xml
│ └── plurals.xml
├── <languageCode>
│ ├── strings.xml
│ └── plurals.xml
├── images
├── fonts
├── files
└── assets
```

This directory layout was introduced in moko-resources 0.24.0. When upgrading from 0.23.x, move
resources from `src/commonMain/resources/MR` to `src/commonMain/moko-resources`; the directory
structure inside the resource root remains unchanged. See the
[0.24.0 changelog and migration guide](https://github.com/icerockdev/moko-resources/discussions/730).

#### Custom resource sourceSet

If you need custom path for source of resources, you need add in plugin configuration resourcesSourceSets option:
Expand All @@ -121,7 +152,7 @@ On next step, you must create inside of project directory folder with name: `cus
-- customResources
--- assets
--- base
--- image
--- images
```

Example of custom sourceSet in: `resources-gallery` sample, inside `jvm-app`
Expand All @@ -134,7 +165,7 @@ should [add `export` declarations](https://kotlinlang.org/docs/multiplatform-bui
```
framework {
export("dev.icerock.moko:resources:0.26.4")
export("dev.icerock.moko:graphics:0.10.0") // toUIColor here
export("dev.icerock.moko:graphics:0.10.2") // toUIColor here
}
```

Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ commonsCodecVersion = "1.15"
batikVersion = "1.17"

# moko
mokoGraphicsVersion = "0.10.0"
mokoGraphicsVersion = "0.10.2"
mokoTestVersion = "0.6.1"
mokoMultiplatformPluginVersion = "0.14.2"

Expand Down Expand Up @@ -81,4 +81,4 @@ composeJetBrainsPlugin = { module = "org.jetbrains.compose:compose-gradle-plugin
nexusPublishing = { module = "io.github.gradle-nexus:publish-plugin", version = "2.0.0" }

[plugins]
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlinVersion" }
composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlinVersion" }
4 changes: 3 additions & 1 deletion gradle/moko.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[versions]
resourcesVersion = "0.26.4"
graphicsVersion = "0.10.2"
resourcesVersion = "0.27.0"

[libraries]
graphics = { module = "dev.icerock.moko:graphics", version.ref = "graphicsVersion" }
resources = { module = "dev.icerock.moko:resources", version.ref = "resourcesVersion" }
resourcesCompose = { module = "dev.icerock.moko:resources-compose", version.ref = "resourcesVersion" }
resourcesTest = { module = "dev.icerock.moko:resources-test", version.ref = "resourcesVersion" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ kotlin {
watchosX64()
watchosArm32()
watchosArm64()
watchosDeviceArm64()
watchosSimulatorArm64()

sourceSets {
Expand All @@ -27,9 +28,11 @@ kotlin {
val watchosArm64Main by getting{
dependsOn(watchosMain)
}
val watchosDeviceArm64Main by getting {
dependsOn(watchosMain)
}
val watchosSimulatorArm64Main by getting{
dependsOn(watchosMain)
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

package dev.icerock.moko.resources.compose

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.SystemTheme
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
Expand All @@ -25,10 +23,9 @@ import org.jetbrains.skia.Data
import org.jetbrains.skia.Image
import org.jetbrains.skia.svg.SVGDOM

@OptIn(InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
val fileUrl: String = if (LocalSystemTheme.current == SystemTheme.Dark) {
val fileUrl: String = if (isSystemInDarkTheme()) {
imageResource.darkFileUrl ?: imageResource.fileUrl
} else {
imageResource.fileUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

package dev.icerock.moko.resources.compose

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.toComposeImageBitmap
Expand All @@ -18,10 +17,11 @@ import org.jetbrains.skia.Image
import platform.CoreGraphics.CGImageRef
import platform.UIKit.UIImage

@OptIn(ExperimentalForeignApi::class, InternalComposeUiApi::class)
@OptIn(ExperimentalForeignApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
return remember(LocalSystemTheme.current, imageResource) {
val isDarkTheme: Boolean = isSystemInDarkTheme()
return remember(isDarkTheme, imageResource) {
val uiImage: UIImage = imageResource.toUIImage()
?: throw IllegalArgumentException("can't read UIImage of $imageResource")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

package dev.icerock.moko.resources.compose

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.SystemTheme
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import dev.icerock.moko.resources.ImageResource

@OptIn(InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
val filePath: String = if (LocalSystemTheme.current == SystemTheme.Dark) {
val filePath: String = if (isSystemInDarkTheme()) {
imageResource.darkFilePath ?: imageResource.filePath
} else {
imageResource.filePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

package dev.icerock.moko.resources.compose

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.InternalComposeUiApi
import androidx.compose.ui.LocalSystemTheme
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.graphics.toComposeImageBitmap
Expand All @@ -19,10 +18,11 @@ import platform.AppKit.NSImage
import platform.CoreGraphics.CGImageRef
import platform.CoreGraphics.CGImageRelease

@OptIn(ExperimentalForeignApi::class, InternalComposeUiApi::class)
@OptIn(ExperimentalForeignApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
return remember(LocalSystemTheme.current, imageResource) {
val isDarkTheme: Boolean = isSystemInDarkTheme()
return remember(isDarkTheme, imageResource) {
val nsImage: NSImage = imageResource.toNSImage()
?: throw IllegalArgumentException("can't read NSImage of $imageResource")

Expand Down
Loading
Loading