From 33e1a252f66225d4277be3a721c6d5cfc4ad031b Mon Sep 17 00:00:00 2001 From: takahirom Date: Thu, 17 Aug 2023 15:41:21 +0900 Subject: [PATCH 01/11] CI preview test --- .../confsched2023/about/component/AboutContent.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/feature/about/src/main/java/io/github/droidkaigi/confsched2023/about/component/AboutContent.kt b/feature/about/src/main/java/io/github/droidkaigi/confsched2023/about/component/AboutContent.kt index 8071ded9c..5b7e6c798 100644 --- a/feature/about/src/main/java/io/github/droidkaigi/confsched2023/about/component/AboutContent.kt +++ b/feature/about/src/main/java/io/github/droidkaigi/confsched2023/about/component/AboutContent.kt @@ -22,6 +22,8 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import io.github.droidkaigi.confsched2023.about.AboutStrings +import io.github.droidkaigi.confsched2023.designsystem.preview.MultiLanguagePreviews +import io.github.droidkaigi.confsched2023.designsystem.preview.MultiThemePreviews import io.github.droidkaigi.confsched2023.designsystem.theme.KaigiTheme @Composable @@ -72,8 +74,9 @@ fun AboutContentColumn( } } -@Preview(locale = "en", uiMode = Configuration.UI_MODE_NIGHT_NO) -@Preview(locale = "ja", uiMode = Configuration.UI_MODE_NIGHT_NO) +@MultiThemePreviews +@MultiLanguagePreviews +@Preview @Composable fun AboutContentColumnPreview() { KaigiTheme { From d597bd2b75201022adaf283a0d90d483197b040e Mon Sep 17 00:00:00 2001 From: takahirom Date: Thu, 17 Aug 2023 16:27:39 +0900 Subject: [PATCH 02/11] Fix showkase doesn't collect the custom preview --- core/designsystem/build.gradle.kts | 1 + .../droidkaigi/confsched2023/about/component/AboutContent.kt | 1 - gradle/libs.versions.toml | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index eb6e25552..9a0eafef5 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -8,6 +8,7 @@ plugins { id("droidkaigi.primitive.kmp.compose") id("droidkaigi.primitive.kmp.android.hilt") id("droidkaigi.primitive.spotless") + id("droidkaigi.primitive.android.roborazzi") } android.namespace = "io.github.droidkaigi.confsched2023.core.designsystem" diff --git a/feature/about/src/main/java/io/github/droidkaigi/confsched2023/about/component/AboutContent.kt b/feature/about/src/main/java/io/github/droidkaigi/confsched2023/about/component/AboutContent.kt index 5b7e6c798..06203b05a 100644 --- a/feature/about/src/main/java/io/github/droidkaigi/confsched2023/about/component/AboutContent.kt +++ b/feature/about/src/main/java/io/github/droidkaigi/confsched2023/about/component/AboutContent.kt @@ -76,7 +76,6 @@ fun AboutContentColumn( @MultiThemePreviews @MultiLanguagePreviews -@Preview @Composable fun AboutContentColumnPreview() { KaigiTheme { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 90880746f..8f97f5c22 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -25,7 +25,7 @@ ktlint = "0.49.1" kotlinxSerialization = "1.5.1" ktor = "2.3.3" roborazzi = "1.6.0-alpha-3" -showkase = "1.0.0-beta17" +showkase = "1.0.0-beta18" ksp = "1.9.0-1.0.13" multiplatformFirebaseAuth = "1.8.1" kermit = "1.2.2" From 732797107152e595b4b4db3f805ed8580833b810 Mon Sep 17 00:00:00 2001 From: takahirom Date: Thu, 17 Aug 2023 16:42:23 +0900 Subject: [PATCH 03/11] Fix build --- core/designsystem/build.gradle.kts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index 9a0eafef5..86d61ccff 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -1,4 +1,4 @@ -import io.github.droidkaigi.confsched2023.primitive.implementation +import io.github.droidkaigi.confsched2023.primitive.ksp import io.github.droidkaigi.confsched2023.primitive.libs plugins { @@ -8,7 +8,6 @@ plugins { id("droidkaigi.primitive.kmp.compose") id("droidkaigi.primitive.kmp.android.hilt") id("droidkaigi.primitive.spotless") - id("droidkaigi.primitive.android.roborazzi") } android.namespace = "io.github.droidkaigi.confsched2023.core.designsystem" @@ -21,6 +20,12 @@ kotlin { implementation(libs.findLibrary("kotlinxAtomicfu").get()) } } + androidTarget { + dependencies { + // FIXME: move this to build-logic + ksp(libs.findLibrary("showkaseProcessor")) + } + } } } From d9df0394c798cbe3cc4df355e9141278c74efd7c Mon Sep 17 00:00:00 2001 From: Jaesung Lee Date: Wed, 16 Aug 2023 20:13:22 +0900 Subject: [PATCH 04/11] Add read more text --- .../droidkaigi/confsched2023/sessions/SessionsStrings.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/SessionsStrings.kt b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/SessionsStrings.kt index 1b3b5f75c..1e46cd72f 100644 --- a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/SessionsStrings.kt +++ b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/SessionsStrings.kt @@ -32,6 +32,7 @@ sealed class SessionsStrings : Strings(Bindings) { data object WatchVideo : SessionsStrings() data object Speaker : SessionsStrings() data object TargetAudience : SessionsStrings() + data object ReadMore : SessionsStrings() private object Bindings : StringsBindings( Lang.Japanese to { item, _ -> when (item) { @@ -62,6 +63,7 @@ sealed class SessionsStrings : Strings(Bindings) { TargetAudience -> "対象者" WatchVideo -> "動画を見る" Speaker -> "スピーカー" + ReadMore -> "続きを読む" } }, Lang.English to { item, bindings -> @@ -93,6 +95,7 @@ sealed class SessionsStrings : Strings(Bindings) { WatchVideo -> "Watch Video" Speaker -> "Speaker" TargetAudience -> "Target Audience" + ReadMore -> "Read More" } }, default = Lang.Japanese, From 2c26ea61fd31d00e5cdb59692fbaf28138f94d66 Mon Sep 17 00:00:00 2001 From: Jaesung Lee Date: Wed, 16 Aug 2023 20:30:58 +0900 Subject: [PATCH 05/11] Add ReadMoreOutlinedButton with multi-language previews --- .../component/TimetableItemDetailContent.kt | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt index 3b6d3e730..d9857d689 100644 --- a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt +++ b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt @@ -33,6 +33,8 @@ 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 io.github.droidkaigi.confsched2023.designsystem.preview.MultiLanguagePreviews +import io.github.droidkaigi.confsched2023.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched2023.designsystem.theme.md_theme_light_outline import io.github.droidkaigi.confsched2023.model.TimetableItem import io.github.droidkaigi.confsched2023.model.TimetableItem.Session @@ -68,7 +70,11 @@ fun TimetableItemDetailContent( } @Composable -private fun DescriptionSection(description: String, modifier: Modifier = Modifier) { +private fun DescriptionSection( + description: String, + modifier: Modifier = Modifier, + onClick: () -> Unit = {}, +) { Column(modifier = modifier) { Text( text = description, @@ -76,6 +82,10 @@ private fun DescriptionSection(description: String, modifier: Modifier = Modifie color = MaterialTheme.colorScheme.onSurface, modifier = Modifier.padding(start = 16.dp, end = 16.dp), ) + ReadMoreOutlinedButton( + onClick = onClick, + modifier = Modifier.padding(top = 16.dp, start = 16.dp, end = 16.dp) + ) BorderLine(modifier = Modifier.padding(top = 24.dp)) } } @@ -256,3 +266,35 @@ private fun BorderLine(modifier: Modifier = Modifier) { .background(MaterialTheme.colorScheme.outlineVariant), ) } + +@Composable +private fun ReadMoreOutlinedButton( + onClick: () -> Unit, + modifier: Modifier = Modifier, +) { + Surface( + modifier = modifier.fillMaxWidth(), + shape = RoundedCornerShape(100.dp), + border = BorderStroke( + width = 1.dp, + color = MaterialTheme.colorScheme.outline + ), + onClick = onClick + ) { + Text( + modifier = Modifier.padding(vertical = 10.dp), + text = SessionsStrings.ReadMore.asString(), + fontSize = 14.sp, + textAlign = TextAlign.Center, + color = MaterialTheme.colorScheme.primary + ) + } +} + +@MultiLanguagePreviews +@Composable +private fun ReadMoreOutlinedButtonPreview() { + KaigiTheme { + ReadMoreOutlinedButton(onClick = {}) + } +} From 5417b5ba0b49bf089e9bf60df9606f02f7f99c62 Mon Sep 17 00:00:00 2001 From: Jaesung Lee Date: Thu, 17 Aug 2023 00:53:34 +0900 Subject: [PATCH 06/11] Add state for expandable text --- .../sessions/component/TimetableItemDetailContent.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt index d9857d689..90f93408a 100644 --- a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt +++ b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt @@ -24,12 +24,17 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.vector.rememberVectorPainter import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -73,17 +78,20 @@ fun TimetableItemDetailContent( private fun DescriptionSection( description: String, modifier: Modifier = Modifier, - onClick: () -> Unit = {}, ) { + var isExpanded by rememberSaveable { mutableStateOf(false) } + Column(modifier = modifier) { Text( text = description, fontSize = 16.sp, color = MaterialTheme.colorScheme.onSurface, + maxLines = if (isExpanded) Int.MAX_VALUE else 5, + overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(start = 16.dp, end = 16.dp), ) ReadMoreOutlinedButton( - onClick = onClick, + onClick = { isExpanded = !isExpanded }, modifier = Modifier.padding(top = 16.dp, start = 16.dp, end = 16.dp) ) BorderLine(modifier = Modifier.padding(top = 24.dp)) From f7a60ee39070e5c3cc5724a0fd141810e8d7d196 Mon Sep 17 00:00:00 2001 From: Jaesung Lee Date: Thu, 17 Aug 2023 01:29:15 +0900 Subject: [PATCH 07/11] add trailing comma --- .../sessions/component/TimetableItemDetailContent.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt index 90f93408a..600525b6b 100644 --- a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt +++ b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt @@ -92,7 +92,7 @@ private fun DescriptionSection( ) ReadMoreOutlinedButton( onClick = { isExpanded = !isExpanded }, - modifier = Modifier.padding(top = 16.dp, start = 16.dp, end = 16.dp) + modifier = Modifier.padding(top = 16.dp, start = 16.dp, end = 16.dp), ) BorderLine(modifier = Modifier.padding(top = 24.dp)) } @@ -285,16 +285,16 @@ private fun ReadMoreOutlinedButton( shape = RoundedCornerShape(100.dp), border = BorderStroke( width = 1.dp, - color = MaterialTheme.colorScheme.outline + color = MaterialTheme.colorScheme.outline, ), - onClick = onClick + onClick = onClick, ) { Text( modifier = Modifier.padding(vertical = 10.dp), text = SessionsStrings.ReadMore.asString(), fontSize = 14.sp, textAlign = TextAlign.Center, - color = MaterialTheme.colorScheme.primary + color = MaterialTheme.colorScheme.primary, ) } } From 0a855e0f9e8e61e6559b5e131eefe6075d1d82ca Mon Sep 17 00:00:00 2001 From: Jaesung Lee Date: Thu, 17 Aug 2023 16:44:13 +0900 Subject: [PATCH 08/11] Modify ReadMoreOutlinedButton visibility --- .../sessions/component/TimetableItemDetailContent.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt index 600525b6b..8ca08a5b4 100644 --- a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt +++ b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt @@ -90,10 +90,12 @@ private fun DescriptionSection( overflow = TextOverflow.Ellipsis, modifier = Modifier.padding(start = 16.dp, end = 16.dp), ) - ReadMoreOutlinedButton( - onClick = { isExpanded = !isExpanded }, - modifier = Modifier.padding(top = 16.dp, start = 16.dp, end = 16.dp), - ) + if (!isExpanded) { + ReadMoreOutlinedButton( + onClick = { isExpanded = !isExpanded }, + modifier = Modifier.padding(top = 16.dp, start = 16.dp, end = 16.dp), + ) + } BorderLine(modifier = Modifier.padding(top = 24.dp)) } } From dc8174030b4ab1fc67477ed35d86c2bf7ec6aefc Mon Sep 17 00:00:00 2001 From: takahirom Date: Thu, 17 Aug 2023 16:53:35 +0900 Subject: [PATCH 09/11] Fix build --- build-logic/build.gradle.kts | 4 ++++ .../primitive/KmpAndroidShowkasePlugin.kt | 23 +++++++++++++++++++ core/designsystem/build.gradle.kts | 8 +------ 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 build-logic/src/main/kotlin/io/github/droidkaigi/confsched2023/primitive/KmpAndroidShowkasePlugin.kt diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 51d6fd28f..2ca1acbbe 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -84,6 +84,10 @@ gradlePlugin { id = "droidkaigi.primitive.kmp.android.hilt" implementationClass = "io.github.droidkaigi.confsched2023.primitive.KmpAndroidHiltPlugin" } + register("kotlinMppAndroidShowkase") { + id = "droidkaigi.primitive.kmp.android.showkase" + implementationClass = "io.github.droidkaigi.confsched2023.primitive.KmpAndroidShowkasePlugin" + } register("kotlinMppKotlinSerialization") { id = "droidkaigi.primitive.kmp.serialization" implementationClass = "io.github.droidkaigi.confsched2023.primitive.KotlinSerializationPlugin" diff --git a/build-logic/src/main/kotlin/io/github/droidkaigi/confsched2023/primitive/KmpAndroidShowkasePlugin.kt b/build-logic/src/main/kotlin/io/github/droidkaigi/confsched2023/primitive/KmpAndroidShowkasePlugin.kt new file mode 100644 index 000000000..7f7544d42 --- /dev/null +++ b/build-logic/src/main/kotlin/io/github/droidkaigi/confsched2023/primitive/KmpAndroidShowkasePlugin.kt @@ -0,0 +1,23 @@ +package io.github.droidkaigi.confsched2023.primitive + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.get + +@Suppress("unused") +class KmpAndroidShowkasePlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply(libs.findPlugin("kspGradlePlugin").get().get().pluginId) + } + kotlin { + + } + dependencies { + this.add("kspAndroid", libs.findLibrary("showkaseProcessor").get()) + } + } + } +} diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index 86d61ccff..3efc7fe18 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -1,4 +1,3 @@ -import io.github.droidkaigi.confsched2023.primitive.ksp import io.github.droidkaigi.confsched2023.primitive.libs plugins { @@ -8,6 +7,7 @@ plugins { id("droidkaigi.primitive.kmp.compose") id("droidkaigi.primitive.kmp.android.hilt") id("droidkaigi.primitive.spotless") + id("droidkaigi.primitive.kmp.android.showkase") } android.namespace = "io.github.droidkaigi.confsched2023.core.designsystem" @@ -20,12 +20,6 @@ kotlin { implementation(libs.findLibrary("kotlinxAtomicfu").get()) } } - androidTarget { - dependencies { - // FIXME: move this to build-logic - ksp(libs.findLibrary("showkaseProcessor")) - } - } } } From 55c4b46f8e342dd0a4c2653b3676cc96fa569b9a Mon Sep 17 00:00:00 2001 From: takahirom Date: Thu, 17 Aug 2023 16:59:28 +0900 Subject: [PATCH 10/11] Fix runtime --- .../confsched2023/primitive/KmpAndroidShowkasePlugin.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build-logic/src/main/kotlin/io/github/droidkaigi/confsched2023/primitive/KmpAndroidShowkasePlugin.kt b/build-logic/src/main/kotlin/io/github/droidkaigi/confsched2023/primitive/KmpAndroidShowkasePlugin.kt index 7f7544d42..29c8640f6 100644 --- a/build-logic/src/main/kotlin/io/github/droidkaigi/confsched2023/primitive/KmpAndroidShowkasePlugin.kt +++ b/build-logic/src/main/kotlin/io/github/droidkaigi/confsched2023/primitive/KmpAndroidShowkasePlugin.kt @@ -13,7 +13,11 @@ class KmpAndroidShowkasePlugin : Plugin { apply(libs.findPlugin("kspGradlePlugin").get().get().pluginId) } kotlin { - + sourceSets.getByName("androidMain") { + dependencies { + implementation(libs.findLibrary("showkaseRuntime").get()) + } + } } dependencies { this.add("kspAndroid", libs.findLibrary("showkaseProcessor").get()) From 02abba1544369b2ea230ab006ac80072e6911a79 Mon Sep 17 00:00:00 2001 From: hiraike32 Date: Thu, 17 Aug 2023 17:59:34 +0900 Subject: [PATCH 11/11] Fix the error by showkase's private preview --- .../sessions/component/TimetableItemDetailContent.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt index 8ca08a5b4..ee34b6536 100644 --- a/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt +++ b/feature/sessions/src/main/java/io/github/droidkaigi/confsched2023/sessions/component/TimetableItemDetailContent.kt @@ -303,7 +303,7 @@ private fun ReadMoreOutlinedButton( @MultiLanguagePreviews @Composable -private fun ReadMoreOutlinedButtonPreview() { +fun ReadMoreOutlinedButtonPreview() { KaigiTheme { ReadMoreOutlinedButton(onClick = {}) }