Browse Source

Added app icon to desktop version of ImageViewer.

pull/24/head
Roman Sedaikin 4 years ago
parent
commit
df6fa95b9b
  1. 21
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/style/Decoration.kt
  2. 12
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt
  3. BIN
      examples/imageviewer/common/src/desktopMain/resources/images/ic_imageviewer_round.png
  4. 7
      examples/imageviewer/desktop/src/main/kotlin/imageviewer/Main.kt

21
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/style/Decoration.kt

@ -18,6 +18,8 @@ package example.imageviewer.style
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.ImageAsset
import androidx.compose.ui.res.imageResource
import java.awt.image.BufferedImage
import javax.imageio.ImageIO
@Composable
fun icEmpty(): ImageAsset = imageResource("images/empty.png")
@ -51,3 +53,22 @@ fun icFilterBlurOff(): ImageAsset = imageResource("images/blur_off.png")
@Composable
fun icFilterUnknown(): ImageAsset = imageResource("images/filter_unknown.png")
private var icon: BufferedImage? = null
fun icAppRounded(): BufferedImage {
if (icon != null) {
return icon!!
}
try {
val imageRes = "images/ic_imageviewer_round.png"
val img = Thread.currentThread().contextClassLoader.getResource(imageRes)
val bitmap: BufferedImage? = ImageIO.read(img)
if (bitmap != null) {
icon = bitmap
return bitmap
}
} catch (e: Exception) {
e.printStackTrace()
}
return BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)
}

12
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/MainScreen.kt

@ -163,18 +163,8 @@ fun setTitleBar(text: String, content: ContentState) {
@Composable
fun setPreviewImageUI(content: ContentState) {
val previewImageHover = remember { mutableStateOf(false) }
Clickable(
modifier = Modifier.hover(
onEnter = {
previewImageHover.value = true
false
},
onExit = {
previewImageHover.value = false
false
})
.background(color = if (previewImageHover.value) PreviewImageAreaHoverColor else DarkGray),
modifier = Modifier.background(color = DarkGray),
onClick = {
AppState.screenState(ScreenType.FullscreenImage)
}) {

BIN
examples/imageviewer/common/src/desktopMain/resources/images/ic_imageviewer_round.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

7
examples/imageviewer/desktop/src/main/kotlin/imageviewer/Main.kt

@ -20,6 +20,7 @@ import example.imageviewer.utils.getPreferredWindowSize
import example.imageviewer.view.BuildAppUI
import example.imageviewer.model.ContentState
import example.imageviewer.model.ImageRepository
import example.imageviewer.style.icAppRounded
fun main() {
@ -27,7 +28,11 @@ fun main() {
"https://spvessel.com/iv/images/fetching.list"
)
AppWindow("ImageViewer", getPreferredWindowSize(800, 1000)).show {
AppWindow(
title = "ImageViewer",
size = getPreferredWindowSize(800, 1000),
icon = icAppRounded()
).show {
BuildAppUI(content)
}
}
Loading…
Cancel
Save