From b4bf0c2e904b28d093f5dfe06d6a334d19c82fbe Mon Sep 17 00:00:00 2001 From: Yang Date: Fri, 1 Dec 2023 13:03:33 +1100 Subject: [PATCH] Replace `ThemePreviews` with `@PreviewLightDark`. --- .../kstreamlined/android/common/ui/feed/KotlinBlogCard.kt | 6 +++--- .../android/common/ui/feed/KotlinWeeklyCard.kt | 6 +++--- .../android/common/ui/feed/KotlinYouTubeCard.kt | 6 +++--- .../android/common/ui/feed/TalkingKotlinCard.kt | 6 +++--- .../kstreamlined/android/designsystem/ThemePreviews.kt | 8 -------- .../kstreamlined/android/designsystem/component/Chip.kt | 4 ++-- .../android/designsystem/component/Divider.kt | 6 +++--- .../android/designsystem/component/IconButton.kt | 8 ++++---- .../android/designsystem/component/TopNavBar.kt | 8 ++++---- .../android/feature/home/component/FeedFilterChip.kt | 4 ++-- .../android/feature/home/component/SyncButton.kt | 4 ++-- detekt.yml | 2 +- 12 files changed, 30 insertions(+), 38 deletions(-) delete mode 100644 android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/ThemePreviews.kt diff --git a/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinBlogCard.kt b/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinBlogCard.kt index 88ac5319..9194725e 100644 --- a/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinBlogCard.kt +++ b/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinBlogCard.kt @@ -13,9 +13,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import coil.compose.AsyncImage -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.component.IconButton import io.github.reactivecircus.kstreamlined.android.designsystem.component.Surface import io.github.reactivecircus.kstreamlined.android.designsystem.component.Text @@ -91,7 +91,7 @@ public fun KotlinBlogCard( private val ImageHeight = 200.dp @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewKotlinBlogCard_unsaved() { KSTheme { Surface { @@ -113,7 +113,7 @@ private fun PreviewKotlinBlogCard_unsaved() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewKotlinBlogCard_saved() { KSTheme { Surface { diff --git a/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinWeeklyCard.kt b/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinWeeklyCard.kt index b1c4d998..8d368a82 100644 --- a/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinWeeklyCard.kt +++ b/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinWeeklyCard.kt @@ -13,8 +13,8 @@ import androidx.compose.ui.geometry.CornerRadius import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.component.IconButton import io.github.reactivecircus.kstreamlined.android.designsystem.component.Surface import io.github.reactivecircus.kstreamlined.android.designsystem.component.Text @@ -88,7 +88,7 @@ public fun KotlinWeeklyCard( } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewKotlinWeeklyCard_unsaved() { KSTheme { Surface { @@ -109,7 +109,7 @@ private fun PreviewKotlinWeeklyCard_unsaved() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewKotlinWeeklyCard_saved() { KSTheme { Surface { diff --git a/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinYouTubeCard.kt b/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinYouTubeCard.kt index e88a72e0..83f06ae7 100644 --- a/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinYouTubeCard.kt +++ b/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/KotlinYouTubeCard.kt @@ -21,9 +21,9 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import coil.compose.AsyncImage -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.component.Icon import io.github.reactivecircus.kstreamlined.android.designsystem.component.IconButton import io.github.reactivecircus.kstreamlined.android.designsystem.component.Surface @@ -139,7 +139,7 @@ private fun PlayIconOverlay( private val ImageHeight = 200.dp @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewKotlinYouTubeCard_unsaved() { KSTheme { Surface { @@ -162,7 +162,7 @@ private fun PreviewKotlinYouTubeCard_unsaved() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewKotlinYouTubeCard_saved() { KSTheme { Surface { diff --git a/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/TalkingKotlinCard.kt b/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/TalkingKotlinCard.kt index 5829b59d..7477e70e 100644 --- a/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/TalkingKotlinCard.kt +++ b/android/common-ui/feed/src/main/java/io/github/reactivecircus/kstreamlined/android/common/ui/feed/TalkingKotlinCard.kt @@ -13,9 +13,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import coil.compose.AsyncImage -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.component.IconButton import io.github.reactivecircus.kstreamlined.android.designsystem.component.Surface import io.github.reactivecircus.kstreamlined.android.designsystem.component.Text @@ -89,7 +89,7 @@ public fun TalkingKotlinCard( } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewTalkingKotlinCard_unsaved() { KSTheme { Surface { @@ -111,7 +111,7 @@ private fun PreviewTalkingKotlinCard_unsaved() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewTalkingKotlinCard_saved() { KSTheme { Surface { diff --git a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/ThemePreviews.kt b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/ThemePreviews.kt deleted file mode 100644 index de46c0d8..00000000 --- a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/ThemePreviews.kt +++ /dev/null @@ -1,8 +0,0 @@ -package io.github.reactivecircus.kstreamlined.android.designsystem - -import android.content.res.Configuration -import androidx.compose.ui.tooling.preview.Preview - -@Preview(uiMode = Configuration.UI_MODE_NIGHT_NO, name = "Light") -@Preview(uiMode = Configuration.UI_MODE_NIGHT_YES, name = "Dark") -public annotation class ThemePreviews diff --git a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/Chip.kt b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/Chip.kt index aa621a84..04c8409e 100644 --- a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/Chip.kt +++ b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/Chip.kt @@ -9,8 +9,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.KSTheme import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon.KSIcons @@ -44,7 +44,7 @@ public fun Chip( } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewChip() { KSTheme { Surface { diff --git a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/Divider.kt b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/Divider.kt index 57d0ba95..14a22848 100644 --- a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/Divider.kt +++ b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/Divider.kt @@ -11,9 +11,9 @@ import androidx.compose.runtime.NonRestartableComposable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.KSTheme import androidx.compose.material3.HorizontalDivider as MaterialHorizontalDivider import androidx.compose.material3.VerticalDivider as MaterialVerticalDivider @@ -47,7 +47,7 @@ public fun VerticalDivider( } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewHorizontalDivider() { KSTheme { Surface { @@ -67,7 +67,7 @@ private fun PreviewHorizontalDivider() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewVerticalDivider() { KSTheme { Surface { diff --git a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/IconButton.kt b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/IconButton.kt index d11ecf6e..82cfbb1f 100644 --- a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/IconButton.kt +++ b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/IconButton.kt @@ -24,9 +24,9 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.role import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.KSTheme import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.color.LocalContentColor import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon.BookmarkAdd @@ -155,7 +155,7 @@ private val LargeIconSize = 32.dp private val LargeContainerSize = 48.dp @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewIconButton() { KSTheme { Surface { @@ -170,7 +170,7 @@ private fun PreviewIconButton() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewLargeIconButton() { KSTheme { Surface { @@ -185,7 +185,7 @@ private fun PreviewLargeIconButton() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewFilledIconButton() { KSTheme { Surface { diff --git a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/TopNavBar.kt b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/TopNavBar.kt index 661bca5c..590428e6 100644 --- a/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/TopNavBar.kt +++ b/android/designsystem/src/main/java/io/github/reactivecircus/kstreamlined/android/designsystem/component/TopNavBar.kt @@ -21,10 +21,10 @@ import androidx.compose.ui.graphics.Shader import androidx.compose.ui.graphics.ShaderBrush import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.KSTheme import io.github.reactivecircus.kstreamlined.android.designsystem.foundation.icon.KSIcons @@ -118,7 +118,7 @@ private fun GradientTitle( private const val GradientHorizontalScale = 1.3f @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewTopNavBar() { KSTheme { Surface { @@ -137,7 +137,7 @@ private fun PreviewTopNavBar() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewTopNavBar_withBottomRow() { KSTheme { Surface { @@ -171,7 +171,7 @@ private fun PreviewTopNavBar_withBottomRow() { } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewTopNavBar_withNavigationIcon() { KSTheme { Surface { diff --git a/android/feature/home/src/main/java/io/github/reactivecircus/kstreamlined/android/feature/home/component/FeedFilterChip.kt b/android/feature/home/src/main/java/io/github/reactivecircus/kstreamlined/android/feature/home/component/FeedFilterChip.kt index 7ce0dc45..a4ecf85f 100644 --- a/android/feature/home/src/main/java/io/github/reactivecircus/kstreamlined/android/feature/home/component/FeedFilterChip.kt +++ b/android/feature/home/src/main/java/io/github/reactivecircus/kstreamlined/android/feature/home/component/FeedFilterChip.kt @@ -5,9 +5,9 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.component.Chip import io.github.reactivecircus.kstreamlined.android.designsystem.component.Icon import io.github.reactivecircus.kstreamlined.android.designsystem.component.Surface @@ -39,7 +39,7 @@ internal fun FeedFilterChip( } @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewFeedFilterChip() { KSTheme { Surface { diff --git a/android/feature/home/src/main/java/io/github/reactivecircus/kstreamlined/android/feature/home/component/SyncButton.kt b/android/feature/home/src/main/java/io/github/reactivecircus/kstreamlined/android/feature/home/component/SyncButton.kt index 6d41e76e..f6d135c3 100644 --- a/android/feature/home/src/main/java/io/github/reactivecircus/kstreamlined/android/feature/home/component/SyncButton.kt +++ b/android/feature/home/src/main/java/io/github/reactivecircus/kstreamlined/android/feature/home/component/SyncButton.kt @@ -16,9 +16,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.rotate import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import io.github.reactivecircus.kstreamlined.android.designsystem.ThemePreviews import io.github.reactivecircus.kstreamlined.android.designsystem.component.Chip import io.github.reactivecircus.kstreamlined.android.designsystem.component.Icon import io.github.reactivecircus.kstreamlined.android.designsystem.component.Surface @@ -84,7 +84,7 @@ internal fun SyncButton( private const val AnimationDurationMillis = 1000 @Composable -@ThemePreviews +@PreviewLightDark private fun PreviewSyncButton() { KSTheme { Surface { diff --git a/detekt.yml b/detekt.yml index 191d4c22..bc5d9b5d 100644 --- a/detekt.yml +++ b/detekt.yml @@ -29,4 +29,4 @@ style: UnusedPrivateMember: ignoreAnnotated: - Preview - - ThemePreviews + - PreviewLightDark