Browse Source
The PR adds a generation special properties with maps a string ID to the resource for each type of resources: ```kotlin val Res.allDrawableResources: Map<String, DrawableResource> val Res.allStringResources: Map<String, StringResource> val Res.allStringArrayResources: Map<String, StringArrayResource> val Res.allPluralStringResources: Map<String, PluralStringResource> val Res.allFontResources: Map<String, FontResource> ``` <!-- Optional --> Fixes https://github.com/JetBrains/compose-multiplatform/issues/4880 Fixes https://youtrack.jetbrains.com/issue/CMP-1607 ## Testing I checked it in the sample project but this should be tested by QA (KMP and JVM only projects) ## Release Notes ### Features - Resources - Now the gradle plugin generates resources map to find a resource by a string IDpull/5091/head
Konstantin
4 months ago
committed by
GitHub
31 changed files with 1218 additions and 352 deletions
@ -0,0 +1,116 @@ |
|||||||
|
package org.jetbrains.compose.resources |
||||||
|
|
||||||
|
import org.gradle.api.file.ConfigurableFileCollection |
||||||
|
import org.gradle.api.file.DirectoryProperty |
||||||
|
import org.gradle.api.provider.Property |
||||||
|
import org.gradle.api.tasks.Input |
||||||
|
import org.gradle.api.tasks.InputFiles |
||||||
|
import org.gradle.api.tasks.OutputDirectory |
||||||
|
import org.gradle.api.tasks.PathSensitive |
||||||
|
import org.gradle.api.tasks.PathSensitivity |
||||||
|
import org.jetbrains.compose.internal.IdeaImportTask |
||||||
|
import org.jetbrains.compose.internal.utils.uppercaseFirstChar |
||||||
|
|
||||||
|
internal abstract class GenerateExpectResourceCollectorsTask : IdeaImportTask() { |
||||||
|
@get:Input |
||||||
|
abstract val packageName: Property<String> |
||||||
|
|
||||||
|
@get:Input |
||||||
|
abstract val shouldGenerateCode: Property<Boolean> |
||||||
|
|
||||||
|
@get:Input |
||||||
|
abstract val makeAccessorsPublic: Property<Boolean> |
||||||
|
|
||||||
|
@get:OutputDirectory |
||||||
|
abstract val codeDir: DirectoryProperty |
||||||
|
|
||||||
|
override fun safeAction() { |
||||||
|
val kotlinDir = codeDir.get().asFile |
||||||
|
|
||||||
|
logger.info("Clean directory $kotlinDir") |
||||||
|
kotlinDir.deleteRecursively() |
||||||
|
kotlinDir.mkdirs() |
||||||
|
|
||||||
|
if (shouldGenerateCode.get()) { |
||||||
|
logger.info("Generate expect ResourceCollectors for $kotlinDir") |
||||||
|
|
||||||
|
val pkgName = packageName.get() |
||||||
|
val isPublic = makeAccessorsPublic.get() |
||||||
|
val spec = getExpectResourceCollectorsFileSpec(pkgName, "ExpectResourceCollectors", isPublic) |
||||||
|
spec.writeTo(kotlinDir) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
internal abstract class GenerateActualResourceCollectorsTask : IdeaImportTask() { |
||||||
|
@get:Input |
||||||
|
abstract val packageName: Property<String> |
||||||
|
|
||||||
|
@get:Input |
||||||
|
abstract val shouldGenerateCode: Property<Boolean> |
||||||
|
|
||||||
|
@get:Input |
||||||
|
abstract val makeAccessorsPublic: Property<Boolean> |
||||||
|
|
||||||
|
@get:Input |
||||||
|
abstract val useActualModifier: Property<Boolean> |
||||||
|
|
||||||
|
@get:InputFiles |
||||||
|
@get:PathSensitive(PathSensitivity.RELATIVE) |
||||||
|
abstract val resourceAccessorDirs: ConfigurableFileCollection |
||||||
|
|
||||||
|
@get:OutputDirectory |
||||||
|
abstract val codeDir: DirectoryProperty |
||||||
|
|
||||||
|
override fun safeAction() { |
||||||
|
val kotlinDir = codeDir.get().asFile |
||||||
|
val inputDirs = resourceAccessorDirs.files |
||||||
|
|
||||||
|
logger.info("Clean directory $kotlinDir") |
||||||
|
kotlinDir.deleteRecursively() |
||||||
|
kotlinDir.mkdirs() |
||||||
|
|
||||||
|
val inputFiles = inputDirs.flatMap { dir -> |
||||||
|
dir.walkTopDown().filter { !it.isHidden && it.isFile && it.extension == "kt" }.toList() |
||||||
|
} |
||||||
|
|
||||||
|
if (shouldGenerateCode.get()) { |
||||||
|
logger.info("Generate actual ResourceCollectors for $kotlinDir") |
||||||
|
val funNames = inputFiles.mapNotNull { inputFile -> |
||||||
|
if (inputFile.nameWithoutExtension.contains('.')) { |
||||||
|
val (fileName, suffix) = inputFile.nameWithoutExtension.split('.') |
||||||
|
val type = ResourceType.values().firstOrNull { fileName.startsWith(it.accessorName, true) } |
||||||
|
val name = "_collect${suffix.uppercaseFirstChar()}${fileName}Resources" |
||||||
|
|
||||||
|
if (type == null) { |
||||||
|
logger.warn("Unknown resources type: `$inputFile`") |
||||||
|
null |
||||||
|
} else if (!inputFile.readText().contains(name)) { |
||||||
|
logger.warn("A function '$name' is not found in the `$inputFile` file!") |
||||||
|
null |
||||||
|
} else { |
||||||
|
logger.info("Found collector function: `$name`") |
||||||
|
type to name |
||||||
|
} |
||||||
|
} else { |
||||||
|
logger.warn("Unknown file name: `$inputFile`") |
||||||
|
null |
||||||
|
} |
||||||
|
}.groupBy({ it.first }, { it.second }) |
||||||
|
|
||||||
|
val pkgName = packageName.get() |
||||||
|
val isPublic = makeAccessorsPublic.get() |
||||||
|
val useActual = useActualModifier.get() |
||||||
|
val spec = getActualResourceCollectorsFileSpec( |
||||||
|
pkgName, |
||||||
|
"ActualResourceCollectors", |
||||||
|
isPublic, |
||||||
|
useActual, |
||||||
|
funNames |
||||||
|
) |
||||||
|
spec.writeTo(kotlinDir) |
||||||
|
} else { |
||||||
|
logger.info("Generation ResourceCollectors for $kotlinDir is disabled") |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,53 @@ |
|||||||
|
@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) |
||||||
|
|
||||||
|
package my.lib.res |
||||||
|
|
||||||
|
import kotlin.OptIn |
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allDrawableResources: Map<String, DrawableResource> by lazy { |
||||||
|
val map = mutableMapOf<String, DrawableResource>() |
||||||
|
_collectCommonMainDrawable0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allStringResources: Map<String, StringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringResource>() |
||||||
|
_collectAndroidMainString0Resources(map) |
||||||
|
_collectCommonMainString0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringArrayResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, PluralStringResource>() |
||||||
|
_collectCommonMainPlurals0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allFontResources: Map<String, FontResource> by lazy { |
||||||
|
val map = mutableMapOf<String, FontResource>() |
||||||
|
_collectCommonMainFont0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
@ -0,0 +1,25 @@ |
|||||||
|
package my.lib.res |
||||||
|
|
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public expect val Res.allDrawableResources: Map<String, DrawableResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public expect val Res.allStringResources: Map<String, StringResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public expect val Res.allStringArrayResources: Map<String, StringArrayResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public expect val Res.allPluralStringResources: Map<String, PluralStringResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public expect val Res.allFontResources: Map<String, FontResource> |
@ -0,0 +1,53 @@ |
|||||||
|
@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) |
||||||
|
|
||||||
|
package my.lib.res |
||||||
|
|
||||||
|
import kotlin.OptIn |
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allDrawableResources: Map<String, DrawableResource> by lazy { |
||||||
|
val map = mutableMapOf<String, DrawableResource>() |
||||||
|
_collectCommonMainDrawable0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allStringResources: Map<String, StringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringResource>() |
||||||
|
_collectDesktopMainString0Resources(map) |
||||||
|
_collectCommonMainString0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringArrayResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, PluralStringResource>() |
||||||
|
_collectCommonMainPlurals0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
public actual val Res.allFontResources: Map<String, FontResource> by lazy { |
||||||
|
val map = mutableMapOf<String, FontResource>() |
||||||
|
_collectCommonMainFont0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
@ -0,0 +1,53 @@ |
|||||||
|
@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) |
||||||
|
|
||||||
|
package app.group.resources_test.generated.resources |
||||||
|
|
||||||
|
import kotlin.OptIn |
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allDrawableResources: Map<String, DrawableResource> by lazy { |
||||||
|
val map = mutableMapOf<String, DrawableResource>() |
||||||
|
_collectCommonMainDrawable0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allStringResources: Map<String, StringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringResource>() |
||||||
|
_collectAndroidMainString0Resources(map) |
||||||
|
_collectCommonMainString0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringArrayResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, PluralStringResource>() |
||||||
|
_collectCommonMainPlurals0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allFontResources: Map<String, FontResource> by lazy { |
||||||
|
val map = mutableMapOf<String, FontResource>() |
||||||
|
_collectCommonMainFont0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
@ -0,0 +1,25 @@ |
|||||||
|
package app.group.resources_test.generated.resources |
||||||
|
|
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allDrawableResources: Map<String, DrawableResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allStringResources: Map<String, StringResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allStringArrayResources: Map<String, StringArrayResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allPluralStringResources: Map<String, PluralStringResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allFontResources: Map<String, FontResource> |
@ -0,0 +1,53 @@ |
|||||||
|
@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) |
||||||
|
|
||||||
|
package app.group.resources_test.generated.resources |
||||||
|
|
||||||
|
import kotlin.OptIn |
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allDrawableResources: Map<String, DrawableResource> by lazy { |
||||||
|
val map = mutableMapOf<String, DrawableResource>() |
||||||
|
_collectCommonMainDrawable0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allStringResources: Map<String, StringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringResource>() |
||||||
|
_collectDesktopMainString0Resources(map) |
||||||
|
_collectCommonMainString0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringArrayResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, PluralStringResource>() |
||||||
|
_collectCommonMainPlurals0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allFontResources: Map<String, FontResource> by lazy { |
||||||
|
val map = mutableMapOf<String, FontResource>() |
||||||
|
_collectCommonMainFont0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
@ -1,49 +0,0 @@ |
|||||||
@file:OptIn( |
|
||||||
org.jetbrains.compose.resources.InternalResourceApi::class, |
|
||||||
org.jetbrains.compose.resources.ExperimentalResourceApi::class, |
|
||||||
) |
|
||||||
|
|
||||||
package app.group.empty_res.generated.resources |
|
||||||
|
|
||||||
import kotlin.ByteArray |
|
||||||
import kotlin.OptIn |
|
||||||
import kotlin.String |
|
||||||
import org.jetbrains.compose.resources.ExperimentalResourceApi |
|
||||||
import org.jetbrains.compose.resources.getResourceUri |
|
||||||
import org.jetbrains.compose.resources.readResourceBytes |
|
||||||
|
|
||||||
internal object Res { |
|
||||||
/** |
|
||||||
* Reads the content of the resource file at the specified path and returns it as a byte array. |
|
||||||
* |
|
||||||
* Example: `val bytes = Res.readBytes("files/key.bin")` |
|
||||||
* |
|
||||||
* @param path The path of the file to read in the compose resource's directory. |
|
||||||
* @return The content of the file as a byte array. |
|
||||||
*/ |
|
||||||
@ExperimentalResourceApi |
|
||||||
public suspend fun readBytes(path: String): ByteArray = |
|
||||||
readResourceBytes("composeResources/app.group.empty_res.generated.resources/" + path) |
|
||||||
|
|
||||||
/** |
|
||||||
* Returns the URI string of the resource file at the specified path. |
|
||||||
* |
|
||||||
* Example: `val uri = Res.getUri("files/key.bin")` |
|
||||||
* |
|
||||||
* @param path The path of the file in the compose resource's directory. |
|
||||||
* @return The URI string of the file. |
|
||||||
*/ |
|
||||||
@ExperimentalResourceApi |
|
||||||
public fun getUri(path: String): String = |
|
||||||
getResourceUri("composeResources/app.group.empty_res.generated.resources/" + path) |
|
||||||
|
|
||||||
public object drawable |
|
||||||
|
|
||||||
public object string |
|
||||||
|
|
||||||
public object array |
|
||||||
|
|
||||||
public object plurals |
|
||||||
|
|
||||||
public object font |
|
||||||
} |
|
@ -0,0 +1,25 @@ |
|||||||
|
package app.group.empty_res.generated.resources |
||||||
|
|
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allDrawableResources: Map<String, DrawableResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allStringResources: Map<String, StringResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allStringArrayResources: Map<String, StringArrayResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allPluralStringResources: Map<String, PluralStringResource> |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal expect val Res.allFontResources: Map<String, FontResource> |
@ -0,0 +1,49 @@ |
|||||||
|
@file:OptIn( |
||||||
|
org.jetbrains.compose.resources.InternalResourceApi::class, |
||||||
|
org.jetbrains.compose.resources.ExperimentalResourceApi::class, |
||||||
|
) |
||||||
|
|
||||||
|
package app.group.empty_res.generated.resources |
||||||
|
|
||||||
|
import kotlin.ByteArray |
||||||
|
import kotlin.OptIn |
||||||
|
import kotlin.String |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.getResourceUri |
||||||
|
import org.jetbrains.compose.resources.readResourceBytes |
||||||
|
|
||||||
|
internal object Res { |
||||||
|
/** |
||||||
|
* Reads the content of the resource file at the specified path and returns it as a byte array. |
||||||
|
* |
||||||
|
* Example: `val bytes = Res.readBytes("files/key.bin")` |
||||||
|
* |
||||||
|
* @param path The path of the file to read in the compose resource's directory. |
||||||
|
* @return The content of the file as a byte array. |
||||||
|
*/ |
||||||
|
@ExperimentalResourceApi |
||||||
|
public suspend fun readBytes(path: String): ByteArray = |
||||||
|
readResourceBytes("composeResources/app.group.empty_res.generated.resources/" + path) |
||||||
|
|
||||||
|
/** |
||||||
|
* Returns the URI string of the resource file at the specified path. |
||||||
|
* |
||||||
|
* Example: `val uri = Res.getUri("files/key.bin")` |
||||||
|
* |
||||||
|
* @param path The path of the file in the compose resource's directory. |
||||||
|
* @return The URI string of the file. |
||||||
|
*/ |
||||||
|
@ExperimentalResourceApi |
||||||
|
public fun getUri(path: String): String = |
||||||
|
getResourceUri("composeResources/app.group.empty_res.generated.resources/" + path) |
||||||
|
|
||||||
|
public object drawable |
||||||
|
|
||||||
|
public object string |
||||||
|
|
||||||
|
public object array |
||||||
|
|
||||||
|
public object plurals |
||||||
|
|
||||||
|
public object font |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) |
||||||
|
|
||||||
|
package app.group.empty_res.generated.resources |
||||||
|
|
||||||
|
import kotlin.OptIn |
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allDrawableResources: Map<String, DrawableResource> by lazy { |
||||||
|
val map = mutableMapOf<String, DrawableResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allStringResources: Map<String, StringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringArrayResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, PluralStringResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal actual val Res.allFontResources: Map<String, FontResource> by lazy { |
||||||
|
val map = mutableMapOf<String, FontResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
@ -0,0 +1,49 @@ |
|||||||
|
@file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) |
||||||
|
|
||||||
|
package me.app.jvmonlyresources.generated.resources |
||||||
|
|
||||||
|
import kotlin.OptIn |
||||||
|
import kotlin.String |
||||||
|
import kotlin.collections.Map |
||||||
|
import org.jetbrains.compose.resources.DrawableResource |
||||||
|
import org.jetbrains.compose.resources.ExperimentalResourceApi |
||||||
|
import org.jetbrains.compose.resources.FontResource |
||||||
|
import org.jetbrains.compose.resources.PluralStringResource |
||||||
|
import org.jetbrains.compose.resources.StringArrayResource |
||||||
|
import org.jetbrains.compose.resources.StringResource |
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal val Res.allDrawableResources: Map<String, DrawableResource> by lazy { |
||||||
|
val map = mutableMapOf<String, DrawableResource>() |
||||||
|
_collectMainDrawable0Resources(map) |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal val Res.allStringResources: Map<String, StringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy { |
||||||
|
val map = mutableMapOf<String, StringArrayResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy { |
||||||
|
val map = mutableMapOf<String, PluralStringResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@ExperimentalResourceApi |
||||||
|
internal val Res.allFontResources: Map<String, FontResource> by lazy { |
||||||
|
val map = mutableMapOf<String, FontResource>() |
||||||
|
return@lazy map |
||||||
|
} |
||||||
|
|
Loading…
Reference in new issue