Skip to content

Commit

Permalink
Use new resource library
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Sep 29, 2024
1 parent cad8fa8 commit b59917c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
16 changes: 14 additions & 2 deletions app/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ dependencies {
implementation(project.dependencies.compose.materialIconsExtended)
implementation(project.dependencies.compose.material3)
implementation(libs.logback)
implementation(compose.components.resources)

if(windowsBuild) {
if (windowsBuild) {
implementation(projects.app.desktop.uwpHelper)
} else {
implementation(libs.ktor.server.netty)
Expand All @@ -28,7 +29,9 @@ dependencies {

sourceSets {
main {
if(windowsBuild) {
kotlin.srcDir("build/generated/compose/resourceGenerator/kotlin/commonResClass")
kotlin.srcDir("build/generated/compose/resourceGenerator/kotlin/mainResourceAccessors")
if (windowsBuild) {
kotlin.srcDir("src/windowsMain/kotlin")
} else {
kotlin.srcDir("src/nonWindowsMain/kotlin")
Expand Down Expand Up @@ -92,6 +95,15 @@ compose.desktop {
}
}

compose.resources {
publicResClass = false
packageOfResClass = "dev.schlaubi.tonbrett.app.desktop"
customDirectory(
sourceSetName = "main",
directoryProvider = provider { layout.projectDirectory.dir("src/main/composeResources") }
)
}

tasks {
register<Tar>("packageDistributable") {
from(named("createReleaseDistributable"))
Expand Down
File renamed without changes
5 changes: 2 additions & 3 deletions app/desktop/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.res.loadImageBitmap
import androidx.compose.ui.res.useResource
import androidx.compose.ui.window.*
import cafe.adriel.lyricist.LocalStrings
import dev.schlaubi.tonbrett.app.ColorScheme
Expand All @@ -29,6 +27,7 @@ import dev.schlaubi.tonbrett.app.desktop.Platform.start
import dev.schlaubi.tonbrett.app.title
import io.github.oshai.kotlinlogging.KotlinLogging
import io.ktor.serialization.*
import org.jetbrains.compose.resources.imageResource
import java.net.URI
import java.awt.Window as AWTWindow

Expand Down Expand Up @@ -103,7 +102,7 @@ private fun ApplicationScope.startActualApplication(
fun ApplicationScope.TonbrettWindow(content: @Composable FrameWindowScope.() -> Unit) = Window(
onCloseRequest = ::exitApplication,
title = title,
icon = BitmapPainter(useResource("logo.png", ::loadImageBitmap)),
icon = BitmapPainter(imageResource(Res.drawable.logo))
) {
ProvideLocalWindow(window) {
content()
Expand Down

0 comments on commit b59917c

Please sign in to comment.