Theme the toolbar and swing components

This commit is contained in:
Syer10
2021-05-02 09:45:42 -04:00
parent df4c1969b9
commit d06f0a033f
2 changed files with 20 additions and 0 deletions

View File

@@ -29,6 +29,9 @@ dependencies {
implementation("br.com.devsrsouza.compose.icons.jetbrains:font-awesome:0.2.0")
implementation("com.github.Syer10:compose-router:45a8c4fe83")
// UI (Swing)
implementation("com.github.weisj:darklaf-core:2.5.5")
// Threading
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3")

View File

@@ -17,12 +17,19 @@ import ca.gosyer.data.DataModule
import ca.gosyer.data.server.ServerService
import ca.gosyer.data.server.ServerService.ServerResult
import ca.gosyer.data.ui.UiPreferences
import ca.gosyer.data.ui.model.ThemeMode
import ca.gosyer.data.ui.model.WindowSettings
import ca.gosyer.ui.base.components.ErrorScreen
import ca.gosyer.ui.base.components.LoadingScreen
import ca.gosyer.ui.base.theme.AppTheme
import ca.gosyer.util.system.getAsFlow
import com.github.weisj.darklaf.LafManager
import com.github.weisj.darklaf.theme.DarculaTheme
import com.github.weisj.darklaf.theme.IntelliJTheme
import com.github.zsoltk.compose.backpress.BackPressHandler
import com.github.zsoltk.compose.backpress.LocalBackPressHandler
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.launchIn
import org.apache.logging.log4j.core.config.Configurator
import toothpick.configuration.Configuration
import toothpick.ktp.KTP
@@ -56,6 +63,16 @@ fun main() {
val serverService = scope.getInstance<ServerService>()
scope.getInstance<UiPreferences>().themeMode()
.getAsFlow {
val theme = when (it) {
ThemeMode.Light -> IntelliJTheme()
ThemeMode.Dark -> DarculaTheme()
}
LafManager.install(theme)
}
.launchIn(GlobalScope)
val windowSettings = scope.getInstance<UiPreferences>().window()
val (offset, size) = windowSettings.get().get()