Browse Source

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

pull/2757/head
Nikita Lipsky 2 years 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 { val jvmAndAndroidMain by creating {
dependsOn(commonMain) dependsOn(commonMain)
} }
val nativeMain by creating {
dependsOn(commonMain)
}
val desktopMain by getting { val desktopMain by getting {
dependsOn(skikoMain) dependsOn(skikoMain)
dependsOn(jvmAndAndroidMain) dependsOn(jvmAndAndroidMain)
@ -68,6 +71,7 @@ kotlin {
val iosMain by getting { val iosMain by getting {
dependsOn(skikoMain) dependsOn(skikoMain)
dependsOn(commonButJSMain) dependsOn(commonButJSMain)
dependsOn(nativeMain)
} }
val iosTest by getting val iosTest by getting
val iosSimulatorArm64Main by getting val iosSimulatorArm64Main by getting
@ -80,6 +84,7 @@ kotlin {
val macosMain by creating { val macosMain by creating {
dependsOn(skikoMain) dependsOn(skikoMain)
dependsOn(commonButJSMain) dependsOn(commonButJSMain)
dependsOn(nativeMain)
} }
val macosX64Main by getting { val macosX64Main by getting {
dependsOn(macosMain) 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) * (https://developer.android.com/reference/android/graphics/drawable/VectorDrawable)
* except that external references to Android resources are not supported. * 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 @ExperimentalResourceApi
@Composable @Composable

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

@ -5,10 +5,8 @@
package org.jetbrains.compose.resources package org.jetbrains.compose.resources
import org.jetbrains.compose.resources.vector.xmldom.Element
import kotlinx.cinterop.addressOf import kotlinx.cinterop.addressOf
import kotlinx.cinterop.usePinned import kotlinx.cinterop.usePinned
import org.jetbrains.compose.resources.vector.xmldom.parse
import platform.Foundation.NSBundle import platform.Foundation.NSBundle
import platform.Foundation.NSData import platform.Foundation.NSData
import platform.Foundation.NSFileManager import platform.Foundation.NSFileManager
@ -36,5 +34,3 @@ private class UIKitResourceImpl(path: String) : AbstractResourceImpl(path) {
internal actual class MissingResourceException actual constructor(path: String) : internal actual class MissingResourceException actual constructor(path: String) :
Exception("Missing resource with path: $path") 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 package org.jetbrains.compose.resources
import org.jetbrains.compose.resources.vector.xmldom.Element
import kotlinx.cinterop.addressOf import kotlinx.cinterop.addressOf
import kotlinx.cinterop.usePinned import kotlinx.cinterop.usePinned
import platform.Foundation.NSData import platform.Foundation.NSData
@ -39,6 +38,3 @@ private class MacOSResourceImpl(path: String) : AbstractResourceImpl(path) {
internal actual class MissingResourceException actual constructor(path: String) : internal actual class MissingResourceException actual constructor(path: String) :
Exception("Missing resource with path: $path") 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