diff --git a/build-logic/src/main/kotlin/io/github/droidkaigi/confsched/primitive/KmpComposePlugin.kt b/build-logic/src/main/kotlin/io/github/droidkaigi/confsched/primitive/KmpComposePlugin.kt index 81d55657d..ba61c0087 100644 --- a/build-logic/src/main/kotlin/io/github/droidkaigi/confsched/primitive/KmpComposePlugin.kt +++ b/build-logic/src/main/kotlin/io/github/droidkaigi/confsched/primitive/KmpComposePlugin.kt @@ -3,8 +3,10 @@ package io.github.droidkaigi.confsched.primitive import io.github.droidkaigi.confsched.convention.buildComposeMetricsParameters import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.withType +import org.jetbrains.compose.resources.ResourcesExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @Suppress("unused") @@ -23,6 +25,9 @@ class KmpComposePlugin : Plugin { } } val compose = extensions.get("compose") as org.jetbrains.compose.ComposeExtension + compose.extensions.configure { + publicResClass = true + } kotlin { with(sourceSets) { getByName("commonMain").apply { diff --git a/feature/sessions/src/commonMain/composeResources/values-ja/strings.xml b/feature/sessions/src/commonMain/composeResources/values-ja/strings.xml new file mode 100644 index 000000000..5f4e5ce69 --- /dev/null +++ b/feature/sessions/src/commonMain/composeResources/values-ja/strings.xml @@ -0,0 +1,5 @@ + + スケジュール + ユーザー + エラー + diff --git a/feature/sessions/src/commonMain/composeResources/values/strings.xml b/feature/sessions/src/commonMain/composeResources/values/strings.xml new file mode 100644 index 000000000..36987535b --- /dev/null +++ b/feature/sessions/src/commonMain/composeResources/values/strings.xml @@ -0,0 +1,5 @@ + + Schedule + User + Error + diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SessionRes.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SessionRes.kt new file mode 100644 index 000000000..b1fe596be --- /dev/null +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SessionRes.kt @@ -0,0 +1,8 @@ +package io.github.droidkaigi.confsched.sessions + +import conference_app_2024.feature.sessions.generated.resources.Res + +object SessionRes { + val string = Res.string + val drawable = Res.drawable +} diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SessionsStrings.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SessionsStrings.kt deleted file mode 100644 index e32461842..000000000 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/SessionsStrings.kt +++ /dev/null @@ -1,33 +0,0 @@ -package io.github.droidkaigi.confsched.sessions - -import io.github.droidkaigi.confsched.designsystem.strings.Lang -import io.github.droidkaigi.confsched.designsystem.strings.Strings -import io.github.droidkaigi.confsched.designsystem.strings.StringsBindings - -// FIXME: Use multiplatform resource instead of this -sealed class SessionsStrings : Strings(Bindings) { - data object ScheduleIcon : SessionsStrings() - data object UserIcon : SessionsStrings() - data object EventDay : SessionsStrings() - data object ErrorIcon : SessionsStrings() - - private object Bindings : StringsBindings( - Lang.Japanese to { item, _ -> - when (item) { - ScheduleIcon -> "スケジュールアイコン" - UserIcon -> "ユーザーアイコン" - EventDay -> "開催日" - ErrorIcon -> "エラーアイコン" - } - }, - Lang.English to { item, _ -> - when (item) { - ScheduleIcon -> "Schedule icon" - UserIcon -> "User icon" - EventDay -> "Day" - ErrorIcon -> "Error Icon" - } - }, - default = Lang.Japanese, - ) -} diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableGridItem.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableGridItem.kt index 66d345a14..e36e1e6df 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableGridItem.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableGridItem.kt @@ -35,6 +35,9 @@ import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import conference_app_2024.feature.sessions.generated.resources.content_description_error_icon +import conference_app_2024.feature.sessions.generated.resources.content_description_schedule_icon +import conference_app_2024.feature.sessions.generated.resources.content_description_user_icon import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched.designsystem.theme.LocalRoomTheme import io.github.droidkaigi.confsched.designsystem.theme.ProvideRoomTheme @@ -51,9 +54,7 @@ import io.github.droidkaigi.confsched.model.TimetableRoom import io.github.droidkaigi.confsched.model.TimetableSessionType import io.github.droidkaigi.confsched.model.TimetableSpeaker import io.github.droidkaigi.confsched.model.fake -import io.github.droidkaigi.confsched.sessions.SessionsStrings -import io.github.droidkaigi.confsched.sessions.SessionsStrings.ScheduleIcon -import io.github.droidkaigi.confsched.sessions.SessionsStrings.UserIcon +import io.github.droidkaigi.confsched.sessions.SessionRes import io.github.droidkaigi.confsched.sessions.section.TimetableSizes import io.github.droidkaigi.confsched.ui.previewOverride import io.github.droidkaigi.confsched.ui.rememberAsyncImagePainter @@ -64,6 +65,7 @@ import kotlinx.datetime.LocalDateTime import kotlinx.datetime.TimeZone import kotlinx.datetime.minus import kotlinx.datetime.toInstant +import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview import kotlin.math.ceil import kotlin.math.roundToInt @@ -128,7 +130,7 @@ fun TimetableGridItem( Icon( modifier = Modifier.height(TimetableGridItemSizes.scheduleHeight), imageVector = Icons.Default.Schedule, - contentDescription = ScheduleIcon.asString(), + contentDescription = stringResource(SessionRes.string.content_description_schedule_icon), ) Spacer(modifier = Modifier.width(4.dp)) var scheduleTextStyle = MaterialTheme.typography.bodySmall @@ -180,7 +182,7 @@ fun TimetableGridItem( modifier = Modifier .size(TimetableGridItemSizes.errorHeight), imageVector = Icons.Default.Error, - contentDescription = SessionsStrings.ErrorIcon.asString(), + contentDescription = stringResource(SessionRes.string.content_description_error_icon), tint = MaterialTheme.colorScheme.errorContainer, ) } @@ -236,7 +238,7 @@ private fun SpeakerIcon( painter = previewOverride(previewPainter = { rememberVectorPainter(image = Icons.Default.Person) }) { rememberAsyncImagePainter(iconUrl) }, - contentDescription = UserIcon.asString(), + contentDescription = stringResource(SessionRes.string.content_description_user_icon), modifier = modifier .size(TimetableGridItemSizes.speakerHeight) .clip(RoundedCornerShape(8.dp)) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailBottomAppBar.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailBottomAppBar.kt index 9cc2a8528..a94917fb5 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailBottomAppBar.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailBottomAppBar.kt @@ -13,11 +13,11 @@ import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag -import conference_app_2024.feature.sessions.generated.resources.Res import conference_app_2024.feature.sessions.generated.resources.calendar_add_on import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched.model.TimetableItem import io.github.droidkaigi.confsched.model.fake +import io.github.droidkaigi.confsched.sessions.SessionRes import io.github.droidkaigi.confsched.sessions.TimetableItemDetailBookmarkIconTestTag import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.ui.tooling.preview.Preview @@ -42,7 +42,7 @@ fun TimetableItemDetailBottomAppBar( } IconButton(onClick = { onCalendarRegistrationClick(timetableItem) }) { Icon( - painter = painterResource(Res.drawable.calendar_add_on), + painter = painterResource(SessionRes.drawable.calendar_add_on), contentDescription = "Calendar", ) }