diff --git a/examples/imageviewer/shared/build.gradle.kts b/examples/imageviewer/shared/build.gradle.kts index 24cb5db809..69f5c82f03 100755 --- a/examples/imageviewer/shared/build.gradle.kts +++ b/examples/imageviewer/shared/build.gradle.kts @@ -32,8 +32,7 @@ kotlin { implementation(compose.foundation) implementation(compose.material) //implementation(compose.materialIconsExtended) // TODO not working on iOS for now - @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) + implementation("org.jetbrains.compose.components:components-resources:1.6.0-dev1275") implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") diff --git a/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/storage/AndroidImageStorage.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/storage/AndroidImageStorage.kt index 727f051a53..d3af3ddb07 100644 --- a/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/storage/AndroidImageStorage.kt +++ b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/storage/AndroidImageStorage.kt @@ -21,7 +21,7 @@ import kotlinx.serialization.decodeFromString import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.resource +import org.jetbrains.compose.resources.readResourceBytes import java.io.File private const val maxStorableImageSizePx = 2000 @@ -117,7 +117,7 @@ class AndroidImageStorage( if (!tempFileToShare.exists()) { tempFileToShare.createNewFile() } - tempFileToShare.writeBytes(resource(picture.resource).readBytes()) + tempFileToShare.writeBytes(readResourceBytes(picture.resource)) } } FileProvider.getUriForFile( diff --git a/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt index 00bfab8a4f..2498d9a3be 100644 --- a/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt +++ b/examples/imageviewer/shared/src/androidMain/kotlin/example/imageviewer/view/CameraView.android.kt @@ -37,7 +37,7 @@ import example.imageviewer.model.createCameraPictureData import kotlinx.coroutines.delay import kotlinx.coroutines.launch import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.resource +import org.jetbrains.compose.resources.readResourceBytes import java.nio.ByteBuffer import java.util.* import java.util.concurrent.Executors @@ -176,7 +176,7 @@ private fun CameraWithGrantedPermission( delay(5000) if (capturePhotoStarted) { addLocationInfoAndReturnResult( - resource("android-emulator-photo.jpg").readBytes().toImageBitmap() + readResourceBytes("android-emulator-photo.jpg").toImageBitmap() ) } } diff --git a/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Dependencies.kt b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Dependencies.kt index c976f982e4..3d0feef9e9 100644 --- a/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Dependencies.kt +++ b/examples/imageviewer/shared/src/commonMain/kotlin/example/imageviewer/Dependencies.kt @@ -5,11 +5,11 @@ import androidx.compose.runtime.snapshots.SnapshotStateList import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.ImageBitmap import example.imageviewer.filter.PlatformContext -import example.imageviewer.model.* +import example.imageviewer.model.PictureData import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.resource +import org.jetbrains.compose.resources.readResourceBytes @OptIn(ExperimentalResourceApi::class) abstract class Dependencies { @@ -22,7 +22,7 @@ abstract class Dependencies { val imageProvider: ImageProvider = object : ImageProvider { override suspend fun getImage(picture: PictureData): ImageBitmap = when (picture) { is PictureData.Resource -> { - resource(picture.resource).readBytes().toImageBitmap() + readResourceBytes(picture.resource).toImageBitmap() } is PictureData.Camera -> { @@ -32,7 +32,7 @@ abstract class Dependencies { override suspend fun getThumbnail(picture: PictureData): ImageBitmap = when (picture) { is PictureData.Resource -> { - resource(picture.thumbnailResource).readBytes().toImageBitmap() + readResourceBytes(picture.thumbnailResource).toImageBitmap() } is PictureData.Camera -> { diff --git a/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/CameraView.desktop.kt b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/CameraView.desktop.kt index 8e7aa23151..e816bdae17 100644 --- a/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/CameraView.desktop.kt +++ b/examples/imageviewer/shared/src/desktopMain/kotlin/example/imageviewer/view/CameraView.desktop.kt @@ -18,10 +18,7 @@ import example.imageviewer.icon.IconPhotoCamera import example.imageviewer.model.PictureData import example.imageviewer.model.createCameraPictureData import org.jetbrains.compose.resources.ExperimentalResourceApi -import org.jetbrains.compose.resources.orEmpty -import org.jetbrains.compose.resources.rememberImageBitmap -import org.jetbrains.compose.resources.resource -import java.util.* +import org.jetbrains.compose.resources.imageResource @OptIn(ExperimentalResourceApi::class) @Composable @@ -30,10 +27,10 @@ actual fun CameraView( onCapture: (picture: PictureData.Camera, image: PlatformStorableImage) -> Unit ) { val randomPicture = remember { resourcePictures.random() } - val imageBitmap = resource(randomPicture.resource).rememberImageBitmap().orEmpty() + val imageBitmap = imageResource(randomPicture.resource) Box(Modifier.fillMaxSize().background(Color.Black)) { Image( - bitmap = imageBitmap, + bitmap = imageResource(randomPicture.resource), contentDescription = "Camera stub", Modifier.fillMaxSize() )