Skip to content

Commit

Permalink
Apply runtime configurations with type checking for images
Browse files Browse the repository at this point in the history
  • Loading branch information
ashdavies committed Feb 17, 2024
1 parent 6821147 commit 312fd5f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.painter.BitmapPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.unit.dp
import coil3.compose.rememberAsyncImagePainter
Expand Down Expand Up @@ -103,10 +106,16 @@ private fun LauncherItem(
) {
Card(modifier = modifier.clickable(onClick = onClick)) {
Column {
val imagePainter = rememberAsyncImagePainter(
model = item.imageModel,
contentScale = ContentScale.Crop,
)
val imagePainter = when (val imageModel = item.imageModel) {
is ImageBitmap -> remember(imageModel) {
BitmapPainter(imageModel)
}

else -> rememberAsyncImagePainter(
model = item.imageModel,
contentScale = ContentScale.Crop,
)
}

Image(
painter = imagePainter,
Expand Down
6 changes: 6 additions & 0 deletions app-launcher/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ kotlin {
implementation(libs.ktor.client.core)
implementation(libs.slack.circuit.foundation)
}

jvmMain.dependencies {
runtimeOnly(compose.desktop.currentOs)
runtimeOnly(libs.kotlinx.coroutines.swing)
runtimeOnly(libs.slf4j.simple)
}
}

compose.desktop {
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ kotlinx-collections-immutable = "org.jetbrains.kotlinx:kotlinx-collections-immut

kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-swing", version.ref = "kotlinx-coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }

kotlinx-datetime = "org.jetbrains.kotlinx:kotlinx-datetime:0.5.0"
Expand Down

0 comments on commit 312fd5f

Please sign in to comment.