From a14f9fb28ffdee2e1315d3189451426180b59e1a Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:36:36 +0900 Subject: [PATCH 01/22] add language switcher component --- .../sessions/component/TimetableItemDetailHeadline.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 1644b25a3..f0fd5fc09 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -98,6 +98,11 @@ fun TimetableItemDetailHeadline( } } +@Composable +fun TimetableItemDetailLanguageSwitcher(modifier: Modifier = Modifier) { + // TODO +} + @Composable @Preview fun TimetableItemDetailHeadlinePreview() { From 2da386685a94426d455c9420a5a88f492b6b7436 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:40:47 +0900 Subject: [PATCH 02/22] add basic switcher content --- .../component/TimetableItemDetailHeadline.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index f0fd5fc09..e1cdde6c6 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -16,19 +16,24 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp +import conference_app_2024.feature.sessions.generated.resources.english +import conference_app_2024.feature.sessions.generated.resources.japanese import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched.designsystem.theme.LocalRoomTheme import io.github.droidkaigi.confsched.model.Lang import io.github.droidkaigi.confsched.model.TimetableItem import io.github.droidkaigi.confsched.model.fake +import io.github.droidkaigi.confsched.sessions.SessionsRes import io.github.droidkaigi.confsched.ui.component.TimetableItemTag import io.github.droidkaigi.confsched.ui.rememberAsyncImagePainter +import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview const val TimetableItemDetailHeadlineTestTag = "TimetableItemDetailHeadlineTestTag" @@ -100,7 +105,19 @@ fun TimetableItemDetailHeadline( @Composable fun TimetableItemDetailLanguageSwitcher(modifier: Modifier = Modifier) { - // TODO + Row(modifier = modifier) { + Text( + text = stringResource(SessionsRes.string.japanese), + style = MaterialTheme.typography.labelMedium, + ) + VerticalDivider( + color = MaterialTheme.colorScheme.outlineVariant, + ) + Text( + text = stringResource(SessionsRes.string.english), + style = MaterialTheme.typography.labelMedium, + ) + } } @Composable From 96b0632af91a8dac5da737936c6d10d357ed2a6a Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:42:42 +0900 Subject: [PATCH 03/22] change content color on selected language --- .../component/TimetableItemDetailHeadline.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index e1cdde6c6..1691eb60a 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -104,10 +104,18 @@ fun TimetableItemDetailHeadline( } @Composable -fun TimetableItemDetailLanguageSwitcher(modifier: Modifier = Modifier) { +fun TimetableItemDetailLanguageSwitcher( + currentLang: Lang, + modifier: Modifier = Modifier, +) { Row(modifier = modifier) { Text( text = stringResource(SessionsRes.string.japanese), + color = if (currentLang == Lang.JAPANESE) { + LocalRoomTheme.current.primaryColor + } else { + MaterialTheme.colorScheme.onSurfaceVariant + }, style = MaterialTheme.typography.labelMedium, ) VerticalDivider( @@ -115,6 +123,11 @@ fun TimetableItemDetailLanguageSwitcher(modifier: Modifier = Modifier) { ) Text( text = stringResource(SessionsRes.string.english), + color = if (currentLang == Lang.ENGLISH) { + LocalRoomTheme.current.primaryColor + } else { + MaterialTheme.colorScheme.onSurfaceVariant + }, style = MaterialTheme.typography.labelMedium, ) } From bbc28a824699baba28d04bccc8f992353b759156 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:43:46 +0900 Subject: [PATCH 04/22] add language switcher to the headline --- .../sessions/component/TimetableItemDetailHeadline.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 1691eb60a..6a4924c66 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -64,6 +64,10 @@ fun TimetableItemDetailHeadline( tagColor = MaterialTheme.colorScheme.onSurfaceVariant, ) } + Spacer(modifier = Modifier.weight(1f)) + TimetableItemDetailLanguageSwitcher( + currentLang = currentLang, + ) } Spacer(modifier = Modifier.height(16.dp)) Text( From c0ccb0d34ba211baee4852b22dd92116967847ed Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:46:52 +0900 Subject: [PATCH 05/22] pass language switch handler to the switcher --- .../confsched/sessions/TimetableItemDetailScreen.kt | 1 + .../sessions/component/TimetableItemDetailHeadline.kt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt index b7854873b..b4a8f17f2 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt @@ -229,6 +229,7 @@ private fun TimetableItemDetailScreen( TimetableItemDetailHeadline( currentLang = uiState.currentLang, timetableItem = uiState.timetableItem, + onLanguageSwitch = onSelectedLanguage, ) } diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 6a4924c66..7fd790bee 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -42,6 +42,7 @@ const val TimetableItemDetailHeadlineTestTag = "TimetableItemDetailHeadlineTestT fun TimetableItemDetailHeadline( currentLang: Lang?, timetableItem: TimetableItem, + onLanguageSwitch: (Lang) -> Unit, modifier: Modifier = Modifier, ) { val currentLang = currentLang ?: Lang.ENGLISH @@ -67,6 +68,7 @@ fun TimetableItemDetailHeadline( Spacer(modifier = Modifier.weight(1f)) TimetableItemDetailLanguageSwitcher( currentLang = currentLang, + onLanguageSwitch = onLanguageSwitch, ) } Spacer(modifier = Modifier.height(16.dp)) @@ -110,6 +112,7 @@ fun TimetableItemDetailHeadline( @Composable fun TimetableItemDetailLanguageSwitcher( currentLang: Lang, + onLanguageSwitch: (Lang) -> Unit, modifier: Modifier = Modifier, ) { Row(modifier = modifier) { @@ -146,6 +149,7 @@ fun TimetableItemDetailHeadlinePreview() { TimetableItemDetailHeadline( timetableItem = TimetableItem.Session.fake(), currentLang = Lang.JAPANESE, + onLanguageSwitch = {}, ) } } @@ -161,6 +165,7 @@ fun TimetableItemDetailHeadlineWithEnglishPreview() { TimetableItemDetailHeadline( timetableItem = TimetableItem.Session.fake(), currentLang = Lang.ENGLISH, + onLanguageSwitch = {}, ) } } @@ -176,6 +181,7 @@ fun TimetableItemDetailHeadlineWithMixedPreview() { TimetableItemDetailHeadline( timetableItem = TimetableItem.Session.fake(), currentLang = Lang.MIXED, + onLanguageSwitch = {}, ) } } From 2a8c53e059bcbbfad37829657bcbdc8bf1ea0429 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:47:30 +0900 Subject: [PATCH 06/22] tap switcher item to switch the language --- .../component/TimetableItemDetailHeadline.kt | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 7fd790bee..00ac8f6a4 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -16,6 +16,7 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -116,27 +117,31 @@ fun TimetableItemDetailLanguageSwitcher( modifier: Modifier = Modifier, ) { Row(modifier = modifier) { - Text( - text = stringResource(SessionsRes.string.japanese), - color = if (currentLang == Lang.JAPANESE) { - LocalRoomTheme.current.primaryColor - } else { - MaterialTheme.colorScheme.onSurfaceVariant - }, - style = MaterialTheme.typography.labelMedium, - ) + TextButton(onClick = { onLanguageSwitch(Lang.JAPANESE) }) { + Text( + text = stringResource(SessionsRes.string.japanese), + color = if (currentLang == Lang.JAPANESE) { + LocalRoomTheme.current.primaryColor + } else { + MaterialTheme.colorScheme.onSurfaceVariant + }, + style = MaterialTheme.typography.labelMedium, + ) + } VerticalDivider( color = MaterialTheme.colorScheme.outlineVariant, ) - Text( - text = stringResource(SessionsRes.string.english), - color = if (currentLang == Lang.ENGLISH) { - LocalRoomTheme.current.primaryColor - } else { - MaterialTheme.colorScheme.onSurfaceVariant - }, - style = MaterialTheme.typography.labelMedium, - ) + TextButton(onClick = { onLanguageSwitch(Lang.ENGLISH) }) { + Text( + text = stringResource(SessionsRes.string.english), + color = if (currentLang == Lang.ENGLISH) { + LocalRoomTheme.current.primaryColor + } else { + MaterialTheme.colorScheme.onSurfaceVariant + }, + style = MaterialTheme.typography.labelMedium, + ) + } } } From 3f026292041ef4c8c7e2f2202f8760c4d0e47e5e Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:49:31 +0900 Subject: [PATCH 07/22] align the divider --- .../sessions/component/TimetableItemDetailHeadline.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 00ac8f6a4..d9d75ba07 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -116,7 +116,10 @@ fun TimetableItemDetailLanguageSwitcher( onLanguageSwitch: (Lang) -> Unit, modifier: Modifier = Modifier, ) { - Row(modifier = modifier) { + Row( + modifier = modifier, + verticalAlignment = Alignment.CenterVertically, + ) { TextButton(onClick = { onLanguageSwitch(Lang.JAPANESE) }) { Text( text = stringResource(SessionsRes.string.japanese), @@ -129,6 +132,7 @@ fun TimetableItemDetailLanguageSwitcher( ) } VerticalDivider( + modifier = Modifier.height(11.dp), color = MaterialTheme.colorScheme.outlineVariant, ) TextButton(onClick = { onLanguageSwitch(Lang.ENGLISH) }) { From 7bea7eea05ef23abd1f43ec508d74fcca7610707 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:50:18 +0900 Subject: [PATCH 08/22] align the header row --- .../sessions/component/TimetableItemDetailHeadline.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index d9d75ba07..56f5c1295 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -51,10 +51,10 @@ fun TimetableItemDetailHeadline( modifier = modifier // FIXME: Implement and use a theme color instead of fixed colors like RoomColors.primary and RoomColors.primaryDim .background(LocalRoomTheme.current.dimColor) - .padding(8.dp) + .padding(horizontal = 8.dp) .fillMaxWidth(), ) { - Row { + Row(verticalAlignment = Alignment.CenterVertically) { TimetableItemTag( tagText = timetableItem.room.name.currentLangTitle, tagColor = LocalRoomTheme.current.primaryColor, From 5a1efdf203d521b58447f775e57e4e5a8bd57112 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:53:16 +0900 Subject: [PATCH 09/22] build the switcher from the language list --- .../component/TimetableItemDetailHeadline.kt | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 56f5c1295..47d650a5e 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -116,35 +116,37 @@ fun TimetableItemDetailLanguageSwitcher( onLanguageSwitch: (Lang) -> Unit, modifier: Modifier = Modifier, ) { + val availableLangs: Map = mapOf( + stringResource(SessionsRes.string.japanese) to Lang.JAPANESE, + stringResource(SessionsRes.string.english) to Lang.ENGLISH, + ) Row( modifier = modifier, verticalAlignment = Alignment.CenterVertically, ) { - TextButton(onClick = { onLanguageSwitch(Lang.JAPANESE) }) { - Text( - text = stringResource(SessionsRes.string.japanese), - color = if (currentLang == Lang.JAPANESE) { - LocalRoomTheme.current.primaryColor - } else { - MaterialTheme.colorScheme.onSurfaceVariant - }, - style = MaterialTheme.typography.labelMedium, - ) - } - VerticalDivider( - modifier = Modifier.height(11.dp), - color = MaterialTheme.colorScheme.outlineVariant, - ) - TextButton(onClick = { onLanguageSwitch(Lang.ENGLISH) }) { - Text( - text = stringResource(SessionsRes.string.english), - color = if (currentLang == Lang.ENGLISH) { + val lastIndex = availableLangs.size - 1 + availableLangs.entries.forEachIndexed { index, (label, lang) -> + TextButton( + onClick = { onLanguageSwitch(lang) }, + ) { + val isSelected = currentLang == lang + val contentColor = if (isSelected) { LocalRoomTheme.current.primaryColor } else { MaterialTheme.colorScheme.onSurfaceVariant - }, - style = MaterialTheme.typography.labelMedium, - ) + } + Text( + text = label, + color = contentColor, + style = MaterialTheme.typography.labelMedium, + ) + } + if (index < lastIndex) { + VerticalDivider( + modifier = Modifier.height(11.dp), + color = MaterialTheme.colorScheme.outlineVariant, + ) + } } } } From 34f9198cbeea3a28c3a6fcca8018727281c22a73 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:55:45 +0900 Subject: [PATCH 10/22] add active language icon to the switcher --- .../component/TimetableItemDetailHeadline.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 47d650a5e..beef9a524 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -1,5 +1,6 @@ package io.github.droidkaigi.confsched.sessions.component +import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -13,6 +14,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Check +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -135,6 +139,14 @@ fun TimetableItemDetailLanguageSwitcher( } else { MaterialTheme.colorScheme.onSurfaceVariant } + AnimatedVisibility(isSelected) { + Icon( + imageVector = Icons.Default.Check, + contentDescription = null, + modifier = Modifier.size(16.dp), + tint = contentColor, + ) + } Text( text = label, color = contentColor, From 3ff51e0980791c6f8bcc150a63fd9591c30c66a9 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:56:42 +0900 Subject: [PATCH 11/22] set explicit content padding to the switcher button --- .../confsched/sessions/component/TimetableItemDetailHeadline.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index beef9a524..c810fcc93 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth @@ -132,6 +133,7 @@ fun TimetableItemDetailLanguageSwitcher( availableLangs.entries.forEachIndexed { index, (label, lang) -> TextButton( onClick = { onLanguageSwitch(lang) }, + contentPadding = PaddingValues(12.dp), ) { val isSelected = currentLang == lang val contentColor = if (isSelected) { From 3e928e196e32723007d008e6d2860d60a0d05efb Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 01:00:28 +0900 Subject: [PATCH 12/22] show the language switcher only when available --- .../sessions/TimetableItemDetailScreen.kt | 1 + .../component/TimetableItemDetailHeadline.kt | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt index b4a8f17f2..e3a851394 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt @@ -229,6 +229,7 @@ private fun TimetableItemDetailScreen( TimetableItemDetailHeadline( currentLang = uiState.currentLang, timetableItem = uiState.timetableItem, + isLangSelectable = uiState.isLangSelectable, onLanguageSwitch = onSelectedLanguage, ) } diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index c810fcc93..71c2dc4c2 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -48,6 +48,7 @@ const val TimetableItemDetailHeadlineTestTag = "TimetableItemDetailHeadlineTestT fun TimetableItemDetailHeadline( currentLang: Lang?, timetableItem: TimetableItem, + isLangSelectable: Boolean, onLanguageSwitch: (Lang) -> Unit, modifier: Modifier = Modifier, ) { @@ -72,10 +73,12 @@ fun TimetableItemDetailHeadline( ) } Spacer(modifier = Modifier.weight(1f)) - TimetableItemDetailLanguageSwitcher( - currentLang = currentLang, - onLanguageSwitch = onLanguageSwitch, - ) + if (isLangSelectable) { + TimetableItemDetailLanguageSwitcher( + currentLang = currentLang, + onLanguageSwitch = onLanguageSwitch, + ) + } } Spacer(modifier = Modifier.height(16.dp)) Text( @@ -174,6 +177,7 @@ fun TimetableItemDetailHeadlinePreview() { TimetableItemDetailHeadline( timetableItem = TimetableItem.Session.fake(), currentLang = Lang.JAPANESE, + isLangSelectable = true, onLanguageSwitch = {}, ) } @@ -190,6 +194,7 @@ fun TimetableItemDetailHeadlineWithEnglishPreview() { TimetableItemDetailHeadline( timetableItem = TimetableItem.Session.fake(), currentLang = Lang.ENGLISH, + isLangSelectable = true, onLanguageSwitch = {}, ) } @@ -206,6 +211,7 @@ fun TimetableItemDetailHeadlineWithMixedPreview() { TimetableItemDetailHeadline( timetableItem = TimetableItem.Session.fake(), currentLang = Lang.MIXED, + isLangSelectable = true, onLanguageSwitch = {}, ) } From 76ada655c85717a8e89ecd9c146ea3dbadde8f17 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 01:08:26 +0900 Subject: [PATCH 13/22] regard Lang.MIXED as English --- .../sessions/component/TimetableItemDetailHeadline.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 71c2dc4c2..bb83ccbce 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -124,6 +124,11 @@ fun TimetableItemDetailLanguageSwitcher( onLanguageSwitch: (Lang) -> Unit, modifier: Modifier = Modifier, ) { + val normalizedCurrentLang = if (currentLang == Lang.MIXED) { + Lang.ENGLISH + } else { + currentLang + } val availableLangs: Map = mapOf( stringResource(SessionsRes.string.japanese) to Lang.JAPANESE, stringResource(SessionsRes.string.english) to Lang.ENGLISH, @@ -138,7 +143,7 @@ fun TimetableItemDetailLanguageSwitcher( onClick = { onLanguageSwitch(lang) }, contentPadding = PaddingValues(12.dp), ) { - val isSelected = currentLang == lang + val isSelected = normalizedCurrentLang == lang val contentColor = if (isSelected) { LocalRoomTheme.current.primaryColor } else { From e7bf63b26112bacd20acd298997379aa1abb7c9b Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 01:12:46 +0900 Subject: [PATCH 14/22] initial selected language should be the same as the speaker's one - this prevents awkward language switching on the appearance of the screen --- .../confsched/sessions/component/TimetableItemDetailHeadline.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index bb83ccbce..02c9a0e42 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -52,7 +52,7 @@ fun TimetableItemDetailHeadline( onLanguageSwitch: (Lang) -> Unit, modifier: Modifier = Modifier, ) { - val currentLang = currentLang ?: Lang.ENGLISH + val currentLang = currentLang ?: timetableItem.language.toLang() Column( modifier = modifier // FIXME: Implement and use a theme color instead of fixed colors like RoomColors.primary and RoomColors.primaryDim From fdeb137540663b37c59eb3608e31b005ff6c29b5 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 01:19:30 +0900 Subject: [PATCH 15/22] remove the language switch menu replaced by the switcher --- .../sessions/TimetableItemDetailScreen.kt | 2 - .../component/TimetableItemDetailTopAppBar.kt | 48 ------------------- 2 files changed, 50 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt index e3a851394..5e70e6a9c 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt @@ -176,9 +176,7 @@ private fun TimetableItemDetailScreen( if (uiState is Loaded) { ProvideRoomTheme(uiState.roomThemeKey) { TimetableItemDetailTopAppBar( - isLangSelectable = uiState.isLangSelectable, onNavigationIconClick = onNavigationIconClick, - onSelectedLanguage = onSelectedLanguage, scrollBehavior = scrollBehavior, ) } diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailTopAppBar.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailTopAppBar.kt index ca3b66bf5..18b04a9e2 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailTopAppBar.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailTopAppBar.kt @@ -32,9 +32,7 @@ import org.jetbrains.compose.ui.tooling.preview.Preview @OptIn(ExperimentalMaterial3Api::class) @Composable fun TimetableItemDetailTopAppBar( - isLangSelectable: Boolean, onNavigationIconClick: () -> Unit, - onSelectedLanguage: (Lang) -> Unit, scrollBehavior: TopAppBarScrollBehavior, modifier: Modifier = Modifier, ) { @@ -53,48 +51,6 @@ fun TimetableItemDetailTopAppBar( ) } }, - actions = { - if (isLangSelectable) { - var expanded by remember { mutableStateOf(false) } - - IconButton(onClick = { expanded = true }) { - Icon( - imageVector = Icons.Outlined.GTranslate, - contentDescription = "Select Language", - ) - } - - DropdownMenu( - expanded = expanded, - onDismissRequest = { expanded = false }, - ) { - DropdownMenuItem( - text = { - Text( - text = stringResource(SessionsRes.string.japanese), - style = MaterialTheme.typography.bodySmall, - ) - }, - onClick = { - onSelectedLanguage(Lang.JAPANESE) - expanded = false - }, - ) - DropdownMenuItem( - text = { - Text( - text = stringResource(SessionsRes.string.english), - style = MaterialTheme.typography.bodySmall, - ) - }, - onClick = { - onSelectedLanguage(Lang.ENGLISH) - expanded = false - }, - ) - } - } - }, scrollBehavior = scrollBehavior, ) } @@ -107,9 +63,7 @@ fun TimetableItemDetailTopAppBarPreview() { ProvideFakeRoomTheme { Surface { TimetableItemDetailTopAppBar( - isLangSelectable = true, onNavigationIconClick = {}, - onSelectedLanguage = {}, scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(), ) } @@ -125,9 +79,7 @@ fun TimetableItemDetailTopAppBarUnSelectablePreview() { ProvideFakeRoomTheme { Surface { TimetableItemDetailTopAppBar( - isLangSelectable = false, onNavigationIconClick = {}, - onSelectedLanguage = {}, scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(), ) } From d1701c7105f313bac4c75a684f19aad9c5f00c0f Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 01:21:20 +0900 Subject: [PATCH 16/22] rename handler according to the other handler naming conventions --- .../sessions/TimetableItemDetailScreen.kt | 2 +- .../component/TimetableItemDetailHeadline.kt | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt index 5e70e6a9c..70fa96897 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/TimetableItemDetailScreen.kt @@ -228,7 +228,7 @@ private fun TimetableItemDetailScreen( currentLang = uiState.currentLang, timetableItem = uiState.timetableItem, isLangSelectable = uiState.isLangSelectable, - onLanguageSwitch = onSelectedLanguage, + onLanguageSelect = onSelectedLanguage, ) } diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 02c9a0e42..2d8742cb3 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -49,7 +49,7 @@ fun TimetableItemDetailHeadline( currentLang: Lang?, timetableItem: TimetableItem, isLangSelectable: Boolean, - onLanguageSwitch: (Lang) -> Unit, + onLanguageSelect: (Lang) -> Unit, modifier: Modifier = Modifier, ) { val currentLang = currentLang ?: timetableItem.language.toLang() @@ -76,7 +76,7 @@ fun TimetableItemDetailHeadline( if (isLangSelectable) { TimetableItemDetailLanguageSwitcher( currentLang = currentLang, - onLanguageSwitch = onLanguageSwitch, + onLanguageSelect = onLanguageSelect, ) } } @@ -121,7 +121,7 @@ fun TimetableItemDetailHeadline( @Composable fun TimetableItemDetailLanguageSwitcher( currentLang: Lang, - onLanguageSwitch: (Lang) -> Unit, + onLanguageSelect: (Lang) -> Unit, modifier: Modifier = Modifier, ) { val normalizedCurrentLang = if (currentLang == Lang.MIXED) { @@ -140,7 +140,7 @@ fun TimetableItemDetailLanguageSwitcher( val lastIndex = availableLangs.size - 1 availableLangs.entries.forEachIndexed { index, (label, lang) -> TextButton( - onClick = { onLanguageSwitch(lang) }, + onClick = { onLanguageSelect(lang) }, contentPadding = PaddingValues(12.dp), ) { val isSelected = normalizedCurrentLang == lang @@ -183,7 +183,7 @@ fun TimetableItemDetailHeadlinePreview() { timetableItem = TimetableItem.Session.fake(), currentLang = Lang.JAPANESE, isLangSelectable = true, - onLanguageSwitch = {}, + onLanguageSelect = {}, ) } } @@ -200,7 +200,7 @@ fun TimetableItemDetailHeadlineWithEnglishPreview() { timetableItem = TimetableItem.Session.fake(), currentLang = Lang.ENGLISH, isLangSelectable = true, - onLanguageSwitch = {}, + onLanguageSelect = {}, ) } } @@ -217,7 +217,7 @@ fun TimetableItemDetailHeadlineWithMixedPreview() { timetableItem = TimetableItem.Session.fake(), currentLang = Lang.MIXED, isLangSelectable = true, - onLanguageSwitch = {}, + onLanguageSelect = {}, ) } } From db65347dda0015f75d924e8b2ad9384b82acd28f Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 01:27:13 +0900 Subject: [PATCH 17/22] make the switcher private because it's only used within the file --- .../sessions/component/TimetableItemDetailHeadline.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 2d8742cb3..fe6d405eb 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -74,7 +74,7 @@ fun TimetableItemDetailHeadline( } Spacer(modifier = Modifier.weight(1f)) if (isLangSelectable) { - TimetableItemDetailLanguageSwitcher( + LanguageSwitcher( currentLang = currentLang, onLanguageSelect = onLanguageSelect, ) @@ -119,7 +119,7 @@ fun TimetableItemDetailHeadline( } @Composable -fun TimetableItemDetailLanguageSwitcher( +private fun LanguageSwitcher( currentLang: Lang, onLanguageSelect: (Lang) -> Unit, modifier: Modifier = Modifier, From fe9263037914cd3bb19a601a0c71b0b33969bb47 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Sat, 24 Aug 2024 01:38:06 +0900 Subject: [PATCH 18/22] minor adjustment to the switcher active icon according to Figma --- .../sessions/component/TimetableItemDetailHeadline.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index fe6d405eb..a6c3b1591 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -153,7 +153,9 @@ private fun LanguageSwitcher( Icon( imageVector = Icons.Default.Check, contentDescription = null, - modifier = Modifier.size(16.dp), + modifier = Modifier + .padding(end = 4.dp) + .size(12.dp), tint = contentColor, ) } From fe40e5514b256314d3a10c346340a0a09bb7be4d Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:07:39 +0900 Subject: [PATCH 19/22] remove unused imports by auto-formatting --- .../component/TimetableItemDetailTopAppBar.kt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailTopAppBar.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailTopAppBar.kt index a570c4ea7..8ae418530 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailTopAppBar.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailTopAppBar.kt @@ -8,15 +8,10 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.statusBars import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.ArrowBack -import androidx.compose.material.icons.outlined.GTranslate -import androidx.compose.material3.DropdownMenu -import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface -import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarScrollBehavior @@ -24,15 +19,9 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier -import conference_app_2024.feature.sessions.generated.resources.english -import conference_app_2024.feature.sessions.generated.resources.japanese import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched.designsystem.theme.LocalRoomTheme -import io.github.droidkaigi.confsched.model.Lang -import io.github.droidkaigi.confsched.sessions.SessionsRes -import org.jetbrains.compose.resources.stringResource import org.jetbrains.compose.ui.tooling.preview.Preview @OptIn(ExperimentalMaterial3Api::class) From 197df78458818a1d332037bb4ca747bd759503a2 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:19:10 +0900 Subject: [PATCH 20/22] add semantics for switching group --- .../component/TimetableItemDetailHeadline.kt | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index eca892729..57482b034 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width +import androidx.compose.foundation.selection.selectableGroup import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Check @@ -28,6 +29,14 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.platform.testTag +import androidx.compose.ui.semantics.CollectionInfo +import androidx.compose.ui.semantics.CollectionItemInfo +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.collectionInfo +import androidx.compose.ui.semantics.collectionItemInfo +import androidx.compose.ui.semantics.role +import androidx.compose.ui.semantics.selected +import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp import conference_app_2024.feature.sessions.generated.resources.english import conference_app_2024.feature.sessions.generated.resources.japanese @@ -134,16 +143,34 @@ private fun LanguageSwitcher( stringResource(SessionsRes.string.english) to Lang.ENGLISH, ) Row( - modifier = modifier, + modifier = modifier + .selectableGroup() + .semantics { + collectionInfo = CollectionInfo( + rowCount = availableLangs.size, + columnCount = 1, + ) + }, verticalAlignment = Alignment.CenterVertically, ) { val lastIndex = availableLangs.size - 1 availableLangs.entries.forEachIndexed { index, (label, lang) -> + val isSelected = normalizedCurrentLang == lang TextButton( onClick = { onLanguageSelect(lang) }, + modifier = Modifier + .semantics { + role = Role.Tab + selected = isSelected + collectionItemInfo = CollectionItemInfo( + rowIndex = index, + rowSpan = 1, + columnIndex = 1, + columnSpan = 1, + ) + }, contentPadding = PaddingValues(12.dp), ) { - val isSelected = normalizedCurrentLang == lang val contentColor = if (isSelected) { LocalRoomTheme.current.primaryColor } else { From 4ca372c2ff3735d7058fc2a97fcf10009c9a59a3 Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:24:27 +0900 Subject: [PATCH 21/22] add contentDescription for the lang switcher --- .../sessions/component/TimetableItemDetailHeadline.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index 57482b034..e824a7227 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -34,12 +34,14 @@ import androidx.compose.ui.semantics.CollectionItemInfo import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.collectionInfo import androidx.compose.ui.semantics.collectionItemInfo +import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.selected import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp import conference_app_2024.feature.sessions.generated.resources.english import conference_app_2024.feature.sessions.generated.resources.japanese +import conference_app_2024.feature.sessions.generated.resources.select_language import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched.designsystem.theme.LocalRoomTheme import io.github.droidkaigi.confsched.droidkaigiui.component.TimetableItemTag @@ -142,10 +144,12 @@ private fun LanguageSwitcher( stringResource(SessionsRes.string.japanese) to Lang.JAPANESE, stringResource(SessionsRes.string.english) to Lang.ENGLISH, ) + val switcherContentDescription = stringResource(SessionsRes.string.select_language) Row( modifier = modifier .selectableGroup() .semantics { + contentDescription = switcherContentDescription collectionInfo = CollectionInfo( rowCount = availableLangs.size, columnCount = 1, From 2965993d6a9c022a5ebe6e51a7c440506498c7eb Mon Sep 17 00:00:00 2001 From: mangano-ito <47137677+mangano-ito@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:38:47 +0900 Subject: [PATCH 22/22] fix columnIndex, which is specified as index 1 but should be 0 --- .../confsched/sessions/component/TimetableItemDetailHeadline.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt index e824a7227..4d777a48a 100644 --- a/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt +++ b/feature/sessions/src/commonMain/kotlin/io/github/droidkaigi/confsched/sessions/component/TimetableItemDetailHeadline.kt @@ -169,7 +169,7 @@ private fun LanguageSwitcher( collectionItemInfo = CollectionItemInfo( rowIndex = index, rowSpan = 1, - columnIndex = 1, + columnIndex = 0, columnSpan = 1, ) },