Reuse basic theme preview annotation

This commit is contained in:
arkon 2022-12-08 22:45:17 -05:00
parent 01c6e46a71
commit 1009e15aa6
7 changed files with 32 additions and 62 deletions

View File

@ -1,6 +1,5 @@
package eu.kanade.presentation.components
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@ -27,10 +26,10 @@ import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastFirstOrNull
import eu.kanade.presentation.theme.TachiyomiTheme
import eu.kanade.presentation.util.ThemePreviews
import eu.kanade.presentation.util.secondaryItemAlpha
import eu.kanade.tachiyomi.R
import kotlin.random.Random
@ -146,17 +145,7 @@ private fun ActionButton(
}
}
@Preview(
name = "Light",
widthDp = 400,
heightDp = 400,
)
@Preview(
name = "Dark",
widthDp = 400,
heightDp = 400,
uiMode = UI_MODE_NIGHT_YES,
)
@ThemePreviews
@Composable
private fun NoActionPreview() {
TachiyomiTheme {
@ -168,17 +157,7 @@ private fun NoActionPreview() {
}
}
@Preview(
name = "Light",
widthDp = 400,
heightDp = 400,
)
@Preview(
name = "Dark",
widthDp = 400,
heightDp = 400,
uiMode = UI_MODE_NIGHT_YES,
)
@ThemePreviews
@Composable
private fun WithActionPreview() {
TachiyomiTheme {

View File

@ -1,6 +1,5 @@
package eu.kanade.presentation.manga
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@ -47,7 +46,6 @@ import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.fastForEachIndexed
import eu.kanade.domain.manga.model.Manga
@ -59,6 +57,7 @@ import eu.kanade.presentation.components.HorizontalPager
import eu.kanade.presentation.components.TabIndicator
import eu.kanade.presentation.components.rememberPagerState
import eu.kanade.presentation.theme.TachiyomiTheme
import eu.kanade.presentation.util.ThemePreviews
import eu.kanade.tachiyomi.R
import kotlinx.coroutines.launch
@ -472,13 +471,7 @@ private fun DisplayPageItem(
private val HorizontalPadding = 24.dp
private val VerticalPadding = 8.dp
@Preview(
name = "Light",
)
@Preview(
name = "Dark",
uiMode = UI_MODE_NIGHT_YES,
)
@ThemePreviews
@Composable
private fun ChapterSettingsDialogPreview() {
TachiyomiTheme {

View File

@ -1,6 +1,5 @@
package eu.kanade.presentation.more.settings.widget
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.animation.animateContentSize
import androidx.compose.foundation.background
import androidx.compose.foundation.border
@ -38,12 +37,12 @@ import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import eu.kanade.domain.ui.model.AppTheme
import eu.kanade.presentation.components.DIVIDER_ALPHA
import eu.kanade.presentation.components.MangaCover
import eu.kanade.presentation.theme.TachiyomiTheme
import eu.kanade.presentation.util.ThemePreviews
import eu.kanade.presentation.util.secondaryItemAlpha
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.DeviceUtil
@ -252,15 +251,7 @@ fun AppThemePreviewItem(
}
}
@Preview(
name = "light",
showBackground = true,
)
@Preview(
name = "dark",
showBackground = true,
uiMode = UI_MODE_NIGHT_YES,
)
@ThemePreviews
@Composable
private fun AppThemesListPreview() {
var appTheme by remember { mutableStateOf(AppTheme.DEFAULT) }

View File

@ -1,6 +1,5 @@
package eu.kanade.presentation.more.settings.widget
import android.content.res.Configuration.UI_MODE_NIGHT_YES
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
@ -13,9 +12,9 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.theme.TachiyomiTheme
import eu.kanade.presentation.util.ThemePreviews
import eu.kanade.presentation.util.secondaryItemAlpha
import eu.kanade.tachiyomi.R
@ -38,16 +37,7 @@ internal fun InfoWidget(text: String) {
}
}
@Preview(
name = "Light",
showBackground = true,
)
@Preview(
name = "Dark",
showBackground = true,
uiMode = UI_MODE_NIGHT_YES,
)
@ThemePreviews
@Composable
private fun InfoWidgetPreview() {
TachiyomiTheme {

View File

@ -4,13 +4,13 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Preview
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.tooling.preview.Preview
import eu.kanade.presentation.theme.TachiyomiTheme
import eu.kanade.presentation.util.ThemePreviews
@Composable
fun SwitchPreferenceWidget(
@ -37,10 +37,10 @@ fun SwitchPreferenceWidget(
)
}
@Preview
@ThemePreviews
@Composable
private fun SwitchPreferenceWidgetPreview() {
MaterialTheme {
TachiyomiTheme {
Surface {
Column {
SwitchPreferenceWidget(

View File

@ -13,6 +13,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.tooling.preview.Preview
import eu.kanade.presentation.theme.TachiyomiTheme
import eu.kanade.presentation.util.ThemePreviews
import eu.kanade.presentation.util.secondaryItemAlpha
@Composable
@ -58,10 +60,10 @@ fun TextPreferenceWidget(
)
}
@Preview
@ThemePreviews
@Composable
private fun TextPreferenceWidgetPreview() {
MaterialTheme {
TachiyomiTheme {
Surface {
Column {
TextPreferenceWidget(

View File

@ -0,0 +1,15 @@
package eu.kanade.presentation.util
import android.content.res.Configuration
import androidx.compose.ui.tooling.preview.Preview
@Preview(
name = "Light",
showBackground = true,
)
@Preview(
name = "Dark",
showBackground = true,
uiMode = Configuration.UI_MODE_NIGHT_YES,
)
annotation class ThemePreviews