https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
l

Lukáš Kúšik

09/30/2022, 9:12 AM
Hi, I'm having trouble with properties in
expect value
classes. I'm trying to create a multiplatform
Color
class, backed by Compose's Color class in the jvm target.
Copy code
// android module
actual typealias Color = androidx.compose.ui.graphics.Color
Compose
Color
class contains getter for color components.
Copy code
// Compose's Color class
@kotlin.jvm.JvmInline
value class Color(val value: ULong) {
    
    val red: Float
        get() {
           ...
        }
}
I would like to put these getters into my expected
Color
class and can't seem to find the correct syntax that would allow me to do it (see the attached image).
t

Tijl

09/30/2022, 9:31 AM
not sure if that can be fixed easily, but an alternative is to expect extension properties for
red
,
blue
etc
d

Derek Ellis

09/30/2022, 4:46 PM
You could also define those properties in an interface and have
Color
extend that interface. The
actual
definitions would then have to implement them.
2 Views