Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ local.properties
local.gradle
moko-resources-generated.js
.fleet
.kotlin
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ buildscript {
dependencies {
classpath("dev.icerock.moko:resources-generator")
classpath(libs.composeJetBrainsPlugin)
classpath(libs.composeCompilerPlugin)
classpath(":resources-build-logic")
}
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ kotlin.mpp.enableCInteropCommonization=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.uikit.enabled=true
org.jetbrains.compose.experimental.macos.enabled=true
org.jetbrains.compose.experimental.wasm.enabled=true

android.useAndroidX=true

Expand Down
26 changes: 17 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[versions]
kotlinVersion = "1.9.20"
androidGradleVersion = "8.1.4"
androidSdkCommonVersion = "31.1.2"
kotlinVersion = "2.1.21"
androidGradleVersion = "8.9.3"
androidSdkCommonVersion = "31.10.1"

# kotlinx
kotlinxSerializationVersion = "1.6.1"
kotlinxCoroutinesVersion = "1.6.4"
kotlinxSerializationVersion = "1.8.1"
kotlinxCoroutinesVersion = "1.10.2"
kotlinxBrowserVersion = "0.3"

# android
androidAppCompatVersion = "1.6.1"
androidAppCompatVersion = "1.7.0"
androidxActivityComposeVersion = "1.10.1"
androidxCoreVersion = "1.16.0"

# android compose
composeUiVersion = "1.5.1"
composeUiVersion = "1.8.1"

# jetbrains compose
composeJetbrainsVersion = "1.6.0"
composeJetbrainsVersion = "1.8.1"

# jvm
apacheCommonsTextVersion = "1.10.0"
Expand All @@ -25,21 +28,25 @@ commonsCodecVersion = "1.15"
batikVersion = "1.17"

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

[libraries]
# kotlinx
kotlinxSerialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationVersion" }
kotlinxCoroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutinesVersion" }
kotlinxBrowser = { module = "org.jetbrains.kotlinx:kotlinx-browser", version.ref = "kotlinxBrowserVersion" }

# moko
mokoGraphics = { module = "dev.icerock.moko:graphics", version.ref = "mokoGraphicsVersion" }
mokoTestCore = { module = "dev.icerock.moko:test-core", version.ref = "mokoTestVersion" }

# android
appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidAppCompatVersion" }
appCompatResources = { module = "androidx.appcompat:appcompat-resources", version.ref = "androidAppCompatVersion" }
androidxActivityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidxActivityComposeVersion" }
androidxCore = { module = "androidx.core:core-ktx", version.ref = "androidxCoreVersion" }

# android compose
composeUi = { module = "androidx.compose.ui:ui", version.ref = "composeUiVersion" }
Expand All @@ -60,3 +67,4 @@ kotlinCompilerEmbeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embe
detektGradlePlugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detektVersion" }
mokoMultiplatformPlugin = { module = "dev.icerock:mobile-multiplatform", version.ref = "mokoMultiplatformPluginVersion" }
composeJetBrainsPlugin = { module = "org.jetbrains.compose:compose-gradle-plugin", version.ref = "composeJetbrainsVersion" }
composeCompilerPlugin = { module = "org.jetbrains.kotlin.plugin.compose:org.jetbrains.kotlin.plugin.compose.gradle.plugin", version.ref = "kotlinVersion" }
2 changes: 1 addition & 1 deletion gradle/moko.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
resourcesVersion = "0.24.5"
resourcesVersion = "0.24.6"
Comment thread
Alex009 marked this conversation as resolved.
Outdated

[libraries]
resources = { module = "dev.icerock.moko:resources", version.ref = "resourcesVersion" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Tue Jul 25 10:40:31 NOVT 2023
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.14.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
788 changes: 420 additions & 368 deletions kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import com.android.build.gradle.BaseExtension

configure<BaseExtension> {
compileSdkVersion(33)
compileSdkVersion(35)

defaultConfig {
minSdk = 16
targetSdk = 33
targetSdk = 35
}

compileOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ kotlin.targets

fun KonanTarget.getAppleSdk(): String {
return when (this) {
KonanTarget.IOS_ARM32,
KonanTarget.IOS_ARM64 -> "iphoneos"

KonanTarget.IOS_SIMULATOR_ARM64,
Expand All @@ -124,16 +123,14 @@ fun KonanTarget.getAppleSdk(): String {

KonanTarget.WATCHOS_ARM64,
KonanTarget.WATCHOS_SIMULATOR_ARM64,
KonanTarget.WATCHOS_X64,
KonanTarget.WATCHOS_X86 -> "watchsimulator"
KonanTarget.WATCHOS_X64 -> "watchsimulator"

else -> error("Unsupported target for selecting SDK: $this")
}
}

fun KonanTarget.getClangTarget(): String {
return when (this) {
KonanTarget.IOS_ARM32 -> "armv7-apple-ios"
KonanTarget.IOS_ARM64 -> "aarch64-apple-ios"
KonanTarget.IOS_SIMULATOR_ARM64 -> "aarch64-apple-ios-simulator"
KonanTarget.IOS_X64 -> "x86_64-apple-ios-simulator"
Expand All @@ -150,7 +147,6 @@ fun KonanTarget.getClangTarget(): String {
KonanTarget.WATCHOS_DEVICE_ARM64 -> "aarch64-apple-watchos"
KonanTarget.WATCHOS_SIMULATOR_ARM64 -> "aarch64-apple-watchos-simulator"
KonanTarget.WATCHOS_X64 -> "x86_64-apple-watchos-simulator"
KonanTarget.WATCHOS_X86 -> "i386-apple-watchos"

else -> error("Unsupported target for selecting clang target: $this")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

plugins {
id("com.android.library")
Expand All @@ -25,6 +26,21 @@ kotlin {
useCommonJs()
}

@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
useCommonJs()
}

// For https://youtrack.jetbrains.com/issue/KT-61573
targets.configureEach {
compilations.configureEach {
compileTaskProvider.get().compilerOptions {
Comment thread
Alex009 marked this conversation as resolved.
Outdated
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}

sourceSets {
val commonMain by getting

Expand Down Expand Up @@ -57,6 +73,16 @@ kotlin {
macosX64Main.dependsOn(this)
}

val commonJsMain = create("commonJsMain") {
dependsOn(commonMain)
}
val jsMain by getting {
dependsOn(commonJsMain)
}
val wasmJsMain by getting {
dependsOn(commonJsMain)
}

val commonTest by getting
val macosArm64Test by getting
val macosX64Test by getting
Expand All @@ -70,6 +96,10 @@ kotlin {
val jsTest by getting {
dependsOn(commonTest)
}

val wasmJsTest by getting {
dependsOn(commonTest)
}
}

jvmToolchain(11)
Expand Down
7 changes: 7 additions & 0 deletions resources-compose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl

/*
* Copyright 2021 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/
Expand All @@ -13,6 +15,7 @@ plugins {
id("org.jetbrains.compose")
id("javadoc-stub-convention")
id("publication-convention")
id("org.jetbrains.kotlin.plugin.compose")
}

android {
Expand All @@ -34,6 +37,10 @@ kotlin {
js(IR) {
browser()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
}

sourceSets {
commonMain {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2025 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.moko.resources.compose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,4 @@ actual fun stringResource(resource: PluralsResource, quantity: Int, vararg args:
}

@Composable
private fun localized(stringDesc: StringDesc): String {
return produceState(initialValue = "", stringDesc) {
value = stringDesc.toLocalizedString()
}.value
}
internal expect fun localized(stringDesc: StringDesc): String
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
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
Expand All @@ -18,7 +18,7 @@ import org.jetbrains.skia.Image
import platform.CoreGraphics.CGImageRef
import platform.UIKit.UIImage

@OptIn(ExperimentalForeignApi::class, InternalComposeApi::class)
@OptIn(ExperimentalForeignApi::class, InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
return remember(LocalSystemTheme.current, imageResource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
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
Expand All @@ -25,7 +25,7 @@ import org.jetbrains.skia.Data
import org.jetbrains.skia.Image
import org.jetbrains.skia.svg.SVGDOM

@OptIn(InternalComposeApi::class)
@OptIn(InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
val fileUrl: String = if (LocalSystemTheme.current == SystemTheme.Dark) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright 2024 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.produceState
import dev.icerock.moko.resources.desc.StringDesc

@Composable
internal actual fun localized(stringDesc: StringDesc): String {
return produceState(initialValue = "", stringDesc) {
value = stringDesc.toLocalizedString()
}.value
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
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(InternalComposeApi::class)
@OptIn(InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
val filePath: String = if (LocalSystemTheme.current == SystemTheme.Dark) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.InternalComposeApi
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
Expand All @@ -19,7 +19,7 @@ import platform.AppKit.NSImage
import platform.CoreGraphics.CGImageRef
import platform.CoreGraphics.CGImageRelease

@OptIn(ExperimentalForeignApi::class, InternalComposeApi::class)
@OptIn(ExperimentalForeignApi::class, InternalComposeUiApi::class)
@Composable
actual fun painterResource(imageResource: ImageResource): Painter {
return remember(LocalSystemTheme.current, imageResource) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.moko.resources.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.produceState
import dev.icerock.moko.resources.AssetResource

@Composable
actual fun AssetResource.readTextAsState(): State<String?> {
return produceState<String?>(null, this) {
value = getText()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2023 IceRock MAG Inc. Use of this source code is governed by the Apache 2.0 license.
*/

package dev.icerock.moko.resources.compose

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import dev.icerock.moko.resources.ColorResource

@Composable
actual fun colorResource(resource: ColorResource): Color {
// TODO https://github.com/icerockdev/moko-resources/issues/442
// web isSystemInDarkTheme not works now
val mokoColor: dev.icerock.moko.graphics.Color = if (isSystemInDarkTheme()) {
resource.darkColor
} else {
resource.lightColor
}

return Color(mokoColor.argb)
}
Loading
Loading