All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.woojiahao.style.css.CssProperty.kt Maven / Gradle / Ivy

There is a newer version: 0.2.3
Show newest version
package com.github.woojiahao.style.css

import com.github.woojiahao.style.Settings.Theme.DARK
import com.github.woojiahao.style.Settings.Theme.LIGHT
import com.github.woojiahao.style.Settings.theme
import kotlin.reflect.KProperty

class CssProperty(
  private var light: T? = null,
  private var dark: T? = light,
  private val fallback: T? = null
) {

  operator fun getValue(thisRef: Any?, property: KProperty<*>) =
    when (theme) {
      LIGHT -> light
      DARK -> dark
    } ?: fallback

  operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T?) {
    when (theme) {
      LIGHT -> {
        this.light = value
      }
      DARK -> {
        this.dark = value
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy