Skip to content

Commit 8955e66

Browse files
authored
Introduce a 'composeResources/files' directory for any files. (JetBrains#4079)
Introduce a 'composeResources/files' directory for any files.
1 parent 86cfe35 commit 8955e66

File tree

32 files changed

+231
-112
lines changed

32 files changed

+231
-112
lines changed

components/resources/demo/shared/src/commonMain/kotlin/org/jetbrains/compose/resources/demo/shared/FileRes.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import androidx.compose.runtime.remember
1919
import androidx.compose.runtime.setValue
2020
import androidx.compose.ui.Modifier
2121
import androidx.compose.ui.unit.dp
22-
import org.jetbrains.compose.resources.readResourceBytes
22+
import components.resources.demo.generated.resources.Res
2323

2424
@Composable
2525
fun FileRes(paddingValues: PaddingValues) {
@@ -28,7 +28,7 @@ fun FileRes(paddingValues: PaddingValues) {
2828
) {
2929
Text(
3030
modifier = Modifier.padding(16.dp),
31-
text = "File: 'composeRes/drawable/droid_icon.xml'",
31+
text = "File: 'files/icon.xml'",
3232
style = MaterialTheme.typography.titleLarge
3333
)
3434
OutlinedCard(
@@ -38,7 +38,7 @@ fun FileRes(paddingValues: PaddingValues) {
3838
) {
3939
var bytes by remember { mutableStateOf(ByteArray(0)) }
4040
LaunchedEffect(Unit) {
41-
bytes = readResourceBytes("composeRes/drawable/droid_icon.xml")
41+
bytes = Res.readBytes("files/icon.xml")
4242
}
4343
Text(
4444
modifier = Modifier.padding(8.dp).height(200.dp).verticalScroll(rememberScrollState()),
@@ -54,7 +54,7 @@ fun FileRes(paddingValues: PaddingValues) {
5454
mutableStateOf(ByteArray(0))
5555
}
5656
LaunchedEffect(Unit) {
57-
bytes = readResourceBytes("composeRes/drawable/droid_icon.xml")
57+
bytes = Res.readFileBytes("files/icon.xml")
5858
}
5959
Text(bytes.decodeToString())
6060
""".trimIndent()

components/resources/demo/shared/src/commonMain/kotlin/org/jetbrains/compose/resources/demo/shared/StringRes.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fun StringRes(paddingValues: PaddingValues) {
3333
) {
3434
Text(
3535
modifier = Modifier.padding(16.dp),
36-
text = "composeRes/values/strings.xml",
36+
text = "values/strings.xml",
3737
style = MaterialTheme.typography.titleLarge
3838
)
3939
OutlinedCard(
@@ -43,7 +43,7 @@ fun StringRes(paddingValues: PaddingValues) {
4343
) {
4444
var bytes by remember { mutableStateOf(ByteArray(0)) }
4545
LaunchedEffect(Unit) {
46-
bytes = readResourceBytes("composeRes/values/strings.xml")
46+
bytes = Res.readBytes("values/strings.xml")
4747
}
4848
Text(
4949
modifier = Modifier.padding(8.dp),

components/resources/demo/shared/src/commonMain/resources/composeRes/drawable/compose.png renamed to components/resources/demo/shared/src/commonMain/resources/composeResources/drawable/compose.png

File renamed without changes.

components/resources/demo/shared/src/commonMain/resources/composeRes/drawable/droid_icon.xml renamed to components/resources/demo/shared/src/commonMain/resources/composeResources/drawable/droid_icon.xml

File renamed without changes.

components/resources/demo/shared/src/commonMain/resources/composeRes/drawable/insta_icon.xml renamed to components/resources/demo/shared/src/commonMain/resources/composeResources/drawable/insta_icon.xml

File renamed without changes.

components/resources/demo/shared/src/commonMain/resources/composeRes/drawable/land.webp renamed to components/resources/demo/shared/src/commonMain/resources/composeResources/drawable/land.webp

File renamed without changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportWidth="108"
6+
android:viewportHeight="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeWidth="1"
11+
android:strokeColor="#00000000">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0" />
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0" />
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeWidth="1"
33+
android:strokeColor="#00000000" />
34+
</vector>

components/resources/demo/shared/src/commonMain/resources/composeRes/font/font_awesome.otf renamed to components/resources/demo/shared/src/commonMain/resources/composeResources/font/font_awesome.otf

File renamed without changes.

components/resources/demo/shared/src/commonMain/resources/composeRes/values/strings.xml renamed to components/resources/demo/shared/src/commonMain/resources/composeResources/values/strings.xml

File renamed without changes.

components/resources/library/src/commonMain/kotlin/org/jetbrains/compose/resources/Resource.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import androidx.compose.runtime.Immutable
55
@RequiresOptIn("This API is experimental and is likely to change in the future.")
66
annotation class ExperimentalResourceApi
77

8+
@RequiresOptIn("This is internal API of the Compose gradle plugin.")
9+
annotation class InternalResourceApi
10+
811
/**
912
* Represents a resource with an ID and a set of resource items.
1013
*

0 commit comments

Comments
 (0)