Browse Source

Add XML Vector Drawables to MacOS native target. (#2756)

pull/2757/head
Nikita Lipsky 1 year ago committed by GitHub
parent
commit
05ee5aef35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      components/resources/library/build.gradle.kts
  2. 3
      components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ComposeResource.common.kt
  3. 4
      components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/Resource.ios.kt
  4. 4
      components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/Resource.macos.kt
  5. 11
      components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/Resource.native.kt
  6. 0
      components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt

5
components/resources/library/build.gradle.kts

@ -44,6 +44,9 @@ kotlin {
val jvmAndAndroidMain by creating {
dependsOn(commonMain)
}
val nativeMain by creating {
dependsOn(commonMain)
}
val desktopMain by getting {
dependsOn(skikoMain)
dependsOn(jvmAndAndroidMain)
@ -68,6 +71,7 @@ kotlin {
val iosMain by getting {
dependsOn(skikoMain)
dependsOn(commonButJSMain)
dependsOn(nativeMain)
}
val iosTest by getting
val iosSimulatorArm64Main by getting
@ -80,6 +84,7 @@ kotlin {
val macosMain by creating {
dependsOn(skikoMain)
dependsOn(commonButJSMain)
dependsOn(nativeMain)
}
val macosX64Main by getting {
dependsOn(macosMain)

3
components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ComposeResource.common.kt

@ -111,8 +111,7 @@ private fun painterResource(
* (https://developer.android.com/reference/android/graphics/drawable/VectorDrawable)
* except that external references to Android resources are not supported.
*
* Note that XML Vector Drawables are not supported for Web and native MacOS targets currently.
*
* Note that XML Vector Drawables are not supported for Web target currently.
*/
@ExperimentalResourceApi
@Composable

4
components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/Resource.ios.kt

@ -5,10 +5,8 @@
package org.jetbrains.compose.resources
import org.jetbrains.compose.resources.vector.xmldom.Element
import kotlinx.cinterop.addressOf
import kotlinx.cinterop.usePinned
import org.jetbrains.compose.resources.vector.xmldom.parse
import platform.Foundation.NSBundle
import platform.Foundation.NSData
import platform.Foundation.NSFileManager
@ -36,5 +34,3 @@ private class UIKitResourceImpl(path: String) : AbstractResourceImpl(path) {
internal actual class MissingResourceException actual constructor(path: String) :
Exception("Missing resource with path: $path")
internal actual fun parseXML(byteArray: ByteArray): Element = parse(byteArray.decodeToString())

4
components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/Resource.macos.kt

@ -5,7 +5,6 @@
package org.jetbrains.compose.resources
import org.jetbrains.compose.resources.vector.xmldom.Element
import kotlinx.cinterop.addressOf
import kotlinx.cinterop.usePinned
import platform.Foundation.NSData
@ -39,6 +38,3 @@ private class MacOSResourceImpl(path: String) : AbstractResourceImpl(path) {
internal actual class MissingResourceException actual constructor(path: String) :
Exception("Missing resource with path: $path")
internal actual fun parseXML(byteArray: ByteArray): Element {
throw UnsupportedOperationException("XML Vector Drawables are not supported for MacOS target")
}

11
components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/Resource.native.kt

@ -0,0 +1,11 @@
/*
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.resources
import org.jetbrains.compose.resources.vector.xmldom.Element
import org.jetbrains.compose.resources.vector.xmldom.parse
internal actual fun parseXML(byteArray: ByteArray): Element = parse(byteArray.decodeToString())

0
components/resources/library/src/iosMain/kotlin/org/jetbrains/compose/resources/xmldom/DomXmlParser.kt → components/resources/library/src/nativeMain/kotlin/org/jetbrains/compose/resources/vector/xmldom/DomXmlParser.kt

Loading…
Cancel
Save