From 392c9c58cc7a3ada701c8d5d6003b68387a82343 Mon Sep 17 00:00:00 2001 From: Konstantin Tskhovrebov Date: Tue, 5 Dec 2023 18:15:55 +0100 Subject: [PATCH] Update graphics-2d and widgets-gallery to the new resources library --- .../{assets => composeRes/images}/clock.png | Bin .../images/compose_community_primary.xml} | 0 .../{assets => composeRes/images}/flag.png | Bin .../{assets => composeRes/images}/mine.png | Bin examples/graphics-2d/shared/build.gradle.kts | 92 +++++------------- .../kotlin/minesweeper/MineSweeper.common.kt | 7 +- .../commonMain/kotlin/minesweeper/Widgets.kt | 13 +-- .../kotlin/visualeffects/RotatingWords.kt | 3 +- .../{assets => composeRes/images}/clock.png | Bin .../images/compose_community_primary.xml} | 0 .../{assets => composeRes/images}/flag.png | Bin .../{assets => composeRes/images}/mine.png | Bin .../widgets-gallery/shared/build.gradle.kts | 2 +- .../demo/widgets/data/DemoDataProvider.kt | 2 - .../compose/demo/widgets/platform/Res.kt | 13 +-- .../demo/widgets/ui/screens/AppBars.kt | 16 +-- .../compose/demo/widgets/ui/screens/Chips.kt | 8 +- .../demo/widgets/ui/screens/UICards.kt | 10 +- .../images}/ic_instagram.xml | 0 .../images}/ic_send.xml | 0 .../images}/ic_twitter.xml | 0 .../images}/p1.jpeg | Bin .../images}/p2.jpeg | Bin .../images}/p3.jpeg | Bin .../images}/p6.jpeg | Bin .../resources/composeRes/values/strings.xml | 5 + 26 files changed, 60 insertions(+), 111 deletions(-) rename examples/graphics-2d/jsApp/src/jsMain/resources/{assets => composeRes/images}/clock.png (100%) rename examples/graphics-2d/jsApp/src/jsMain/resources/{compose-community-primary.xml => composeRes/images/compose_community_primary.xml} (100%) rename examples/graphics-2d/jsApp/src/jsMain/resources/{assets => composeRes/images}/flag.png (100%) rename examples/graphics-2d/jsApp/src/jsMain/resources/{assets => composeRes/images}/mine.png (100%) rename examples/graphics-2d/shared/src/commonMain/resources/{assets => composeRes/images}/clock.png (100%) rename examples/graphics-2d/shared/src/commonMain/resources/{compose-community-primary.xml => composeRes/images/compose_community_primary.xml} (100%) rename examples/graphics-2d/shared/src/commonMain/resources/{assets => composeRes/images}/flag.png (100%) rename examples/graphics-2d/shared/src/commonMain/resources/{assets => composeRes/images}/mine.png (100%) rename examples/widgets-gallery/shared/src/commonMain/resources/{drawable => composeRes/images}/ic_instagram.xml (100%) rename examples/widgets-gallery/shared/src/commonMain/resources/{drawable => composeRes/images}/ic_send.xml (100%) rename examples/widgets-gallery/shared/src/commonMain/resources/{drawable => composeRes/images}/ic_twitter.xml (100%) rename examples/widgets-gallery/shared/src/commonMain/resources/{drawable-nodpi => composeRes/images}/p1.jpeg (100%) rename examples/widgets-gallery/shared/src/commonMain/resources/{drawable-nodpi => composeRes/images}/p2.jpeg (100%) rename examples/widgets-gallery/shared/src/commonMain/resources/{drawable-nodpi => composeRes/images}/p3.jpeg (100%) rename examples/widgets-gallery/shared/src/commonMain/resources/{drawable-nodpi => composeRes/images}/p6.jpeg (100%) create mode 100644 examples/widgets-gallery/shared/src/commonMain/resources/composeRes/values/strings.xml diff --git a/examples/graphics-2d/jsApp/src/jsMain/resources/assets/clock.png b/examples/graphics-2d/jsApp/src/jsMain/resources/composeRes/images/clock.png similarity index 100% rename from examples/graphics-2d/jsApp/src/jsMain/resources/assets/clock.png rename to examples/graphics-2d/jsApp/src/jsMain/resources/composeRes/images/clock.png diff --git a/examples/graphics-2d/jsApp/src/jsMain/resources/compose-community-primary.xml b/examples/graphics-2d/jsApp/src/jsMain/resources/composeRes/images/compose_community_primary.xml similarity index 100% rename from examples/graphics-2d/jsApp/src/jsMain/resources/compose-community-primary.xml rename to examples/graphics-2d/jsApp/src/jsMain/resources/composeRes/images/compose_community_primary.xml diff --git a/examples/graphics-2d/jsApp/src/jsMain/resources/assets/flag.png b/examples/graphics-2d/jsApp/src/jsMain/resources/composeRes/images/flag.png similarity index 100% rename from examples/graphics-2d/jsApp/src/jsMain/resources/assets/flag.png rename to examples/graphics-2d/jsApp/src/jsMain/resources/composeRes/images/flag.png diff --git a/examples/graphics-2d/jsApp/src/jsMain/resources/assets/mine.png b/examples/graphics-2d/jsApp/src/jsMain/resources/composeRes/images/mine.png similarity index 100% rename from examples/graphics-2d/jsApp/src/jsMain/resources/assets/mine.png rename to examples/graphics-2d/jsApp/src/jsMain/resources/composeRes/images/mine.png diff --git a/examples/graphics-2d/shared/build.gradle.kts b/examples/graphics-2d/shared/build.gradle.kts index adff5037ca..ede41c9586 100644 --- a/examples/graphics-2d/shared/build.gradle.kts +++ b/examples/graphics-2d/shared/build.gradle.kts @@ -1,7 +1,3 @@ -@file:Suppress("OPT_IN_IS_NOT_ENABLED") - -import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler - plugins { kotlin("multiplatform") @@ -19,15 +15,11 @@ kotlin { browser() } - macosX64 { - binaries { - executable { - entryPoint = "main" - } - } - } - macosArm64 { - binaries { + listOf( + macosX64(), + macosArm64() + ).forEach { macosTarget -> + macosTarget.binaries { executable { entryPoint = "main" } @@ -45,67 +37,27 @@ kotlin { } } - val enableKjsWorkaround = project.properties["workaround.kotlin.js.kt60852"] == "true" - - fun KotlinDependencyHandler.addCommonDependencies() { - implementation(compose.ui) - implementation(compose.runtime) - implementation(compose.foundation) - implementation(compose.material3) - @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) - } - sourceSets { - val commonMain by getting { - dependencies { - if (!enableKjsWorkaround) { - addCommonDependencies() - } - } + commonMain.dependencies { + implementation(compose.ui) + implementation(compose.runtime) + implementation(compose.foundation) + implementation(compose.material3) + @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) + implementation("org.jetbrains.compose.components:components-resources:1.6.0-dev1306") } - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - implementation(kotlin("test-annotations-common")) - } - } - val androidMain by getting { - dependencies { - api("androidx.activity:activity-compose:1.7.2") - api("androidx.appcompat:appcompat:1.6.1") - api("androidx.core:core-ktx:1.10.1") - } - } - val iosMain by creating { - dependsOn(commonMain) - } - val iosX64Main by getting { - dependsOn(iosMain) - } - val iosArm64Main by getting { - dependsOn(iosMain) + commonTest.dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-annotations-common")) } - val iosSimulatorArm64Main by getting { - dependsOn(iosMain) + androidMain.dependencies { + api("androidx.activity:activity-compose:1.7.2") + api("androidx.appcompat:appcompat:1.6.1") + api("androidx.core:core-ktx:1.10.1") } - val desktopMain by getting { - dependencies { - implementation(compose.desktop.common) - } - } - val macosMain by creating { - dependsOn(commonMain) - } - val macosArm64Main by getting { - dependsOn(macosMain) - } - val jsMain by getting { - dependencies { - if (enableKjsWorkaround) { - addCommonDependencies() - } - } + val desktopMain by getting + desktopMain.dependencies { + implementation(compose.desktop.common) } } } diff --git a/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt index 967c9db826..5f4442cd59 100644 --- a/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/MineSweeper.common.kt @@ -12,12 +12,13 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.unit.* import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.ImageResource import org.jetbrains.compose.resources.painterResource import kotlin.math.max @OptIn(ExperimentalResourceApi::class) @Composable -fun loadImage(res: String): Painter = painterResource(res) +fun loadImage(img: ImageResource): Painter = painterResource(img) expect fun hasRightClick(): Boolean @@ -77,9 +78,9 @@ fun MineSweeper(requestWindowSize: ((width: Dp, height: Dp) -> Unit)? = null) = Row { Column { val bombsLeft = max(game.bombs - game.flagsSet, 0) - IndicatorWithIcon("assets/clock.png", "Seconds", game.seconds) + IndicatorWithIcon(ImageResource("composeRes/images/clock.png"), "Seconds", game.seconds) Box(modifier = Modifier.size(2.dp)) {} - IndicatorWithIcon("assets/mine.png", "Bombs Left", bombsLeft) + IndicatorWithIcon(ImageResource("composeRes/images/mine.png"), "Bombs Left", bombsLeft) } Column(modifier = Modifier.padding(8.dp)) { diff --git a/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt index 6d00968141..7a4ddded0f 100644 --- a/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/minesweeper/Widgets.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import org.jetbrains.compose.resources.ImageResource @Composable fun OpenedCell(cell: Cell) { @@ -30,9 +31,9 @@ fun OpenedCell(cell: Cell) { } @Composable -fun CellWithIcon(src: String, alt: String) { +fun CellWithIcon(img: ImageResource, alt: String) { Image( - painter = loadImage(src), + painter = loadImage(img), contentDescription = alt, modifier = Modifier.fillMaxSize().padding(Dp(4.0f)) ) @@ -40,20 +41,20 @@ fun CellWithIcon(src: String, alt: String) { @Composable fun Mine() { - CellWithIcon(src = "assets/mine.png", alt = "Bomb") + CellWithIcon(ImageResource("composeRes/images/mine.png"), alt = "Bomb") } @Composable fun Flag() { - CellWithIcon(src = "assets/flag.png", alt = "Flag") + CellWithIcon(ImageResource("composeRes/images/flag.png"), alt = "Flag") } @Composable -fun IndicatorWithIcon(iconPath: String, alt: String, value: Int) { +fun IndicatorWithIcon(img: ImageResource, alt: String, value: Int) { Box(modifier = Modifier.background(Color(0x8e, 0x6e, 0x0e))) { Row(verticalAlignment = Alignment.CenterVertically) { Box(modifier = Modifier.size(40.dp, 40.dp)) { - CellWithIcon(iconPath, alt) + CellWithIcon(img, alt) } Box(modifier = Modifier.size(56.dp, 36.dp)) { diff --git a/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt index 16f04f3b3e..8306b1da48 100644 --- a/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt +++ b/examples/graphics-2d/shared/src/commonMain/kotlin/visualeffects/RotatingWords.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.unit.DpOffset import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.ImageResource import org.jetbrains.compose.resources.painterResource @OptIn(ExperimentalResourceApi::class) @@ -46,7 +47,7 @@ fun Words() { ) ) - val logoImg = painterResource("compose-community-primary.xml") + val logoImg = painterResource(ImageResource("composeRes/images/compose_community_primary.xml")) val baseLogo = DpOffset(350.dp, 270.dp) diff --git a/examples/graphics-2d/shared/src/commonMain/resources/assets/clock.png b/examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/clock.png similarity index 100% rename from examples/graphics-2d/shared/src/commonMain/resources/assets/clock.png rename to examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/clock.png diff --git a/examples/graphics-2d/shared/src/commonMain/resources/compose-community-primary.xml b/examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/compose_community_primary.xml similarity index 100% rename from examples/graphics-2d/shared/src/commonMain/resources/compose-community-primary.xml rename to examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/compose_community_primary.xml diff --git a/examples/graphics-2d/shared/src/commonMain/resources/assets/flag.png b/examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/flag.png similarity index 100% rename from examples/graphics-2d/shared/src/commonMain/resources/assets/flag.png rename to examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/flag.png diff --git a/examples/graphics-2d/shared/src/commonMain/resources/assets/mine.png b/examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/mine.png similarity index 100% rename from examples/graphics-2d/shared/src/commonMain/resources/assets/mine.png rename to examples/graphics-2d/shared/src/commonMain/resources/composeRes/images/mine.png diff --git a/examples/widgets-gallery/shared/build.gradle.kts b/examples/widgets-gallery/shared/build.gradle.kts index dddee39c28..26fd7599d3 100644 --- a/examples/widgets-gallery/shared/build.gradle.kts +++ b/examples/widgets-gallery/shared/build.gradle.kts @@ -32,7 +32,7 @@ kotlin { implementation(compose.material) implementation(compose.materialIconsExtended) @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) - implementation(compose.components.resources) + implementation("org.jetbrains.compose.components:components-resources:1.6.0-dev1306") } } val androidMain by getting { diff --git a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt index 65fd232eb0..2dd9817731 100644 --- a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt +++ b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/data/DemoDataProvider.kt @@ -1,8 +1,6 @@ package org.jetbrains.compose.demo.widgets.data import org.jetbrains.compose.demo.widgets.data.model.Item -import org.jetbrains.compose.demo.widgets.data.model.Tweet -import org.jetbrains.compose.demo.widgets.platform.Res object DemoDataProvider { val item = Item( diff --git a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt index 10f57c7cd7..cfa63a8965 100644 --- a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt +++ b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/platform/Res.kt @@ -1,18 +1,7 @@ package org.jetbrains.compose.demo.widgets.platform object Res { - object drawable { - val p1 = "drawable-nodpi/p1.jpeg" - val p2 = "drawable-nodpi/p2.jpeg" - val p3 = "drawable-nodpi/p3.jpeg" - val p6 = "drawable-nodpi/p6.jpeg" - - val ic_instagram = "drawable/ic_instagram.xml" - val ic_send = "drawable/ic_send.xml" - val ic_twitter = "drawable/ic_twitter.xml" - } - - object string { + object strings { val spotify_nav_home = "Home" val spotify_nav_search = "Search" val spotify_nav_library = "Your Library" diff --git a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt index 9e16ee1d11..4990285078 100644 --- a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt +++ b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/AppBars.kt @@ -21,6 +21,7 @@ import org.jetbrains.compose.demo.widgets.theme.twitterColor import org.jetbrains.compose.demo.widgets.ui.utils.SubtitleText import org.jetbrains.compose.demo.widgets.ui.utils.TitleText import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.ImageResource @Composable fun AppBars() { @@ -53,12 +54,12 @@ private fun TopAppBarsDemo() { elevation = 8.dp, navigationIcon = { IconButton(onClick = {}) { - Icon(painterResource(Res.drawable.ic_instagram), contentDescription = "Instagram") + Icon(painterResource(ImageResource("composeRes/images/ic_instagram.xml")), contentDescription = "Instagram") } }, actions = { IconButton(onClick = {}) { - Icon(painterResource(Res.drawable.ic_send), contentDescription = "Send") + Icon(painterResource(ImageResource("composeRes/images/ic_send.xml")), contentDescription = "Send") } } ) @@ -68,7 +69,7 @@ private fun TopAppBarsDemo() { TopAppBar( title = { Icon( - painterResource(Res.drawable.ic_twitter), + painterResource(ImageResource("composeRes/images/ic_twitter.xml")), contentDescription = "Twitter", tint = twitterColor, modifier = Modifier.fillMaxWidth() @@ -79,7 +80,7 @@ private fun TopAppBarsDemo() { elevation = 8.dp, navigationIcon = { Image( - painterResource(Res.drawable.p6), + painterResource(ImageResource("composeRes/images/p6.jpeg")), contentDescription = "", modifier = Modifier.padding(vertical = 4.dp, horizontal = 8.dp) .requiredSize(32.dp).clip(CircleShape) @@ -111,6 +112,7 @@ private fun BottomAppBarDemo() { } } +@OptIn(ExperimentalResourceApi::class) @Composable private fun NavigationBarDemo() { Spacer(modifier = Modifier.height(16.dp)) @@ -121,19 +123,19 @@ private fun NavigationBarDemo() { icon = { Icon(Icons.Outlined.Home, contentDescription = "Home") }, selected = navItemState.value == NavType.HOME, onClick = { navItemState.value = NavType.HOME }, - label = { Text(text = Res.string.spotify_nav_home) }, + label = { Text(text = Res.strings.spotify_nav_home) }, ) BottomNavigationItem( icon = { Icon(Icons.Outlined.Search, contentDescription = "Search") }, selected = navItemState.value == NavType.SEARCH, onClick = { navItemState.value = NavType.SEARCH }, - label = { Text(text = Res.string.spotify_nav_search) } + label = { Text(text = Res.strings.spotify_nav_search) } ) BottomNavigationItem( icon = { Icon(Icons.Outlined.LibraryMusic, contentDescription = "LibraryMusic") }, selected = navItemState.value == NavType.LIBRARY, onClick = { navItemState.value = NavType.LIBRARY }, - label = { Text(text = Res.string.spotify_nav_library) } + label = { Text(text = Res.strings.spotify_nav_library) } ) } diff --git a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt index 392eaf94ca..fa42888f9a 100644 --- a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt +++ b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/Chips.kt @@ -15,10 +15,10 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import org.jetbrains.compose.demo.widgets.platform.Res import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.demo.widgets.ui.utils.SubtitleText import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.ImageResource @Composable fun Chips() { @@ -33,9 +33,9 @@ fun Chips() { modifier = Modifier.padding(horizontal = 8.dp) ) Spacer(modifier = Modifier.padding(8.dp)) - CustomImageChip(text = "custom", imageId = Res.drawable.p2, selected = true) + CustomImageChip(text = "custom", imageId = ImageResource("composeRes/images/p2.jpeg"), selected = true) Spacer(modifier = Modifier.padding(8.dp)) - CustomImageChip(text = "custom2", imageId = Res.drawable.p6, selected = false) + CustomImageChip(text = "custom2", imageId = ImageResource("composeRes/images/p6.jpeg"), selected = false) } SubtitleText(subtitle = "Buttons with circle clipping.") Column(modifier = Modifier.padding(8.dp)) { @@ -62,7 +62,7 @@ fun Chips() { @Composable private fun CustomImageChip( text: String, - imageId: String, + imageId: ImageResource, selected: Boolean, modifier: Modifier = Modifier ) { diff --git a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt index c1982b0bdd..08223f5e6e 100644 --- a/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt +++ b/examples/widgets-gallery/shared/src/commonMain/kotlin/org/jetbrains/compose/demo/widgets/ui/screens/UICards.kt @@ -11,10 +11,10 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import org.jetbrains.compose.demo.widgets.data.DemoDataProvider -import org.jetbrains.compose.demo.widgets.platform.Res import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.demo.widgets.theme.typography import org.jetbrains.compose.resources.ExperimentalResourceApi +import org.jetbrains.compose.resources.ImageResource @OptIn(ExperimentalMaterialApi::class, ExperimentalResourceApi::class) @Composable @@ -54,7 +54,7 @@ fun UICards() { ) { Row { Image( - painterResource(Res.drawable.p3), + painterResource(ImageResource("composeRes/images/p3.jpeg")), contentDescription = null, modifier = Modifier.requiredSize(60.dp) ) @@ -78,7 +78,7 @@ fun UICards() { Divider(modifier = Modifier.padding(4.dp)) ListItem(text = { Text(item.title) }, secondaryText = { Text(item.subtitle) }, icon = { Image( - painterResource(Res.drawable.p3), + painterResource(ImageResource("composeRes/images/p3.jpeg")), contentDescription = null ) }) @@ -87,7 +87,7 @@ fun UICards() { ListItem( text = { Text(item.title) }, secondaryText = { Text(item.subtitle) }, - icon = { Image(painterResource(Res.drawable.p1), contentDescription = null) }, + icon = { Image(painterResource(ImageResource("composeRes/images/p1.jpeg")), contentDescription = null) }, overlineText = { Text("Overline text") }, singleLineSecondaryText = false ) @@ -95,7 +95,7 @@ fun UICards() { ListItem( text = { Text(item.title) }, secondaryText = { Text(item.subtitle) }, - icon = { Image(painterResource(Res.drawable.p2), contentDescription = null) }, + icon = { Image(painterResource(ImageResource("composeRes/images/p2.jpeg")), contentDescription = null) }, trailing = { Icon(Icons.Default.ShoppingCart, contentDescription = null) }, singleLineSecondaryText = false ) diff --git a/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_instagram.xml b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/ic_instagram.xml similarity index 100% rename from examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_instagram.xml rename to examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/ic_instagram.xml diff --git a/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_send.xml b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/ic_send.xml similarity index 100% rename from examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_send.xml rename to examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/ic_send.xml diff --git a/examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_twitter.xml b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/ic_twitter.xml similarity index 100% rename from examples/widgets-gallery/shared/src/commonMain/resources/drawable/ic_twitter.xml rename to examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/ic_twitter.xml diff --git a/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p1.jpeg b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/p1.jpeg similarity index 100% rename from examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p1.jpeg rename to examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/p1.jpeg diff --git a/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p2.jpeg b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/p2.jpeg similarity index 100% rename from examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p2.jpeg rename to examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/p2.jpeg diff --git a/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p3.jpeg b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/p3.jpeg similarity index 100% rename from examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p3.jpeg rename to examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/p3.jpeg diff --git a/examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p6.jpeg b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/p6.jpeg similarity index 100% rename from examples/widgets-gallery/shared/src/commonMain/resources/drawable-nodpi/p6.jpeg rename to examples/widgets-gallery/shared/src/commonMain/resources/composeRes/images/p6.jpeg diff --git a/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/values/strings.xml b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/values/strings.xml new file mode 100644 index 0000000000..d1c2bf7c2a --- /dev/null +++ b/examples/widgets-gallery/shared/src/commonMain/resources/composeRes/values/strings.xml @@ -0,0 +1,5 @@ + + Home + Search + Your Library +