Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ compose.desktop {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "Flipcash"
packageVersion = "1.0.0"
// Rendered from the iOS app's Icon Composer file (code-ios-app Flipcash/Supporting Files/AppIcon.icon)
// with ictool, so all three desktop icons match the phone apps.
macOS { iconFile.set(project.file("icons/Flipcash.icns")) }
windows { iconFile.set(project.file("icons/Flipcash.ico")) }
linux { iconFile.set(project.file("icons/Flipcash.png")) }
}
}
}
Expand Down
Binary file added apps/desktop/icons/Flipcash.icns
Binary file not shown.
Binary file added apps/desktop/icons/Flipcash.ico
Binary file not shown.
Binary file added apps/desktop/icons/Flipcash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions apps/desktop/src/main/kotlin/com/flipcash/desktop/Main.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.flipcash.desktop

import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.graphics.toAwtImage
import androidx.compose.ui.graphics.toComposeImageBitmap
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Window
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
import dev.zacsweers.metro.createGraph
import kotlinx.coroutines.runBlocking
import org.jetbrains.skia.Image
import java.awt.Taskbar
import java.lang.management.ManagementFactory

fun main() {
Expand All @@ -15,10 +21,12 @@ fun main() {
graph.startup()
graph.restoreSession()
}
val appIcon = loadAppIcon()
application {
Window(
onCloseRequest = ::exitApplication,
title = "Flipcash",
icon = appIcon,
state = rememberWindowState(width = 420.dp, height = 860.dp),
) {
DesktopApp(graph, signedIn)
Expand All @@ -30,3 +38,21 @@ fun main() {
}
}
}

/**
* Title bar and taskbar icon on Windows and Linux. A packaged Mac app takes its Dock icon from the bundle;
* `gradle run` does not, so the Dock would show the Java icon without the Taskbar call. The Mac image
* keeps the 824/1024 icon grid margin so it sits level with other Dock icons.
*/
private fun loadAppIcon(): BitmapPainter {
if (Taskbar.isTaskbarSupported() && Taskbar.getTaskbar().isSupported(Taskbar.Feature.ICON_IMAGE)) {
Taskbar.getTaskbar().iconImage = loadBitmap("/flipcash-icon-macos.png").toAwtImage()
}
return BitmapPainter(loadBitmap("/flipcash-icon.png"))
}

private fun loadBitmap(path: String): ImageBitmap {
val bytes = checkNotNull(object {}.javaClass.getResourceAsStream(path)) { "missing resource $path" }
.use { it.readBytes() }
return Image.makeFromEncoded(bytes).toComposeImageBitmap()
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading